Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16643 | Rev 16768 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 16643 Rev 16766
Línea 3... Línea 3...
3
declare(strict_types=1);
3
declare(strict_types=1);
Línea 4... Línea 4...
4
 
4
 
Línea 5... Línea 5...
5
namespace LeadersLinked\Controller;
5
namespace LeadersLinked\Controller;
6
 
6
 
Línea 7... Línea 7...
7
use Laminas\Db\Adapter\AdapterInterface;
7
use Laminas\Db\Adapter\AdapterInterface;
8
use Laminas\Cache\Storage\Adapter\AbstractAdapter;
8
use LeadersLinked\Cache\CacheInterface;
Línea 9... Línea 9...
9
 
9
 
Línea 37... Línea 37...
37
    private $adapter;
37
    private $adapter;
Línea 38... Línea 38...
38
 
38
 
39
 
39
 
40
    /**
40
    /**
41
     *
41
     *
42
     * @var AbstractAdapter
42
     * @var CacheInterface
Línea 43... Línea 43...
43
     */
43
     */
44
    private $cache;
44
    private $cache;
Línea 56... Línea 56...
56
    private $config;
56
    private $config;
Línea 57... Línea 57...
57
 
57
 
58
    /**
58
    /**
59
     *
59
     *
60
     * @param AdapterInterface $adapter
60
     * @param AdapterInterface $adapter
61
     * @param AbstractAdapter $cache
61
     * @param CacheInterface $cache
62
     * @param LoggerInterface $logger
62
     * @param LoggerInterface $logger
63
     * @param array $config
63
     * @param array $config
64
     */
64
     */
65
    public function __construct($adapter, $cache, $logger, $config)
65
    public function __construct($adapter, $cache, $logger, $config)
Línea 97... Línea 97...
97
                }
97
                }
98
            }
98
            }
Línea 99... Línea 99...
99
 
99
 
