[*] MO : Review of the productcomments module - Part2
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8016 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -18,7 +18,8 @@
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @author Presta
|
||||
SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 7040 $
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
@@ -91,7 +92,7 @@ class ProductComment extends ObjectModel
|
||||
*
|
||||
* @return array Comments
|
||||
*/
|
||||
public static function getByProduct($id_product, $p = 1, $n = null)
|
||||
public static function getByProduct($id_product, $p = 1, $n = null, $id_customer = null)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_product))
|
||||
die(Tools::displayError());
|
||||
@@ -102,8 +103,14 @@ class ProductComment extends ObjectModel
|
||||
$p = 1;
|
||||
if ($n != null AND $n <= 0)
|
||||
$n = 5;
|
||||
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
|
||||
SELECT pc.`id_product_comment`, IF(c.id_customer, CONCAT(c.`firstname`, \' \', LEFT(c.`lastname`, 1)), pc.customer_name) customer_name, pc.`content`, pc.`grade`, pc.`date_add`, pc.title
|
||||
SELECT pc.`id_product_comment`,
|
||||
(SELECT count(*) FROM `ps_product_comment_usefulness` pcu WHERE pcu.`id_product_comment` = pc.`id_product_comment` AND pcu.`usefulness` = 1) as total_useful,
|
||||
(SELECT count(*) FROM `ps_product_comment_usefulness` pcu WHERE pcu.`id_product_comment` = pc.`id_product_comment`) as total_advice, '.
|
||||
($id_customer ? '(SELECT count(*) FROM `ps_product_comment_usefulness` pcuc WHERE pcuc.`id_product_comment` = pc.`id_product_comment` AND pcuc.id_customer = '.(int)$id_customer.') as customer_advice, ' : '').
|
||||
($id_customer ? '(SELECT count(*) FROM `ps_product_comment_report` pcrc WHERE pcrc.`id_product_comment` = pc.`id_product_comment` AND pcrc.id_customer = '.(int)$id_customer.') as customer_report, ' : '').'
|
||||
IF(c.id_customer, CONCAT(c.`firstname`, \' \', LEFT(c.`lastname`, 1)), pc.customer_name) customer_name, pc.`content`, pc.`grade`, pc.`date_add`, pc.title
|
||||
FROM `'._DB_PREFIX_.'product_comment` pc
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON c.`id_customer` = pc.`id_customer`
|
||||
WHERE pc.`id_product` = '.(int)($id_product).($validate == '1' ? ' AND pc.`validate` = 1' : '').'
|
||||
@@ -111,6 +118,11 @@ class ProductComment extends ObjectModel
|
||||
'.($n ? 'LIMIT '.(int)(($p - 1) * $n).', '.(int)($n) : ''));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return customer's comment
|
||||
*
|
||||
* @return arrayComments
|
||||
*/
|
||||
public static function getByCustomer($id_product, $id_customer, $last = false, $id_guest = false)
|
||||
{
|
||||
$results = Db::getInstance()->ExecuteS('
|
||||
@@ -221,9 +233,8 @@ class ProductComment extends ObjectModel
|
||||
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`)
|
||||
WHERE pc.`validate` = '.(int)($validate).'
|
||||
AND pl.`id_lang` = '.(int)Context::getContext()->language->id.'
|
||||
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').')
|
||||
WHERE pc.`validate` = '.(int)($validate).'
|
||||
ORDER BY pc.`date_add` DESC'));
|
||||
}
|
||||
|
||||
@@ -255,4 +266,88 @@ class ProductComment extends ObjectModel
|
||||
DELETE FROM `'._DB_PREFIX_.'product_comment_grade`
|
||||
WHERE `id_product_comment` = '.(int)($id_product_comment)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Reports
|
||||
*
|
||||
* @return boolean succeed
|
||||
*/
|
||||
public static function deleteReports($id_product_comment)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_product_comment))
|
||||
die(Tools::displayError());
|
||||
return (Db::getInstance()->Execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'product_comment_report`
|
||||
WHERE `id_product_comment` = '.(int)($id_product_comment)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Report comment
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function reportComment($id_product_comment, $id_customer)
|
||||
{
|
||||
return (Db::getInstance()->Execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'product_comment_report` (`id_product_comment`, `id_customer`)
|
||||
VALUES ('.(int)$id_product_comment.', '.$id_customer.')'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Comment already report
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isAlreadyReport($id_product_comment, $id_customer)
|
||||
{
|
||||
return (bool)Db::getInstance()->getValue('
|
||||
SELECT COUNT(*)
|
||||
FROM `'._DB_PREFIX_.'product_comment_report`
|
||||
WHERE `id_customer` = '.(int)($id_customer).'
|
||||
AND `id_product_comment` = '.(int)($id_product_comment));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set comment usefulness
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function setCommentUsefulness($id_product_comment, $usefulness, $id_customer)
|
||||
{
|
||||
return (Db::getInstance()->Execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'product_comment_usefulness` (`id_product_comment`, `usefulness`, `id_customer`)
|
||||
VALUES ('.(int)$id_product_comment.', '.(int)$usefulness.', '.(int)$id_customer.')'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Usefulness already set
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isAlreadyUsefulness($id_product_comment, $id_customer)
|
||||
{
|
||||
return (bool)Db::getInstance()->getValue('
|
||||
SELECT COUNT(*)
|
||||
FROM `'._DB_PREFIX_.'product_comment_usefulness`
|
||||
WHERE `id_customer` = '.(int)($id_customer).'
|
||||
AND `id_product_comment` = '.(int)($id_product_comment));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get reported comments
|
||||
*
|
||||
* @return array Comments
|
||||
*/
|
||||
public static function getReportedComments()
|
||||
{
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
|
||||
SELECT DISTINCT(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_report` pcr
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_comment` pc
|
||||
ON pcr.id_product_comment = pc.id_product_comment
|
||||
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.' AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Context::getContext()->shop->sqlLang('pl').')
|
||||
ORDER BY pc.`date_add` DESC');
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -36,6 +36,8 @@ $_MODULE['<{productcomments}prestashop>productcomments_c4408d335012a56ff58937d78
|
||||
$_MODULE['<{productcomments}prestashop>productcomments_f2a6c498fb90ee345d997f888fce3b18'] = 'Supprimer';
|
||||
$_MODULE['<{productcomments}prestashop>productcomments_8bf0c707232d63bf83b4b2467d2df41a'] = 'Sélection :';
|
||||
$_MODULE['<{productcomments}prestashop>productcomments_d00b7f656273a495f555bead0248d6f5'] = 'Aucun commentaire à valider.';
|
||||
$_MODULE['<{productcomments}prestashop>productcomments_82bd3dd5eb07bcc37a9649cbb1a5fd33'] = 'Commentaires signalés';
|
||||
$_MODULE['<{productcomments}prestashop>productcomments_66c4dd257983350f8cc2f8b71ade47ba'] = 'Aucun commentaire signalé';
|
||||
$_MODULE['<{productcomments}prestashop>productcomments_7799b301b44c329fc9ec6a3a9c1905e0'] = 'Ajouter un nouveau critère';
|
||||
$_MODULE['<{productcomments}prestashop>productcomments_7753ab38f8e113e8af65ab1241331625'] = 'Vous pouvez définir plusieurs critères afin de guider vos clients dans leur commentaire. Par exemple: performance, design etc ...';
|
||||
$_MODULE['<{productcomments}prestashop>productcomments_bc58d00e1e42de31a8e58f8dc7d9bdc7'] = 'Vous pouvez ajouter un nouveau critère ci-dessous :';
|
||||
@@ -65,6 +67,12 @@ $_MODULE['<{productcomments}prestashop>productcomments_6bf852d9850445291f5e9d474
|
||||
$_MODULE['<{productcomments}prestashop>productcomments_6d28f2900adb9e500868166f6d04da92'] = 'Vous devez attendre';
|
||||
$_MODULE['<{productcomments}prestashop>productcomments_ba8d7ae5dcadfba739f28a777378f208'] = 'secondes avant de poster un nouveau 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';
|
||||
$_MODULE['<{productcomments}prestashop>productcomments_39630ad6ee79b8653ea89194cdb45bec'] = 'Ce commentaire vous a-t-il été utile?';
|
||||
$_MODULE['<{productcomments}prestashop>productcomments_a6105c0a611b41b08f1209506350279e'] = 'oui';
|
||||
$_MODULE['<{productcomments}prestashop>productcomments_7fa3b767c460b54a2be4d49030b349c7'] = 'non';
|
||||
$_MODULE['<{productcomments}prestashop>productcomments_28b3b1e564a00f572c5d4e21da986d49'] = 'Reporter un abus';
|
||||
$_MODULE['<{productcomments}prestashop>productcomments_08621d00a3a801b9159a11b8bbd69f89'] = 'Aucun commentaire n\'a été publié pour le moment.';
|
||||
$_MODULE['<{productcomments}prestashop>products-comparison_8413c683b4b27cc3f4dbd4c90329d8ba'] = 'Commentaires';
|
||||
$_MODULE['<{productcomments}prestashop>products-comparison_b1897515d548a960afe49ecf66a29021'] = 'Moyenne';
|
||||
|
||||
@@ -50,4 +50,17 @@ CREATE TABLE IF NOT EXISTS `PREFIX_product_comment_grade` (
|
||||
`grade` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id_product_comment`, `id_product_comment_criterion`),
|
||||
KEY `id_product_comment_criterion` (`id_product_comment_criterion`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `PREFIX_product_comment_usefulness` (
|
||||
`id_product_comment` int(10) unsigned NOT NULL,
|
||||
`id_customer` int(10) unsigned NOT NULL,
|
||||
`usefulness` tinyint(1) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id_product_comment`, `id_customer`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `PREFIX_product_comment_report` (
|
||||
`id_product_comment` int(10) unsigned NOT NULL,
|
||||
`id_customer` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id_product_comment`, `id_customer`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__).'/../../config/config.inc.php');
|
||||
require_once(dirname(__FILE__).'/../../init.php');
|
||||
include(dirname(__FILE__).'/ProductComment.php');
|
||||
|
||||
if (Tools::getValue('action') AND Tools::getValue('id_product_comment') AND Context::getContext()->cookie->id_customer)
|
||||
{
|
||||
if (Tools::getValue('action') == 'report')
|
||||
{
|
||||
if (!ProductComment::isAlreadyReport(Tools::getValue('id_product_comment'), Context::getContext()->cookie->id_customer) AND ProductComment::reportComment((int)Tools::getValue('id_product_comment'), (int)Context::getContext()->cookie->id_customer))
|
||||
die('0');
|
||||
}
|
||||
elseif (Tools::getValue('action') == 'usefulness' AND Tools::getValue('value') AND Tools::getValue('value'))
|
||||
{
|
||||
if (!ProductComment::isAlreadyUsefulness(Tools::getValue('id_product_comment'), Context::getContext()->cookie->id_customer) AND ProductComment::setCommentUsefulness((int)Tools::getValue('id_product_comment'), (bool)((int)Tools::getValue('value')), Context::getContext()->cookie->id_customer))
|
||||
die('0');
|
||||
}
|
||||
}
|
||||
|
||||
die('1');
|
||||
|
||||
@@ -114,11 +114,16 @@
|
||||
background-position: 0 -16px
|
||||
}
|
||||
|
||||
#product_comments_block_tab button {
|
||||
#product_comments_block_tab button.usefulness_btn {
|
||||
background-color: #bbb;
|
||||
border: solid 1px #999;
|
||||
padding: 1px;
|
||||
cursor: pointer;
|
||||
color: #fff;
|
||||
border-radius: 3px
|
||||
margin: 3px
|
||||
}
|
||||
|
||||
#product_comments_block_tab span.report_btn {
|
||||
cursor: pointer;
|
||||
text-decoration: underline
|
||||
}
|
||||
@@ -141,6 +141,7 @@ class ProductComments extends Module
|
||||
continue;
|
||||
$comment = new ProductComment((int)$id_product_comment);
|
||||
$comment->validate();
|
||||
ProductComment::deleteReports((int)$id_product_comment);
|
||||
}
|
||||
break;
|
||||
case 'delete':
|
||||
@@ -151,6 +152,7 @@ class ProductComments extends Module
|
||||
$comment = new ProductComment((int)$id_product_comment);
|
||||
$comment->delete();
|
||||
ProductComment::deleteGrades((int)$id_product_comment);
|
||||
ProductComment::deleteReports((int)$id_product_comment);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -159,6 +161,7 @@ class ProductComments extends Module
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function _checkCriterion()
|
||||
{
|
||||
$action_criterion = Tools::getValue('criterion_action');
|
||||
@@ -241,6 +244,7 @@ class ProductComments extends Module
|
||||
private function _displayForm()
|
||||
{
|
||||
$this->_displayFormModerate();
|
||||
$this->_displayFormReported();
|
||||
$this->_displayFormConfigurationCriterion();
|
||||
$this->_displayFormApplicationCriterion();
|
||||
return $this->_html;
|
||||
@@ -327,6 +331,54 @@ class ProductComments extends Module
|
||||
$this->_html .= '</fieldset><br />';
|
||||
}
|
||||
|
||||
private function _displayFormReported()
|
||||
{
|
||||
$this->_html .= '<fieldset class="width2">
|
||||
<legend><img src="'.$this->_path.'img/comments_delete.png" alt="" title="" />'.$this->l('Reported Comments').'</legend>';
|
||||
|
||||
require_once(dirname(__FILE__).'/ProductComment.php');
|
||||
$comments = ProductComment::getReportedComments();
|
||||
if (sizeof($comments))
|
||||
{
|
||||
$this->_html .= '
|
||||
<form action="'.$this->_baseUrl.'" method="post" name="comment_form">
|
||||
<input type="hidden" name="id_product_comment[]" id="id_product_comment" />
|
||||
<input type="hidden" name="action" id="action" />
|
||||
<br /><table class="table" border="0" cellspacing="0" cellpadding="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><input class="noborder" type="checkbox" name="id_product_comment[]" onclick="checkDelBoxes(this.form, \'id_product_comment[]\', this.checked)" /></th>
|
||||
<th style="width:150px;">'.$this->l('Author').'</th>
|
||||
<th style="width:550px;">'.$this->l('Comment').'</th>
|
||||
<th style="width:150px;">'.$this->l('Product name').'</th>
|
||||
<th style="width:30px;">'.$this->l('Actions').'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
foreach ($comments AS $comment)
|
||||
$this->_html .= '<tr>
|
||||
<td><input class="noborder" type="checkbox" value="'.$comment['id_product_comment'].'" name="id_product_comment[]" /></td>
|
||||
<td>'.htmlspecialchars($comment['customer_name'], ENT_COMPAT, 'UTF-8').'.</td>
|
||||
<td>'.htmlspecialchars($comment['content'], ENT_COMPAT, 'UTF-8').'</td>
|
||||
<td>'.$comment['id_product'].' - '.htmlspecialchars($comment['name'], ENT_COMPAT, 'UTF-8').'</td>
|
||||
<td><a href="javascript:;" onclick="acceptComment(\''.(int)($comment['id_product_comment']).'\');"><img src="'.$this->_path.'img/accept.png" alt="'.$this->l('Accept').'" title="'.$this->l('Accept').'" /></a>
|
||||
<a href="javascript:;" onclick="deleteComment(\''.(int)($comment['id_product_comment']).'\');"><img src="'.$this->_path.'img/delete.png" alt="'.$this->l('Delete').'" title="'.$this->l('Delete').'" /></a></td>
|
||||
</tr>';
|
||||
$this->_html .= '
|
||||
<tr>
|
||||
<td colspan="4" style="font-weight:bold;text-align:right">'.$this->l('Selection:').'</td>
|
||||
<td><a href="javascript:;" onclick="acceptComment(0);"><img src="'.$this->_path.'img/accept.png" alt="'.$this->l('Accept').'" title="'.$this->l('Accept').'" /></a>
|
||||
<a href="javascript:;" onclick="deleteComment(0);"><img src="'.$this->_path.'img/delete.png" alt="'.$this->l('Delete').'" title="'.$this->l('Delete').'" /></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>';
|
||||
}
|
||||
else
|
||||
$this->_html .= $this->l('No reported comment at this time.');
|
||||
$this->_html .= '</fieldset><br />';
|
||||
}
|
||||
|
||||
private function _displayFormConfigurationCriterion()
|
||||
{
|
||||
$langs = Language::getLanguages(false);
|
||||
@@ -595,11 +647,11 @@ class ProductComments extends Module
|
||||
foreach ($averages AS $average)
|
||||
$averageTotal += (float)($average);
|
||||
$averageTotal = count($averages) ? ($averageTotal / count($averages)) : 0;
|
||||
|
||||
|
||||
Context::getContext()->smarty->assign(array(
|
||||
'logged' => (int)Context::getContext()->cookie->id_customer,
|
||||
'action_url' => '',
|
||||
'comments' => ProductComment::getByProduct((int)Tools::getValue('id_product')),
|
||||
'comments' => ProductComment::getByProduct((int)Tools::getValue('id_product'), 1, null, Context::getContext()->cookie->id_customer),
|
||||
'criterions' => ProductCommentCriterion::getByProduct((int)Tools::getValue('id_product'), Context::getContext()->language->id),
|
||||
'averages' => $averages,
|
||||
'product_comment_path' => $this->_path,
|
||||
|
||||
@@ -23,6 +23,62 @@
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
<script type="text/javascript">
|
||||
{literal}
|
||||
$('document').ready(function(){
|
||||
$('button[id^=comment_useful_yes_]').click(function(){
|
||||
|
||||
var idProductComment = $(this).attr('id').replace('comment_useful_yes_', '');
|
||||
var parent = $(this).parent();
|
||||
|
||||
$.ajax({
|
||||
{/literal}url: "{$module_dir}productcomments-ajax.php",{literal}
|
||||
post: "POST",
|
||||
data: "id_product_comment=" + idProductComment + "&action=usefulness&value=1",
|
||||
success: function(result){
|
||||
parent.fadeOut("normal", function() {
|
||||
parent.remove();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('button[id^=comment_useful_no_]').click(function(){
|
||||
|
||||
var idProductComment = $(this).attr('id').replace('comment_useful_no_', '');
|
||||
var parent = $(this).parent();
|
||||
|
||||
$.ajax({
|
||||
{/literal}url: "{$module_dir}productcomments-ajax.php",{literal}
|
||||
post: "POST",
|
||||
data: "id_product_comment=" + idProductComment + "&action=usefulness&value=0",
|
||||
success: function(result){
|
||||
parent.fadeOut("normal", function() {
|
||||
parent.remove();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('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}
|
||||
</script>
|
||||
|
||||
<div id="idTab5">
|
||||
<div id="product_comments_block_tab">
|
||||
@@ -48,6 +104,19 @@
|
||||
<div class="comment_details">
|
||||
<h4>{$comment.title}</h4>
|
||||
<p>{$comment.content|escape:'html':'UTF-8'|nl2br}</p>
|
||||
<ul>
|
||||
{if $comment.total_advice > 0}
|
||||
<li>{$comment.total_useful} {l s='out of' mod='productcomments'} {$comment.total_advice} {l s='people found this review useful' mod='productcomments'}</li>
|
||||
{/if}
|
||||
{if $cookie->isLogged() == true}
|
||||
{if !$comment.customer_advice}
|
||||
<li>{l s='Was this comment useful to you?' mod='productcomments'}<button class="usefulness_btn" id="comment_useful_yes_{$comment.id_product_comment}">{l s='yes' mod='productcomments'}</button><button class="usefulness_btn" id="comment_useful_no_{$comment.id_product_comment}">{l s='no' mod='productcomments'}</button></li>
|
||||
{/if}
|
||||
{if !$comment.customer_report}
|
||||
<li><span class="report_btn" id="comment_report_{$comment.id_product_comment}">{l s='Report abuse' mod='productcomments'}</span></li>
|
||||
{/if}
|
||||
{/if}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user