[*] MO : Review of the productcomments module - Part3

This commit is contained in:
gBrunier
2011-08-11 12:07:25 +00:00
parent d0dbb5c185
commit abbcf84e6d
4 changed files with 73 additions and 13 deletions
@@ -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
*
+1
View File
@@ -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';
@@ -107,6 +107,7 @@ class ProductComments extends Module
$this->_html = '<h2>'.$this->displayName.'</h2>';
$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:
+16 -13
View File
@@ -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}