100
            if ($isJson) {
100
            if ($isJson) {
101
                $search = $this->params()->fromQuery('search');
101
                $search = $this->params()->fromQuery('search');
Línea 102... Línea 102...
102
                $search = empty($search['value']) ? '' : filter_var($search['value'], FILTER_SANITIZE_STRING);
102
                $search = empty($search['value']) ? '' :  Functions::sanitizeFilterString($search['value']);
103
 
103
 
104
 
104
 
105
 
105
 
106
                $page               = intval($this->params()->fromQuery('start', 1), 10);
106
                $page               = intval($this->params()->fromQuery('start', 1), 10);
Línea 107... Línea 107...
107
                $records_x_page     = intval($this->params()->fromQuery('length', 10), 10);
107
                $records_x_page     = intval($this->params()->fromQuery('length', 10), 10);
108
                $order =  $this->params()->fromQuery('order', []);
108
                $order =  $this->params()->fromQuery('order', []);
Línea 109... Línea 109...
109
                $order_field        = empty($order[0]['column']) ? 99 :  intval($order[0]['column'], 10);
109
                $order_field        = empty($order[0]['column']) ? 99 :  intval($order[0]['column'], 10);
110
                $order_direction    = empty($order[0]['dir']) ? 'ASC' : strtoupper(filter_var($order[0]['dir'], FILTER_SANITIZE_STRING));
110
                $order_direction    = empty($order[0]['dir']) ? 'ASC' : Functions::sanitizeFilterString(filter_var($order[0]['dir']));
111
 
111
 
Línea 123... Línea 123...
123
 
123
 
124
                $items = [];
124
                $items = [];
125
                $records = $paginator->getCurrentItems();
125
                $records = $paginator->getCurrentItems();
Línea -... Línea 126...
-
 
126
                foreach ($records as $record) {
-
 
127
 
-
 
128
                    switch($record->scholarship)
-
 
129
                    {
-
 
130
                        case DiscoveryContact::SCHOLARSHIP_YES : 
-
 
131
                            $scholarship = 'LABEL_YES';
-
 
132
                            break;
-
 
133
                            
-
 
134
                        case DiscoveryContact::SCHOLARSHIP_NO :
-
 
135
                            $scholarship = 'LABEL_NO';
-
 
136
                            break;
-
 
137
                            
-
 
138
                        default :
-
 
139
                            $scholarship = 'LABEL_UNKNOW';
-
 
140
                            break;
Línea 126... Línea 141...
126
                foreach ($records as $record) {
141
                    }
127
 
142
                    
128
 
143
 
129
                    $item = [
144
                    $item = [
130
                        'first_name' => $record->first_name,
145
                        'first_name' => $record->first_name,
131
                        'last_name' => $record->last_name,
146
                        'last_name' => $record->last_name,
132
                        'corporate_email' => $record->corporate_email,
147
                        'corporate_email' => $record->corporate_email,
-
 
148
                        'company' => $record->company,
133
                        'company' => $record->company,
149
                        'country' => $record->country,
134
                        'country' => $record->country,
150
                        'sector' => $record->sector,
135
                        'sector' => $record->sector,
151
                        'scholarship' => $scholarship,
136
                        'actions' => [
152
                        'actions' => [
137
                            'link_edit' => $this->url()->fromRoute('discovery-contacts/edit', ['id' => $record->uuid]),
153
                            'link_edit' => $this->url()->fromRoute('discovery-contacts/edit', ['id' => $record->uuid]),
Línea 260... Línea 276...
260
                        $discoveryContactLog->details .= 'LABEL_WHATSAPP : ' . $discoveryContact->whatsapp  . PHP_EOL;
276
                        $discoveryContactLog->details .= 'LABEL_WHATSAPP : ' . $discoveryContact->whatsapp  . PHP_EOL;
261
                    }
277
                    }
262
                    if ($discoveryContact->linkedin) {
278
                    if ($discoveryContact->linkedin) {
263
                        $discoveryContactLog->details .= 'LABEL_LINKEDIN : ' . $discoveryContact->linkedin  . PHP_EOL;
279
                        $discoveryContactLog->details .= 'LABEL_LINKEDIN : ' . $discoveryContact->linkedin  . PHP_EOL;
264
                    }
280
                    }
-
 
281
                    if ($discoveryContact->scholarship) {
-
 
282
                        $discoveryContactLog->details .= 'LABEL_SCHOLARSHIP : ' . $discoveryContact->scholarship  . PHP_EOL;
-
 
283
                    }
-
 
284
                    
-
 
285
                    
Línea 265... Línea 286...
265
 
286
 
266
                    $discoveryContactLogMapper = DiscoveryContactLogMapper::getInstance($this->adapter);
287
                    $discoveryContactLogMapper = DiscoveryContactLogMapper::getInstance($this->adapter);
Línea 267... Línea 288...
267
                    $discoveryContactLogMapper->insert($discoveryContactLog);
288
                    $discoveryContactLogMapper->insert($discoveryContactLog);
Línea 401... Línea 422...
401
                        $discoveryContactLog->details .= 'LABEL_WHATSAPP : ' . $discoveryContactOld->whatsapp . ' / ' . $discoveryContact->whatsapp  . PHP_EOL;
422
                        $discoveryContactLog->details .= 'LABEL_WHATSAPP : ' . $discoveryContactOld->whatsapp . ' / ' . $discoveryContact->whatsapp  . PHP_EOL;
402
                    }
423
                    }
403
                    if ($discoveryContactOld->linkedin != $discoveryContact->linkedin) {
424
                    if ($discoveryContactOld->linkedin != $discoveryContact->linkedin) {
404
                        $discoveryContactLog->details .= 'LABEL_LINKEDIN : ' . $discoveryContactOld->linkedin . ' / ' . $discoveryContact->linkedin  . PHP_EOL;
425
                        $discoveryContactLog->details .= 'LABEL_LINKEDIN : ' . $discoveryContactOld->linkedin . ' / ' . $discoveryContact->linkedin  . PHP_EOL;
405
                    }
426
                    }
-
 
427
                    if ($discoveryContactOld->scholarship != $discoveryContact->scholarship) {
-
 
428
                        $discoveryContactLog->details .= 'LABEL_SCHOLARSHIP: ' . $discoveryContactOld->scholarship . ' / ' . $discoveryContact->scholarship  . PHP_EOL;
-
 
429
                    }
406
                    $discoveryContactLogMapper = DiscoveryContactLogMapper::getInstance($this->adapter);
430
                    $discoveryContactLogMapper = DiscoveryContactLogMapper::getInstance($this->adapter);
407
                    $discoveryContactLogMapper->insert($discoveryContactLog);
431
                    $discoveryContactLogMapper->insert($discoveryContactLog);
Línea 408... Línea 432...
408
 
432
 
Línea 449... Línea 473...
449
            $data['phone_extension'] = $data['phone_extension'] ? trim($data['phone_extension']) : '';
473
            $data['phone_extension'] = $data['phone_extension'] ? trim($data['phone_extension']) : '';
450
            $data['personal_email'] = $data['personal_email'] ? trim($data['personal_email']) : '';
474
            $data['personal_email'] = $data['personal_email'] ? trim($data['personal_email']) : '';
451
            $data['celular'] = $data['celular'] ? trim($data['celular']) : '';
475
            $data['celular'] = $data['celular'] ? trim($data['celular']) : '';
452
            $data['whatsapp'] = $data['whatsapp'] ? trim($data['whatsapp']) : '';
476
            $data['whatsapp'] = $data['whatsapp'] ? trim($data['whatsapp']) : '';
453
            $data['linkedin'] = $data['linkedin'] ? trim($data['linkedin']) : '';
477
            $data['linkedin'] = $data['linkedin'] ? trim($data['linkedin']) : '';
-
 
478
            $data['scholarship'] = $data['scholarship'] ? trim($data['scholarship']) : '';
Línea 454... Línea 479...
454
 
479
 
Línea 581... Línea 606...
581
            $data['phone_extension'] = $data['phone_extension'] ? trim($data['phone_extension']) : '';
606
            $data['phone_extension'] = $data['phone_extension'] ? trim($data['phone_extension']) : '';
582
            $data['personal_email'] = $data['personal_email'] ? trim($data['personal_email']) : '';
607
            $data['personal_email'] = $data['personal_email'] ? trim($data['personal_email']) : '';
583
            $data['celular'] = $data['celular'] ? trim($data['celular']) : '';
608
            $data['celular'] = $data['celular'] ? trim($data['celular']) : '';
584
            $data['whatsapp'] = $data['whatsapp'] ? trim($data['whatsapp']) : '';
609
            $data['whatsapp'] = $data['whatsapp'] ? trim($data['whatsapp']) : '';
585
            $data['linkedin'] = $data['linkedin'] ? trim($data['linkedin']) : '';
610
            $data['linkedin'] = $data['linkedin'] ? trim($data['linkedin']) : '';
-
 
611
            $data['scholarship'] = $data['scholarship'] ? trim($data['scholarship']) : '';
Línea 586... Línea 612...
586
 
612
 
587
 
613
 
588
            $data['link_interactions'] = $this->url()->fromRoute('discovery-contacts/interactions', ['id' => $discoveryContact->uuid]);
614
            $data['link_interactions'] = $this->url()->fromRoute('discovery-contacts/interactions', ['id' => $discoveryContact->uuid]);
Línea 626... Línea 652...
626
 
652
 
Línea 627... Línea 653...
627
 
653
 
628
 
654
 
Línea 629... Línea 655...
629
        if ($request->isPost()) {
655
        if ($request->isPost()) {
Línea 676... Línea 702...
676
                        O = Sector
702
                        O = Sector
Línea 677... Línea 703...
677
 
703
 
Línea 678... Línea 704...
678
                         */
704
                         */
679
 
705
 
680
 
706
 
681
                        $first_name = trim(filter_var($record['A'], FILTER_SANITIZE_STRING));
707
                        $first_name = Functions::sanitizeFilterString($record['A']);
682
                        $last_name = trim(filter_var($record['B'], FILTER_SANITIZE_STRING));
708
                        $last_name = Functions::sanitizeFilterString($record['B']);
683
                        $email_personal = trim(filter_var($record['C'], FILTER_SANITIZE_EMAIL));
709
                        $email_personal = strtolower(Functions::sanitizeFilterString($record['C']));
684
                        $email_company = trim(filter_var($record['D'], FILTER_SANITIZE_EMAIL));
710
                        $email_company = strtolower(Functions::sanitizeFilterString($record['D']));
685
 
711
 
686
                        $company =  isset($record['E']) ? trim(filter_var($record['E'], FILTER_SANITIZE_STRING)) : '';
712
                        $company =  isset($record['E']) ? Functions::sanitizeFilterString($record['E']) : '';
687
                        $position = isset($record['F']) ? trim(filter_var($record['F'], FILTER_SANITIZE_STRING)) : '';
713
                        $position = isset($record['F']) ? Functions::sanitizeFilterString($record['F']) : '';
Línea 688... Línea 714...
688
                        $country = isset($record['G']) ? trim(filter_var($record['G'], FILTER_SANITIZE_STRING)) : '';
714
                        $country = isset($record['G']) ? Functions::sanitizeFilterString($record['G']) : '';
689
                        $state = isset($record['H']) ? trim(filter_var($record['H'], FILTER_SANITIZE_STRING)) : '';
715
                        $state = isset($record['H']) ? Functions::sanitizeFilterString($record['H']) : '';
Línea 690... Línea 716...
690
                        $city = isset($record['I']) ? trim(filter_var($record['I'], FILTER_SANITIZE_STRING)) : '';
716
                        $city = isset($record['I']) ? Functions::sanitizeFilterString($record['I']) : '';
691
 
717
 
Línea 692... Línea 718...
692
 
718
 
693
                        $phone = isset($record['J']) ? trim(filter_var($record['J'], FILTER_SANITIZE_STRING)) : '';
719
                        $phone = isset($record['J']) ? Functions::sanitizeFilterString(filter_var($record['J'])) : '';
Línea 694... Línea 720...
694
                        $phone = preg_replace('/[^0-9]/', '', $phone);
720
                        $phone = preg_replace('/[^0-9]/', '', $phone);
695
 
721
 
Línea 696... Línea 722...
696
                        $extension = isset($record['K']) ? trim(filter_var($record['K'], FILTER_SANITIZE_STRING)) : '';
722
                        $extension = isset($record['K']) ? Functions::sanitizeFilterString($record['K']) : '';
697
                        $extension = preg_replace('/[^0-9]/', '', $extension);
723
                        $extension = preg_replace('/[^0-9]/', '', $extension);
-
 
724
 
-
 
725
                        $movil = isset($record['L']) ? Functions::sanitizeFilterString($record['L']) : '';
-
 
726
                        $movil = preg_replace('/[^0-9]/', '', $movil);
-
 
727
 
-
 
728
                        $whatsapp = isset($record['M']) ? Functions::sanitizeFilterString($record['M']) : '';
-
 
729
                        $whatsapp = preg_replace('/[^0-9]/', '', $whatsapp);
-
 
730
 
-
 
731
 
-
 
732
                        $linkedin = isset($record['N']) ? trim(filter_var($record['N'], FILTER_SANITIZE_URL)) : '';
698
 
733
                        $sector = isset($record['O']) ? Functions::sanitizeFilterString($record['O']) : '';
-
 
734
                        $scholarship = isset($record['P']) ? strtolower(Functions::sanitizeFilterString($record['P'])) : '';
699
                        $movil = isset($record['L']) ? trim(filter_var($record['L'], FILTER_SANITIZE_STRING)) : '';
735
                        
700
                        $movil = preg_replace('/[^0-9]/', '', $movil);
736
                        if($scholarship == 'yes' || $scholarship == 'si') {
701
 
737
                            $scholarship = DiscoveryContact::SCHOLARSHIP_YES;
702
                        $whatsapp = isset($record['M']) ? trim(filter_var($record['M'], FILTER_SANITIZE_STRING)) : '';
738
                        } else {
Línea 729... Línea 765...
729
                                'extension' => $extension,
765
                                'extension' => $extension,
730
                                'movil' => $movil,
766
                                'movil' => $movil,
731
                                'whatsapp' =>  $whatsapp,
767
                                'whatsapp' =>  $whatsapp,
732
                                'linkedin' => $linkedin,
768
                                'linkedin' => $linkedin,
733
                                'sector' => $sector,
769
                                'sector' => $sector,
-
 
770
                                'scholarship' => $scholarship,
734
                            ]);
771
                            ]);
735
                        }
772
                        }
736
                    }
