当前位置: 首页>>代码示例>>PHP>>正文


PHP Carrier::cleanPositions方法代码示例

本文整理汇总了PHP中Carrier::cleanPositions方法的典型用法代码示例。如果您正苦于以下问题:PHP Carrier::cleanPositions方法的具体用法?PHP Carrier::cleanPositions怎么用?PHP Carrier::cleanPositions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Carrier的用法示例。


在下文中一共展示了Carrier::cleanPositions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: delete

 /**
  * @since 1.5.0
  * @see ObjectModel::delete()
  */
 public function delete()
 {
     if (!parent::delete()) {
         return false;
     }
     Carrier::cleanPositions();
     return Db::getInstance()->delete('cart_rule_carrier', 'id_carrier = ' . (int) $this->id) && Db::getInstance()->delete('module_carrier', 'id_reference = ' . (int) $this->id_reference) && $this->deleteTaxRulesGroup(Shop::getShops(true, null, true));
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:12,代码来源:Carrier.php

示例2: postProcess

 public function postProcess()
 {
     if (Tools::getValue('submitAdd' . $this->table)) {
         /* Checking fields validity */
         $this->validateRules();
         if (!count($this->errors)) {
             $id = (int) Tools::getValue('id_' . $this->table);
             /* Object update */
             if (isset($id) && !empty($id)) {
                 try {
                     if ($this->tabAccess['edit'] === '1') {
                         $current_carrier = new Carrier($id);
                         if (!Validate::isLoadedObject($current_carrier)) {
                             throw new PrestaShopException('Cannot load Carrier object');
                         }
                         // Duplicate current Carrier
                         $new_carrier = $current_carrier->duplicateObject();
                         if (Validate::isLoadedObject($new_carrier)) {
                             // Set flag deteled to true for historization
                             $current_carrier->deleted = true;
                             $current_carrier->update();
                             // Fill the new carrier object
                             $this->copyFromPost($new_carrier, $this->table);
                             $new_carrier->position = $current_carrier->position;
                             $new_carrier->update();
                             $this->updateAssoShop($new_carrier->id);
                             $new_carrier->copyCarrierData((int) $current_carrier->id);
                             $this->changeGroups($new_carrier->id);
                             // Call of hooks
                             Hook::exec('actionCarrierUpdate', array('id_carrier' => (int) $current_carrier->id, 'carrier' => $new_carrier));
                             $this->postImage($new_carrier->id);
                             $this->changeZones($new_carrier->id);
                             $new_carrier->setTaxRulesGroup((int) Tools::getValue('id_tax_rules_group'));
                             Tools::redirectAdmin(self::$currentIndex . '&id_' . $this->table . '=' . $current_carrier->id . '&conf=4&token=' . $this->token);
                         } else {
                             $this->errors[] = Tools::displayError('An error occurred while updating an object.') . ' <b>' . $this->table . '</b>';
                         }
                     } else {
                         $this->errors[] = Tools::displayError('You do not have permission to edit this.');
                     }
                 } catch (PrestaShopException $e) {
                     $this->errors[] = $e->getMessage();
                 }
             } else {
                 if ($this->tabAccess['add'] === '1') {
                     // Create new Carrier
                     $carrier = new Carrier();
                     $this->copyFromPost($carrier, $this->table);
                     $carrier->position = Carrier::getHigherPosition() + 1;
                     if ($carrier->add()) {
                         if (($_POST['id_' . $this->table] = $carrier->id) && $this->postImage($carrier->id) && $this->_redirect) {
                             $carrier->setTaxRulesGroup((int) Tools::getValue('id_tax_rules_group'), true);
                             $this->changeZones($carrier->id);
                             $this->changeGroups($carrier->id);
                             $this->updateAssoShop($carrier->id);
                             Tools::redirectAdmin(self::$currentIndex . '&id_' . $this->table . '=' . $carrier->id . '&conf=3&token=' . $this->token);
                         }
                     } else {
                         $this->errors[] = Tools::displayError('An error occurred while creating an object.') . ' <b>' . $this->table . '</b>';
                     }
                 } else {
                     $this->errors[] = Tools::displayError('You do not have permission to add this.');
                 }
             }
         }
         parent::postProcess();
     } else {
         if (isset($_GET['isFree' . $this->table])) {
             $this->processIsFree();
         } else {
             /*
             	if ((Tools::isSubmit('submitDel'.$this->table) && in_array(Configuration::get('PS_CARRIER_DEFAULT'), Tools::getValue('carrierBox')))
             				|| (isset($_GET['delete'.$this->table]) && Tools::getValue('id_carrier') == Configuration::get('PS_CARRIER_DEFAULT')))
             					$this->errors[] = $this->l('Please set another carrier as default before deleting this one.');
             			else
             			{
             */
             // if deletion : removes the carrier from the warehouse/carrier association
             if (Tools::isSubmit('delete' . $this->table)) {
                 $id = (int) Tools::getValue('id_' . $this->table);
                 // Delete from the reference_id and not from the carrier id
                 $carrier = new Carrier((int) $id);
                 Warehouse::removeCarrier($carrier->id_reference);
             } else {
                 if (Tools::isSubmit($this->table . 'Box') && count(Tools::isSubmit($this->table . 'Box')) > 0) {
                     $ids = Tools::getValue($this->table . 'Box');
                     array_walk($ids, 'intval');
                     foreach ($ids as $id) {
                         // Delete from the reference_id and not from the carrier id
                         $carrier = new Carrier((int) $id);
                         Warehouse::removeCarrier($carrier->id_reference);
                     }
                 }
             }
             parent::postProcess();
             Carrier::cleanPositions();
             //}
         }
     }
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:100,代码来源:AdminCarriersController.php

示例3: delete

 /**
  * @since 1.5.0
  * @see ObjectModel::delete()
  */
 public function delete()
 {
     if (!parent::delete()) {
         return false;
     }
     Carrier::cleanPositions();
     return Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'cart_rule_carrier WHERE id_carrier = ' . (int) $this->id) && $this->deleteTaxRulesGroup(Shop::getShops(true, null, true));
 }
开发者ID:rrameshsat,项目名称:Prestashop,代码行数:12,代码来源:Carrier.php

示例4: postProcess

 /**
  * Manage page processing
  */
 public function postProcess()
 {
     if (!isset($this->table)) {
         return false;
     }
     // set token
     $token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
     // Sub included tab postProcessing
     $this->includeSubTab('postProcess', array('status', 'submitAdd1', 'submitDel', 'delete', 'submitFilter', 'submitReset'));
     /* Delete object image */
     if (isset($_GET['deleteImage'])) {
         if (Validate::isLoadedObject($object = $this->loadObject())) {
             /** @var ObjectModel $object */
             if ($object->deleteImage()) {
                 Tools::redirectAdmin(self::$currentIndex . '&add' . $this->table . '&' . $this->identifier . '=' . Tools::getValue($this->identifier) . '&conf=7&token=' . $token);
             }
         }
         $this->_errors[] = Tools::displayError('An error occurred during image deletion (cannot load object).');
     } elseif (isset($_GET['delete' . $this->table])) {
         if ($this->tabAccess['delete'] === '1') {
             if (Validate::isLoadedObject($object = $this->loadObject()) && isset($this->fieldImageSettings)) {
                 /** @var ObjectModel $object */
                 // check if request at least one object with noZeroObject
                 if (isset($object->noZeroObject) && count(call_user_func(array($this->className, $object->noZeroObject))) <= 1) {
                     $this->_errors[] = Tools::displayError('You need at least one object.') . ' <b>' . $this->table . '</b><br />' . Tools::displayError('You cannot delete all of the items.');
                 } else {
                     if ($this->deleted) {
                         $object->deleteImage();
                         $object->deleted = 1;
                         if (method_exists($object, 'cleanPositions')) {
                             $object->cleanPositions();
                         }
                         if ($object->update()) {
                             Tools::redirectAdmin(self::$currentIndex . '&conf=1&token=' . $token);
                         }
                     } elseif ($object->delete()) {
                         if (method_exists($object, 'cleanPositions')) {
                             $object->cleanPositions();
                         }
                         Tools::redirectAdmin(self::$currentIndex . '&conf=1&token=' . $token);
                     }
                     $this->_errors[] = Tools::displayError('An error occurred during deletion.');
                 }
             } else {
                 $this->_errors[] = Tools::displayError('An error occurred while deleting object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to delete here.');
         }
     } elseif ((isset($_GET['status' . $this->table]) || isset($_GET['status'])) && Tools::getValue($this->identifier)) {
         if ($this->tabAccess['edit'] === '1') {
             if (Validate::isLoadedObject($object = $this->loadObject())) {
                 /** @var ObjectModel $object */
                 if ($object->toggleStatus()) {
                     Tools::redirectAdmin(self::$currentIndex . '&conf=5' . (($id_category = (int) Tools::getValue('id_category')) && Tools::getValue('id_product') ? '&id_category=' . $id_category : '') . '&token=' . $token);
                 } else {
                     $this->_errors[] = Tools::displayError('An error occurred while updating status.');
                 }
             } else {
                 $this->_errors[] = Tools::displayError('An error occurred while updating status for object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
         }
     } elseif (isset($_GET['position'])) {
         /** @var ObjectModel $object */
         if ($this->tabAccess['edit'] !== '1') {
             $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
         } elseif (!Validate::isLoadedObject($object = $this->loadObject())) {
             $this->_errors[] = Tools::displayError('An error occurred while updating status for object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
         } elseif (!$object->updatePosition((int) Tools::getValue('way'), (int) Tools::getValue('position'))) {
             $this->_errors[] = Tools::displayError('Failed to update the position.');
         } else {
             Tools::redirectAdmin(self::$currentIndex . '&' . $this->table . 'Orderby=position&' . $this->table . 'Orderway=asc&conf=5' . (($id_identifier = (int) Tools::getValue($this->identifier)) ? '&' . $this->identifier . '=' . $id_identifier : '') . '&token=' . $token);
         }
     } elseif (Tools::getValue('submitDel' . $this->table)) {
         if ($this->tabAccess['delete'] === '1') {
             if (isset($_POST[$this->table . 'Box'])) {
                 /** @var ObjectModel $object */
                 $object = new $this->className();
                 if (isset($object->noZeroObject) && (count(call_user_func(array($this->className, $object->noZeroObject))) <= 1 || count($_POST[$this->table . 'Box']) == count(call_user_func(array($this->className, $object->noZeroObject))))) {
                     $this->_errors[] = Tools::displayError('You need at least one object.') . ' <b>' . $this->table . '</b><br />' . Tools::displayError('You cannot delete all of the items.');
                 } else {
                     $result = true;
                     if ($this->deleted) {
                         foreach (Tools::getValue($this->table . 'Box') as $id) {
                             /** @var ObjectModel $toDelete */
                             $toDelete = new $this->className($id);
                             $toDelete->deleted = 1;
                             $result = $result && $toDelete->update();
                         }
                     } else {
                         $result = $object->deleteSelection(Tools::getValue($this->table . 'Box'));
                     }
                     if ($result) {
                         Tools::redirectAdmin(self::$currentIndex . '&conf=2&token=' . $token);
                     }
//.........这里部分代码省略.........
开发者ID:abdoumej,项目名称:libsamy,代码行数:101,代码来源:AdminTab.php


注:本文中的Carrier::cleanPositions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。