Ejemplo n.º 1
0
 public static function doAjaxStuff($parameters = array())
 {
     $errors = static::checkAccessPermissions(array('CHECK_CSRF' => true));
     $data = array();
     if (count($errors) == 0) {
         $import = static::getImportInstance($parameters);
         $request = static::getRequest();
         // action: restore indexes
         if (isset($request['POST']['RESTORE_INDEXES'])) {
             $import->restoreIndexes();
             $import->unLockProcess();
         }
         // action: process ajax
         if (isset($request['POST']['AJAX_CALL'])) {
             $data = array();
             if ($request['POST']['step'] == 0) {
                 $import->reset();
             }
             @set_time_limit(0);
             $data['PERCENT'] = $import->performStage();
             $data['NEXT_STAGE'] = $import->getStageCode();
             if ($data['PERCENT'] == 100) {
                 $import->logFinalResult();
                 $data['STAT'] = array_values($import->getStatisticsAll());
                 // to force to [] in json
                 Finder::setIndexInvalid();
                 // drop search index
                 LocationHelper::deleteInformer('SALE_LOCATIONPRO_DATABASE_FAILURE');
                 // delete database failure messages, if any
                 $GLOBALS['CACHE_MANAGER']->ClearByTag('sale-location-data');
                 if ($request['POST']['OPTIONS']['DROP_ALL'] == 1 || $request['POST']['ONLY_DELETE_ALL'] == 1) {
                     Main\Config\Option::set('sale', self::LOC2_IMPORT_PERFORMED_OPTION, 'Y');
                 }
             }
         }
     }
     return array('ERRORS' => $errors, 'DATA' => $data);
 }