Skip to content

Commit 9e6a1f6

Browse files
Merge pull request #221 from PrestaShop/dev
Release 8.0.0
2 parents 7287476 + 8455fd8 commit 9e6a1f6

15 files changed

+108
-288
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ Check out our contribution guidelines to find out how to complete it:
77
https://devdocs.prestashop.com/1.7/contribute/contribution-guidelines/#pull-requests
88
------------------------------------------------------------------------------>
99

10-
| Questions | Answers
11-
| ------------- | -------------------------------------------------------
12-
| Description? | Please be specific when describing the PR. <br> Every detail helps: versions, browser/server configuration, specific module/theme, etc. Feel free to add more information below this table.
13-
| Type? | bug fix / improvement / new feature / refacto / critical
14-
| BC breaks? | yes / no
15-
| Deprecations? | yes / no
16-
| Fixed ticket? | Fixes PrestaShop/Prestashop#{issue number here}.
17-
| How to test? | Please indicate how to best verify that this PR is correct.
10+
| Questions | Answers
11+
| ----------------- | -------------------------------------------------------
12+
| Description? | Please be specific when describing the PR. <br> Every detail helps: versions, browser/server configuration, specific module/theme, etc. Feel free to add more information below this table.
13+
| Type? | bug fix / improvement / new feature / refacto / critical
14+
| BC breaks? | yes / no
15+
| Deprecations? | yes / no
16+
| Fixed ticket? | Fixes PrestaShop/Prestashop#{issue number here}.
17+
| How to test? | Please indicate how to best verify that this PR is correct.
18+
| Sponsor company | Your company or customer's name goes here (if applicable).
1819

1920
<!-- Click the form's "Preview" button to make sure the table is functional in GitHub. Thank you! -->

.github/workflows/build-release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- name: Checkout
10-
uses: actions/checkout@v3.1.0
10+
uses: actions/checkout@v4
1111
- name: Install composer dependencies
1212
run: composer install --no-dev -o
1313
- name: Clean-up project
@@ -17,7 +17,7 @@ jobs:
1717
- name: Generate index.php
1818
run: ~/.composer/vendor/bin/autoindex
1919
- name: Create & upload artifact
20-
uses: actions/upload-artifact@v3
20+
uses: actions/upload-artifact@v4
2121
with:
2222
name: ${{ github.event.repository.name }}
2323
path: /home/runner/work/${{ github.event.repository.name }}
@@ -27,7 +27,7 @@ jobs:
2727
if: github.event_name == 'push' && (github.event.ref == 'refs/heads/main' || github.event.ref == 'refs/heads/master')
2828
steps:
2929
- name: Download artifact
30-
uses: actions/download-artifact@v3
30+
uses: actions/download-artifact@v4
3131
with:
3232
name: ${{ github.event.repository.name }}
3333
path: ${{ github.event.repository.name }}

.github/workflows/php.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- name: Checkout
10-
uses: actions/checkout@v3.1.0
10+
uses: actions/checkout@v4
1111

1212
- name: PHP syntax checker 7.2
1313
uses: prestashop/github-action-php-lint/7.2@master
@@ -38,10 +38,10 @@ jobs:
3838
php-version: '7.4'
3939

4040
- name: Checkout
41-
uses: actions/checkout@v3.1.0
41+
uses: actions/checkout@v4
4242

4343
- name: Cache dependencies
44-
uses: actions/cache@v3
44+
uses: actions/cache@v4
4545
with:
4646
path: vendor
4747
key: php-${{ hashFiles('composer.lock') }}
@@ -66,18 +66,18 @@ jobs:
6666
php-version: '7.4'
6767

6868
- name: Checkout
69-
uses: actions/checkout@v3.1.0
69+
uses: actions/checkout@v4
7070

7171
# Add vendor folder in cache to make next builds faster
7272
- name: Cache vendor folder
73-
uses: actions/cache@v3
73+
uses: actions/cache@v4
7474
with:
7575
path: vendor
7676
key: php-${{ hashFiles('composer.lock') }}
7777

7878
# Add composer local folder in cache to make next builds faster
7979
- name: Cache composer folder
80-
uses: actions/cache@v3
80+
uses: actions/cache@v4
8181
with:
8282
path: ~/.composer/cache
8383
key: php-composer-cache

