From 0d1b99f6741d40ef68c06f5f10a5d0e13dd3375d Mon Sep 17 00:00:00 2001
From: leemyongpakva <leemyongpak@gmail.com>
Date: Tue, 7 May 2024 08:29:21 +0700
Subject: [PATCH] remove deprecated since v4.0.0 functions

---
 ProductComment.php          | 100 ------------------------------------
 ProductCommentCriterion.php |  67 ------------------------
 2 files changed, 167 deletions(-)

diff --git a/ProductComment.php b/ProductComment.php
index 53cca30..d9ce206 100644
--- a/ProductComment.php
+++ b/ProductComment.php
@@ -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 */
@@ -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
      *
@@ -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
      *
diff --git a/ProductCommentCriterion.php b/ProductCommentCriterion.php
index 1ae4df3..c8a88ed 100644
--- a/ProductCommentCriterion.php
+++ b/ProductCommentCriterion.php
@@ -133,73 +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