public function postProcess() { if (Tools::isSubmit('deletesmart_blog_category') && Tools::getValue('id_smart_blog_category') != '') { $id_lang = (int) Context::getContext()->language->id; $catpost = (int) SmartBlogPost::getToltalByCategory($id_lang, Tools::getValue('id_smart_blog_category')); if ((int) $catpost != 0) { $this->errors[] = Tools::displayError('You need to delete all posts associate with this category .'); } else { $BlogCategory = new BlogCategory((int) Tools::getValue('id_smart_blog_category')); if (!$BlogCategory->delete()) { $this->errors[] = Tools::displayError('An error occurred while deleting the object.') . ' <b>' . $this->table . ' (' . Db::getInstance()->getMsgError() . ')</b>'; } else { Hook::exec('actionsbdeletecat', array('BlogCategory' => $BlogCategory)); Tools::redirectAdmin($this->context->link->getAdminLink('AdminBlogCategory')); } } } elseif (Tools::isSubmit('submitAddsmart_blog_category')) { parent::validateRules(); if (count($this->errors)) { return false; } if (!($id_smart_blog_category = (int) Tools::getValue('id_smart_blog_category'))) { $BlogCategory = new BlogCategory(); $languages = Language::getLanguages(false); foreach ($languages as $language) { $title = str_replace('"', '', htmlspecialchars_decode(html_entity_decode(Tools::getValue('meta_title_' . $language['id_lang'])))); $BlogCategory->meta_title[$language['id_lang']] = $title; $BlogCategory->meta_keyword[$language['id_lang']] = Tools::getValue('meta_keyword_' . $language['id_lang']); $BlogCategory->meta_description[$language['id_lang']] = Tools::getValue('meta_description_' . $language['id_lang']); $BlogCategory->description[$language['id_lang']] = Tools::getValue('description_' . $language['id_lang']); if (Tools::getValue('link_rewrite_' . $language['id_lang']) == '' && Tools::getValue('link_rewrite_' . $language['id_lang']) == null) { $BlogCategory->link_rewrite[$language['id_lang']] = str_replace(array(' ', ':', '\\', '/', '#', '!', '*', '.', '?'), '-', Tools::getValue('meta_title_' . $language['id_lang'])); } else { $BlogCategory->link_rewrite[$language['id_lang']] = str_replace(array(' ', ':', '\\', '/', '#', '!', '*', '.', '?'), '-', Tools::getValue('link_rewrite_' . $language['id_lang'])); } } $BlogCategory->id_parent = Tools::getValue('id_parent'); $BlogCategory->position = Tools::getValue('position'); $BlogCategory->desc_limit = Tools::getValue('desc_limit'); $BlogCategory->active = Tools::getValue('active'); $BlogCategory->created = Date('y-m-d H:i:s'); $BlogCategory->modified = Date('y-m-d H:i:s'); if (!$BlogCategory->save()) { $this->errors[] = Tools::displayError('An error has occurred: Can\'t save the current object'); } else { Hook::exec('actionsbnewcat', array('BlogCategory' => $BlogCategory)); $this->processImageCategory($_FILES, $BlogCategory->id); Tools::redirectAdmin($this->context->link->getAdminLink('AdminBlogCategory')); } } elseif ($id_smart_blog_category = Tools::getValue('id_smart_blog_category')) { $BlogCategory = new BlogCategory($id_smart_blog_category); $languages = Language::getLanguages(false); foreach ($languages as $language) { $title = str_replace('"', '', htmlspecialchars_decode(html_entity_decode(Tools::getValue('meta_title_' . $language['id_lang'])))); $BlogCategory->meta_title[$language['id_lang']] = $title; $BlogCategory->meta_keyword[$language['id_lang']] = Tools::getValue('meta_keyword_' . $language['id_lang']); $BlogCategory->meta_description[$language['id_lang']] = Tools::getValue('meta_description_' . $language['id_lang']); $BlogCategory->description[$language['id_lang']] = Tools::getValue('description_' . $language['id_lang']); $BlogCategory->link_rewrite[$language['id_lang']] = str_replace(array(' ', ':', '\\', '/', '#', '!', '*', '.', '?'), '-', Tools::getValue('link_rewrite_' . $language['id_lang'])); } $BlogCategory->id_parent = Tools::getValue('id_parent'); $BlogCategory->position = Tools::getValue('position'); $BlogCategory->desc_limit = Tools::getValue('desc_limit'); $BlogCategory->active = Tools::getValue('active'); $BlogCategory->modified = Date('y-m-d H:i:s'); if (!$BlogCategory->update()) { $this->errors[] = Tools::displayError('An error occurred while updating an object.') . ' <b>' . $this->table . ' (' . Db::getInstance()->getMsgError() . ')</b>'; } else { Hook::exec('actionsbupdatecat', array('BlogCategory' => $BlogCategory)); } $this->processImageCategory($_FILES, $BlogCategory->id_smart_blog_category); Tools::redirectAdmin($this->context->link->getAdminLink('AdminBlogCategory')); } } elseif (Tools::isSubmit('statussmart_blog_category') && Tools::getValue($this->identifier)) { if ($this->tabAccess['edit'] === '1') { if (Validate::isLoadedObject($object = $this->loadObject())) { if ($object->toggleStatus()) { Hook::exec('actionsbtogglecat', array('SmartBlogCat' => $this->object)); $identifier = (int) $object->id_parent ? '&id_smart_blog_category=' . (int) $object->id_parent : ''; Tools::redirectAdmin($this->context->link->getAdminLink('AdminBlogCategory')); } 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('smart_blog_categoryOrderby') && Tools::isSubmit('smart_blog_categoryOrderway')) { $this->_defaultOrderBy = Tools::getValue('smart_blog_categoryOrderby'); $this->_defaultOrderWay = Tools::getValue('smart_blog_categoryOrderway'); } }