ProductComment.php

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -190,21 +190,6 @@ public static function getRatings($id_product)
190190
return Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->getRow($sql);
191191
}
192192

193-
/**
194-
* @deprecated 4.0.0
195-
*/
196-
public static function getAverageGrade($id_product)
197-
{
198-
$validate = Configuration::get('PRODUCT_COMMENTS_MODERATE');
199-
200-
return Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->getRow('
201-
SELECT AVG(pc.`grade`) AS grade
202-
FROM `' . _DB_PREFIX_ . 'product_comment` pc
203-
WHERE pc.`id_product` = ' . (int) $id_product . '
204-
AND pc.`deleted` = 0' .
205-
($validate == '1' ? ' AND pc.`validate` = 1' : ''));
206-
}
207-
208193
public static function getAveragesByProduct($id_product, $id_lang)
209194
{
210195
/* Get all grades */
@@ -234,31 +219,6 @@ public static function getAveragesByProduct($id_product, $id_lang)
234219
return $averages;
235220
}
236221

237-
/**
238-
* Return number of comments and average grade by products
239-
*
240-
* @return int|false
241-
*
242-
* @deprecated 4.0.0
243-
*/
244-
public static function getCommentNumber($id_product)
245-
{
246-
if (!Validate::isUnsignedId($id_product)) {
247-
return false;
248-
}
249-
$validate = (bool) Configuration::get('PRODUCT_COMMENTS_MODERATE');
250-
$cache_id = 'ProductComment::getCommentNumber_' . $id_product . '-' . $validate;
251-
if (!Cache::isStored($cache_id)) {
252-
$result = (int) Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->getValue('
253-
SELECT COUNT(`id_product_comment`) AS "nbr"
254-
FROM `' . _DB_PREFIX_ . 'product_comment` pc
255-
WHERE `id_product` = ' . $id_product . ($validate ? ' AND `validate` = 1' : ''));
256-
Cache::store($cache_id, (string) $result);
257-
}
258-
259-
return (int) Cache::retrieve($cache_id);
260-
}
261-
262222
/**
263223
* Return number of comments and average grade by products
264224
*
@@ -434,66 +394,6 @@ public static function deleteUsefulness($id_product_comment)
434394
WHERE `id_product_comment` = ' . $id_product_comment);
435395
}
436396

437-
/**
438-
* Report comment
439-
*
440-
* @return bool
441-
*
442-
* @deprecated 4.0.0 - migrated to controllers/front/ReportComment and src/Entity/ProductCommentReport
443-
*/
444-
public static function reportComment($id_product_comment, $id_customer)
445-
{
446-
return Db::getInstance()->execute('
447-
INSERT INTO `' . _DB_PREFIX_ . 'product_comment_report` (`id_product_comment`, `id_customer`)
448-
VALUES (' . (int) $id_product_comment . ', ' . (int) $id_customer . ')');
449-
}
450-
451-
/**
452-
* Comment already report
453-
*
454-
* @return bool
455-
*
456-
* @deprecated 4.0.0 - migrated to controllers/front/ReportComment and src/Entity/ProductCommentReport
457-
*/
458-
public static function isAlreadyReport($id_product_comment, $id_customer)
459-
{
460-
return (bool) Db::getInstance()->getValue('
461-
SELECT COUNT(*)
462-
FROM `' . _DB_PREFIX_ . 'product_comment_report`
463-
WHERE `id_customer` = ' . (int) $id_customer . '
464-
AND `id_product_comment` = ' . (int) $id_product_comment);
465-
}
466-
467-
/**
468-
* Set comment usefulness
469-
*
470-
* @return bool
471-
*
472-
* @deprecated 4.0.0 - migrated to controllers/front/UpdateCommentUsefulness and src/Entity/ProductCommentUsefulness
473-
*/
474-
public static function setCommentUsefulness($id_product_comment, $usefulness, $id_customer)
475-
{
476-
return Db::getInstance()->execute('
477-
INSERT INTO `' . _DB_PREFIX_ . 'product_comment_usefulness` (`id_product_comment`, `usefulness`, `id_customer`)
478-
VALUES (' . (int) $id_product_comment . ', ' . (int) $usefulness . ', ' . (int) $id_customer . ')');
479-
}
480-
481-
/**
482-
* Usefulness already set
483-
*
484-
* @return bool
485-
*
486-
* @deprecated 4.0.0 - migrated to controllers/front/UpdateCommentUsefulness and src/Entity/ProductCommentUsefulness
487-
*/
488-
public static function isAlreadyUsefulness($id_product_comment, $id_customer)
489-
{
490-
return (bool) Db::getInstance()->getValue('
491-
SELECT COUNT(*)
492-
FROM `' . _DB_PREFIX_ . 'product_comment_usefulness`
493-
WHERE `id_customer` = ' . (int) $id_customer . '
494-
AND `id_product_comment` = ' . (int) $id_product_comment);
495-
}
496-
497397
/**
498398
* Get reported comments
499399
*

ProductCommentCriterion.php

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -133,74 +133,6 @@ public function addCategory($id_category)
133133
');
134134
}
135135

136-
/**
137-
* Add grade to a criterion
138-
*
139-
* @return bool succeed
140-
*
141-
* @deprecated 4.0.0
142-
*/
143-
public function addGrade($id_product_comment, $grade)
144-
{
145-
if (!Validate::isUnsignedId($id_product_comment)) {
146-
exit(Tools::displayError());
147-
}
148-
if ($grade < 0) {
149-
$grade = 0;
150-
} elseif ($grade > 10) {
151-
$grade = 10;
152-
}
153-
154-
return Db::getInstance()->execute('
155-
INSERT INTO `' . _DB_PREFIX_ . 'product_comment_grade`
156-
(`id_product_comment`, `id_product_comment_criterion`, `grade`) VALUES(
157-
' . $id_product_comment . ',
158-
' . (int) $this->id . ',
159-
' . (int) ($grade) . ')');
160-
}
161-
162-
/**
163-
* Get criterion by Product
164-
*
165-
* @return array Criterion
166-
*
167-
* @deprecated 4.0.0
168-
*/
169-
public static function getByProduct($id_product, $id_lang)
170-
{
171-
if (!Validate::isUnsignedId($id_product) ||
172-
!Validate::isUnsignedId($id_lang)) {
173-
exit(Tools::displayError());
174-
}
175-
176-
$cache_id = 'ProductCommentCriterion::getByProduct_' . $id_product . '-' . $id_lang;
177-
if (!Cache::isStored($cache_id)) {
178-
$result = Db::getInstance()->executeS('
179-
SELECT pcc.`id_product_comment_criterion`, pccl.`name`
180-
FROM `' . _DB_PREFIX_ . 'product_comment_criterion` pcc
181-
LEFT JOIN `' . _DB_PREFIX_ . 'product_comment_criterion_lang` pccl
182-
ON (pcc.id_product_comment_criterion = pccl.id_product_comment_criterion)
183-
LEFT JOIN `' . _DB_PREFIX_ . 'product_comment_criterion_product` pccp
184-
ON (pcc.`id_product_comment_criterion` = pccp.`id_product_comment_criterion` AND pccp.`id_product` = ' . $id_product . ')
185-
LEFT JOIN `' . _DB_PREFIX_ . 'product_comment_criterion_category` pccc
186-
ON (pcc.`id_product_comment_criterion` = pccc.`id_product_comment_criterion`)
187-
LEFT JOIN `' . _DB_PREFIX_ . 'product_shop` ps
188-
ON (ps.id_category_default = pccc.id_category AND ps.id_product = ' . $id_product . ')
189-
WHERE pccl.`id_lang` = ' . $id_lang . '
190-
AND (
191-
pccp.id_product IS NOT NULL
192-
OR ps.id_product IS NOT NULL
193-
OR pcc.id_product_comment_criterion_type = 1
194-
)
195-
AND pcc.active = 1
196-
GROUP BY pcc.id_product_comment_criterion
197-
');
198-
Cache::store($cache_id, $result);
199-
}
200-
201-
return Cache::retrieve($cache_id);
202-
}
203-
204136
/**
205137
* Get Criterions
206138
*

config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<module>
33
<name>productcomments</name>
44
<displayName><![CDATA[Product Comments]]></displayName>
5-
<version><![CDATA[7.0.0]]></version>
5+
<version><![CDATA[8.0.0]]></version>
66
<description><![CDATA[Allows users to post reviews and rate products on specific criteria.]]></description>
77
<author><![CDATA[PrestaShop]]></author>
88
<tab><![CDATA[front_office_features]]></tab>

controllers/front/ListComments.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public function display()
7171

7272
if ($isLastNameAnonymous) {
7373
$productComment['customer_name'] = $this->anonymizeName($productComment['customer_name']);
74+
$productComment['lastname'] = '...';
7475
}
7576

7677
$productComment['customer_name'] = htmlentities($productComment['customer_name']);

controllers/front/PostComment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ProductCommentsPostCommentModuleFrontController extends ModuleFrontControl
3434
public function display()
3535
{
3636
header('Content-Type: application/json');
37-
if (!(int) $this->context->cookie->id_customer && !Configuration::get('PRODUCT_COMMENTS_ALLOW_GUESTS')) {
37+
if (!$this->context->customer->isLogged() && !Configuration::get('PRODUCT_COMMENTS_ALLOW_GUESTS')) {
3838
$this->ajaxRender(
3939
json_encode(
4040
[

productcomments.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct()
4747
{
4848
$this->name = 'productcomments';
4949
$this->tab = 'front_office_features';
50-
$this->version = '7.0.0';
50+
$this->version = '8.0.0';
5151
$this->author = 'PrestaShop';
5252
$this->need_instance = 0;
5353
$this->bootstrap = true;
@@ -455,7 +455,7 @@ public function renderModerateLists()
455455
$helper->table = $this->name;
456456
$helper->table_id = 'waiting-approval-productcomments-list';
457457
$helper->token = Tools::getAdminTokenLite('AdminModules');
458-
$helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name;
458+
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false, [], ['configure' => $this->name, 'tab_module' => $this->tab, 'module_name' => $this->name]);
459459
$helper->no_link = true;
460460

461461
$return .= $helper->generateList($comments, $fields_list);
@@ -480,7 +480,7 @@ public function renderModerateLists()
480480
$helper->table = $this->name;
481481
$helper->table_id = 'reported-productcomments-list';
482482
$helper->token = Tools::getAdminTokenLite('AdminModules');
483-
$helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name;
483+
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false, [], ['configure' => $this->name, 'tab_module' => $this->tab, 'module_name' => $this->name]);
484484
$helper->no_link = true;
485485

486486
$return .= $helper->generateList($comments, $fields_list);
@@ -564,7 +564,7 @@ public function renderCriterionList()
564564
$helper->title = $this->trans('Review Criteria', [], 'Modules.Productcomments.Admin');
565565
$helper->table = $this->name . 'criterion';
566566
$helper->token = Tools::getAdminTokenLite('AdminModules');
567-
$helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name;
567+
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false, [], ['configure' => $this->name, 'tab_module' => $this->tab, 'module_name' => $this->name]);
568568

569569
return $helper->generateList($criterions, $fields_list);
570570
}
@@ -585,7 +585,7 @@ public function renderCommentsList()
585585
$helper->table = $this->name;
586586
$helper->table_id = 'approved-productcomments-list';
587587
$helper->token = Tools::getAdminTokenLite('AdminModules');
588-
$helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name;
588+
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false, [], ['configure' => $this->name, 'tab_module' => $this->tab, 'module_name' => $this->name]);
589589
$helper->no_link = true;
590590

591591
$page = ($page = Tools::getValue('submitFilter' . $helper->list_id)) ? (int) $page : 1;
@@ -1076,11 +1076,19 @@ public function renderWidget($hookName = null, array $configuration = [])
10761076
case 'quickview':
10771077
$filePath = $tplHookPath . 'product-additional-info-quickview.tpl';
10781078
break;
1079+
case 'refresh':
1080+
if (Tools::getValue('quickview') == true) {
1081+
$filePath = '';
1082+
} else {
1083+
$filePath = $tplHookPath . 'product-additional-info.tpl';
1084+
}
1085+
break;
10791086
case '':
10801087
$filePath = $tplHookPath . 'product-additional-info.tpl';
10811088
break;
1082-
default: // 'refresh' and other unpredicted cases
1089+
default:
10831090
$filePath = '';
1091+
break;
10841092
}
10851093
}
10861094

0 commit comments

Comments
 (0)