Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 6.0.3 #203

Merged
merged 47 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
552f86f
Replace deprecated CHARSET utf8 in install.sql
leemyongpakvn Jun 27, 2022
46e1106
Upgrade deprecated charset utf8 by newer utfmb4
leemyongpakvn Jun 28, 2022
27d1329
Update and rename install-5.0.2.php to install-5.0.3.php
leemyongpakvn Sep 26, 2022
0ee9c91
php-cs-fixer 1 space less
leemyongpakvn Sep 26, 2022
d18b4b1
Update upgrade/install-5.0.3.php
leemyongpakvn Feb 26, 2023
352c633
Rename install-5.0.3.php to install-6.0.1.php
leemyongpakvn Aug 24, 2023
b49b55d
Update install-6.0.1.php - new v6
leemyongpakvn Aug 24, 2023
39a9a8c
Rename install-6.0.1.php to install-6.0.3.php
leemyongpakvn Sep 5, 2023
ccb8fb1
Merge pull request #144 from leemyongpakvn/patch-3
leemyongpakvn Sep 7, 2023
3fb17dc
rm with --user root
leemyongpakvn Sep 11, 2023
799da9d
Merge pull request #187 from leemyongpakvn/improved-phpstan-script
kpodemski Sep 15, 2023
b79bfef
mark deprecated funtions
leemyongpakvn Oct 4, 2023
b05b70d
mark deprecated functions since v4.0.0 n v6.0.0
leemyongpakvn Oct 4, 2023
d6078d1
correct function name
leemyongpakvn Oct 4, 2023
cbe39e0
CS fix
leemyongpakvn Oct 4, 2023
b6c6cda
Merge pull request #188 from leemyongpakvn/mark-deprecated-functions-…
leemyongpakvn Oct 4, 2023
d10632a
replace jQueryAJAX by FetchAPI
leemyongpakvn Oct 13, 2023
c72a8c5
lint fix
leemyongpakvn Oct 13, 2023
1a6a64a
use application/x-www-form-urlencoded to avoid changes in PHP code
leemyongpakvn Oct 26, 2023
fae55dc
Merge pull request #189 from leemyongpakvn/replace_jqueryAJAX_by_Fetc…
nicosomb Nov 14, 2023
4d00c37
Handle bad deletion page call
matks Nov 16, 2023
9ccab00
Apply suggestions from code review
matks Nov 16, 2023
96bc83c
Merge pull request #190 from matks/fix-bad-delete
leemyongpakvn Nov 17, 2023
35125b4
partial migration to Symfony FormData Provider n Handler
leemyongpakvn Dec 9, 2023
d7a89ad
replace Manual lang field process by Doctrine Entity Relation
leemyongpakvn Dec 9, 2023
a99f017
mark deprcated functions, replace migrated functions call by new one
leemyongpakvn Dec 9, 2023
28fb214
redundant comment
leemyongpakvn Dec 14, 2023
499fc04
Remove unneeded check
Hlavtox Dec 30, 2023
0061498
Remove remaining alias usage
Hlavtox Dec 30, 2023
e53bfe8
Merge pull request #192 from Hlavtox/modernize
Hlavtox Dec 30, 2023
a46ac63
Merge pull request #191 from leemyongpakvn/migrate_manualLangProcess_…
nicosomb Jan 9, 2024
e7e83f2
disable Write your view in QuickView refresh action
leemyongpakvn Jan 10, 2024
045816c
Update and rename install-2.4.php to install-2.4.0.php
Hlavtox Jan 11, 2024
01e2562
Merge pull request #194 from Hlavtox/standardize-upgrade-files
Hlavtox Jan 11, 2024
9657431
Update productcomments.php
Hlavtox Jan 11, 2024
4cbdb61
Update config.xml
Hlavtox Jan 11, 2024
c09d073
Merge pull request #195 from Hlavtox/bump-version
Hlavtox Jan 11, 2024
40614d2
Merge pull request #193 from leemyongpakvn/disable_WriteYourReview_in…
leemyongpakvn Jan 16, 2024
fea6fa7
make rating mandatory
leemyongpakvn Jan 20, 2024
10ddd32
put Mandatory message inside the current modal instead of a new modal
leemyongpakvn Jan 21, 2024
dc9c3f3
unify
leemyongpakvn Jan 21, 2024
36d69ce
tweak message color and alignment
leemyongpakvn Jan 23, 2024
415fee7
hide Mandatory message at each showPostCommentModal call
leemyongpakvn Jan 29, 2024
51a0320
fix compatibility with hummingbird theme
SharakPL Jan 31, 2024
357a3f6
forced to chose rating in any new review
leemyongpakvn Feb 5, 2024
f2f4d1f
Merge pull request #197 from leemyongpakvn/make_rating_mandatory
leemyongpakvn Feb 6, 2024
3fe4fad
Merge pull request #198 from SharakPL/fix-compatibility-with-themes
SharakPL Mar 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ProductComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ public static function deleteUsefulness($id_product_comment)
* Report comment
*
* @return bool
*
* @deprecated 4.0.0 - migrated to controllers/front/ReportComment and src/Entity/ProductCommentReport
*/
public static function reportComment($id_product_comment, $id_customer)
{
Expand All @@ -450,6 +452,8 @@ public static function reportComment($id_product_comment, $id_customer)
* Comment already report
*
* @return bool
*
* @deprecated 4.0.0 - migrated to controllers/front/ReportComment and src/Entity/ProductCommentReport
*/
public static function isAlreadyReport($id_product_comment, $id_customer)
{
Expand All @@ -464,6 +468,8 @@ public static function isAlreadyReport($id_product_comment, $id_customer)
* Set comment usefulness
*
* @return bool
*
* @deprecated 4.0.0 - migrated to controllers/front/UpdateCommentUsefulness and src/Entity/ProductCommentUsefulness
*/
public static function setCommentUsefulness($id_product_comment, $usefulness, $id_customer)
{
Expand All @@ -476,6 +482,8 @@ public static function setCommentUsefulness($id_product_comment, $usefulness, $i
* Usefulness already set
*
* @return bool
*
* @deprecated 4.0.0 - migrated to controllers/front/UpdateCommentUsefulness and src/Entity/ProductCommentUsefulness
*/
public static function isAlreadyUsefulness($id_product_comment, $id_customer)
{
Expand Down
18 changes: 9 additions & 9 deletions ProductCommentCriterion.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class ProductCommentCriterion extends ObjectModel
],
];

/**
* @deprecated 6.0.0 - migrated to src/Repository/ProductCommentCriterionRepository
*/
public function delete()
{
if (!parent::delete()) {
Expand Down Expand Up @@ -96,6 +99,8 @@ public function update($nullValues = false)
* Link a Comment Criterion to a product
*
* @return bool succeed
*
* @deprecated 6.0.0 - migrated to src/Repository/ProductCommentCriterionRepository
*/
public function addProduct($id_product)
{
Expand All @@ -113,6 +118,8 @@ public function addProduct($id_product)
* Link a Comment Criterion to a category
*
* @return bool succeed
*
* @deprecated 6.0.0 - migrated to src/Repository/ProductCommentCriterionRepository
*/
public function addCategory($id_category)
{
Expand Down Expand Up @@ -165,13 +172,6 @@ public static function getByProduct($id_product, $id_lang)
!Validate::isUnsignedId($id_lang)) {
exit(Tools::displayError());
}
$alias = 'p';
$table = '';
// check if version > 1.5 to add shop association
if (version_compare(_PS_VERSION_, '1.5', '>')) {
$table = '_shop';
$alias = 'ps';
}

$cache_id = 'ProductCommentCriterion::getByProduct_' . $id_product . '-' . $id_lang;
if (!Cache::isStored($cache_id)) {
Expand All @@ -184,8 +184,8 @@ public static function getByProduct($id_product, $id_lang)
ON (pcc.`id_product_comment_criterion` = pccp.`id_product_comment_criterion` AND pccp.`id_product` = ' . $id_product . ')
LEFT JOIN `' . _DB_PREFIX_ . 'product_comment_criterion_category` pccc
ON (pcc.`id_product_comment_criterion` = pccc.`id_product_comment_criterion`)
LEFT JOIN `' . _DB_PREFIX_ . 'product' . $table . '` ' . $alias . '
ON (' . $alias . '.id_category_default = pccc.id_category AND ' . $alias . '.id_product = ' . $id_product . ')
LEFT JOIN `' . _DB_PREFIX_ . 'product_shop` ps
ON (ps.id_category_default = pccc.id_category AND ps.id_product = ' . $id_product . ')
WHERE pccl.`id_lang` = ' . $id_lang . '
AND (
pccp.id_product IS NOT NULL
Expand Down
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>productcomments</name>
<displayName><![CDATA[Product Comments]]></displayName>
<version><![CDATA[6.0.2]]></version>
<version><![CDATA[6.0.3]]></version>
<description><![CDATA[Allows users to post reviews and rate products on specific criteria.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[front_office_features]]></tab>
Expand Down
16 changes: 16 additions & 0 deletions config/admin/services.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
imports:
- { resource: ../common.yml }

services:
product_comment_criterion_form_data_provider:
class: 'PrestaShop\Module\ProductComment\Form\ProductCommentCriterionFormDataProvider'
public: true
arguments:
- '@product_comment_criterion_repository'
- '@prestashop.core.admin.lang.repository'

product_comment_criterion_form_data_handler:
class: 'PrestaShop\Module\ProductComment\Form\ProductCommentCriterionFormDataHandler'
public: true
arguments:
- '@product_comment_criterion_repository'
- '@prestashop.core.admin.lang.repository'
- '@doctrine.orm.default_entity_manager'
16 changes: 8 additions & 8 deletions install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,56 +14,56 @@ CREATE TABLE IF NOT EXISTS `PREFIX_product_comment` (
KEY `id_product` (`id_product`),
KEY `id_customer` (`id_customer`),
KEY `id_guest` (`id_guest`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS `PREFIX_product_comment_criterion` (
`id_product_comment_criterion` int(10) unsigned NOT NULL auto_increment,
`id_product_comment_criterion_type` tinyint(1) NOT NULL,
`active` tinyint(1) NOT NULL,
PRIMARY KEY (`id_product_comment_criterion`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS `PREFIX_product_comment_criterion_product` (
`id_product` int(10) unsigned NOT NULL,
`id_product_comment_criterion` int(10) unsigned NOT NULL,
PRIMARY KEY(`id_product`, `id_product_comment_criterion`),
KEY `id_product_comment_criterion` (`id_product_comment_criterion`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS `PREFIX_product_comment_criterion_lang` (
`id_product_comment_criterion` INT(11) UNSIGNED NOT NULL ,
`id_lang` INT(11) UNSIGNED NOT NULL ,
`name` VARCHAR(64) NOT NULL ,
PRIMARY KEY ( `id_product_comment_criterion` , `id_lang` )
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS `PREFIX_product_comment_criterion_category` (
`id_product_comment_criterion` int(10) unsigned NOT NULL,
`id_category` int(10) unsigned NOT NULL,
PRIMARY KEY(`id_product_comment_criterion`, `id_category`),
KEY `id_category` (`id_category`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS `PREFIX_product_comment_grade` (
`id_product_comment` int(10) unsigned NOT NULL,
`id_product_comment_criterion` int(10) unsigned NOT NULL,
`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;
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4;

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;
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4;

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;
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4;

INSERT IGNORE INTO `PREFIX_product_comment_criterion` VALUES ('1', '1', '1');

Expand Down
71 changes: 53 additions & 18 deletions productcomments.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct()
{
$this->name = 'productcomments';
$this->tab = 'front_office_features';
$this->version = '6.0.2';
$this->version = '6.0.3';
$this->author = 'PrestaShop';
$this->need_instance = 0;
$this->bootstrap = true;
Expand Down Expand Up @@ -169,8 +169,10 @@ public function getCacheId($id_product = null)
protected function _postProcess()
{
$id_product_comment = (int) Tools::getValue('id_product_comment');
$id_product_comment_criterion = (int) Tools::getValue('id_product_comment_criterion');
$commentRepository = $this->get('product_comment_repository');
$criterionRepository = $this->get('product_comment_criterion_repository');
$criterionFormHandler = $this->get('product_comment_criterion_form_data_handler');

if (Tools::isSubmit('submitModerate')) {
$errors = [];
Expand Down Expand Up @@ -207,9 +209,20 @@ protected function _postProcess()
$commentRepository->deleteReports($id_product_comment);
} elseif (Tools::isSubmit('deleteproductcomments')) {
$comment = $commentRepository->find($id_product_comment);
$commentRepository->delete($comment);

if ($comment === null) {
$this->_html .= $this->displayError($this->trans('The comment cannot be deleted', [], 'Modules.Productcomments.Admin'));
} else {
$commentRepository->delete($comment);
Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', true, [], ['configure' => $this->name]));
}
} elseif (Tools::isSubmit('submitEditCriterion')) {
$criterion = $criterionRepository->findRelation((int) Tools::getValue('id_product_comment_criterion'));
if ($id_product_comment_criterion > 0) {
$criterion = $criterionRepository->find($id_product_comment_criterion);
} else {
$criterion = new ProductCommentCriterion();
}

$criterion->setType((int) Tools::getValue('id_product_comment_criterion_type'));
$criterion->setActive(Tools::getValue('active'));

Expand All @@ -218,7 +231,12 @@ protected function _postProcess()
foreach ($languages as $key => $value) {
$name[$value['id_lang']] = Tools::getValue('name_' . $value['id_lang']);
}
$criterion->setNames($name);

if ($id_product_comment_criterion > 0) {
$criterionFormHandler->updateLangs($criterion, $name);
} else {
$criterionFormHandler->createLangs($criterion, $name);
}

if (!$criterion->isValid()) {
$this->_html .= $this->displayError($this->trans('The criterion cannot be saved', [], 'Modules.Productcomments.Admin'));
Expand All @@ -232,14 +250,18 @@ protected function _postProcess()
}
}
} elseif (Tools::isSubmit('deleteproductcommentscriterion')) {
$criterion = $criterionRepository->findRelation((int) Tools::getValue('id_product_comment_criterion'));
$criterion = $criterionRepository->find($id_product_comment_criterion);
if ($criterionRepository->delete($criterion)) {
$this->_html .= $this->displayConfirmation($this->trans('Criterion deleted', [], 'Modules.Productcomments.Admin'));
Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', true, [], ['configure' => $this->name]));
} else {
$this->_html .= $this->displayError($this->trans('Criterion cannot be deleted', [], 'Modules.Productcomments.Admin'));
}
} elseif (Tools::isSubmit('statusproductcommentscriterion')) {
$criterion = $criterionRepository->findRelation((int) Tools::getValue('id_product_comment_criterion'));
$criterion = $criterionRepository->find($id_product_comment_criterion);
$criterion->setActive(!$criterion->isActive());
Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', true, [], ['configure' => $this->name, 'tab_module' => $this->tab, 'conf' => 4, 'module_name' => $this->name]));
$criterionRepository->updateGeneral($criterion);

Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', true, [], ['configure' => $this->name]));
} elseif ($id_product_comment = (int) Tools::getValue('approveComment')) {
$comment = $commentRepository->find($id_product_comment);
$commentRepository->validate($comment, 1);
Expand Down Expand Up @@ -596,16 +618,22 @@ public function getConfigFieldsValues()
];
}

public function getCriterionFieldsValues($id = 0)
public function getCriterionFieldsValues(int $id = 0)
{
$criterionRepos = $this->get('product_comment_criterion_repository');
$criterion = $criterionRepos->findRelation($id);
$criterionFormProvider = $this->get('product_comment_criterion_form_data_provider');

if ($id > 0) {
$criterionData = $criterionFormProvider->getData($id);
} else {
$criterionData = $criterionFormProvider->getDefaultData();
}

return [
'name' => $criterion->getNames(),
'id_product_comment_criterion_type' => $criterion->getType(),
'active' => $criterion->isActive(),
'id_product_comment_criterion' => $criterion->getId(),
'name' => $criterionData['name'],
'id_product_comment_criterion_type' => $criterionData['type'],
'active' => $criterionData['active'],
'id_product_comment_criterion' => $id,
];
}

Expand Down Expand Up @@ -696,7 +724,7 @@ public function renderCriterionForm($id_criterion = 0)

$criterionRepository = $this->get('product_comment_criterion_repository');

$criterion = $criterionRepository->findRelation($id_criterion);
$criterion = $criterionRepository->find($id_criterion);
$selected_categories = $criterionRepository->getCategories($id_criterion);

$product_table_values = Product::getSimpleProducts($this->langId);
Expand Down Expand Up @@ -1044,9 +1072,16 @@ public function renderWidget($hookName = null, array $configuration = [])
$idProduct = $this->context->controller->getProduct()->id;
$variables = $this->getWidgetVariables($hookName, ['id_product' => $idProduct]);

$filePath = 'quickview' === Tools::getValue('action')
? $tplHookPath . 'product-additional-info-quickview.tpl'
: $tplHookPath . 'product-additional-info.tpl';
switch (Tools::getValue('action')) {
case 'quickview':
$filePath = $tplHookPath . 'product-additional-info-quickview.tpl';
break;
case '':
$filePath = $tplHookPath . 'product-additional-info.tpl';
break;
default: // 'refresh' and other unpredicted cases
$filePath = '';
}
}

if (empty($variables) || empty($filePath)) {
Expand Down
Loading
Loading