public function postProcess($token = NULL) { global $cookie, $currentIndex; $this->tabAccess = Profile::getProfileAccess($cookie->profile, $this->id); if (Tools::isSubmit('submitAdd' . $this->table)) { if ($id_cms_category = (int) Tools::getValue('id_cms_category')) { if (!CMSCategory::checkBeforeMove($id_cms_category, (int) Tools::getValue('id_parent'))) { $this->_errors[] = Tools::displayError('CMS Category cannot be moved here'); return false; } } } elseif (isset($_GET['statuscms_category']) and Tools::getValue($this->identifier)) { if ($this->tabAccess['edit'] === '1') { if (Validate::isLoadedObject($object = $this->loadObject())) { if ($object->toggleStatus()) { Tools::redirectAdmin($currentIndex . '&conf=5' . ((int) $object->id_parent ? '&id_cms_category=' . (int) $object->id_parent : '') . '&token=' . Tools::getValue('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['delete' . $this->table])) { if ($this->tabAccess['delete'] === '1') { if (Validate::isLoadedObject($object = $this->loadObject()) and isset($this->fieldImageSettings)) { // check if request at least one object with noZeroObject if (isset($object->noZeroObject) and sizeof($taxes = 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 { $this->deleteImage($object->id); if ($this->deleted) { $object->deleted = 1; if ($object->update()) { Tools::redirectAdmin($currentIndex . '&conf=1&token=' . Tools::getValue('token')); } } elseif ($object->delete()) { Tools::redirectAdmin($currentIndex . '&conf=1&token=' . Tools::getValue('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['position'])) { if ($this->tabAccess['edit'] !== '1') { $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); } elseif (!Validate::isLoadedObject($object = new CMSCategory((int) Tools::getValue($this->identifier, Tools::getValue('id_cms_category_to_move', 1))))) { $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($currentIndex . '&' . $this->table . 'Orderby=position&' . $this->table . 'Orderway=asc&conf=5' . (($id_category = (int) Tools::getValue($this->identifier, Tools::getValue('id_cms_category_parent', 1))) ? '&' . $this->identifier . '=' . $id_category : '') . '&token=' . Tools::getAdminTokenLite('AdminCMSContent')); } } elseif (Tools::getValue('submitDel' . $this->table)) { if ($this->tabAccess['delete'] === '1') { if (isset($_POST[$this->table . 'Box'])) { $cms_category = new CMSCategory(); $result = true; $result = $cms_category->deleteSelection(Tools::getValue($this->table . 'Box')); if ($result) { $cms_category->cleanPositions((int) Tools::getValue('id_cms_category')); Tools::redirectAdmin($currentIndex . '&conf=2&token=' . Tools::getAdminTokenLite('AdminCMSContent') . '&id_category=' . (int) Tools::getValue('id_cms_category')); } $this->_errors[] = Tools::displayError('An error occurred while deleting selection.'); } else { $this->_errors[] = Tools::displayError('You must select at least one element to delete.'); } } else { $this->_errors[] = Tools::displayError('You do not have permission to delete here.'); } } parent::postProcess(true); }
public function postProcess() { $this->tabAccess = Profile::getProfileAccess($this->context->employee->id_profile, $this->id); if (Tools::isSubmit('submitAdd' . $this->table)) { $this->action = 'save'; if ($id_cms_category = (int) Tools::getValue('id_cms_category')) { $this->id_object = $id_cms_category; if (!CMSCategory::checkBeforeMove($id_cms_category, (int) Tools::getValue('id_parent'))) { $this->errors[] = Tools::displayError('The CMS Category cannot be moved here.'); return false; } } $object = parent::postProcess(); $this->updateAssoShop((int) Tools::getValue('id_cms_category')); if ($object !== false) { Tools::redirectAdmin(self::$currentIndex . '&conf=3&id_cms_category=' . (int) $object->id . '&token=' . Tools::getValue('token')); } return $object; } elseif (Tools::isSubmit('statuscms_category') && Tools::getValue($this->identifier)) { if ($this->tabAccess['edit'] === '1') { if (Validate::isLoadedObject($object = $this->loadObject())) { if ($object->toggleStatus()) { $identifier = (int) $object->id_parent ? '&id_cms_category=' . (int) $object->id_parent : ''; Tools::redirectAdmin(self::$currentIndex . '&conf=5' . $identifier . '&token=' . Tools::getValue('token')); } else { $this->errors[] = Tools::displayError('An error occurred while updating the status.'); } } else { $this->errors[] = Tools::displayError('An error occurred while updating the status for an object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)'); } } else { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } } elseif (Tools::isSubmit('delete' . $this->table)) { if ($this->tabAccess['delete'] === '1') { if (Validate::isLoadedObject($object = $this->loadObject()) && isset($this->fieldImageSettings)) { // check if request at least one object with noZeroObject if (isset($object->noZeroObject) && count($taxes = 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 { $identifier = (int) $object->id_parent ? '&' . $this->identifier . '=' . (int) $object->id_parent : ''; if ($this->deleted) { $object->deleted = 1; if ($object->update()) { Tools::redirectAdmin(self::$currentIndex . '&conf=1&token=' . Tools::getValue('token') . $identifier); } } elseif ($object->delete()) { Tools::redirectAdmin(self::$currentIndex . '&conf=1&token=' . Tools::getValue('token') . $identifier); } $this->errors[] = Tools::displayError('An error occurred during deletion.'); } } else { $this->errors[] = Tools::displayError('An error occurred while deleting the object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)'); } } else { $this->errors[] = Tools::displayError('You do not have permission to delete this.'); } } elseif (Tools::isSubmit('position')) { $object = new CMSCategory((int) Tools::getValue($this->identifier, Tools::getValue('id_cms_category_to_move', 1))); if ($this->tabAccess['edit'] !== '1') { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } elseif (!Validate::isLoadedObject($object)) { $this->errors[] = Tools::displayError('An error occurred while updating the status for an 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 { $identifier = (int) $object->id_parent ? '&' . $this->identifier . '=' . (int) $object->id_parent : ''; $token = Tools::getAdminTokenLite('AdminCmsContent'); Tools::redirectAdmin(self::$currentIndex . '&' . $this->table . 'Orderby=position&' . $this->table . 'Orderway=asc&conf=5' . $identifier . '&token=' . $token); } } elseif (Tools::getValue('submitDel' . $this->table) || Tools::getValue('submitBulkdelete' . $this->table)) { if ($this->tabAccess['delete'] === '1') { if (Tools::isSubmit($this->table . 'Box')) { $cms_category = new CMSCategory(); $result = true; $result = $cms_category->deleteSelection(Tools::getValue($this->table . 'Box')); if ($result) { $cms_category->cleanPositions((int) Tools::getValue('id_cms_category')); $token = Tools::getAdminTokenLite('AdminCmsContent'); Tools::redirectAdmin(self::$currentIndex . '&conf=2&token=' . $token . '&id_cms_category=' . (int) Tools::getValue('id_cms_category')); } $this->errors[] = Tools::displayError('An error occurred while deleting this selection.'); } else { $this->errors[] = Tools::displayError('You must select at least one element to delete.'); } } else { $this->errors[] = Tools::displayError('You do not have permission to delete this.'); } } parent::postProcess(); }