Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 17270 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 17270 Rev 17271
Línea 716... Línea 716...
716
                    'data'   => 'ERROR_UNAUTHORIZED'
716
                    'data'   => 'ERROR_UNAUTHORIZED'
717
                ]);
717
                ]);
718
            }
718
            }
Línea 719... Línea 719...
719
            
719
            
720
            $step = Functions::sanitizeFilterString($this->params()->fromPost('step')); 
-
 
721
 
-
 
722
            $storage = Storage::getInstance($this->config, $this->adapter);
-
 
723
            
-
 
724
            // Log uploaded files info
-
 
725
            $files = $request->getFiles()->toArray();
-
 
726
            $this->logger->info('Uploaded files: ' . print_r($files, true));
-
 
727
            
-
 
728
            $storage->setFiles($files);
-
 
729
 
-
 
730
            if(!$storage->setCurrentFilename('file')) {
-
 
731
                $this->logger->err('Upload failed: Could not set current filename');
-
 
732
                return new JsonModel([
-
 
733
                    'success' => false,
-
 
734
                    'data' => 'ERROR_UPLOAD_FILE'
-
 
735
                ]);
-
 
Línea 736... Línea 720...
736
            }
720
            $step = Functions::sanitizeFilterString($this->params()->fromPost('step')); 
737
                
721
                
738
            if($step == 'validation') { 
722
            if($step == 'validation') { 
739
                try {
723
                try {
-
 
724
                    $userMapper = UserMapper::getInstance($this->adapter);
-
 
725
                    $topicUserMapper = MicrolearningTopicUserMapper::getInstance($this->adapter);
-
 
726
                    $storage = Storage::getInstance($this->config, $this->adapter);
-
 
727
            
-
 
728
                    // Log uploaded files info
-
 
729
                    $files = $request->getFiles()->toArray();
-
 
730
                    $this->logger->info('Uploaded files: ' . print_r($files, true));
-
 
731
                    
-
 
732
                    $storage->setFiles($files);
-
 
733
        
-
 
734
                    if(!$storage->setCurrentFilename('file')) {
-
 
735
                        $this->logger->err('Upload failed: Could not set current filename');
-
 
736
                        return new JsonModel([
-
 
737
                            'success' => false,
-
 
738
                            'data' => 'ERROR_UPLOAD_FILE'
Línea 740... Línea 739...
740
                    $userMapper = UserMapper::getInstance($this->adapter);
739
                        ]);
741
                    $topicUserMapper = MicrolearningTopicUserMapper::getInstance($this->adapter);
740
                    }
742
 
741
 
743
                    $tmp_filename = $storage->getTmpFilename();
742
                    $tmp_filename = $storage->getTmpFilename();
Línea 891... Línea 890...
891
                    throw $e;
890
                    throw $e;
892
                }
891
                }
893
            }
892
            }
Línea 894... Línea 893...
894
 
893
 
