本文整理汇总了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();
}
}
}
示例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();
}
}
}