diff --git a/modules/productcomments/ProductComment.php b/modules/productcomments/ProductComment.php index 575cfb39c..ed254b0d4 100644 --- a/modules/productcomments/ProductComment.php +++ b/modules/productcomments/ProductComment.php @@ -281,6 +281,21 @@ class ProductComment extends ObjectModel WHERE `id_product_comment` = '.(int)($id_product_comment))); } + /** + * Delete usefulness + * + * @return boolean succeed + */ + public static function deleteUsefulness($id_product_comment) + { + if (!Validate::isUnsignedId($id_product_comment)) + die(Tools::displayError()); + + return (Db::getInstance()->Execute(' + DELETE FROM `'._DB_PREFIX_.'product_comment_usefulness` + WHERE `id_product_comment` = '.(int)($id_product_comment))); + } + /** * Report comment * diff --git a/modules/productcomments/fr.php b/modules/productcomments/fr.php index 70145adf7..5f3268d1f 100644 --- a/modules/productcomments/fr.php +++ b/modules/productcomments/fr.php @@ -66,6 +66,7 @@ $_MODULE['<{productcomments}prestashop>productcomments_f8694a9aae2eb045920f613cf $_MODULE['<{productcomments}prestashop>productcomments_6bf852d9850445291f5e9d4740ac7b50'] = 'Un texte est nécessaire pour publier un commentaire.'; $_MODULE['<{productcomments}prestashop>productcomments_6d28f2900adb9e500868166f6d04da92'] = 'Vous devez attendre'; $_MODULE['<{productcomments}prestashop>productcomments_ba8d7ae5dcadfba739f28a777378f208'] = 'secondes avant de poster un nouveau commentaire.'; +$_MODULE['<{productcomments}prestashop>productcomments_4494d00c901c9e22ff3b953177205cea'] = 'Etes vous sur de vouloir signaler ce commentaire?'; $_MODULE['<{productcomments}prestashop>productcomments_7c3b0e9898b88deee7ea75aafd2e37e2'] = 'Note moyenne'; $_MODULE['<{productcomments}prestashop>productcomments_663fc7093256cda156e571631ddb295e'] = 'personne(s) sur'; $_MODULE['<{productcomments}prestashop>productcomments_e759c67f646fedbee26e1e6732588a98'] = 'ont trouvé ce commentaire utile'; diff --git a/modules/productcomments/productcomments.php b/modules/productcomments/productcomments.php index cf2c82986..77f45f0d0 100644 --- a/modules/productcomments/productcomments.php +++ b/modules/productcomments/productcomments.php @@ -107,6 +107,7 @@ class ProductComments extends Module $this->_html = '

'.$this->displayName.'

'; $this->_postProcess(); $this->_checkModerateComment(); + $this->_checkReportedComment(); $this->_checkCriterion(); $this->_updateApplicationCriterion(); @@ -129,6 +130,45 @@ class ProductComments extends Module (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: + ; + } + } + } + } + + private function _checkReportedComment() + { + $action = Tools::getValue('action'); + if (empty($action) === false) + { + $product_comments = Tools::getValue('id_product_comment'); + if (sizeof($product_comments)) { require_once(dirname(__FILE__).'/ProductComment.php'); @@ -153,6 +193,7 @@ class ProductComments extends Module $comment->delete(); ProductComment::deleteGrades((int)$id_product_comment); ProductComment::deleteReports((int)$id_product_comment); + ProductComment::deleteUsefulness((int)$id_product_comment); } break; default: diff --git a/modules/productcomments/productcomments.tpl b/modules/productcomments/productcomments.tpl index fcac10223..28634d2b6 100644 --- a/modules/productcomments/productcomments.tpl +++ b/modules/productcomments/productcomments.tpl @@ -62,19 +62,22 @@ $('span[id^=comment_report_]').click(function(){ - var idProductComment = $(this).attr('id').replace('comment_report_', ''); - var parent = $(this).parent(); - - $.ajax({ - {/literal}url: "{$module_dir}productcomments-ajax.php",{literal} - post: "POST", - data: "id_product_comment=" + idProductComment + "&action=report", - success: function(result){ - parent.fadeOut("normal", function() { - parent.remove(); - }); - } - }); + {/literal}if (confirm('{l s='Are you sure you want report this comment?' mod='productcomments'}')){literal} + { + var idProductComment = $(this).attr('id').replace('comment_report_', ''); + var parent = $(this).parent(); + + $.ajax({ + {/literal}url: "{$module_dir}productcomments-ajax.php",{literal} + post: "POST", + data: "id_product_comment=" + idProductComment + "&action=report", + success: function(result){ + parent.fadeOut("normal", function() { + parent.remove(); + }); + } + }); + } }); }); {/literal}