Skip to content

Commit

Permalink
Merge pull request #207 from leemyongpakva/remove_deprecated_since_4.…
Browse files Browse the repository at this point in the history
…0.0_code

Remove deprecated since v4.0.0 functions
  • Loading branch information
kpodemski authored May 15, 2024
2 parents faf1502 + 45d1fba commit 3b8119f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 168 deletions.
100 changes: 0 additions & 100 deletions ProductComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,21 +190,6 @@ public static function getRatings($id_product)
return Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->getRow($sql);
}

/**
* @deprecated 4.0.0
*/
public static function getAverageGrade($id_product)
{
$validate = Configuration::get('PRODUCT_COMMENTS_MODERATE');

return Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->getRow('
SELECT AVG(pc.`grade`) AS grade
FROM `' . _DB_PREFIX_ . 'product_comment` pc
WHERE pc.`id_product` = ' . (int) $id_product . '
AND pc.`deleted` = 0' .
($validate == '1' ? ' AND pc.`validate` = 1' : ''));
}

public static function getAveragesByProduct($id_product, $id_lang)
{
/* Get all grades */
Expand Down Expand Up @@ -234,31 +219,6 @@ public static function getAveragesByProduct($id_product, $id_lang)
return $averages;
}

/**
* Return number of comments and average grade by products
*
* @return int|false
*
* @deprecated 4.0.0
*/
public static function getCommentNumber($id_product)
{
if (!Validate::isUnsignedId($id_product)) {
return false;
}
$validate = (bool) Configuration::get('PRODUCT_COMMENTS_MODERATE');
$cache_id = 'ProductComment::getCommentNumber_' . $id_product . '-' . $validate;
if (!Cache::isStored($cache_id)) {
$result = (int) Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->getValue('
SELECT COUNT(`id_product_comment`) AS "nbr"
FROM `' . _DB_PREFIX_ . 'product_comment` pc
WHERE `id_product` = ' . $id_product . ($validate ? ' AND `validate` = 1' : ''));
Cache::store($cache_id, (string) $result);
}

return (int) Cache::retrieve($cache_id);
}

/**
* Return number of comments and average grade by products
*
Expand Down Expand Up @@ -434,66 +394,6 @@ public static function deleteUsefulness($id_product_comment)
WHERE `id_product_comment` = ' . $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)
{
return Db::getInstance()->execute('
INSERT INTO `' . _DB_PREFIX_ . 'product_comment_report` (`id_product_comment`, `id_customer`)
VALUES (' . (int) $id_product_comment . ', ' . (int) $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)
{
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 bool
*
* @deprecated 4.0.0 - migrated to controllers/front/UpdateCommentUsefulness and src/Entity/ProductCommentUsefulness
*/
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 bool
*
* @deprecated 4.0.0 - migrated to controllers/front/UpdateCommentUsefulness and src/Entity/ProductCommentUsefulness
*/
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
*
Expand Down
68 changes: 0 additions & 68 deletions ProductCommentCriterion.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,74 +133,6 @@ public function addCategory($id_category)
');
}

/**
* Add grade to a criterion
*
* @return bool succeed
*
* @deprecated 4.0.0
*/
public function addGrade($id_product_comment, $grade)
{
if (!Validate::isUnsignedId($id_product_comment)) {
exit(Tools::displayError());
}
if ($grade < 0) {
$grade = 0;
} elseif ($grade > 10) {
$grade = 10;
}

return Db::getInstance()->execute('
INSERT INTO `' . _DB_PREFIX_ . 'product_comment_grade`
(`id_product_comment`, `id_product_comment_criterion`, `grade`) VALUES(
' . $id_product_comment . ',
' . (int) $this->id . ',
' . (int) ($grade) . ')');
}

/**
* Get criterion by Product
*
* @return array Criterion
*
* @deprecated 4.0.0
*/
public static function getByProduct($id_product, $id_lang)
{
if (!Validate::isUnsignedId($id_product) ||
!Validate::isUnsignedId($id_lang)) {
exit(Tools::displayError());
}

$cache_id = 'ProductCommentCriterion::getByProduct_' . $id_product . '-' . $id_lang;
if (!Cache::isStored($cache_id)) {
$result = Db::getInstance()->executeS('
SELECT pcc.`id_product_comment_criterion`, pccl.`name`
FROM `' . _DB_PREFIX_ . 'product_comment_criterion` pcc
LEFT JOIN `' . _DB_PREFIX_ . 'product_comment_criterion_lang` pccl
ON (pcc.id_product_comment_criterion = pccl.id_product_comment_criterion)
LEFT JOIN `' . _DB_PREFIX_ . 'product_comment_criterion_product` pccp
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_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
OR ps.id_product IS NOT NULL
OR pcc.id_product_comment_criterion_type = 1
)
AND pcc.active = 1
GROUP BY pcc.id_product_comment_criterion
');
Cache::store($cache_id, $result);
}

return Cache::retrieve($cache_id);
}

/**
* Get Criterions
*
Expand Down

0 comments on commit 3b8119f

Please sign in to comment.