Ejemplo n.º 1
0
 private function _checkCriterion()
 {
     $action_criterion = Tools::getValue('criterion_action');
     $name = Tools::getValue('criterion');
     if (Tools::isSubmit('submitAddCriterion')) {
         require_once dirname(__FILE__) . '/ProductCommentCriterion.php';
         $languages = Language::getLanguages();
         $id_criterion = (int) Tools::getValue('id_product_comment_criterion');
         $productCommentCriterion = new ProductCommentCriterion((int) $id_criterion);
         foreach ($languages as $lang) {
             $productCommentCriterion->name[(int) $lang['id_lang']] = Tools::getValue('criterion_' . (int) $lang['id_lang']);
         }
         // Check default language criterion name
         $defaultLanguage = new Language((int) Configuration::get('PS_LANG_DEFAULT'));
         if (!Tools::getValue('criterion_' . $defaultLanguage->id)) {
             $this->_html .= '<div class="error"><img src="../img/admin/error2.png" />' . $this->l('The field <b>Name</b> is required at least in') . ' ' . $defaultLanguage->name . '</div>';
             return;
         }
         $productCommentCriterion->id_product_comment_criterion_type = (int) Tools::getValue('criterion_type');
         $productCommentCriterion->active = (int) Tools::getValue('criterion_active');
         if ($productCommentCriterion->save()) {
             $this->_html .= '<div class="conf confirm">' . (Tools::getValue('editCriterion') ? $this->l('Criterion updated') : $this->l('Criterion added')) . '</div>';
         }
     } else {
         if (!empty($action_criterion) && empty($name)) {
             $id_product_comment_criterion = Tools::getValue('id_product_comment_criterion');
             require_once dirname(__FILE__) . '/ProductCommentCriterion.php';
             switch ($action_criterion) {
                 case 'edit':
                     ProductCommentCriterion::update($id_product_comment_criterion, Tools::getValue('criterion_id_lang'), Tools::getValue('criterion_name'));
                     break;
                 case 'delete':
                     ProductCommentCriterion::delete($id_product_comment_criterion);
                     break;
                 default:
             }
         }
     }
 }
Ejemplo n.º 2
0
 private function _checkCriterion()
 {
     $action_criterion = Tools::getValue('criterion_action');
     $name = Tools::getValue('criterion');
     if (Tools::isSubmit('submitCriterion') and empty($action_criterion) and !empty($name)) {
         global $cookie;
         require_once dirname(__FILE__) . '/ProductCommentCriterion.php';
         ProductCommentCriterion::add($cookie->id_lang, $name);
         $this->_html .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="' . $this->l('Confirmation') . '" />' . $this->l('Settings updated') . '</div>';
     } elseif (!empty($action_criterion) and empty($name)) {
         $id_product_comment_criterion = Tools::getValue('id_product_comment_criterion');
         require_once dirname(__FILE__) . '/ProductCommentCriterion.php';
         switch ($action_criterion) {
             case 'edit':
                 ProductCommentCriterion::update($id_product_comment_criterion, Tools::getValue('criterion_id_lang'), Tools::getValue('criterion_name'));
                 break;
             case 'delete':
                 ProductCommentCriterion::delete($id_product_comment_criterion);
                 break;
             default:
         }
     }
 }
Ejemplo n.º 3
0
 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');
 }
Ejemplo n.º 4
0
 private function _checkCriterion()
 {
     $action_criterion = Tools::getValue('criterion_action');
     $name = Tools::getValue('criterion');
     if (Tools::isSubmit('submitAddCriterion')) {
         global $cookie;
         require_once dirname(__FILE__) . '/ProductCommentCriterion.php';
         $languages = Language::getLanguages();
         $id_criterion = (int) Tools::getValue('id_product_comment_criterion');
         $productCommentCriterion = new ProductCommentCriterion((int) $id_criterion);
         foreach ($languages as $lang) {
             $productCommentCriterion->name[(int) $lang['id_lang']] = Tools::getValue('criterion_' . (int) $lang['id_lang']);
         }
         $productCommentCriterion->id_product_comment_criterion_type = (int) Tools::getValue('criterion_type');
         $productCommentCriterion->active = (int) Tools::getValue('criterion_active');
         if ($productCommentCriterion->save()) {
             $this->_html .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="' . $this->l('Confirmation') . '" />' . (Tools::getValue('editCriterion') ? $this->l('Criterion updated') : $this->l('Criterion added')) . '</div>';
         }
     } elseif (!empty($action_criterion) and empty($name)) {
         $id_product_comment_criterion = Tools::getValue('id_product_comment_criterion');
         require_once dirname(__FILE__) . '/ProductCommentCriterion.php';
         switch ($action_criterion) {
             case 'edit':
                 ProductCommentCriterion::update($id_product_comment_criterion, Tools::getValue('criterion_id_lang'), Tools::getValue('criterion_name'));
                 break;
             case 'delete':
                 ProductCommentCriterion::delete($id_product_comment_criterion);
                 break;
             default:
         }
     }
 }