895
            if($step == 'process') {
-
 
896
                // get the key from the post
894
            if($step == 'process') {
-
 
895
                $key = Functions::sanitizeFilterString($this->params()->fromPost('key')); 
897
                $key = Functions::sanitizeFilterString($this->params()->fromPost('key')); 
896
                
898
                if(!$key) {
897
                if(!$key) {
899
                    return new JsonModel([
898
                    return new JsonModel([
900
                        'success' => false,
899
                        'success' => false,
901
                        'data' => 'ERROR_CACHE_KEY_EMPTY'
900
                        'data' => 'ERROR_CACHE_KEY_EMPTY'
902
                    ]); 
901
                    ]); 
903
                }
-
 
-
 
902
                }
904
                // get the value from the cache
903
                
905
                $value = $this->cache->getItem($key);
-
 
906
                $this->logger->info('Value: ' . print_r($value, true));
-
 
-
 
904
                $value = $this->cache->getItem($key);
907
                // if the value is not found, return an error
905
 
908
                if(!$value) {
906
                if(!$value) {
909
                    return new JsonModel([
907
                    return new JsonModel([
910
                        'success' => false,
908
                        'success' => false,
911
                        'data' => 'ERROR_CACHE_NOT_FOUND'
909
                        'data' => 'ERROR_CACHE_NOT_FOUND'
912
                    ]); 
910
                    ]); 
Línea 913... Línea -...
913
                }
-
 
914
                
911
                }
915
                // unserialize the value
912
                
916
                $records = unserialize($value);
-
 
-
 
913
                $records = unserialize($value);
917
                $this->logger->info('Records: ' . print_r($records, true));
914
                $this->logger->info('Records: ' . print_r($records, true));
918
                // if the value is not found, return an error
915
 
919
                if(!$records) {
916
                if(!$records) {
920
                    return new JsonModel([
917
                    return new JsonModel([
921
                        'success' => false,
918
                        'success' => false,
Línea 1017... Línea 1014...
1017
                    } else {
1014
                    } else {
1018
                        $user->is_adult = $isAdult ? User::IS_ADULT_YES : User::IS_ADULT_NO;
1015
                        $user->is_adult = $isAdult ? User::IS_ADULT_YES : User::IS_ADULT_NO;
1019
                        if($user->email_verified == User::EMAIL_VERIFIED_NO || $user->status != User::STATUS_ACTIVE) {
1016
                        if($user->email_verified == User::EMAIL_VERIFIED_NO || $user->status != User::STATUS_ACTIVE) {
1020
                            $user->email_verified = User::EMAIL_VERIFIED_YES;
1017
                            $user->email_verified = User::EMAIL_VERIFIED_YES;
1021
                            $user->status != User::STATUS_ACTIVE;
1018
                            $user->status != User::STATUS_ACTIVE;
1022
                            
-
 
1023
                            
-
 
1024
                        }
1019
                        }
1025
                        if(!$userMapper->update($user)) {
1020
                        if(!$userMapper->update($user)) {
1026
                            $csv .= "$first_name|$last_name|$email|FAIL UPDATE USER \r\n";
1021
                            $csv .= "$first_name|$last_name|$email|FAIL UPDATE USER \r\n";
1027
                            continue;
1022
                            continue;
1028
                        }
1023
                        }
1029
                            
-
 
1030
                        
-
 
1031
                    }
1024
                    }
Línea 1032... Línea 1025...
1032
                    
1025
                    
1033
        
1026
        
Línea 1307... Línea 1300...
1307
                    
1300
                    
Línea 1308... Línea 1301...
1308
                }
1301
                }
Línea 1309... Línea -...
1309
                
-
 
1310
                $notificationMapper = NotificationMapper::getInstance($this->adapter);
1302
                
1311
                
1303
                $notificationMapper = NotificationMapper::getInstance($this->adapter);
1312
                
1304
                
1313
                $users_processed = 0;
1305
                $users_processed = 0;
1314
                $users_previous = 0;
1306
                $users_previous = 0;
Línea 1390... Línea 1382...
1390
                        'users_in_the_topic' => $users_in_the_topic,
1382
                        'users_in_the_topic' => $users_in_the_topic,
1391
                        'users_previous' => $users_previous,
1383
                        'users_previous' => $users_previous,
1392
                        'csv_base64_content' => base64_encode($csv),
1384
                        'csv_base64_content' => base64_encode($csv),
1393
                        'csv_filename' => 'topic-users-' .date('Y-m-d-h-i-s').  '.csv'
1385
                        'csv_filename' => 'topic-users-' .date('Y-m-d-h-i-s').  '.csv'
1394
                    ]
1386
                    ]
1395
                ]); 
1387
                ]);
1396
                
-
 
1397
                
-
 
1398
                
-
 
1399
                
-
 
1400
            }
1388
            }
Línea -... Línea 1389...
-
 
1389
            
1401
            
1390
            
1402
            return new JsonModel([
1391
            return new JsonModel([
1403
                'success' => false,
1392
                'success' => false,
1404
                'data' => 'ERROR_PARAMETERS_ARE_INVALID'
1393
                'data' => 'ERROR_PARAMETERS_ARE_INVALID'
1405
            ]);
1394
            ]);