Esempio n. 1
0
 protected function stageCleanup()
 {
     Finder::setIndexInvalid();
     WordTable::cleanUpData();
     ChainTable::cleanUpData();
     SiteLinkTable::cleanUpData();
     $this->nextStage();
 }
Esempio n. 2
0
 /**
  * Deletes location from the tree
  *
  *
  */
 public static function delete($primary, $behaviour = array('REBALANCE' => true, 'DELETE_SUBTREE' => true, 'RESET_LEGACY' => true))
 {
     $primary = Assert::expectIntegerPositive($primary, '$primary');
     if (!is_array($behaviour)) {
         $behaviour = array();
     }
     if (!isset($behaviour['REBALANCE'])) {
         $behaviour['REBALANCE'] = true;
     }
     if (!isset($behaviour['RESET_LEGACY'])) {
         $behaviour['RESET_LEGACY'] = true;
     }
     if (!isset($behaviour['DELETE_SUBTREE'])) {
         $behaviour['DELETE_SUBTREE'] = true;
     }
     // delete connected data of sub-nodes
     if ($behaviour['DELETE_SUBTREE']) {
         $rangeSql = parent::getSubtreeRangeSqlForNode($primary);
         Name\LocationTable::deleteMultipleByParentRangeSql($rangeSql);
         ExternalTable::deleteMultipleByParentRangeSql($rangeSql);
     }
     if ($behaviour['RESET_LEGACY']) {
         $data = static::getList(array('filter' => array('=ID' => $primary), 'select' => array('TYPE_ID')))->fetch();
     }
     $delResult = parent::delete($primary, $behaviour);
     // delete connected data
     if ($delResult->isSuccess()) {
         Name\LocationTable::deleteMultipleForOwner($primary);
         ExternalTable::deleteMultipleForOwner($primary);
         if ($behaviour['RESET_LEGACY'] && intval($data['TYPE_ID'])) {
             $type = TypeTable::getList(array('filter' => array('=ID' => $data['TYPE_ID']), 'select' => array('CODE')))->fetch();
             if (strlen($type['CODE']) && in_array($type['CODE'], array('COUNTRY', 'REGION', 'CITY'))) {
                 static::resetLegacyPath();
             }
         }
         $GLOBALS['CACHE_MANAGER']->ClearByTag('sale-location-data');
         Search\Finder::setIndexInvalid();
     }
     return $delResult;
 }
Esempio n. 3
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);
 }