773
                    }
Línea 759... Línea 796...
759
                        'data'   => $messages
796
                        'data'   => $messages
760
                    ]);
797
                    ]);
761
                }
798
                }
762
            } else if ($step == 'process') {
799
            } else if ($step == 'process') {
Línea 763... Línea 800...
763
 
800
 
764
                $key = filter_var($this->params()->fromPost('key'), FILTER_SANITIZE_STRING);
801
                $key = Functions::sanitizeFilterString($this->params()->fromPost('key'));
765
                if (!$key) {
802
                if (!$key) {
766
                    return new JsonModel([
803
                    return new JsonModel([
767
                        'success' => false,
804
                        'success' => false,
768
                        'data' => 'ERROR_CACHE_KEY_EMPTY'
805
                        'data' => 'ERROR_CACHE_KEY_EMPTY'
Línea 821... Línea 858...
821
                    $extension = $record['extension'];
858
                    $extension = $record['extension'];
822
                    $movil = $record['movil'];
859
                    $movil = $record['movil'];
823
                    $whatsapp =  $record['whatsapp'];
860
                    $whatsapp =  $record['whatsapp'];
824
                    $linkedin = $record['linkedin'];
861
                    $linkedin = $record['linkedin'];
825
                    $sector = $record['sector'];
862
                    $sector = $record['sector'];
-
 
863
                    $scholarship = $record['scholarship'];
Línea 826... Línea 864...
826
                    
864
                    
827
                    
865
                    
828
                    $discoveryContact = $discoveryContactMapper->fetchOneByCorporateEmail($email_company);
866
                    $discoveryContact = $discoveryContactMapper->fetchOneByCorporateEmail($email_company);
Línea 845... Línea 883...
845
                        $discoveryContact->phone = empty($phone) ? '' : '+' . $phone;
883
                        $discoveryContact->phone = empty($phone) ? '' : '+' . $phone;
846
                        $discoveryContact->phone_extension = $extension;
884
                        $discoveryContact->phone_extension = $extension;
847
                        $discoveryContact->celular = empty($movil) ? '' : '+' . $movil;
885
                        $discoveryContact->celular = empty($movil) ? '' : '+' . $movil;
848
                        $discoveryContact->whatsapp = empty($whatsapp) ? '' : '+' . $whatsapp;
886
                        $discoveryContact->whatsapp = empty($whatsapp) ? '' : '+' . $whatsapp;
849
                        $discoveryContact->linkedin = $linkedin;
887
                        $discoveryContact->linkedin = $linkedin;
-
 
888
                        $discoveryContact->scholarship = $scholarship;
Línea 850... Línea 889...
850
                      
889
                      
851
                        
890
                        
Línea 898... Línea 937...
898
                                $discoveryContactLog->details .= 'LABEL_WHATSAPP : ' . $discoveryContact->whatsapp  . PHP_EOL;
937
                                $discoveryContactLog->details .= 'LABEL_WHATSAPP : ' . $discoveryContact->whatsapp  . PHP_EOL;
899
                            }
938
                            }
900
                            if ($discoveryContact->linkedin) {
939
                            if ($discoveryContact->linkedin) {
901
                                $discoveryContactLog->details .= 'LABEL_LINKEDIN : ' . $discoveryContact->linkedin  . PHP_EOL;
940
                                $discoveryContactLog->details .= 'LABEL_LINKEDIN : ' . $discoveryContact->linkedin  . PHP_EOL;
902
                            }
941
                            }
-
 
942
                            if ($discoveryContact->scholarship) {
-
 
943
                                $discoveryContactLog->details .= 'LABEL_SCHOLARSHIP : ' . $discoveryContact->scholarship  . PHP_EOL;
-
 
944
                            }
Línea 903... Línea 945...
903
                            
945