diff --git a/modules/productcomments/ProductComment.php b/modules/productcomments/ProductComment.php index 1e08f3dee..7b6007ab4 100644 --- a/modules/productcomments/ProductComment.php +++ b/modules/productcomments/ProductComment.php @@ -256,6 +256,21 @@ class ProductComment extends ObjectModel ORDER BY pc.`date_add` DESC')); } + /** + * Get all comments + * + * @return array Comments + */ + public static function getAll() + { + return (Db::getInstance()->ExecuteS(' + SELECT pc.`id_product_comment`, pc.`id_product`, IF(c.id_customer, CONCAT(c.`firstname`, \' \', c.`lastname`), pc.customer_name) customer_name, pc.`content`, pc.`grade`, pc.`date_add`, pl.`name` + FROM `'._DB_PREFIX_.'product_comment` pc + LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = pc.`id_customer`) + LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = pc.`id_product` AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Context::getContext()->shop->sqlLang('pl').') + ORDER BY pc.`date_add` DESC')); + } + /** * Validate a comment * diff --git a/modules/productcomments/js/moderate.js b/modules/productcomments/js/moderate.js index 620d3e3fa..93700f938 100644 --- a/modules/productcomments/js/moderate.js +++ b/modules/productcomments/js/moderate.js @@ -32,6 +32,14 @@ function getCommentForm() return (document.comment_form); } +function getCommentDeleteForm() +{ + if (document.forms) + return (document.forms['delete_comment_form']); + else + return (document.delete_comment_form); +} + function acceptComment(id) { var form = getCommentForm(); @@ -51,6 +59,19 @@ function deleteComment(id) form.submit(); } +function delComment(id, confirmation) +{ + var answer = confirm(confirmation); + if (answer) + { + var form = getCommentDeleteForm(); + if (id) + form.elements['delete_id_product_comment'].value = id; + form.elements['delete_action'].value = 'delete'; + form.submit(); + } +} + function getCriterionForm() { if (document.forms) diff --git a/modules/productcomments/productcomments-extra.tpl b/modules/productcomments/productcomments-extra.tpl index ffd5ed460..2805bd600 100644 --- a/modules/productcomments/productcomments-extra.tpl +++ b/modules/productcomments/productcomments-extra.tpl @@ -62,7 +62,6 @@ o.value = $(this).val(); datas.push(o); }); - console.log(datas); $.ajax({ {/literal}url: "{$module_dir}productcomments-ajax.php",{literal} post: "POST", diff --git a/modules/productcomments/productcomments.php b/modules/productcomments/productcomments.php index acfda5b47..69f55bf4e 100644 --- a/modules/productcomments/productcomments.php +++ b/modules/productcomments/productcomments.php @@ -131,6 +131,7 @@ class ProductComments extends Module $this->_checkReportedComment(); $this->_checkCriterion(); $this->_updateApplicationCriterion(); + $this->_checkDeleteComment(); return $this->_html.$this->_displayForm(); } @@ -309,6 +310,8 @@ class ProductComments extends Module $this->_displayFormReported(); $this->_displayFormConfigurationCriterion(); $this->_displayFormApplicationCriterion(); + $this->_displayFormDelete(); + return $this->_html; } @@ -596,6 +599,77 @@ class ProductComments extends Module } } + private function _displayFormDelete() + { + $this->_html .= ' +