Example #1
0
 private function _checkModerateComment()
 {
     $action = Tools::getValue('action');
     if (Tools::isSubmit('submitModerate')) {
         $moderate = Tools::getValue('moderate');
         if (intval($moderate) != 0) {
             $moderate = 1;
         }
         Configuration::updateValue('PRODUCT_COMMENTS_MODERATE', intval($moderate));
         $this->_html .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="' . $this->l('Confirmation') . '" />' . $this->l('Settings updated') . '</div>';
     } else {
         if (empty($action) === false && intval(Configuration::get('PRODUCT_COMMENTS_MODERATE'))) {
             $id_product_comment = Tools::getValue('id_product_comment');
             require_once dirname(__FILE__) . '/ProductComment.php';
             switch ($action) {
                 case 'accept':
                     $comment = new ProductComment($id_product_comment);
                     $comment->validate();
                     break;
                 case 'delete':
                     $comment = new ProductComment($id_product_comment);
                     $comment->delete();
                     ProductComment::deleteGrades($id_product_comment);
                     break;
                 default:
             }
         }
     }
 }
Example #2
0
 private function _checkReportedComment()
 {
     $action = Tools::getValue('action');
     if (empty($action) === false) {
         $product_comments = Tools::getValue('id_product_comment');
         if (count($product_comments)) {
             require_once dirname(__FILE__) . '/ProductComment.php';
             switch ($action) {
                 case 'accept':
                     foreach ($product_comments as $id_product_comment) {
                         if (!$id_product_comment) {
                             continue;
                         }
                         $comment = new ProductComment((int) $id_product_comment);
                         $comment->validate();
                         ProductComment::deleteReports((int) $id_product_comment);
                     }
                     break;
                 case 'delete':
                     foreach ($product_comments as $id_product_comment) {
                         if (!$id_product_comment) {
                             continue;
                         }
                         $comment = new ProductComment((int) $id_product_comment);
                         $comment->delete();
                         ProductComment::deleteGrades((int) $id_product_comment);
                         ProductComment::deleteReports((int) $id_product_comment);
                         ProductComment::deleteUsefulness((int) $id_product_comment);
                     }
                     break;
                 default:
             }
         }
     }
 }
 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');
 }
 private function _checkModerateComment()
 {
     $action = Tools::getValue('action');
     if (empty($action) === false && (int) Configuration::get('PRODUCT_COMMENTS_MODERATE')) {
         $product_comments = Tools::getValue('id_product_comment');
         if (sizeof($product_comments)) {
             require_once dirname(__FILE__) . '/ProductComment.php';
             switch ($action) {
                 case 'accept':
                     foreach ($product_comments as $id_product_comment) {
                         if (!$id_product_comment) {
                             continue;
                         }
                         $comment = new ProductComment((int) $id_product_comment);
                         $comment->validate();
                     }
                     break;
                 case 'delete':
                     foreach ($product_comments as $id_product_comment) {
                         if (!$id_product_comment) {
                             continue;
                         }
                         $comment = new ProductComment((int) $id_product_comment);
                         $comment->delete();
                         ProductComment::deleteGrades((int) $id_product_comment);
                     }
                     break;
                 default:
             }
         }
     }
 }