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


PHP Hook::updateCarrier方法代码示例

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


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

示例1: postProcess

 public function postProcess()
 {
     global $currentIndex;
     if (Tools::getValue('submitAdd' . $this->table)) {
         /* Checking fields validity */
         $this->validateRules();
         if (!sizeof($this->_errors)) {
             $id = (int) Tools::getValue('id_' . $this->table);
             /* Object update */
             if (isset($id) and !empty($id)) {
                 if ($this->tabAccess['edit'] === '1') {
                     $object = new $this->className($id);
                     if (Validate::isLoadedObject($object)) {
                         Db::getInstance()->Execute('DELETE FROM ' . _DB_PREFIX_ . 'carrier_group WHERE id_carrier = ' . (int) $id);
                         $object->deleted = 1;
                         $object->update();
                         $objectNew = new $this->className();
                         $this->copyFromPost($objectNew, $this->table);
                         $result = $objectNew->add();
                         if (Validate::isLoadedObject($objectNew)) {
                             $this->afterDelete($objectNew, $object->id);
                             Hook::updateCarrier((int) $object->id, $objectNew);
                         }
                         $this->changeGroups($objectNew->id);
                         if (!$result) {
                             $this->_errors[] = Tools::displayError('An error occurred while updating object.') . ' <b>' . $this->table . '</b>';
                         } elseif ($this->postImage($objectNew->id)) {
                             $this->changeZones($objectNew->id);
                             Tools::redirectAdmin($currentIndex . '&id_' . $this->table . '=' . $object->id . '&conf=4' . '&token=' . $this->token);
                         }
                     } else {
                         $this->_errors[] = Tools::displayError('An error occurred while updating object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
                     }
                 } else {
                     $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
                 }
             } else {
                 if ($this->tabAccess['add'] === '1') {
                     $object = new $this->className();
                     $this->copyFromPost($object, $this->table);
                     if (!$object->add()) {
                         $this->_errors[] = Tools::displayError('An error occurred while creating object.') . ' <b>' . $this->table . '</b>';
                     } elseif ($_POST['id_' . $this->table] = $object->id and $this->postImage($object->id) and $this->_redirect) {
                         $this->changeZones($object->id);
                         $this->changeGroups($object->id);
                         Tools::redirectAdmin($currentIndex . '&id_' . $this->table . '=' . $object->id . '&conf=3' . '&token=' . $this->token);
                     }
                 } else {
                     $this->_errors[] = Tools::displayError('You do not have permission to add here.');
                 }
             }
         }
     } elseif ((isset($_GET['status' . $this->table]) or isset($_GET['status'])) and Tools::getValue($this->identifier)) {
         if ($this->tabAccess['edit'] === '1') {
             if (Tools::getValue('id_carrier') == Configuration::get('PS_CARRIER_DEFAULT')) {
                 $this->_errors[] = Tools::displayError('You can\'t disable the default carrier, please change your default carrier first.');
             } else {
                 parent::postProcess();
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
         }
     } else {
         if (Tools::isSubmit('submitDel' . $this->table) && in_array(Configuration::get('PS_CARRIER_DEFAULT'), Tools::getValue('carrierBox')) or isset($_GET['delete' . $this->table]) and Tools::getValue('id_carrier') == Configuration::get('PS_CARRIER_DEFAULT')) {
             $this->_errors[] = $this->l('Please set another carrier as default before deleting');
         } else {
             parent::postProcess();
         }
     }
 }
开发者ID:srikanthash09,项目名称:codetestdatld,代码行数:70,代码来源:AdminCarriers.php

示例2: postProcess

 public function postProcess()
 {
     global $currentIndex;
     if (Tools::getValue('submitAdd' . $this->table)) {
         /* Checking fields validity */
         $this->validateRules();
         if (!sizeof($this->_errors)) {
             $id = intval(Tools::getValue('id_' . $this->table));
             /* Object update */
             if (isset($id) and !empty($id)) {
                 if ($this->tabAccess['edit'] === '1') {
                     $object = new $this->className($id);
                     if (Validate::isLoadedObject($object)) {
                         $object->deleted = 1;
                         $object->update();
                         $objectNew = new $this->className();
                         $this->copyFromPost($objectNew, $this->table);
                         $result = $objectNew->add();
                         if (Validate::isLoadedObject($objectNew)) {
                             $this->afterDelete($objectNew, $object->id);
                             Hook::updateCarrier(intval($object->id), $objectNew);
                         }
                         if (!$result) {
                             $this->_errors[] = Tools::displayError('an error occurred while updating object') . ' <b>' . $this->table . '</b>';
                         } elseif ($this->postImage($objectNew->id)) {
                             $this->changeZones($objectNew->id);
                             Tools::redirectAdmin($currentIndex . '&id_' . $this->table . '=' . $object->id . '&conf=4' . '&token=' . $this->token);
                         }
                     } else {
                         $this->_errors[] = Tools::displayError('an error occurred while updating object') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
                     }
                 } else {
                     $this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
                 }
             } else {
                 if ($this->tabAccess['add'] === '1') {
                     $object = new $this->className();
                     $this->copyFromPost($object, $this->table);
                     if (!$object->add()) {
                         $this->_errors[] = Tools::displayError('an error occurred while creating object') . ' <b>' . $this->table . '</b>';
                     } elseif ($_POST['id_' . $this->table] = $object->id and $this->postImage($object->id) and $this->_redirect) {
                         $this->changeZones($object->id);
                         Tools::redirectAdmin($currentIndex . '&id_' . $this->table . '=' . $object->id . '&conf=3' . '&token=' . $this->token);
                     }
                 } else {
                     $this->_errors[] = Tools::displayError('You do not have permission to add anything here.');
                 }
             }
         }
     } else {
         if (isset($_GET['delete' . $this->table]) and Tools::getValue('id_carrier') == Configuration::get('PS_CARRIER_DEFAULT')) {
             $this->_errors[] = $this->l('Please set another carrier as default before deleting');
         } else {
             parent::postProcess();
         }
     }
 }
开发者ID:raulgimenez,项目名称:dreamongraphics_shop,代码行数:57,代码来源:AdminCarriers.php


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