private function _updateApplicationCriterion() { if (Tools::isSubmit('submitApplicationCriterion')) { include_once dirname(__FILE__) . '/ProductCommentCriterion.php'; $id_criterion = (int) Tools::getValue('id_criterion'); $productCommentCriterion = new ProductCommentCriterion((int) $id_criterion); if ($productCommentCriterion->id) { if ($productCommentCriterion->id_product_comment_criterion_type == 2) { $productCommentCriterion->deleteCategories(); if ($categories = Tools::getValue('id_product')) { if (count($categories)) { foreach ($categories as $id_category) { $productCommentCriterion->addCategory((int) $id_category); } } } } else { if ($productCommentCriterion->id_product_comment_criterion_type == 3) { $productCommentCriterion->deleteProducts(); if ($products = Tools::getValue('id_product')) { if (count($products)) { foreach ($products as $product) { $productCommentCriterion->addProduct((int) $product); } } } } } } $this->_html .= '<div class="conf confirm">' . $this->l('Settings updated') . '</div>'; } }
protected function _postProcess() { $this->_setFilters(); if (Tools::isSubmit('submitModerate')) { Configuration::updateValue('PRODUCT_COMMENTS_MODERATE', (int) Tools::getValue('PRODUCT_COMMENTS_MODERATE')); Configuration::updateValue('PRODUCT_COMMENTS_ALLOW_GUESTS', (int) Tools::getValue('PRODUCT_COMMENTS_ALLOW_GUESTS')); Configuration::updateValue('PRODUCT_COMMENTS_MINIMAL_TIME', (int) Tools::getValue('PRODUCT_COMMENTS_MINIMAL_TIME')); $this->_html .= '<div class="conf confirm alert alert-success">' . $this->l('Settings updated') . '</div>'; } elseif (Tools::isSubmit('productcomments')) { $id_product_comment = (int) Tools::getValue('id_product_comment'); $comment = new ProductComment($id_product_comment); $comment->validate(); ProductComment::deleteReports($id_product_comment); } elseif (Tools::isSubmit('deleteproductcomments')) { $id_product_comment = (int) Tools::getValue('id_product_comment'); $comment = new ProductComment($id_product_comment); $comment->delete(); } elseif (Tools::isSubmit('submitEditCriterion')) { $criterion = new ProductCommentCriterion((int) Tools::getValue('id_product_comment_criterion')); $criterion->id_product_comment_criterion_type = Tools::getValue('id_product_comment_criterion_type'); $criterion->active = Tools::getValue('active'); $languages = Language::getLanguages(); $name = array(); foreach ($languages as $key => $value) { $name[$value['id_lang']] = Tools::getValue('name_' . $value['id_lang']); } $criterion->name = $name; $criterion->save(); // Clear before reinserting data $criterion->deleteCategories(); $criterion->deleteProducts(); if ($criterion->id_product_comment_criterion_type == 2) { if ($categories = Tools::getValue('categoryBox')) { if (count($categories)) { foreach ($categories as $id_category) { $criterion->addCategory((int) $id_category); } } } } else { if ($criterion->id_product_comment_criterion_type == 3) { if ($products = Tools::getValue('ids_product')) { if (count($products)) { foreach ($products as $product) { $criterion->addProduct((int) $product); } } } } } if ($criterion->save()) { Tools::redirectAdmin(Context::getContext()->link->getAdminLink('AdminModules') . '&configure=' . $this->name . '&conf=4'); } else { $this->_html .= '<div class="conf confirm alert alert-danger">' . $this->l('The criterion could not be saved') . '</div>'; } } elseif (Tools::isSubmit('deleteproductcommentscriterion')) { $productCommentCriterion = new ProductCommentCriterion((int) Tools::getValue('id_product_comment_criterion')); if ($productCommentCriterion->id) { if ($productCommentCriterion->delete()) { $this->_html .= '<div class="conf confirm alert alert-success">' . $this->l('Criterion deleted') . '</div>'; } } } elseif (Tools::isSubmit('statusproductcommentscriterion')) { $criterion = new ProductCommentCriterion((int) Tools::getValue('id_product_comment_criterion')); if ($criterion->id) { $criterion->active = (int) (!$criterion->active); $criterion->save(); } Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules') . '&configure=' . $this->name . '&tab_module=' . $this->tab . '&conf=4&module_name=' . $this->name); } elseif ($id_product_comment = (int) Tools::getValue('approveComment')) { $comment = new ProductComment($id_product_comment); $comment->validate(); } elseif ($id_product_comment = (int) Tools::getValue('noabuseComment')) { ProductComment::deleteReports($id_product_comment); } $this->_clearcache('productcomments_reviews.tpl'); }