diff --git a/config/xml/themes/default.xml b/config/xml/themes/default.xml
index f7c0da20f..25901075a 100644
--- a/config/xml/themes/default.xml
+++ b/config/xml/themes/default.xml
@@ -54,7 +54,7 @@
-
+
@@ -133,12 +133,14 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/controllers/admin/AdminThemesController.php b/controllers/admin/AdminThemesController.php
index ca48faac1..77d173151 100644
--- a/controllers/admin/AdminThemesController.php
+++ b/controllers/admin/AdminThemesController.php
@@ -2111,7 +2111,7 @@ class AdminThemesControllerCore extends AdminController
'mailalerts',
'newsletter',
'pagesnotfound',
- 'productcomments',
+ 'qlohotelreview',
'referralprogram',
'sekeywords',
'statsbestcategories',
diff --git a/controllers/front/CategoryController.php b/controllers/front/CategoryController.php
index ffc087ecd..47e1ceab8 100644
--- a/controllers/front/CategoryController.php
+++ b/controllers/front/CategoryController.php
@@ -233,7 +233,6 @@ class CategoryControllerCore extends FrontController
$adult = 0;
$child = 0;
- $ratting = -1;
$amenities = 0;
$price = 0;
@@ -243,8 +242,6 @@ class CategoryControllerCore extends FrontController
$adult = min($value);
} elseif ($key == 'children') {
$child = min($value);
- } elseif ($key == 'ratting') {
- $ratting = min($value);
} elseif ($key == 'amenities') {
$amenities = array();
foreach ($value as $a_k => $a_v) {
@@ -267,7 +264,7 @@ class CategoryControllerCore extends FrontController
$id_guest = $this->context->cookie->id_guest;
$obj_booking_dtl = new HotelBookingDetail();
- $booking_data = $obj_booking_dtl->DataForFrontSearch($date_from, $date_to, $id_hotel, 0, 0, $adult, $child, $ratting, $amenities, $price, $id_cart, $id_guest);
+ $booking_data = $obj_booking_dtl->DataForFrontSearch($date_from, $date_to, $id_hotel, 0, 0, $adult, $child, -1, $amenities, $price, $id_cart, $id_guest);
// reset array keys from 0
$booking_data['rm_data'] = array_values($booking_data['rm_data']);
if ($sort_by && $sort_value) {
@@ -279,11 +276,7 @@ class CategoryControllerCore extends FrontController
$direction = SORT_DESC;
}
foreach ($booking_data['rm_data'] as $s_k => $s_v) {
- if ($sort_by == 1) {
- $indi_arr[$s_k] = $s_v['ratting'];
- } elseif ($sort_by == 2) {
- $indi_arr[$s_k] = $s_v['price'];
- }
+ $indi_arr[$s_k] = $s_v['price'];
}
array_multisort($indi_arr, $direction, $booking_data['rm_data']);
diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php
index 9b1c66ee0..00ad55e8f 100644
--- a/controllers/front/ProductController.php
+++ b/controllers/front/ProductController.php
@@ -327,11 +327,11 @@ class ProductControllerCore extends FrontController
if (Tools::getValue('error')) {
$this->context->smarty->assign('error', Tools::getValue('error'));
}
- if (Module::isInstalled('productcomments')) {
+ if (Module::isEnabled('qlohotelreview')) {
$this->context->smarty->assign(
array(
- 'num_reviews' => ProductComment::getCommentNumber($this->product->id),
- 'ratting' => ProductComment::getAverageGrade($this->product->id)['grade'],
+ 'num_reviews' => QhrHotelReview::getReviewCountByIdHotel($hotel_id),
+ 'ratting' => QhrHotelReview::getAverageRatingByIdHotel($hotel_id),
)
);
}
diff --git a/install/models/install.php b/install/models/install.php
index 29284e75d..83ab0f67b 100644
--- a/install/models/install.php
+++ b/install/models/install.php
@@ -662,7 +662,7 @@ class InstallModelInstall extends InstallAbstractModel
'qloblockcontact',
'blockcurrencies',
'blocklanguages',
- 'productcomments',
+ 'qlohotelreview',
'wkfooterlangcurrencyblock',
'wkfooterpaymentinfoblockcontainer',
'wkfooteraboutblock',
diff --git a/modules/dashactivity/dashactivity.php b/modules/dashactivity/dashactivity.php
index d253dfd3d..03e1e0d64 100644
--- a/modules/dashactivity/dashactivity.php
+++ b/modules/dashactivity/dashactivity.php
@@ -126,7 +126,6 @@ class Dashactivity extends Module
'abandoned_cart' => round(rand(5, 50)),
'products_out_of_stock' => round(rand(1, 10)),
'new_messages' => round(rand(1, 10) * $days),
- 'product_reviews' => round(rand(5, 50) * $days),
'new_customers' => round(rand(1, 5) * $days),
'online_visitor' => round($online_visitor),
'active_shopping_cart' => round($online_visitor / 10),
@@ -289,19 +288,6 @@ class Dashactivity extends Module
);
}
- $product_reviews = 0;
- if (Module::isInstalled('productcomments')) {
- $product_reviews += Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
- SELECT COUNT(*)
- FROM `'._DB_PREFIX_.'product_comment` pc
- LEFT JOIN `'._DB_PREFIX_.'product` p ON (pc.id_product = p.id_product)
- '.Shop::addSqlAssociation('product', 'p').'
- WHERE pc.deleted = 0
- AND pc.`date_add` BETWEEN "'.pSQL($params['date_from']).'" AND "'.pSQL($params['date_to']).'"
- '.Shop::addSqlRestriction(Shop::SHARE_ORDER)
- );
- }
-
return array(
'data_value' => array(
'pending_orders' => (int)$pending_orders,
@@ -309,7 +295,6 @@ class Dashactivity extends Module
'abandoned_cart' => (int)$abandoned_cart,
'products_out_of_stock' => (int)$products_out_of_stock,
'new_messages' => (int)$new_messages,
- 'product_reviews' => (int)$product_reviews,
'new_customers' => (int)$new_customers,
'online_visitor' => (int)$online_visitor,
'active_shopping_cart' => (int)$active_shopping_cart,
diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php
index 3f020f1ff..554298f84 100644
--- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php
+++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php
@@ -849,9 +849,9 @@ class HotelBookingDetail extends ObjectModel
*/
public function DataForFrontSearch($date_from, $date_to, $id_hotel, $id_product = 0, $for_room_type = 0, $adult = 0, $children = 0, $ratting = -1, $amenities = 0, $price = 0, $id_cart = 0, $id_guest = 0)
{
- if (Module::isInstalled('productcomments')) {
- require_once _PS_MODULE_DIR_.'productcomments/ProductComment.php';
- }
+ // if (Module::isInstalled('productcomments')) {
+ // require_once _PS_MODULE_DIR_.'productcomments/ProductComment.php';
+ // }
$this->context = Context::getContext();
@@ -881,84 +881,86 @@ class HotelBookingDetail extends ObjectModel
if (empty($value['data']['available'])) {
unset($booking_data['rm_data'][$key]);
} else {
- if (Module::isInstalled('productcomments')) {
- $prod_ratting = ProductComment::getAverageGrade($value['id_product'])['grade'];
- }
- if (empty($prod_ratting)) {
- $prod_ratting = 0;
- }
+ $prod_ratting = 0;
+ // if (Module::isInstalled('productcomments')) {
+ // $prod_ratting = ProductComment::getAverageGrade($value['id_product'])['grade'];
+ // }
+ // if (empty($prod_ratting)) {
+ // $prod_ratting = 0;
+ // }
- if ($prod_ratting < $ratting && $ratting != -1) {
- unset($booking_data['rm_data'][$key]);
- } else {
- $product = new Product($value['id_product'], false, $this->context->language->id);
+ // if ($prod_ratting < $ratting && $ratting != -1) {
+ // unset($booking_data['rm_data'][$key]);
+ // } else
+ // {
+ $product = new Product($value['id_product'], false, $this->context->language->id);
- $product_feature = $product->getFrontFeaturesStatic($this->context->language->id, $value['id_product']);
+ $product_feature = $product->getFrontFeaturesStatic($this->context->language->id, $value['id_product']);
- $prod_amen = array();
- if (!empty($amenities) && $amenities) {
- $prod_amen = $amenities;
- foreach ($product_feature as $a_key => $a_val) {
- if (($pa_key = array_search($a_val['id_feature'], $prod_amen)) !== false) {
- unset($prod_amen[$pa_key]);
- if (empty($prod_amen)) {
- break;
- }
+ $prod_amen = array();
+ if (!empty($amenities) && $amenities) {
+ $prod_amen = $amenities;
+ foreach ($product_feature as $a_key => $a_val) {
+ if (($pa_key = array_search($a_val['id_feature'], $prod_amen)) !== false) {
+ unset($prod_amen[$pa_key]);
+ if (empty($prod_amen)) {
+ break;
}
}
- if (!empty($prod_amen)) {
- unset($booking_data['rm_data'][$key]);
- }
}
+ if (!empty($prod_amen)) {
+ unset($booking_data['rm_data'][$key]);
+ }
+ }
- if (empty($prod_amen)) {
- $prod_price = Product::getPriceStatic($value['id_product'], self::useTax());
- $productPriceWithoutReduction = $product->getPriceWithoutReduct(!self::useTax());
- $productFeaturePrice = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax());
+ if (empty($prod_amen)) {
+ $prod_price = Product::getPriceStatic($value['id_product'], self::useTax());
+ $productPriceWithoutReduction = $product->getPriceWithoutReduct(!self::useTax());
+ $productFeaturePrice = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax());
- if (empty($price) || ($price['from'] <= $prod_price && $price['to'] >= $prod_price)) {
- $cover_image_arr = $product->getCover($value['id_product']);
+ if (empty($price) || ($price['from'] <= $prod_price && $price['to'] >= $prod_price)) {
+ $cover_image_arr = $product->getCover($value['id_product']);
- if (!empty($cover_image_arr)) {
- $cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'home_default');
- } else {
- $cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'home_default');
- }
-
- $room_left = count($booking_data['rm_data'][$key]['data']['available']);
-
- $rm_dtl = $obj_rm_type->getRoomTypeInfoByIdProduct($value['id_product']);
-
- $booking_data['rm_data'][$key]['name'] = $product->name;
- $booking_data['rm_data'][$key]['image'] = $cover_img;
- $booking_data['rm_data'][$key]['description'] = $product->description_short;
- $booking_data['rm_data'][$key]['feature'] = $product_feature;
- $booking_data['rm_data'][$key]['price'] = $prod_price;
- $booking_data['rm_data'][$key]['price_without_reduction'] = $productPriceWithoutReduction;
- $booking_data['rm_data'][$key]['feature_price'] = $productFeaturePrice;
- $booking_data['rm_data'][$key]['feature_price_diff'] = $productPriceWithoutReduction - $productFeaturePrice;
-
- // if ($room_left <= (int)Configuration::get('WK_ROOM_LEFT_WARNING_NUMBER'))
- $booking_data['rm_data'][$key]['room_left'] = $room_left;
-
- $booking_data['rm_data'][$key]['adult'] = $rm_dtl['adult'];
- $booking_data['rm_data'][$key]['children'] = $rm_dtl['children'];
-
- $booking_data['rm_data'][$key]['ratting'] = $prod_ratting;
- if (Module::isInstalled('productcomments')) {
- $booking_data['rm_data'][$key]['num_review'] = ProductComment::getCommentNumber($value['id_product']);
- }
-
- if (Configuration::get('PS_REWRITING_SETTINGS')) {
- $booking_data['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($product).'?date_from='.$date_from.'&date_to='.$date_to;
- } else {
- $booking_data['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($product).'&date_from='.$date_from.'&date_to='.$date_to;
- }
+ if (!empty($cover_image_arr)) {
+ $cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'home_default');
} else {
- unset($booking_data['rm_data'][$key]);
+ $cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'home_default');
}
+
+ $room_left = count($booking_data['rm_data'][$key]['data']['available']);
+
+ $rm_dtl = $obj_rm_type->getRoomTypeInfoByIdProduct($value['id_product']);
+
+ $booking_data['rm_data'][$key]['name'] = $product->name;
+ $booking_data['rm_data'][$key]['image'] = $cover_img;
+ $booking_data['rm_data'][$key]['description'] = $product->description_short;
+ $booking_data['rm_data'][$key]['feature'] = $product_feature;
+ $booking_data['rm_data'][$key]['price'] = $prod_price;
+ $booking_data['rm_data'][$key]['price_without_reduction'] = $productPriceWithoutReduction;
+ $booking_data['rm_data'][$key]['feature_price'] = $productFeaturePrice;
+ $booking_data['rm_data'][$key]['feature_price_diff'] = $productPriceWithoutReduction - $productFeaturePrice;
+
+ // if ($room_left <= (int)Configuration::get('WK_ROOM_LEFT_WARNING_NUMBER'))
+ $booking_data['rm_data'][$key]['room_left'] = $room_left;
+
+ $booking_data['rm_data'][$key]['adult'] = $rm_dtl['adult'];
+ $booking_data['rm_data'][$key]['children'] = $rm_dtl['children'];
+
+ $booking_data['rm_data'][$key]['ratting'] = $prod_ratting;
+ // if (Module::isInstalled('productcomments')) {
+ // $booking_data['rm_data'][$key]['num_review'] = ProductComment::getCommentNumber($value['id_product']);
+ // }
+
+ if (Configuration::get('PS_REWRITING_SETTINGS')) {
+ $booking_data['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($product).'?date_from='.$date_from.'&date_to='.$date_to;
+ } else {
+ $booking_data['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($product).'&date_from='.$date_from.'&date_to='.$date_to;
+ }
+ } else {
+ unset($booking_data['rm_data'][$key]);
}
}
+ // }
}
}
}
diff --git a/modules/productcomments/CHANGELOG.txt b/modules/productcomments/CHANGELOG.txt
deleted file mode 100644
index 650ea1596..000000000
--- a/modules/productcomments/CHANGELOG.txt
+++ /dev/null
@@ -1,36 +0,0 @@
--------------------------
-# V3.6.0 to V3.6.1
--------------------------
-
-## Improved/changed features:
-
-* [CO] : [#244] Changed Tools::jsonEncode to json_encode
-
-
--------------------------
-# V3.5.3 to V3.6.0
--------------------------
-
-## Improved/changed features:
-
-[*] FO : [#185] Replaced star rating plugin with jquery Raty in Product Comments module
-
-[*] CO : [#178] Text Changes
-
--------------------------
-# V3.5.2 to V3.5.3
--------------------------
-
-## Improved/changed features:
-
-[+] CO : renderModerateLists(), renderCommentsList() are updated in productcomments.php for managing hotel wise permission management.
-
-## Update Policy
-
-- Mobule need only file update, can be updated only by UPLOADING new version on module
-
-_____________________________________________________________________________________________
-u2014-04-17 11:40:33 +0200 Bug fix (PS 1.5): ps_version_compliancy removed
-2014-04-15 18:54:08 +0200 [*] hookDisplayLeftColumnProduct() added
-2014-04-09 18:28:59 +0200 Fix #PSCSX-1684, display correct date format
-2014-03-21 10:55:15 +0100 Initial commit
diff --git a/modules/productcomments/ProductComment.php b/modules/productcomments/ProductComment.php
deleted file mode 100644
index 248644e4b..000000000
--- a/modules/productcomments/ProductComment.php
+++ /dev/null
@@ -1,454 +0,0 @@
-
-* @copyright 2007-2015 PrestaShop SA
-* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-if (!defined('_PS_VERSION_')) {
- exit;
-}
-
-class ProductComment extends ObjectModel
-{
- public $id;
-
- /** @var integer Product's id */
- public $id_product;
-
- /** @var integer Customer's id */
- public $id_customer;
-
- /** @var integer Guest's id */
- public $id_guest;
-
- /** @var integer Customer name */
- public $customer_name;
-
- /** @var string Title */
- public $title;
-
- /** @var string Content */
- public $content;
-
- /** @var integer Grade */
- public $grade;
-
- /** @var boolean Validate */
- public $validate = 0;
-
- public $deleted = 0;
-
- /** @var string Object creation date */
- public $date_add;
-
- /**
- * @see ObjectModel::$definition
- */
- public static $definition = array(
- 'table' => 'product_comment',
- 'primary' => 'id_product_comment',
- 'fields' => array(
- 'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
- 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
- 'id_guest' => array('type' => self::TYPE_INT),
- 'customer_name' => array('type' => self::TYPE_STRING),
- 'title' => array('type' => self::TYPE_STRING),
- 'content' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'size' => 65535, 'required' => true),
- 'grade' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'),
- 'validate' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
- 'deleted' => array('type' => self::TYPE_BOOL),
- 'date_add' => array('type' => self::TYPE_DATE),
- )
- );
-
- /**
- * Get comments by IdProduct
- *
- * @return array Comments
- */
- public static function getByProduct($id_product, $p = 1, $n = null, $id_customer = null)
- {
- if (!Validate::isUnsignedId($id_product)) {
- return false;
- }
- $validate = Configuration::get('PRODUCT_COMMENTS_MODERATE');
- $p = (int)$p;
- $n = (int)$n;
- if ($p <= 1) {
- $p = 1;
- }
- if ($n != null && $n <= 0) {
- $n = 5;
- }
-
- $cache_id = 'ProductComment::getByProduct_'.(int)$id_product.'-'.(int)$p.'-'.(int)$n.'-'.(int)$id_customer.'-'.(bool)$validate;
- if (!Cache::isStored($cache_id)) {
- $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
- SELECT pc.`id_product_comment`,
- (SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_usefulness` pcu WHERE pcu.`id_product_comment` = pc.`id_product_comment` AND pcu.`usefulness` = 1) as total_useful,
- (SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_usefulness` pcu WHERE pcu.`id_product_comment` = pc.`id_product_comment`) as total_advice, '.
- ((int)$id_customer ? '(SELECT count(*) FROM `'._DB_PREFIX_.'product_comment_usefulness` pcuc WHERE pcuc.`id_product_comment` = pc.`id_product_comment` AND pcuc.id_customer = '.(int)$id_customer.') as customer_advice, ' : '').
- ((int)$id_customer ? '(SELECT count(*) FROM `'._DB_PREFIX_.'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' : '').'
- ORDER BY pc.`date_add` DESC
- '.($n ? 'LIMIT '.(int)(($p - 1) * $n).', '.(int)($n) : ''));
- Cache::store($cache_id, $result);
- }
- return Cache::retrieve($cache_id);
- }
-
- /**
- * Return customer's comment
- *
- * @return arrayComments
- */
- public static function getByCustomer($id_product, $id_customer, $get_last = false, $id_guest = false)
- {
- $cache_id = 'ProductComment::getByCustomer_'.(int)$id_product.'-'.(int)$id_customer.'-'.(bool)$get_last.'-'.(int)$id_guest;
- if (!Cache::isStored($cache_id)) {
- $results = Db::getInstance()->executeS('
- SELECT *
- FROM `'._DB_PREFIX_.'product_comment` pc
- WHERE pc.`id_product` = '.(int)$id_product.'
- AND '.(!$id_guest ? 'pc.`id_customer` = '.(int)$id_customer : 'pc.`id_guest` = '.(int)$id_guest).'
- ORDER BY pc.`date_add` DESC '
- .($get_last ? 'LIMIT 1' : '')
- );
-
- if ($get_last && count($results)) {
- $results = array_shift($results);
- }
-
- Cache::store($cache_id, $results);
- }
- return Cache::retrieve($cache_id);
- }
-
- /**
- * Get Grade By product
- *
- * @return array Grades
- */
- public static function getGradeByProduct($id_product, $id_lang)
- {
- if (!Validate::isUnsignedId($id_product) ||
- !Validate::isUnsignedId($id_lang)) {
- return false;
- }
- $validate = Configuration::get('PRODUCT_COMMENTS_MODERATE');
-
-
- return (Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
- SELECT pc.`id_product_comment`, pcg.`grade`, pccl.`name`, pcc.`id_product_comment_criterion`
- FROM `'._DB_PREFIX_.'product_comment` pc
- LEFT JOIN `'._DB_PREFIX_.'product_comment_grade` pcg ON (pcg.`id_product_comment` = pc.`id_product_comment`)
- LEFT JOIN `'._DB_PREFIX_.'product_comment_criterion` pcc ON (pcc.`id_product_comment_criterion` = pcg.`id_product_comment_criterion`)
- LEFT JOIN `'._DB_PREFIX_.'product_comment_criterion_lang` pccl ON (pccl.`id_product_comment_criterion` = pcg.`id_product_comment_criterion`)
- WHERE pc.`id_product` = '.(int)$id_product.'
- AND pccl.`id_lang` = '.(int)$id_lang.
- ($validate == '1' ? ' AND pc.`validate` = 1' : '')));
- }
-
- public static function getRatings($id_product)
- {
- $validate = Configuration::get('PRODUCT_COMMENTS_MODERATE');
-
- $sql = 'SELECT (SUM(pc.`grade`) / COUNT(pc.`grade`)) AS avg,
- MIN(pc.`grade`) AS min,
- MAX(pc.`grade`) AS max
- FROM `'._DB_PREFIX_.'product_comment` pc
- WHERE pc.`id_product` = '.(int)$id_product.'
- AND pc.`deleted` = 0'.
- ($validate == '1' ? ' AND pc.`validate` = 1' : '');
-
-
- return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
- }
-
- public static function getAverageGrade($id_product)
- {
- $validate = Configuration::get('PRODUCT_COMMENTS_MODERATE');
-
- return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
- SELECT (SUM(pc.`grade`) / COUNT(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 */
- $grades = ProductComment::getGradeByProduct((int)$id_product, (int)$id_lang);
- $total = ProductComment::getGradedCommentNumber((int)$id_product);
- if (!count($grades) || (!$total)) {
- return array();
- }
-
- /* Addition grades for each criterion */
- $criterionsGradeTotal = array();
- $count_grades = count($grades);
- for ($i = 0; $i < $count_grades; ++$i) {
- if (array_key_exists($grades[$i]['id_product_comment_criterion'], $criterionsGradeTotal) === false) {
- $criterionsGradeTotal[$grades[$i]['id_product_comment_criterion']] = (int)($grades[$i]['grade']);
- } else {
- $criterionsGradeTotal[$grades[$i]['id_product_comment_criterion']] += (int)($grades[$i]['grade']);
- }
- }
-
- /* Finally compute the averages */
- $averages = array();
- foreach ($criterionsGradeTotal as $key => $criterionGradeTotal) {
- $averages[(int)($key)] = (int)($total) ? ((int)($criterionGradeTotal) / (int)($total)) : 0;
- }
- return $averages;
- }
-
- /**
- * Return number of comments and average grade by products
- *
- * @return array Info
- */
- public static function getCommentNumber($id_product)
- {
- if (!Validate::isUnsignedId($id_product)) {
- return false;
- }
- $validate = (int)Configuration::get('PRODUCT_COMMENTS_MODERATE');
- $cache_id = 'ProductComment::getCommentNumber_'.(int)$id_product.'-'.$validate;
- if (!Cache::isStored($cache_id)) {
- $result = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
- SELECT COUNT(`id_product_comment`) AS "nbr"
- FROM `'._DB_PREFIX_.'product_comment` pc
- WHERE `id_product` = '.(int)($id_product).($validate == '1' ? ' AND `validate` = 1' : ''));
- Cache::store($cache_id, $result);
- }
- return Cache::retrieve($cache_id);
- }
-
- /**
- * Return number of comments and average grade by products
- *
- * @return array Info
- */
- public static function getGradedCommentNumber($id_product)
- {
- if (!Validate::isUnsignedId($id_product)) {
- return false;
- }
- $validate = (int)Configuration::get('PRODUCT_COMMENTS_MODERATE');
-
- $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
- SELECT COUNT(pc.`id_product`) AS nbr
- FROM `'._DB_PREFIX_.'product_comment` pc
- WHERE `id_product` = '.(int)($id_product).($validate == '1' ? ' AND `validate` = 1' : '').'
- AND `grade` > 0');
- return (int)($result['nbr']);
- }
-
- /**
- * Get comments by Validation
- *
- * @return array Comments
- */
- public static function getByValidate($validate = '0', $deleted = false)
- {
- $sql = '
- SELECT pc.`id_product_comment`, pc.`id_product`, IF(c.id_customer, CONCAT(c.`firstname`, \' \', c.`lastname`), pc.customer_name) customer_name, pc.`title`, 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` AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Shop::addSqlRestrictionOnLang('pl').')
- WHERE pc.`validate` = '.(int)$validate;
-
- $sql .= ' ORDER BY pc.`date_add` DESC';
-
- return (Db::getInstance()->executeS($sql));
- }
-
- /**
- * Get all comments
- *
- * @return array Comments
- */
- public static function getAll()
- {
- return (Db::getInstance()->executeS('
- 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` AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Shop::addSqlRestrictionOnLang('pl').')
- ORDER BY pc.`date_add` DESC'));
- }
-
- /**
- * Validate a comment
- *
- * @return boolean succeed
- */
- public function validate($validate = '1')
- {
- if (!Validate::isUnsignedId($this->id)) {
- return false;
- }
-
- $success = (Db::getInstance()->execute('
- UPDATE `'._DB_PREFIX_.'product_comment` SET
- `validate` = '.(int)$validate.'
- WHERE `id_product_comment` = '.(int)$this->id));
-
- Hook::exec('actionObjectProductCommentValidateAfter', array('object' => $this));
- return $success;
- }
-
- /**
- * Delete a comment, grade and report data
- *
- * @return boolean succeed
- */
- public function delete()
- {
- parent::delete();
- ProductComment::deleteGrades($this->id);
- ProductComment::deleteReports($this->id);
- ProductComment::deleteUsefulness($this->id);
- }
-
- /**
- * Delete Grades
- *
- * @return boolean succeed
- */
- public static function deleteGrades($id_product_comment)
- {
- if (!Validate::isUnsignedId($id_product_comment)) {
- return false;
- }
- return (Db::getInstance()->execute('
- 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)) {
- return false;
- }
- return (Db::getInstance()->execute('
- DELETE FROM `'._DB_PREFIX_.'product_comment_report`
- WHERE `id_product_comment` = '.(int)$id_product_comment));
- }
-
- /**
- * Delete usefulness
- *
- * @return boolean succeed
- */
- public static function deleteUsefulness($id_product_comment)
- {
- if (!Validate::isUnsignedId($id_product_comment)) {
- return false;
- }
-
- return (Db::getInstance()->execute('
- DELETE FROM `'._DB_PREFIX_.'product_comment_usefulness`
- 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.', '.(int)$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`, pc.`title`
- 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.Shop::addSqlRestrictionOnLang('pl').')
- ORDER BY pc.`date_add` DESC');
- }
-};
diff --git a/modules/productcomments/ProductCommentCriterion.php b/modules/productcomments/ProductCommentCriterion.php
deleted file mode 100644
index 2589633ed..000000000
--- a/modules/productcomments/ProductCommentCriterion.php
+++ /dev/null
@@ -1,266 +0,0 @@
-
-* @copyright 2007-2015 PrestaShop SA
-* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-class ProductCommentCriterion extends ObjectModel
-{
- public $id;
- public $id_product_comment_criterion_type;
- public $name;
- public $active = true;
-
- /**
- * @see ObjectModel::$definition
- */
- public static $definition = array(
- 'table' => 'product_comment_criterion',
- 'primary' => 'id_product_comment_criterion',
- 'multilang' => true,
- 'fields' => array(
- 'id_product_comment_criterion_type' => array('type' => self::TYPE_INT),
- 'active' => array('type' => self::TYPE_BOOL),
- // Lang fields
- 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128),
- )
- );
-
- public function delete()
- {
- if (!parent::delete())
- return false;
- if ($this->id_product_comment_criterion_type == 2)
- {
- if (!Db::getInstance()->execute('
- DELETE FROM '._DB_PREFIX_.'product_comment_criterion_category
- WHERE id_product_comment_criterion='.(int)$this->id))
- return false;
- }
- elseif ($this->id_product_comment_criterion_type == 3)
- {
- if (!Db::getInstance()->execute('
- DELETE FROM '._DB_PREFIX_.'product_comment_criterion_product
- WHERE id_product_comment_criterion='.(int)$this->id))
- return false;
- }
-
- return Db::getInstance()->execute('
- DELETE FROM `'._DB_PREFIX_.'product_comment_grade`
- WHERE `id_product_comment_criterion` = '.(int)$this->id);
- }
-
- public function update($nullValues = false)
- {
- $previousUpdate = new self((int)$this->id);
- if (!parent::update($nullValues))
- return false;
- if ($previousUpdate->id_product_comment_criterion_type != $this->id_product_comment_criterion_type)
- {
- if ($previousUpdate->id_product_comment_criterion_type == 2)
- return Db::getInstance()->execute('
- DELETE FROM '._DB_PREFIX_.'product_comment_criterion_category
- WHERE id_product_comment_criterion = '.(int)$previousUpdate->id);
- elseif ($previousUpdate->id_product_comment_criterion_type == 3)
- return Db::getInstance()->execute('
- DELETE FROM '._DB_PREFIX_.'product_comment_criterion_product
- WHERE id_product_comment_criterion = '.(int)$previousUpdate->id);
- }
- return true;
- }
-
- /**
- * Link a Comment Criterion to a product
- *
- * @return boolean succeed
- */
- public function addProduct($id_product)
- {
- if (!Validate::isUnsignedId($id_product))
- die(Tools::displayError());
- return Db::getInstance()->execute('
- INSERT INTO `'._DB_PREFIX_.'product_comment_criterion_product` (`id_product_comment_criterion`, `id_product`)
- VALUES('.(int)$this->id.','.(int)$id_product.')
- ');
- }
-
- /**
- * Link a Comment Criterion to a category
- *
- * @return boolean succeed
- */
- public function addCategory($id_category)
- {
- if (!Validate::isUnsignedId($id_category))
- die(Tools::displayError());
- return Db::getInstance()->execute('
- INSERT INTO `'._DB_PREFIX_.'product_comment_criterion_category` (`id_product_comment_criterion`, `id_category`)
- VALUES('.(int)$this->id.','.(int)$id_category.')
- ');
- }
-
- /**
- * Add grade to a criterion
- *
- * @return boolean succeed
- */
- public function addGrade($id_product_comment, $grade)
- {
- if (!Validate::isUnsignedId($id_product_comment))
- die(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(
- '.(int)($id_product_comment).',
- '.(int)$this->id.',
- '.(int)($grade).')'));
- }
-
- /**
- * Get criterion by Product
- *
- * @return array Criterion
- */
- public static function getByProduct($id_product, $id_lang)
- {
- if (!Validate::isUnsignedId($id_product) ||
- !Validate::isUnsignedId($id_lang))
- die(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_'.(int)$id_product.'-'.(int)$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` = '.(int)$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 = '.(int)$id_product.')
- WHERE pccl.`id_lang` = '.(int)($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
- *
- * @return array Criterions
- */
- public static function getCriterions($id_lang, $type = false, $active = false)
- {
- if (!Validate::isUnsignedId($id_lang))
- die(Tools::displayError());
-
- $sql = '
- SELECT pcc.`id_product_comment_criterion`, pcc.id_product_comment_criterion_type, pccl.`name`, pcc.active
- FROM `'._DB_PREFIX_.'product_comment_criterion` pcc
- JOIN `'._DB_PREFIX_.'product_comment_criterion_lang` pccl ON (pcc.id_product_comment_criterion = pccl.id_product_comment_criterion)
- WHERE pccl.`id_lang` = '.(int)$id_lang.($active ? ' AND active = 1' : '').($type ? ' AND id_product_comment_criterion_type = '.(int)$type : '').'
- ORDER BY pccl.`name` ASC';
- $criterions = Db::getInstance()->executeS($sql);
-
- $types = self::getTypes();
- foreach ($criterions as $key => $data)
- $criterions[$key]['type_name'] = $types[$data['id_product_comment_criterion_type']];
-
- return $criterions;
- }
-
- public function getProducts()
- {
- $res = Db::getInstance()->executeS('
- SELECT pccp.id_product, pccp.id_product_comment_criterion
- FROM `'._DB_PREFIX_.'product_comment_criterion_product` pccp
- WHERE pccp.id_product_comment_criterion = '.(int)$this->id);
- $products = array();
- if ($res)
- foreach ($res AS $row)
- $products[] = (int)$row['id_product'];
- return $products;
- }
-
- public function getCategories()
- {
- $res = Db::getInstance()->executeS('
- SELECT pccc.id_category, pccc.id_product_comment_criterion
- FROM `'._DB_PREFIX_.'product_comment_criterion_category` pccc
- WHERE pccc.id_product_comment_criterion = '.(int)$this->id);
- $criterions = array();
- if ($res)
- foreach ($res AS $row)
- $criterions[] = (int)$row['id_category'];
- return $criterions;
- }
-
- public function deleteCategories()
- {
- return Db::getInstance()->execute('
- DELETE FROM `'._DB_PREFIX_.'product_comment_criterion_category`
- WHERE `id_product_comment_criterion` = '.(int)$this->id);
- }
-
- public function deleteProducts()
- {
- return Db::getInstance()->execute('
- DELETE FROM `'._DB_PREFIX_.'product_comment_criterion_product`
- WHERE `id_product_comment_criterion` = '.(int)$this->id);
- }
-
- public static function getTypes()
- {
- // Instance of module class for translations
- $module = new ProductComments();
-
- return array(
- 1 => $module->l('Valid for the entire catalog', 'ProductCommentCriterion'),
- 2 => $module->l('Restricted to some categories', 'ProductCommentCriterion'),
- 3 => $module->l('Restricted to some products', 'ProductCommentCriterion')
- );
- }
-}
diff --git a/modules/productcomments/ProductCriterion.php b/modules/productcomments/ProductCriterion.php
deleted file mode 100644
index 03a5ba5c3..000000000
--- a/modules/productcomments/ProductCriterion.php
+++ /dev/null
@@ -1,174 +0,0 @@
-
-* @copyright 2007-2015 PrestaShop SA
-* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-class ProductCommentCriterion
-{
- /**
- * Add a Comment Criterion
- *
- * @return boolean succeed
- */
- public static function add($id_lang, $name)
- {
- if (!Validate::isUnsignedId($id_lang) ||
- !Validate::isMessage($name))
- die(Tools::displayError());
- return (Db::getInstance()->execute('
- INSERT INTO `'._DB_PREFIX_.'product_comment_criterion`
- (`id_lang`, `name`) VALUES(
- '.(int)($id_lang).',
- \''.pSQL($name).'\')'));
- }
-
- /**
- * Link a Comment Criterion to a product
- *
- * @return boolean succeed
- */
- public static function addToProduct($id_product_comment_criterion, $id_product)
- {
- if (!Validate::isUnsignedId($id_product_comment_criterion) ||
- !Validate::isUnsignedId($id_product))
- die(Tools::displayError());
- return (Db::getInstance()->execute('
- INSERT INTO `'._DB_PREFIX_.'product_comment_criterion_product`
- (`id_product_comment_criterion`, `id_product`) VALUES(
- '.(int)($id_product_comment_criterion).',
- '.(int)($id_product).')'));
- }
-
- /**
- * Add grade to a criterion
- *
- * @return boolean succeed
- */
- public static function addGrade($id_product_comment, $id_product_comment_criterion, $grade)
- {
- if (!Validate::isUnsignedId($id_product_comment) ||
- !Validate::isUnsignedId($id_product_comment_criterion))
- die(Tools::displayError());
- if ($grade < 0)
- $grade = 0;
- else if ($grade > 10)
- $grade = 10;
- return (Db::getInstance()->execute('
- INSERT INTO `'._DB_PREFIX_.'product_comment_grade`
- (`id_product_comment`, `id_product_comment_criterion`, `grade`) VALUES(
- '.(int)($id_product_comment).',
- '.(int)($id_product_comment_criterion).',
- '.(int)($grade).')'));
- }
-
- /**
- * Update criterion
- *
- * @return boolean succeed
- */
- public static function update($id_product_comment_criterion, $id_lang, $name)
- {
- if (!Validate::isUnsignedId($id_product_comment_criterion) ||
- !Validate::isUnsignedId($id_lang) ||
- !Validate::isMessage($name))
- die(Tools::displayError());
- return (Db::getInstance()->execute('
- UPDATE `'._DB_PREFIX_.'product_comment_criterion` SET
- `name` = \''.pSQL($name).'\'
- WHERE `id_product_comment_criterion` = '.(int)($id_product_comment_criterion).' AND
- `id_lang` = '.(int)($id_lang)));
- }
-
- /**
- * Get criterion by Product
- *
- * @return array Criterion
- */
- public static function getByProduct($id_product, $id_lang)
- {
- if (!Validate::isUnsignedId($id_product) ||
- !Validate::isUnsignedId($id_lang))
- die(Tools::displayError());
- return (Db::getInstance()->executeS('
- SELECT pcc.`id_product_comment_criterion`, pcc.`name`
- FROM `'._DB_PREFIX_.'product_comment_criterion` pcc
- INNER JOIN `'._DB_PREFIX_.'product_comment_criterion_product` pccp ON pcc.`id_product_comment_criterion` = pccp.`id_product_comment_criterion`
- WHERE pccp.`id_product` = '.(int)($id_product).' AND
- pcc.`id_lang` = '.(int)($id_lang)));
- }
-
- /**
- * Get Criterions
- *
- * @return array Criterions
- */
- public static function get($id_lang)
- {
- if (!Validate::isUnsignedId($id_lang))
- die(Tools::displayError());
- return (Db::getInstance()->executeS('
- SELECT pcc.`id_product_comment_criterion`, pcc.`name`
- FROM `'._DB_PREFIX_.'product_comment_criterion` pcc
- WHERE pcc.`id_lang` = '.(int)($id_lang).'
- ORDER BY pcc.`name` ASC'));
- }
-
- /**
- * Delete product criterion by product
- *
- * @return boolean succeed
- */
- public static function deleteByProduct($id_product)
- {
- if (!Validate::isUnsignedId($id_product))
- die(Tools::displayError());
- return (Db::getInstance()->execute('
- DELETE FROM `'._DB_PREFIX_.'product_comment_criterion_product`
- WHERE `id_product` = '.(int)($id_product)));
- }
-
- /**
- * Delete all reference of a criterion
- *
- * @return boolean succeed
- */
- public static function delete($id_product_comment_criterion)
- {
- if (!Validate::isUnsignedId($id_product_comment_criterion))
- die(Tools::displayError());
- $result = Db::getInstance()->execute('
- DELETE FROM `'._DB_PREFIX_.'product_comment_grade`
- WHERE `id_product_comment_criterion` = '.(int)($id_product_comment_criterion));
- if ($result === false)
- return ($result);
- $result = Db::getInstance()->execute('
- DELETE FROM `'._DB_PREFIX_.'product_comment_criterion_product`
- WHERE `id_product_comment_criterion` = '.(int)($id_product_comment_criterion));
- if ($result === false)
- return ($result);
- return (Db::getInstance()->execute('
- DELETE FROM `'._DB_PREFIX_.'product_comment_criterion`
- WHERE `id_product_comment_criterion` = '.(int)($id_product_comment_criterion)));
- }
-};
\ No newline at end of file
diff --git a/modules/productcomments/Readme.md b/modules/productcomments/Readme.md
deleted file mode 100644
index fa907d97f..000000000
--- a/modules/productcomments/Readme.md
+++ /dev/null
@@ -1,37 +0,0 @@
-# Product Comments
-
-## About
-
-Allows users to post reviews and rate products on specific criteria.
-
-## Contributing
-
-PrestaShop modules are open-source extensions to the PrestaShop e-commerce solution. Everyone is welcome and even encouraged to contribute with their own improvements.
-
-### Requirements
-
-Contributors **must** follow the following rules:
-
-* **Make your Pull Request on the "dev" branch**, NOT the "master" branch.
-* Do not update the module's version number.
-* Follow [the coding standards][1].
-
-### Process in details
-
-Contributors wishing to edit a module's files should follow the following process:
-
-1. Create your GitHub account, if you do not have one already.
-2. Fork the productcomments project to your GitHub account.
-3. Clone your fork to your local machine in the ```/modules``` directory of your PrestaShop installation.
-4. Create a branch in your local clone of the module for your changes.
-5. Change the files in your branch. Be sure to follow [the coding standards][1]!
-6. Push your changed branch to your fork in your GitHub account.
-7. Create a pull request for your changes **on the _'dev'_ branch** of the module's project. Be sure to follow [the commit message norm][2] in your pull request. If you need help to make a pull request, read the [Github help page about creating pull requests][3].
-8. Wait for one of the core developers either to include your change in the codebase, or to comment on possible improvements you should make to your code.
-
-That's it: you have contributed to this open-source project! Congratulations!
-
-[1]: http://doc.prestashop.com/display/PS16/Coding+Standards
-[2]: http://doc.prestashop.com/display/PS16/How+to+write+a+commit+message
-[3]: https://help.github.com/articles/using-pull-requests
-
diff --git a/modules/productcomments/classes/ProductCommentsDb.php b/modules/productcomments/classes/ProductCommentsDb.php
deleted file mode 100644
index 8958f0336..000000000
--- a/modules/productcomments/classes/ProductCommentsDb.php
+++ /dev/null
@@ -1,131 +0,0 @@
-getModuleSql()) {
- foreach ($sql as $query) {
- if ($query) {
- if (!Db::getInstance()->execute(trim($query))) {
- return false;
- }
- }
- }
- }
- return true;
- }
-
- public function dropTables()
- {
- return Db::getInstance()->execute(
- 'DROP TABLE IF EXISTS
- `'._DB_PREFIX_.'product_comment`,
- `'._DB_PREFIX_.'product_comment_criterion`,
- `'._DB_PREFIX_.'product_comment_criterion_product`,
- `'._DB_PREFIX_.'product_comment_criterion_lang`,
- `'._DB_PREFIX_.'product_comment_criterion_category`,
- `'._DB_PREFIX_.'product_comment_grade`,
- `'._DB_PREFIX_.'product_comment_usefulness`,
- `'._DB_PREFIX_.'product_comment_report`'
- );
- }
-}
diff --git a/modules/productcomments/composer.json b/modules/productcomments/composer.json
deleted file mode 100644
index 94a930aef..000000000
--- a/modules/productcomments/composer.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "name": "prestashop/productcomments",
- "description": "PrestaShop module productcomments",
- "homepage": "https://github.com/PrestaShop/productcomments",
- "license": "AFL - Academic Free License (AFL 3.0)",
- "authors": [
- {
- "name": "PrestaShop SA",
- "email": "contact@prestashop.com"
- }
- ],
- "require": {
- "php": ">=5.3.2"
- },
- "config": {
- "preferred-install": "dist"
- },
- "type": "prestashop-module"
-}
diff --git a/modules/productcomments/controllers/front/default.php b/modules/productcomments/controllers/front/default.php
deleted file mode 100644
index e53694ed3..000000000
--- a/modules/productcomments/controllers/front/default.php
+++ /dev/null
@@ -1,180 +0,0 @@
-
-* @copyright 2007-2015 PrestaShop SA
-* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-// Include Module
-include_once(dirname(__FILE__).'/../../productcomments.php');
-// Include Models
-include_once(dirname(__FILE__).'/../../ProductComment.php');
-include_once(dirname(__FILE__).'/../../ProductCommentCriterion.php');
-
-class ProductCommentsDefaultModuleFrontController extends ModuleFrontController
-{
- public function __construct()
- {
- parent::__construct();
-
- $this->context = Context::getContext();
- }
-
- public function initContent()
- {
- parent::initContent();
-
- if (Tools::isSubmit('action'))
- {
- switch(Tools::getValue('action'))
- {
- case 'add_comment':
- $this->ajaxProcessAddComment();
- break;
- case 'report_abuse':
- $this->ajaxProcessReportAbuse();
- break;
- case 'comment_is_usefull':
- $this->ajaxProcessCommentIsUsefull();
- break;
- }
- }
- }
-
- protected function ajaxProcessAddComment()
- {
- $module_instance = new ProductComments();
-
- $result = true;
- $id_guest = 0;
- $id_customer = $this->context->customer->id;
- if (!$id_customer)
- $id_guest = $this->context->cookie->id_guest;
-
- $errors = array();
- // Validation
- if (!Validate::isInt(Tools::getValue('id_product')))
- $errors[] = $module_instance->l('Product ID is incorrect', 'default');
- if (!Tools::getValue('title')) {
- $errors[] = $module_instance->l('Please provide your review title', 'default');
- } elseif(!Validate::isGenericName(Tools::getValue('title'))) {
- $errors[] = $module_instance->l('Review title is incorrect', 'default');
- }
- if (!Tools::getValue('content')) {
- $errors[] = $module_instance->l('Please provide the description', 'default');
- } elseif(!Validate::isMessage(Tools::getValue('content'))) {
- $errors[] = $module_instance->l('Review description is invalid', 'default');
- }
- if (!$id_customer && (!Tools::isSubmit('customer_name') || !Tools::getValue('customer_name'))) {
- $errors[] = $module_instance->l('Customer name is required', 'default');
- } elseif(!Validate::isGenericName(Tools::getValue('customer_name'))) {
- $errors[] = $module_instance->l('Customer name is invalid', 'default');
- }
- if (!$this->context->customer->id && !Configuration::get('PRODUCT_COMMENTS_ALLOW_GUESTS'))
- $errors[] = $module_instance->l('You must be connected in order to send a comment', 'default');
- if (!count(Tools::getValue('criterion')))
- $errors[] = $module_instance->l('You must give a rating', 'default');
-
- $product = new Product(Tools::getValue('id_product'));
- if (!$product->id)
- $errors[] = $module_instance->l('Product not found', 'default');
-
- if (!count($errors))
- {
- $customer_comment = ProductComment::getByCustomer(Tools::getValue('id_product'), $id_customer, true, $id_guest);
- if (!$customer_comment || ($customer_comment && (strtotime($customer_comment['date_add']) + (int)Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME')) < time()))
- {
-
- $comment = new ProductComment();
- $comment->content = strip_tags(Tools::getValue('content'));
- $comment->id_product = (int)Tools::getValue('id_product');
- $comment->id_customer = (int)$id_customer;
- $comment->id_guest = $id_guest;
- $comment->customer_name = Tools::getValue('customer_name');
- if (!$comment->customer_name)
- $comment->customer_name = pSQL($this->context->customer->firstname.' '.$this->context->customer->lastname);
- $comment->title = Tools::getValue('title');
- $comment->grade = 0;
- $comment->validate = 0;
- $comment->save();
-
- $grade_sum = 0;
- foreach(Tools::getValue('criterion') as $id_product_comment_criterion => $grade)
- {
- $grade_sum += $grade;
- $product_comment_criterion = new ProductCommentCriterion($id_product_comment_criterion);
- if ($product_comment_criterion->id)
- $product_comment_criterion->addGrade($comment->id, $grade);
- }
-
- if (count(Tools::getValue('criterion')) >= 1)
- {
- $comment->grade = $grade_sum / count(Tools::getValue('criterion'));
- // Update Grade average of comment
- $comment->save();
- }
- $result = true;
- Tools::clearCache(Context::getContext()->smarty, $this->getTemplatePath('productcomments-reviews.tpl'));
- }
- else
- {
- $result = false;
- $errors[] = $module_instance->l('Please wait before posting another comment', 'default').' '.Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME').' '.$module_instance->l('seconds before posting a new comment', 'default');
- }
- }
- else
- $result = false;
-
- die(json_encode(array(
- 'result' => $result,
- 'errors' => $errors
- )));
- }
-
- protected function ajaxProcessReportAbuse()
- {
- if (!Tools::isSubmit('id_product_comment'))
- die('0');
-
- if (ProductComment::isAlreadyReport(Tools::getValue('id_product_comment'), $this->context->cookie->id_customer))
- die('0');
-
- if (ProductComment::reportComment((int)Tools::getValue('id_product_comment'), $this->context->cookie->id_customer))
- die('1');
-
- die('0');
- }
-
- protected function ajaxProcessCommentIsUsefull()
- {
- if (!Tools::isSubmit('id_product_comment') || !Tools::isSubmit('value'))
- die('0');
-
- if (ProductComment::isAlreadyUsefulness(Tools::getValue('id_product_comment'), $this->context->cookie->id_customer))
- die('0');
-
- if (ProductComment::setCommentUsefulness((int)Tools::getValue('id_product_comment'), (bool)Tools::getValue('value'), $this->context->cookie->id_customer))
- die('1');
-
- die('0');
- }
-}
diff --git a/modules/productcomments/controllers/front/index.php b/modules/productcomments/controllers/front/index.php
deleted file mode 100644
index 044cb85ee..000000000
--- a/modules/productcomments/controllers/front/index.php
+++ /dev/null
@@ -1,35 +0,0 @@
-
-* @copyright 2007-2015 PrestaShop SA
-* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
-header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
-
-header("Cache-Control: no-store, no-cache, must-revalidate");
-header("Cache-Control: post-check=0, pre-check=0", false);
-header("Pragma: no-cache");
-
-header("Location: ../");
-exit;
\ No newline at end of file
diff --git a/modules/productcomments/controllers/index.php b/modules/productcomments/controllers/index.php
deleted file mode 100644
index 044cb85ee..000000000
--- a/modules/productcomments/controllers/index.php
+++ /dev/null
@@ -1,35 +0,0 @@
-
-* @copyright 2007-2015 PrestaShop SA
-* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
-header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
-
-header("Cache-Control: no-store, no-cache, must-revalidate");
-header("Cache-Control: post-check=0, pre-check=0", false);
-header("Pragma: no-cache");
-
-header("Location: ../");
-exit;
\ No newline at end of file
diff --git a/modules/productcomments/img/accept.png b/modules/productcomments/img/accept.png
deleted file mode 100644
index 995fe516f..000000000
Binary files a/modules/productcomments/img/accept.png and /dev/null differ
diff --git a/modules/productcomments/img/bg_bt.gif b/modules/productcomments/img/bg_bt.gif
deleted file mode 100644
index 202d52afb..000000000
Binary files a/modules/productcomments/img/bg_bt.gif and /dev/null differ
diff --git a/modules/productcomments/img/bg_li.png b/modules/productcomments/img/bg_li.png
deleted file mode 100644
index 6b076ee2f..000000000
Binary files a/modules/productcomments/img/bg_li.png and /dev/null differ
diff --git a/modules/productcomments/img/comment.png b/modules/productcomments/img/comment.png
deleted file mode 100644
index 297311914..000000000
Binary files a/modules/productcomments/img/comment.png and /dev/null differ
diff --git a/modules/productcomments/img/comments_delete.png b/modules/productcomments/img/comments_delete.png
deleted file mode 100644
index 546988080..000000000
Binary files a/modules/productcomments/img/comments_delete.png and /dev/null differ
diff --git a/modules/productcomments/img/delete.gif b/modules/productcomments/img/delete.gif
deleted file mode 100644
index 43c6ca876..000000000
Binary files a/modules/productcomments/img/delete.gif and /dev/null differ
diff --git a/modules/productcomments/img/delete.png b/modules/productcomments/img/delete.png
deleted file mode 100644
index 82bae8dc8..000000000
Binary files a/modules/productcomments/img/delete.png and /dev/null differ
diff --git a/modules/productcomments/img/index.php b/modules/productcomments/img/index.php
deleted file mode 100644
index a318ca6dc..000000000
--- a/modules/productcomments/img/index.php
+++ /dev/null
@@ -1,35 +0,0 @@
-
-* @copyright 2007-2017 PrestaShop SA
-* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
-header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
-
-header("Cache-Control: no-store, no-cache, must-revalidate");
-header("Cache-Control: post-check=0, pre-check=0", false);
-header("Pragma: no-cache");
-
-header("Location: ../");
-exit;
\ No newline at end of file
diff --git a/modules/productcomments/img/note.png b/modules/productcomments/img/note.png
deleted file mode 100644
index 4d7030f04..000000000
Binary files a/modules/productcomments/img/note.png and /dev/null differ
diff --git a/modules/productcomments/img/note_go.png b/modules/productcomments/img/note_go.png
deleted file mode 100644
index 4d7ffdfde..000000000
Binary files a/modules/productcomments/img/note_go.png and /dev/null differ
diff --git a/modules/productcomments/img/star.gif b/modules/productcomments/img/star.gif
deleted file mode 100644
index f7f80c2bf..000000000
Binary files a/modules/productcomments/img/star.gif and /dev/null differ
diff --git a/modules/productcomments/img/star.png b/modules/productcomments/img/star.png
deleted file mode 100644
index b8c6422bb..000000000
Binary files a/modules/productcomments/img/star.png and /dev/null differ
diff --git a/modules/productcomments/img/star1.gif b/modules/productcomments/img/star1.gif
deleted file mode 100644
index 6d647b432..000000000
Binary files a/modules/productcomments/img/star1.gif and /dev/null differ
diff --git a/modules/productcomments/index.php b/modules/productcomments/index.php
deleted file mode 100644
index 044cb85ee..000000000
--- a/modules/productcomments/index.php
+++ /dev/null
@@ -1,35 +0,0 @@
-
-* @copyright 2007-2015 PrestaShop SA
-* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
-header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
-
-header("Cache-Control: no-store, no-cache, must-revalidate");
-header("Cache-Control: post-check=0, pre-check=0", false);
-header("Pragma: no-cache");
-
-header("Location: ../");
-exit;
\ No newline at end of file
diff --git a/modules/productcomments/js/index.php b/modules/productcomments/js/index.php
deleted file mode 100644
index 044cb85ee..000000000
--- a/modules/productcomments/js/index.php
+++ /dev/null
@@ -1,35 +0,0 @@
-
-* @copyright 2007-2015 PrestaShop SA
-* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
-header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
-
-header("Cache-Control: no-store, no-cache, must-revalidate");
-header("Cache-Control: post-check=0, pre-check=0", false);
-header("Pragma: no-cache");
-
-header("Location: ../");
-exit;
\ No newline at end of file
diff --git a/modules/productcomments/js/jquery.textareaCounter.plugin.js b/modules/productcomments/js/jquery.textareaCounter.plugin.js
deleted file mode 100644
index fe94870e9..000000000
--- a/modules/productcomments/js/jquery.textareaCounter.plugin.js
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * jQuery Textarea Characters Counter Plugin v 2.0
- * Examples and documentation at: http://roy-jin.appspot.com/jsp/textareaCounter.jsp
- * Copyright (c) 2010 Roy Jin
- * Version: 2.0 (11-JUN-2010)
- * Dual licensed under the MIT and GPL licenses:
- * http://www.opensource.org/licenses/mit-license.php
- * http://www.gnu.org/licenses/gpl.html
- * Requires: jQuery v1.4.2 or later
- */
-(function($){
- $.fn.textareaCount = function(options, fn) {
- var defaults = {
- maxCharacterSize: -1,
- originalStyle: 'originalTextareaInfo',
- warningStyle: 'warningTextareaInfo',
- warningNumber: 20,
- displayFormat: '#input characters | #words words'
- };
- var options = $.extend(defaults, options);
-
- var container = $(this);
-
- $("
").insertAfter(container);
-
- //create charleft css
- var charLeftCss = {
- 'width' : container.width()
- };
-
- var charLeftInfo = getNextCharLeftInformation(container);
- charLeftInfo.addClass(options.originalStyle);
- charLeftInfo.css(charLeftCss);
-
- var numInput = 0;
- var maxCharacters = options.maxCharacterSize;
- var numLeft = 0;
- var numWords = 0;
-
- container.bind('keyup', function(event){limitTextAreaByCharacterCount();})
- .bind('mouseover', function(event){setTimeout(function(){limitTextAreaByCharacterCount();}, 10);})
- .bind('paste', function(event){setTimeout(function(){limitTextAreaByCharacterCount();}, 10);});
-
-
- function limitTextAreaByCharacterCount(){
- charLeftInfo.html(countByCharacters());
- //function call back
- if(typeof fn != 'undefined'){
- fn.call(this, getInfo());
- }
- return true;
- }
-
- function countByCharacters(){
- var content = container.val();
- var contentLength = content.length;
-
- //Start Cut
- if(options.maxCharacterSize > 0){
- //If copied content is already more than maxCharacterSize, chop it to maxCharacterSize.
- if(contentLength >= options.maxCharacterSize) {
- content = content.substring(0, options.maxCharacterSize);
- }
-
- var newlineCount = getNewlineCount(content);
-
- // newlineCount new line character. For windows, it occupies 2 characters
- var systemmaxCharacterSize = options.maxCharacterSize - newlineCount;
- if (!isWin()){
- systemmaxCharacterSize = options.maxCharacterSize
- }
- if(contentLength > systemmaxCharacterSize){
- //avoid scroll bar moving
- var originalScrollTopPosition = this.scrollTop;
- container.val(content.substring(0, systemmaxCharacterSize));
- this.scrollTop = originalScrollTopPosition;
- }
- charLeftInfo.removeClass(options.warningStyle);
- if(systemmaxCharacterSize - contentLength <= options.warningNumber){
- charLeftInfo.addClass(options.warningStyle);
- }
-
- numInput = container.val().length + newlineCount;
- if(!isWin()){
- numInput = container.val().length;
- }
-
- numWords = countWord(getCleanedWordString(container.val()));
-
- numLeft = maxCharacters - numInput;
- } else {
- //normal count, no cut
- var newlineCount = getNewlineCount(content);
- numInput = container.val().length + newlineCount;
- if(!isWin()){
- numInput = container.val().length;
- }
- numWords = countWord(getCleanedWordString(container.val()));
- }
-
- return formatDisplayInfo();
- }
-
- function formatDisplayInfo(){
- var format = options.displayFormat;
- format = format.replace('#input', numInput);
- format = format.replace('#words', numWords);
- //When maxCharacters <= 0, #max, #left cannot be substituted.
- if(maxCharacters > 0){
- format = format.replace('#max', maxCharacters);
- format = format.replace('#left', numLeft);
- }
- return format;
- }
-
- function getInfo(){
- var info = {
- input: numInput,
- max: maxCharacters,
- left: numLeft,
- words: numWords
- };
- return info;
- }
-
- function getNextCharLeftInformation(container){
- return container.next('.charleft');
- }
-
- function isWin(){
- var strOS = navigator.appVersion;
- if (strOS.toLowerCase().indexOf('win') != -1){
- return true;
- }
- return false;
- }
-
- function getNewlineCount(content){
- var newlineCount = 0;
- for(var i=0; i
-* @copyright 2007-2015 PrestaShop SA
-* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-function getCommentForm()
-{
- if (document.forms)
- return (document.forms['comment_form']);
- else
- return (document.comment_form);
-}
-
-function getCommentDeleteForm()
-{
- if (document.forms)
- return (document.forms['delete_comment_form']);
- else
- return (document.delete_comment_form);
-}
-
-function acceptComment(id)
-{
- var form = getCommentForm();
- if (id)
- form.elements['id_product_comment'].value = id;
- form.elements['action'].value = 'accept';
- form.submit();
-}
-
-
-function deleteComment(id)
-{
- var form = getCommentForm();
- if (id)
- form.elements['id_product_comment'].value = id;
- form.elements['action'].value = 'delete';
- form.submit();
-}
-
-function delComment(id, confirmation)
-{
- var answer = confirm(confirmation);
- if (answer)
- {
- var form = getCommentDeleteForm();
- if (id)
- form.elements['delete_id_product_comment'].value = id;
- form.elements['delete_action'].value = 'delete';
- form.submit();
- }
-}
-
-function getCriterionForm()
-{
- if (document.forms)
- return (document.forms['criterion_form']);
- else
- return (document.criterion_form);
-}
-
-function editCriterion(id)
-{
- var form = getCriterionForm();
- form.elements['id_product_comment_criterion'].value = id;
- form.elements['criterion_name'].value = document.getElementById('criterion_name_' + id).value;
- form.elements['criterion_action'].value = 'edit';
- form.submit();
-}
-
-function deleteCriterion(id)
-{
- var form = getCriterionForm();
- form.elements['id_product_comment_criterion'].value = id;
- form.elements['criterion_action'].value = 'delete';
- form.submit();
-}
-
-$( document ).ready(function() {
- $('select#id_product_comment_criterion_type').change(function() {
- // PS 1.6
- $('#categoryBox').closest('div.form-group').hide();
- $('#ids_product').closest('div.form-group').hide();
- // PS 1.5
- $('#categories-treeview').closest('div.margin-form').hide();
- $('#categories-treeview').closest('div.margin-form').prev().hide();
- $('#ids_product').closest('div.margin-form').hide();
- $('#ids_product').closest('div.margin-form').prev().hide();
-
- if (this.value == 2)
- {
- $('#categoryBox').closest('div.form-group').show();
- // PS 1.5
- $('#categories-treeview').closest('div.margin-form').show();
- $('#categories-treeview').closest('div.margin-form').prev().show();
- }
- else if (this.value == 3)
- {
- $('#ids_product').closest('div.form-group').show();
- // PS 1.5
- $('#ids_product').closest('div.margin-form').show();
- $('#ids_product').closest('div.margin-form').prev().show();
- }
- });
-
- $('select#id_product_comment_criterion_type').trigger( "change" );
-});
\ No newline at end of file
diff --git a/modules/productcomments/js/productCriterion.js b/modules/productcomments/js/productCriterion.js
deleted file mode 100644
index 52cc09d9f..000000000
--- a/modules/productcomments/js/productCriterion.js
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-* 2007-2015 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
-* @copyright 2007-2015 PrestaShop SA
-* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-function getProductCriterionForm()
-{
- if (document.forms)
- return (document.forms['product_criterion_form']);
- else
- return (document.product_criterion_form);
-}
-
-function getProductCriterion(path, id_product, id_lang)
-{
- $.get(path + 'productcommentscriterion.php', { id_product: id_product, id_lang: id_lang },
- function(data){
- document.getElementById('product_criterions').innerHTML = data;
- });
-}
diff --git a/modules/productcomments/js/productcomments.js b/modules/productcomments/js/productcomments.js
deleted file mode 100644
index bf1712ce9..000000000
--- a/modules/productcomments/js/productcomments.js
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
-* 2007-2015 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
-* @copyright 2007-2015 PrestaShop SA
-* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-$(document).ready(function(){
- $('.raty_star').raty({
- starType : 'i',
- starOff: 'icon-star-o',
- starOn: 'icon-star',
- halfShow: false,
- score: 3,
- hints: null,
- readOnly: function() {
- return $(this).hasClass('readonly');
- }
- });
- $('#new_comment_tab_btn').on('click', function(e){
- e.preventDefault();
- $('.new_comment_form_outer').show();
- $('.open-comment-block').hide();
- });
-
- $('#cancelreview').on('click', function(e){
- e.preventDefault();
- $('.new_comment_form_outer').hide();
- $('.open-comment-block').show();
- });
-
- /*if (!!$.prototype.fancybox)
- $('.open-comment-form').fancybox({
- 'autoSize' : false,
- 'width' : 600,
- 'height' : 'auto',
- 'hideOnContentClick': false
- });*/
-
- $(document).on('click', '#id_new_comment_form .closefb', function(e){
- e.preventDefault();
- $.fancybox.close();
- });
-
- $(document).on('click', 'a[href=#idTab5]', function(e){
- $('*[id^="idTab"]').addClass('block_hidden_only_for_screen');
- $('div#idTab5').removeClass('block_hidden_only_for_screen');
-
- $('ul#more_info_tabs a[href^="#idTab"]').removeClass('selected');
- $('a[href="#idTab5"]').addClass('selected');
- });
-
- $(document).on('click', 'button.usefulness_btn', function(e){
- var id_product_comment = $(this).data('id-product-comment');
- var is_usefull = $(this).data('is-usefull');
- var parent = $(this).parent();
-
- $.ajax({
- url: productcomments_controller_url + '?rand=' + new Date().getTime(),
- data: {
- id_product_comment: id_product_comment,
- action: 'comment_is_usefull',
- value: is_usefull
- },
- type: 'POST',
- headers: { "cache-control": "no-cache" },
- success: function(result){
- parent.fadeOut('slow', function() {
- parent.remove();
- });
- }
- });
- });
-
- $(document).on('click', 'span.report_btn', function(e){
- if (confirm(confirm_report_message))
- {
- var idProductComment = $(this).data('id-product-comment');
- var parent = $(this).parent();
-
- $.ajax({
- url: productcomments_controller_url + '?rand=' + new Date().getTime(),
- data: {
- id_product_comment: idProductComment,
- action: 'report_abuse'
- },
- type: 'POST',
- headers: { "cache-control": "no-cache" },
- success: function(result){
- parent.fadeOut('slow', function() {
- parent.remove();
- });
- }
- });
- }
- });
-
- $(document).on('click', '#submitNewMessage', function(e){
- // Kill default behaviour
- e.preventDefault();
-
- // Form element
-
- url_options = '?';
- if (!productcomments_url_rewrite)
- url_options = '&';
-
- $.ajax({
- url: productcomments_controller_url + url_options + 'action=add_comment&secure_key=' + secure_key + '&rand=' + new Date().getTime(),
- data: $('#id_new_comment_form').serialize(),
- type: 'POST',
- headers: { "cache-control": "no-cache" },
- dataType: "json",
- success: function(data){
- if (data.result)
- {
- $.fancybox.close();
- var buttons = {};
- buttons[productcomment_ok] = "productcommentRefreshPage";
- fancyChooseBox(moderation_active ? productcomment_added_moderation : productcomment_added, productcomment_title, buttons);
- }
- else
- {
- $('#new_comment_form_error ul').html('');
- $.each(data.errors, function(index, value) {
- $('#new_comment_form_error ul').append('
'+value+'
');
- });
- $('#new_comment_form_error').slideDown('slow');
- }
- }
- });
- });
-});
-
-function productcommentRefreshPage()
-{
- window.location.reload();
-}
\ No newline at end of file
diff --git a/modules/productcomments/js/products-comparison.js b/modules/productcomments/js/products-comparison.js
deleted file mode 100644
index 3af911d0b..000000000
--- a/modules/productcomments/js/products-comparison.js
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
-* 2007-2017 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
-* @copyright 2007-2017 PrestaShop SA
-* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-$(document).ready(function()
-{
- $('input.star').rating();
- $('.auto-submit-star').rating();
- $('a.cluetip').cluetip({
- local:true,
- cursor: 'pointer',
- cluetipClass: 'comparison_comments',
- dropShadow: false,
- dropShadowSteps: 0,
- showTitle: false,
- tracking: true,
- sticky: false,
- mouseOutClose: true,
- width: 450,
- fx: {
- open: 'fadeIn',
- openSpeed: 'fast'
- }
- }).css('opacity', 0.8);
-
- $('.comparison_infos a').each(function(){
- var id_product_comment = parseInt($(this).data('id-product-comment'));
- if (id_product_comment)
- {
- $(this).click(function(e){
- e.preventDefault();
- });
- var htmlContent = $('#comments_' + id_product_comment).html();
- $(this).popover({
- placement : 'bottom', //placement of the popover. also can use top, bottom, left or right
- title : false, //this is the top title bar of the popover. add some basic css
- html: 'true', //needed to show html of course
- content : htmlContent //this is the content of the html box. add the image here or anything you want really.
- });
- }
- });
-});
-
-function closeCommentForm()
-{
- $('#sendComment').slideUp('fast');
- $('input#addCommentButton').fadeIn('slow');
-}
diff --git a/modules/productcomments/logo.gif b/modules/productcomments/logo.gif
deleted file mode 100644
index 39433cf78..000000000
Binary files a/modules/productcomments/logo.gif and /dev/null differ
diff --git a/modules/productcomments/logo.png b/modules/productcomments/logo.png
deleted file mode 100644
index 61ae64b2d..000000000
Binary files a/modules/productcomments/logo.png and /dev/null differ
diff --git a/modules/productcomments/productcomments-ajax.php b/modules/productcomments/productcomments-ajax.php
deleted file mode 100644
index f3ec718f3..000000000
--- a/modules/productcomments/productcomments-ajax.php
+++ /dev/null
@@ -1,138 +0,0 @@
-
-* @copyright 2007-2015 PrestaShop SA
-* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-// The usage of this file is deprecated !!!
-require_once(dirname(__FILE__).'/../../config/config.inc.php');
-require_once(dirname(__FILE__).'/../../init.php');
-require_once(dirname(__FILE__).'/ProductCommentCriterion.php');
-include_once(dirname(__FILE__).'/ProductComment.php');
-include_once(dirname(__FILE__).'/productcomments.php');
-
-$productCom = new productcomments();
-
-if (Tools::getValue('action') && Tools::getValue('id_product_comment') && Context::getContext()->cookie->id_customer)
-{
- if (Tools::getValue('action') == 'report')
- {
- if (!ProductComment::isAlreadyReport(Tools::getValue('id_product_comment'), Context::getContext()->cookie->id_customer) &&
- ProductComment::reportComment((int)Tools::getValue('id_product_comment'), (int)Context::getContext()->cookie->id_customer))
- die('0');
- }
- else if (Tools::getValue('action') == 'usefulness' && Tools::getValue('value') && Tools::getValue('value'))
- {
- if (!ProductComment::isAlreadyUsefulness(Tools::getValue('id_product_comment'), Context::getContext()->cookie->id_customer) &&
- ProductComment::setCommentUsefulness((int)Tools::getValue('id_product_comment'),
- (bool)Tools::getValue('value'),
- Context::getContext()->cookie->id_customer))
- die('0');
- }
-}
-else if (Tools::getValue('action') && Tools::getValue('secure_key') == $productCom->secure_key)
-{
- $review = json_decode(Tools::getValue('review'));
- $id_product = 0;
- $content = null;
- $title = null;
- $name = null;
- $grades = array();
- foreach ($review as $entry)
- {
- if ($entry->key == 'id_product')
- $id_product = $entry->value;
- else if ($entry->key == 'title')
- $title = $entry->value;
- else if ($entry->key == 'content')
- $content = $entry->value;
- else if ($entry->key == 'customer_name')
- $name = $entry->value;
- else if (strstr($entry->key, 'grade'))
- {
- $id = array(explode('_', $entry->key));
- $grades[] = array('id' => $id['0']['0'], 'grade' => $entry->value);
- }
- }
-
- if ($title == '' || $content == '' || !$id_product || count($grades) == 0)
- die('0');
-
- $allow_guests = (int)Configuration::get('PRODUCT_COMMENTS_ALLOW_GUESTS');
-
- if (Context::getContext()->customer->id || (!Context::getContext()->customer->id && $allow_guests))
- {
- $id_guest = (!$id_customer = (int)Context::getContext()->cookie->id_customer) ? (int)Context::getContext()->cookie->id_guest : false;
- $customerComment = ProductComment::getByCustomer((int)($id_product), Context::getContext()->cookie->id_customer, true, (int)$id_guest);
-
- if (!$customerComment || ($customerComment && (strtotime($customerComment['date_add']) + Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME')) < time()))
- {
- $errors = array();
- $customer_name = false;
- if ($id_guest && (!$customer_name = Context::getContext()->customer->firstname.' '.Context::getContext()->customer->lastname))
- $errors[] = $productCom->l('Please fill your name');
-
- if (!count($errors) && $content)
- {
- $comment = new ProductComment();
- $comment->content = strip_tags($content);
- $comment->id_product = (int)$id_product;
- $comment->id_customer = (int)Context::getContext()->cookie->id_customer;
- $comment->id_guest = (int)$id_guest;
- $comment->customer_name = pSQL($customer_name);
- if (!$comment->id_customer)
- $comment->customer_name = pSQL($name);
- $comment->title = pSQL($title);
- $comment->grade = 0;
- $comment->validate = 0;
-
-
- $tgrade = 0;
- $comment->save();
- foreach ($grades as $grade)
- {
- $tgrade += $grade['grade'];
- $productCommentCriterion = new ProductCommentCriterion((int)Tools::getValue('id_product_comment_criterion_'.$grade['id']));
- if ($productCommentCriterion->id)
- $productCommentCriterion->addGrade($comment->id, $grade['grade']);
- }
-
- if ((count($grades) - 1) >= 0)
- $comment->grade = (int)($tgrade / ((int)count($grades)));
-
- if (!$comment->save())
- $errors[] = $productCom->l('An error occurred while saving your comment.');
- else
- Context::getContext()->smarty->assign('confirmation', $productCom->l('Comment posted.').((int)(Configuration::get('PRODUCT_COMMENTS_MODERATE')) ? ' '.$productCom->l('Awaiting moderator validation.') : ''));
-
- }
- else
- $errors[] = $productCom->l('Comment text is required.');
- }
- else
- $errors[] = sprintf($productCom->l('You should wait %d seconds before posting a new comment.'), Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME'));
- }
-}
-
-die('1');
-
diff --git a/modules/productcomments/productcomments-extra.tpl b/modules/productcomments/productcomments-extra.tpl
deleted file mode 100644
index 11cbb1e8c..000000000
--- a/modules/productcomments/productcomments-extra.tpl
+++ /dev/null
@@ -1,64 +0,0 @@
- {*
-* 2007-2015 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
-* @copyright 2007-2015 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
-*}
-{if (!$content_only && (($nbComments == 0 && $too_early == false && ($is_logged || $allow_guests)) || ($nbComments != 0)))}
-
{l s='No customer reviews for the moment.' mod='productcomments'}
- {/if}
-
-
-{strip}
-{addJsDef productcomments_controller_url=$productcomments_controller_url|@addcslashes:'\''}
-{addJsDef moderation_active=$moderation_active|boolval}
-{addJsDef productcomments_url_rewrite=$productcomments_url_rewriting_activated|boolval}
-{addJsDef secure_key=$secure_key}
-
-{addJsDefL name=confirm_report_message}{l s='Are you sure that you want to report this review?' mod='productcomments' js=1}{/addJsDefL}
-{addJsDefL name=productcomment_added}{l s='Your review has been added!' mod='productcomments' js=1}{/addJsDefL}
-{addJsDefL name=productcomment_added_moderation}{l s='Your review has been added and will be available once approved by a moderator.' mod='productcomments' js=1}{/addJsDefL}
-{addJsDefL name=productcomment_title}{l s='New Review' mod='productcomments' js=1}{/addJsDefL}
-{addJsDefL name=productcomment_ok}{l s='OK' mod='productcomments' js=1}{/addJsDefL}
-{/strip}
-
diff --git a/modules/productcomments/productcomments_reviews.tpl b/modules/productcomments/productcomments_reviews.tpl
deleted file mode 100644
index 2ab650171..000000000
--- a/modules/productcomments/productcomments_reviews.tpl
+++ /dev/null
@@ -1,42 +0,0 @@
-{*
-* 2007-2015 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
-* @copyright 2007-2015 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
-*}
-{if isset($nbComments) && $nbComments > 0}
-
-{/if}
diff --git a/modules/productcomments/productcomments_top.tpl b/modules/productcomments/productcomments_top.tpl
deleted file mode 100644
index e69de29bb..000000000
diff --git a/modules/productcomments/productcommentscriterion.php b/modules/productcomments/productcommentscriterion.php
deleted file mode 100644
index 0747a2aec..000000000
--- a/modules/productcomments/productcommentscriterion.php
+++ /dev/null
@@ -1,49 +0,0 @@
-
-* @copyright 2007-2015 PrestaShop SA
-* @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__).'/ProductCommentCriterion.php');
-
-if (empty($_GET['id_lang']) === false &&
- isset($_GET['id_product']) === true)
-{
- $criterions = ProductCommentCriterion::get($_GET['id_lang']);
- if ((int)($_GET['id_product']))
- $selects = ProductCommentCriterion::getByProduct($_GET['id_product'], $_GET['id_lang']);
- echo '';
-}
\ No newline at end of file
diff --git a/modules/productcomments/products-comparison.tpl b/modules/productcomments/products-comparison.tpl
deleted file mode 100644
index 89f915c4b..000000000
--- a/modules/productcomments/products-comparison.tpl
+++ /dev/null
@@ -1,103 +0,0 @@
-{*
-* 2007-2015 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
-* @copyright 2007-2015 PrestaShop SA
-* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*}
-
-
diff --git a/modules/productcomments/tab.tpl b/modules/productcomments/tab.tpl
deleted file mode 100644
index 26839bb90..000000000
--- a/modules/productcomments/tab.tpl
+++ /dev/null
@@ -1,28 +0,0 @@
-{*
-* 2007-2015 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
-* @copyright 2007-2015 PrestaShop SA
-* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*}
-
-
-
{/if}
- {/foreach}
- {else}
- {$smarty.block.parent}
- {/if}
-
-{/block}
diff --git a/modules/productcomments/views/templates/admin/_configure/helpers/form/index.php b/modules/productcomments/views/templates/admin/_configure/helpers/form/index.php
deleted file mode 100644
index 044cb85ee..000000000
--- a/modules/productcomments/views/templates/admin/_configure/helpers/form/index.php
+++ /dev/null
@@ -1,35 +0,0 @@
-
-* @copyright 2007-2015 PrestaShop SA
-* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
-header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
-
-header("Cache-Control: no-store, no-cache, must-revalidate");
-header("Cache-Control: post-check=0, pre-check=0", false);
-header("Pragma: no-cache");
-
-header("Location: ../");
-exit;
\ No newline at end of file
diff --git a/modules/productcomments/views/templates/admin/list_action_approve.tpl b/modules/productcomments/views/templates/admin/list_action_approve.tpl
deleted file mode 100644
index 6dbdcfb1b..000000000
--- a/modules/productcomments/views/templates/admin/list_action_approve.tpl
+++ /dev/null
@@ -1,27 +0,0 @@
-{*
-* 2007-2015 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
-* @copyright 2007-2015 PrestaShop SA
-* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*}
-
- {$action}
-
\ No newline at end of file
diff --git a/modules/productcomments/views/templates/admin/list_action_noabuse.tpl b/modules/productcomments/views/templates/admin/list_action_noabuse.tpl
deleted file mode 100644
index 3ed8024bf..000000000
--- a/modules/productcomments/views/templates/admin/list_action_noabuse.tpl
+++ /dev/null
@@ -1,27 +0,0 @@
-{*
-* 2007-2015 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
-* @copyright 2007-2015 PrestaShop SA
-* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*}
-
- {$action}
-
\ No newline at end of file
diff --git a/modules/productcomments/views/templates/index.php b/modules/productcomments/views/templates/index.php
deleted file mode 100644
index 044cb85ee..000000000
--- a/modules/productcomments/views/templates/index.php
+++ /dev/null
@@ -1,35 +0,0 @@
-
-* @copyright 2007-2015 PrestaShop SA
-* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
-header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
-
-header("Cache-Control: no-store, no-cache, must-revalidate");
-header("Cache-Control: post-check=0, pre-check=0", false);
-header("Pragma: no-cache");
-
-header("Location: ../");
-exit;
\ No newline at end of file
diff --git a/modules/qlohotelreview/CHANGELOG.txt b/modules/qlohotelreview/CHANGELOG.txt
new file mode 100644
index 000000000..5932aa450
--- /dev/null
+++ b/modules/qlohotelreview/CHANGELOG.txt
@@ -0,0 +1,4 @@
+Changelog
+
+v1.0.0
+- first release
\ No newline at end of file
diff --git a/modules/qlohotelreview/CustomizationPolicy.txt b/modules/qlohotelreview/CustomizationPolicy.txt
new file mode 100644
index 000000000..7a688847f
--- /dev/null
+++ b/modules/qlohotelreview/CustomizationPolicy.txt
@@ -0,0 +1,80 @@
+1. Definitions
+--------------
+"Webkul" means Webkul Software Pvt. Ltd.
+"Customization" means those services by which functionality / features are added to a product that are not included in the base installation of a product, which are aimed to suit the specific needs of the customer.
+"Module" means the custom add-on module to be developed and provided by Webkul to you in accordance with this policy and the Order Form.
+"Order Form" means the order form (electronic or hard copy), accepted by Webkul, through which you ordered the Module to be developed and provided by Webkul and which sets out the details, specifications and parameters of the customized Module to be provided.
+"Software" means the software licensed by Webkul to you pursuant to the terms and conditions of a Webkul Software License Agreement.
+
+
+2. Module Development
+---------------------
+All customization Services and use of the Module are subject to the terms and conditions of Webkul’s Software Licence Agreement, found on Webkul’s website, and are also subject to the terms and conditions set forth in the Order Form, as well as the customization parameters. No other customization services will be provided unless expressly agreed upon by you and Webkul in writing, signed by authorized representatives of you and Webkul.
+
+
+3. Customization Services
+-------------------------
+Customization Services will be provided in accordance with the terms of the Order Form and subject to the conditions set forth on the Order Form including full payment of all fees and adherence to all time limits and scheduling restrictions.
+If expressly stated on the Order Form, the Customization Services and Module shall be subject to acceptance by you in accordance with the acceptance criteria set forth in the Order Form. Where there is no acceptance criteria set forth on the Order Form, acceptance shall be deemed to occur upon the earliest of:
+completion of the acceptance criteria,
+Webkul's completion of the Customization Services and written notification to you of such completion,
+your use of the Module in other than a test environment.
+Notwithstanding the foregoing, if acceptance testing, delivery or completion is delayed by thirty (30) days or more for reasons not related to Webkul’s performance, you must pay the value of any milestone that is contingent on acceptance. Such acceptance does not negate any warranty rights that you may have respecting the Module, as set forth herein. You are solely responsible for preparing your facilities and equipment for installation of the Module, where applicable.
+Webkul will make reasonable efforts to accommodate your time and deadline requirements with respect to the performance of Customization Services; however, meeting such requirements is subject to availability of resources, both human and equipment at the time of your request and is dependent on your availability to provide input and to perform necessary actions. Webkul shall not be liable in any way for any delay or damage arising from Webkul’s failure to meet such of your requirements or any deadlines.
+Any changes to the Customization Services or Module requirements after execution of the Order Form will be subject to a cost and delivery re-assessment, and a written change order or re-quote that has been mutually agreed upon by you and Webkul in writing. Webkul reserves the right to make changes in the design of its Software without the obligation to make equivalent changes to the Module.
+If, pursuant to your request, Webkul reviews drawings and documents prepared by others in connection with the Customization Services, including your personnel and other consultants, contractors, and suppliers, Webkul’s review of such drawings and documents shall be only to confirm general compliance with the intent of the design and information given, and shall not constitute acceptance by Webkul of any responsibility for correctness of specifications or details of such drawings and documentation. Webkul shall be entitled to rely on all information provided, and decisions and approvals made, by you in connection with Webkul’s work hereunder. You agree that Webkul and its personnel shall not be subject to any liability or costs relating to the Customization Services to the extent such liability and costs are attributable to any information provided by you that is not complete, accurate or current in all material respects.
+The Module, and all parts thereof, shall at all times be treated as Software licensed to you under the terms and conditions of the Licence Agreement.
+
+
+4. Term and Termination
+-----------------------
+The term of the Development Services, if any, shall be as set out on the Order Form.
+Customization Services may be terminated by Webkul immediately upon notice for cause if:
+you materially breach any agreement entered into between you and Webkul, including Webkul’s Licence Agreement and/or any User / software license agreement relating to Webkul’s products (or you consistently fail to properly perform and observe your obligations under such agreements or any applicable Webkul Software policy), and you fail to rectify the situation within ten (10) calendar days of notice from Webkul; or
+you become insolvent, or a receiver or receiver-manager is appointed for any part of your property, or you make an assignment, proposal or arrangement for the benefit of your creditors or you file an assignment in bankruptcy, or any proceedings under any bankruptcy or insolvency laws are commenced against you.
+Webkul shall have the right to terminate Customization Services immediately upon notice to you, without penalty or refund, if any agreement relating to the Software is terminated for any reason.
+Each party shall have the right to terminate the Development Services for convenience upon ninety (90) days’ notice to the other party.
+Termination of the Customization Services or any agreement shall not affect your payment obligation for any Customization Services performed by Webkul prior to the date of termination, regardless of whether you have had, as at the date of termination, any use of the Module or part thereof. In the event that the Customization Services are terminated prior to the delivery of the Module to you, Webkul shall not be obligated to deliver any work-in-progress or any portion of the Module to you, unless otherwise expressly agreed by the parties in writing.
+
+
+5. Fees
+-------
+You shall pay fees for the Customization Services and Module license in accordance with the fee schedule set forth in the Order Form. Webkul shall submit invoices to you for all fees and payments due, including applicable expenses, on a monthly basis in arrears. You shall pay to Webkul the full amount of each invoice received from Webkul within seven (7) days of receipt of the invoice. All invoices shall detail the nature of the Customization Services performed, the fees payable, and the basis on which the calculation of the fees has been made.
+You are responsible for, and shall pay all taxes relating to the Customization Services and the Module. Unless otherwise indicated, all amounts payable by you under an Order Form are exclusive of any tax, duty, levy, or similar government charge that may be assessed by any jurisdiction, whether based on gross revenue, the delivery, possession or use of the Module, other Software or Customization Services, or otherwise.
+If you fail to pay any amount due within thirty (30) days of such payment becoming due and payable, in addition to any other rights and remedies available to Webkul, Webkul shall be entitled to charge interest on all outstanding amounts at the lesser of 18% per annum or the maximum rate permitted by law, such interest commencing as of the due date for such payment. You shall also be responsible for paying for all reasonable fees and costs incurred by Webkul, including legal fees, in collecting any overdue amounts or enforcing any provision of any agreement entered into between you and Webkul.
+Pricing is subject to Webkul’s understanding of the project requirements, the terms of this policy and the Order Form. Webkul reserves the right to invoice you for additional Customization Services requested by you, or that are required based on incomplete details or specifications provided by you, that are not specified in the Order Form but are provided by Webkul to you, provided that Webkul provides you with notice that such additional Customization Services are not included in the Order Form and are subject to Webkul’s then current time and materials fee schedule for such Customization Services. Invoices for such additional Customization Services shall be subject to payment in accordance with this Section.
+
+
+6. Intellectual Property Rights
+-------------------------------
+Webkul shall own all intellectual property rights (whether or not patentable or registrable under copyright, trade-mark or similar legislation or subject to analogous protection) in and to the Module, and all work conceived, created, invented, produced, designed or reduced to practice by Webkul and its personnel as a result of or with respect to any and all Customization Services provided to you. Your rights and obligations relating to the use of the Module shall be governed by the terms of the applicable Webkul Software License Agreement regardless of whether you may have contributed to any Module in any way. The foregoing shall not be deemed to transfer ownership to Webkul of any pre-existing intellectual property rights that you may have in the materials that you provide to Webkul in order to permit Webkul to perform the Customization Services; however, to the extent that you have provided such materials to Webkul, you hereby grant Webkul a non-exclusive, non-transferable, royalty-free license to use all such materials for the purposes of performing the Customization Services and providing you with the Module.
+
+
+7. Limited Warranty and Limitation of Liability
+-----------------------------------------------
+Limited Warranty: Webkul warrants that all services provided by Webkul shall be provided in a competent, professional manner by persons who are fully trained and qualified to perform the Customization Services. Webkul does not represent or warrant that the Customization Services or Module provided hereunder will be capable of achieving a particular result for your business, or that the operation of the Module will be error free or uninterrupted, or that all errors in the Module can be found or corrected, although Webkul shall use commercially reasonable efforts to do so. Without limiting the foregoing, this warranty is valid only for the six (6) months following the acceptance date as set forth in Section 3(b). The above warranty shall not apply to defects or non-conformities resulting from:
+improper or inadequate maintenance or installation of the Module
+use of the Module in combination with software, interfaces, or other materials that are not supplied or specifically authorized by Webkul,
+unauthorized or improper use or modification of the Module, including use that is not contemplated in the Order Form or instructions provided by Webkul,
+abuse, negligence, accident, or other damage from external sources, or
+improper preparation of your facilities or equipment for installation and use or the Module.
+Limitation of Liability:
+save as otherwise provided in a written agreement between you and Webkul, and to the maximum extent permitted by applicable law, Webkul makes no warranty or condition, express or implied, statutory or otherwise, with respect to the module or the Customization services, including, without limitation, the implied warranties or conditions of merchantability and fitness for a particular purpose.
+in no event shall Webkul be liable to you or any other person for any indirect, special, punitive, exemplary, consequential or incidental damages (including without limitation, damages for loss of revenues or profits, business interruption, loss of business information, and the like) arising out of the use, inability to use or the performance or non-performance of, the module or the provision of the Customization services, even if Webkul has been advised of the possibility of such damage or claim, or it is foreseeable.
+in no event shall Webkul’s maximum aggregate liability to you for direct damages exceed the total amount paid by you for the Customization services performed by Webkul within the six (6) months preceding the date on which the claim arose.
+
+
+8. General Terms and Conditions
+-------------------------------
+As Webkul is primarily a plugin and app development company and its main focus is on constant plugin development fulfilling various latest requirements and keeping up with the latest trends, Webkul has all the right to release the same customized plugin as a new plugin in future to be available to all its customers. The same may include few or every feature of the customisation. Webkul reserve all the rights to do the same as the customisation done for the client is Intellectual property of Webkul.
+The customization undertaken by Webkul would be identical to the discussed requirements, and would not include any sort of additional changes or alterations. Any additional changes or alterations would be considered as a separate project and would be charged separately.
+Webkul would be providing customization support for only one month from the delivery of the project. For any further support extended to you, the same shall be charged separately which includes specifically any further help or bug /error fix.
+The cost of customization doesn’t include the cost of extension installation or exchange of the extension, if it has not been specifically quoted within the project cost.
+During the project customization, you ought not to edit or change any of the files and it is also advisable to have a backup every-time a change is made. If you, on your own, are making certain changes, it is advisable to back up the files, folder and database. Before doing anything on your own, you need to inform Webkul if Webkul is working on the project or your support period is subsisting.
+The customization charge will include a single template. Any time during or after the customization if you change the template, you shall be wholly and solely liable for any loss or damage emanating from the same. Webkul will not be responsible for any loss or damage done due to the same.
+All the communication will take place through Webkul’s help desk system only. If the need arises, the issues can be discussed via Skype once in week or month. Webkul does not allow screen sharing and remote desktop.
+Customization cost will not include any free consulting beyond the scope of the project.
+If while making any changes by yourself or by your team, something gets damaged, then Webkul will not be responsible for it. This includes any issues faced by you for your own fault even during the support period of the module or project.
+Webkul will not be responsible for any damages during the customization. It is advised that you must have a proper backup management system deployed.
+The terms and conditions of this Policy shall be governed by Indian Laws, and the courts in Delhi alone shall only have exclusive jurisdiction to resolve/ adjudicate upon any disputes.
+If any dispute arises between webkul and you/Licensee at any time, in connection with the validity, interpretation, implementation or alleged breach of any provision of this Agreement, the same shall be referred to a sole Arbitrator who shall be an independent and neutral third party appointed exclusively by Webkul. You shall not object to the appointment of the Arbitrator so appointed by Webkul. The place of arbitration shall be Delhi, India. The Arbitration & Conciliation Act, 1996 as amended by The Arbitration & Conciliation (Amendment) Act, 2015, shall govern the arbitration proceedings. The arbitration proceedings shall be held in the English language.
diff --git a/modules/qlohotelreview/LICENSE.txt b/modules/qlohotelreview/LICENSE.txt
new file mode 100644
index 000000000..7845cd4a5
--- /dev/null
+++ b/modules/qlohotelreview/LICENSE.txt
@@ -0,0 +1,223 @@
+SOFTWARE LICENCE AGREEMENT
+===============================
+
+This AGREEMENT is made effective on the date of the purchase of the software between Webkul Software Pvt. Ltd.,Company incorporated under the Companies Act, 1956 (hereinafter referred to as “Licensor"), and the purchaser of the software/ product (hereinafter referred to as "Licensee").
+
+Preamble
+==================
+Licensor is a web and mobile product based organization engaged in the business of developing and marketing software for enterprise level e-commerce businesses. It is an ISO and NSR (NASSCOM) certified organization having a team of more than 150 creative engineers which come from different backgrounds. It has developed more than 700 web extensions and apps in the past few years for open source platforms which are used and trusted globally. Licensee now wishes to obtain license, and Licensor wishes to grant a license, to allow use of the software so purchased in developing the e-commerce business website/ mobile app of the Licensee, subject to the terms and conditions set forth herein.
+
+
+THEREFORE, with the intent to be legally bound, the parties hereby agree as follows:
+
+
+Agreement
+================
+
+1.Definitions :
+------------------
+As used in this Agreement, the following capitalized terms shall have the definitions set forth below:
+
+
+"Derivative Works" are works developed by Licensee, its officers, agents, contractors or employees, which are based upon, in whole or in part, the Source Code and/or the Documentation and may also be based upon and/or incorporate one or more other preexisting works of the Licensor. Derivative Works may be any improvement, revision, modification, translation (including compilation or recapitulation by computer), abridgment, condensation, expansion, or any other form in which such a preexisting work may be recast, transformed, or adapted. For purposes hereof, a Derivative Work shall also include any compilation that incorporates such a preexisting work.
+
+
+"Documentation" is written, printed or otherwise recorded or stored (digital or paper) material relating to the Software and/or Source Code, including technical specifications and instructions for its use including Software/ Source Code annotations and other descriptions of the principles of its operation and instructions for its use.
+
+
+"Improvements" shall mean, with respect to the Software, all modifications and changes made, developed, acquired or conceived after the date hereof and during the entire term of this Agreement.
+
+
+"Source Code" is the computer programming source code form of the Software in the form maintained by the Licensor, and includes all non-third-party executables, libraries, components, and Documentation created or used in the creation, development, maintenance, and support of the Software as well as all updates, error corrections and revisions thereto provided by Licensor, in whole or in part.
+
+
+2. Software License.
+-------------------------
+
+(a)Grant of License. For the consideration set forth below, Licensor hereby grants to Licensee, and Licensee hereby accepts the worldwide, non-exclusive, perpetual, royalty-free rights and licenses set forth below:
+
+
+(i)The right and license to use and incorporate the software, in whole or in part, to develop its website/ mobile app (including the integration of all or part of the Licensor’s software into Licensee's own software) on one domain ( Except Joomla modules , listed on store are entitled to be used on unlimited domain as per the standard guidelines ) only, solely for the own personal or business use of the Licensee. However, the License does not authorize the Licensee to compile, copy or distribute the said Software or its Derivative Works.
+
+
+(ii)The right and license does not authorize the Licensee to make any backup or archival copies of the Software and / or the Source Code and Documentation.
+
+(iii)The right and license does not authorize the Licensee to migrate the domain license to another domain.
+
+
+(b)Scope; Rights and Responsibilities.
+
+
+(i)Licensor shall enable the Licensee to download one complete copy of the Software.
+
+
+(ii)The Software is intended for the sole use of the Licensee in development of its own website/ mobile app.
+
+
+(iii)Licensee does not have the right to hand over, sell, distribute, sub-license, rent, lease or lend any portion of the Software or Documentation, whether modified or unmodified, to anyone. Licensee should not place the Software on a server so that it becomes accessible via a public network such as the Internet for distribution purposes. In case the Licensee is using any source code management system like github, it can use the code there only when it has paid subscription from such management system.
+
+
+(iv)Licensee is not authorized to appoint, or work with, third parties to perform any development services using the Source Code, the source code to Derivative Works and/or the Documentation on behalf of, or working with, the Licensee. Release of Source Code, Derivative Work source code and/or Documentation to any third party shall be considered as violation of the Agreement, inter-alia entailing forthwith termination and legal action.
+
+
+
+(c)Ownership.
+
+
+(i)Software and Source Code. All right, title, copyright, and interest in the Software, Source Code, Software Modifications and Error corrections will be and remain the property of Licensor.
+
+
+(ii)Derivative Works. As creation of Derivative Works by the Licensee is prohibited, thus, all right, title, copyright, and interest in any and/or all Derivative Works and Improvements created by, or on behalf of, Licensee will also be deemed to the property of Licensor. Licensor shall be entitled to protect copyright / intellectual property in all such Derivative Works and Improvements also in any country as it may deem fit including without limitation seeking copyright and/or patent protection.
+
+
+3.Consideration.
+--------------------
+
+(a)Licensee shall pay to Licensor the amount as mentioned on the website from where the order is placed, as one-time, upfront fees in consideration for the licenses and rights granted hereunder (hereinafter referred to as the "License Fee"). The License Fee to be paid by Licensee shall be paid upfront at the time of placing the order, and no credit will be allowed under any circumstances.
+
+
+(b)Once paid, the License Fees shall be non-refundable. The Licensee has fully satisfied itself about the Software and has seen the demonstration, and only thereafter has placed the order. Thus, the License Fees or any part thereof is non-refundable. No claim for refund of the Licence Fees shall be entertained under any circumstances.
+
+
+
+4.Representations and Warranties.
+-------------------------------------
+
+(a)Mutual. Each of the parties represents and warrants to the other as follows.
+
+
+(i)such party is a legal entity duly organized, validly existing and in good standing;
+
+
+(ii)such party has the power and authority to conduct its business as presently conducted and to enter into, execute, deliver and perform this Agreement.
+
+
+(iii)This Agreement has been duly and validly accepted by such party and constitutes the legal, valid and binding obligations of such party respectively, enforceable against such party in accordance with their respective terms;
+
+
+(iv)the acceptance, execution, delivery and performance of this Agreement does not and will not violate such party's charter or by-laws; nor require any consent, authorization, approval, exemption or other action by any third party or governmental entity.
+
+
+(b)Licensor warrants that, at the time of purchase of the Software:
+
+
+the Software will function materially as set forth in the website or published functionality provided by Licensor to customers and potential customers describing the Software; and
+
+
+Software add-ons, if purchased by the Licensee from the Licensor, will not materially diminish the features or functions of or the specifications of the Software as they existed as of the execution of this Agreement.
+
+
+
+(c)Title. Licensor represents and warrants that it is the exclusive owner of all copyright/ intellectual property in the Software (including the Source Code) and has good and marketable title to the Software (including the Source Code) free and clear of all liens, claims and encumbrances of any nature whatsoever (collectively, "Liens"). Licensor's grant of license and rights to Licensee hereunder does not, and will not infringe any third party's property, intellectual property or personal rights.
+
+
+
+5.Term.
+-------------
+
+(a)Subject to Licensee's payment obligations, this Agreement shall commence as on the date of making payment of the Software by the Licensee to the Licensor, and shall continue until terminated by either party.
+
+
+(b)The Licensor retains the right to terminate the license at any time, if the Licensee is not abiding by any of the terms of the Agreement. The Licensee may terminate the Agreement at any time at its own discretion by uninstalling the Software and /or by destroying the said Software (or any copies thereof). However, the Licensee shall not be entitled to seek any refund of the amount paid by it to the Licensor, under any circumstances.
+
+
+(c)Survival. In the event this Agreement is terminated for any reason, the provisions set forth in Sections 2(a), 2(b), and 2(c) shall survive.
+
+
+
+
+6. Indemnification
+----------------------
+
+The Licensee release the Licensor from, and agree to indemnify, defend and hold harmless the Licensor (and its officers, directors, employees, agents and Affiliates) against, any claim, loss, damage, settlement, cost, taxes, expense or other liability (including, without limitation, attorneys' fees) (each, a "Claim") arising from or related to: (a) any actual or alleged breach of any obligations in this Agreement; (b) any refund, adjustment, or return of Software,(c) any claim for actual or alleged infringement of any Intellectual Property Rights made by any third party or damages related thereto; or (d) Taxes.
+
+
+7. Limitation of Liability
+------------------------------
+
+The Licensor will not be liable for any direct, indirect, incidental, special, consequential or exemplary damages, including but not limited to, damages for loss of profits, goodwill, use, data or other intangible losses arising out of or in connection with the Software, whether in contract, warranty, tort etc. (including negligence, software liability, any type of civil responsibility or other theory or otherwise) to the Licensee or any other person for cost of software, cover, recovery or recoupment of any investment made by the Licensee or its affiliates in connection with this Agreement, or for any other loss of profit, revenue, business, or data or punitive or consequential damages arising out of or relating to this Agreement. Further, the aggregate liability of the Licensor, arising out of or in connection with this Agreement or the transactions contemplated hereby will not exceed at any time, or under any circumstances, the total amounts received by the Licensor from the Licensee in connection with the particular software giving rise to the claim.
+
+
+8. Force Majeure
+---------------------
+
+The Licensor will not be liable for any delay or failure to perform any of its obligations under this Agreement by reasons, events or other matters beyond its reasonable control.
+
+
+9. Relationship of Parties
+------------------------------
+
+The Licensor and Licensee are independent legal entities, and nothing in this Agreement will be construed to create a partnership, joint venture, association of persons, agency, franchise, sales representative, or employment relationship between the parties. The Licensee will have no authority to make or accept any offers or representations on behalf of the Licensor. The relationship between the parties is that of Licensor and Licensee only, and the rights, duties, liabilities of each party shall be governed by this Agreement.
+
+
+10. Modification
+------------------------
+
+The Licensor may amend any of the terms and conditions contained in this Agreement at any time and solely at its discretion. Any changes will be effective upon the posting of such changes on the Portal/ website, and the Licensee is responsible for reviewing these changes and informing itself of all applicable changes or notices. The continued use of a software by the Licensee after posting of any changes by the Licensor, will constitute the acceptance of such changes or modifications by the Licensee.
+
+
+
+11.Miscellaneous.
+-----------------------
+
+(a)General Provisions. This Agreement: (i) may be amended only by a writing signed by each of the parties; (ii) may be executed in several counterparts, each of which shall be deemed an original but all of which shall constitute one and the same instrument; (iii) contains the entire agreement of the parties with respect to the transactions contemplated hereby and supersedes all prior written and oral agreements, and all contemporaneous oral agreements, relating to such transactions; (iv) shall be governed by, and construed and enforced in accordance with, the laws of India; and (v) shall be binding upon, and inure to the benefit of, the parties and their respective successors and permitted assigns. Each of the parties hereby irrevocably submits to the jurisdiction of the Courts at Delhi, India, for the purposes of any action or proceeding arising out of or relating to this Agreement or the subject matter hereof and brought by any other party.
+
+
+(b)Assignment. Licensee cannot assign, pledge or otherwise transfer, whether by operation of law or otherwise, this Agreement, or any of its obligations hereunder, without the prior written consent of Licensor, which consent shall not be unreasonably withheld.
+
+
+(c)Notices. Unless otherwise specifically provided herein, all notices, consents, requests, demands and other communications required or permitted hereunder:
+
+
+(i)shall be in writing;
+
+
+(ii)shall be sent by messenger, certified or registered mail/email, or reliable express delivery service, to the appropriate address(es) set forth below; and
+
+
+(iii)shall be deemed to have been given on the date of receipt by the addressee, as evidenced by a receipt executed by the addressee (or a responsible person in his or her office), the records of the Party delivering such communication or a notice to the effect that such addressee refused to claim or accept such communication, if sent by messenger, mail or express delivery service.
+
+
+All such communications shall be sent to the following addresses or numbers, or to such other addresses or numbers as any party may inform the others by giving five days' prior notice:
+
+
+If to Webkul Software Pvt. Ltd.:
+
+
+
+Webkul Software Pvt. Ltd.
+
+A-67, Sector 63, NOIDA – 201301,
+
+Uttar Pradesh, India
+
+
+If to Licensee:
+
+At the address mentioned by the Licensee
+
+(at the time of placing order of generating Invoice)
+
+
+(d)Severability. It is the intent of the parties that the provisions of this Agreement be enforced to the fullest extent permissible under the laws and public policies of India in which enforcement hereof is sought. In furtherance of the foregoing, each provision hereof shall be severable from each other provision, and any provision hereof which is/ becomes unenforceable shall be subject to the following: (i) if such provision is contrary to or conflicts with any requirement of any statute, rule or regulation in effect, then such requirement shall be incorporated into, or substituted for, such unenforceable provision to the minimum extent necessary to make such provision enforceable; (ii) the court, agency or arbitrator considering the matter is hereby authorized to (or, if such court, agency or arbitrator is unwilling or fails to do so, then the parties shall) amend such provision to the minimum extent necessary to make such provision enforceable, and the parties hereby consent to the entry of an order so amending such provision; and (iii) if any such provision cannot be or is not reformed and made enforceable pursuant to clause (i) or (ii) above, then such provision shall be ineffective to the minimum extent necessary to make the remainder of this Agreement enforceable. Any application of the foregoing provisions to any provision hereof shall not effect the validity or enforceability of any other provision hereof.
+
+
+(e)By purchasing the Software, the Licensee acknowledge that it has read this Agreement, and that it agrees to the content of the Agreement, its terms and agree to use the Software in compliance with this Agreement.
+
+
+(f)The Licensor holds the sole copyright of the Software. The Software or any portion thereof is a copyrightable matter and is liable to be protected by the applicable laws. Copyright infringement in any manner can lead to prosecution according to the current law. The Licensor reserves the right to revoke the license of any user who is not holding any license or is holding an invalid license.
+
+
+(g)This Agreement gives the right to use only one copy of the Software on one domain solely for the own personal or business use of the Licensee, subject to all the terms and conditions of this Agreement. A separate License has to be purchased for each new Software installation. Any distribution of the Software without the written consent of the Licensor (including non-commercial distribution) is regarded as violation of this Agreement, and will entail immediate termination of the Agreement and may invite liability, both civil and criminal, as per applicable laws.
+
+
+(h)The Licensor reserves the rights to publish a selected list of users/ Licensees of its Software, and no permission of any Licensee is needed in this regard. The Licensee agrees that the Licensor may, in its sole discretion, disclose or make available any information provided or submitted by the Licensee or related to it under this Agreement to any judicial, quasi-judicial, governmental, regulatory or any other authority as may be required by the Licensor to co-operate and / or comply with any of their orders, instructions or directions or to fulfill any requirements under applicable Laws.
+
+
+(i)If the Licensee continues to use the Software even after the sending of the notice by the Licensor for termination, the Licensee agree to accept an injunction to restrain itself from its further use, and to pay all costs (including but not limited to reasonable attorney fees) to enforce injunction or to revoke the License, and any damages suffered by the Licensor because of the misuse of the Software by the Licensee.
+
+
+12. Arbitration
+-----------------------
+
+If any dispute arises between the Licensor and the Licensee at any time, in connection with the validity, interpretation, implementation or alleged breach of any provision of this Agreement, the same shall be referred to a sole Arbitrator who shall be an independent and neutral third party appointed exclusively by the Licensor. The Licensee shall not object to the appointment of the Arbitrator so appointed by the Licensor. The place of arbitration shall be Delhi, India. The Arbitration & Conciliation Act, 1996 as amended by The Arbitration & Conciliation (Amendment) Act, 2015, shall govern the arbitration proceedings. The arbitration proceedings shall be held in the English language.
\ No newline at end of file
diff --git a/modules/qlohotelreview/README.md b/modules/qlohotelreview/README.md
new file mode 100644
index 000000000..56f6dd178
--- /dev/null
+++ b/modules/qlohotelreview/README.md
@@ -0,0 +1 @@
+##QloApps Hotel Reviews v1.0.0 Compatible with QloApps v1.6.x
diff --git a/modules/qlohotelreview/classes/QhrCategory.php b/modules/qlohotelreview/classes/QhrCategory.php
new file mode 100644
index 000000000..a4c6781d1
--- /dev/null
+++ b/modules/qlohotelreview/classes/QhrCategory.php
@@ -0,0 +1,57 @@
+ 'qhr_category',
+ 'primary' => 'id_category',
+ 'multilang' => true,
+ 'fields' => array(
+ 'name' => array(
+ 'type' => self::TYPE_STRING,
+ 'validate' => 'isGenericName',
+ 'lang' => true,
+ 'required' => true,
+ 'size' => 128
+ ),
+ 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
+ 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
+ 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
+ ),
+ );
+
+ public static function getAll($active = true)
+ {
+ $id_lang = Context::getContext()->language->id;
+ return Db::getInstance()->executeS(
+ 'SELECT * FROM `'._DB_PREFIX_.'qhr_category` qc
+ LEFT JOIN `'._DB_PREFIX_.'qhr_category_lang` qcl
+ ON qcl.`id_category` = qc.`id_category` AND qcl.`id_lang` = '.(int) $id_lang.'
+ '.($active ? 'WHERE qc.`active` = 1' : '')
+ );
+ }
+}
diff --git a/modules/qlohotelreview/classes/QhrHotelReview.php b/modules/qlohotelreview/classes/QhrHotelReview.php
new file mode 100644
index 000000000..0be93805b
--- /dev/null
+++ b/modules/qlohotelreview/classes/QhrHotelReview.php
@@ -0,0 +1,461 @@
+ 'qhr_hotel_review',
+ 'primary' => 'id_hotel_review',
+ 'multilang' => false,
+ 'fields' => array(
+ 'id_hotel' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
+ 'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true),
+ 'rating' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'),
+ 'subject' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'size' => 255, 'required' => true),
+ 'description' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'size' => 65535, 'required' => true),
+ 'approved' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
+ 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
+ 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
+ ),
+ );
+
+ public function __construct($id = null, $id_lang = null)
+ {
+ parent::__construct($id, $id_lang);
+ if ($id) {
+ $this->category_ratings = self::getCategoryRatings($id);
+ $this->full_img_dir = _PS_MODULE_DIR_.'qlohotelreview/views/img/review/'.$this->id.'/';
+ $this->img_dir = _MODULE_DIR_.'qlohotelreview/views/img/review/'.$this->id.'/';
+ }
+ }
+
+ public function delete()
+ {
+ // tables to remove data from
+ $tables = array(
+ 'qhr_review_category_rating',
+ 'qhr_review_usefulness',
+ 'qhr_review_report',
+ 'qhr_review_reply',
+ );
+
+ foreach ($tables as $table) {
+ Db::getInstance()->delete($table, 'id_hotel_review = '.(int) $this->id);
+ }
+
+ Tools::deleteDirectory($this->full_img_dir);
+ return parent::delete();
+ }
+
+ public static function cleanImagesDirectory()
+ {
+ $img_dir = _PS_MODULE_DIR_.'qlohotelreview/views/img/review/';
+ $files = Tools::scandir($img_dir, '');
+ foreach ($files as $file) {
+ if (!in_array($file, array('.', '..', 'index.php'))) {
+ if (!Tools::deleteDirectory($img_dir.$file)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ public static function getAverageRatingByIdHotel($id_hotel)
+ {
+ $validate = Configuration::get('QHR_ADMIN_APPROVAL_ENABLED');
+ $cache_id = 'QhrHotelReview::getAverageRatingByIdHotel_'.(int) $id_hotel.'-'.(int) $validate;
+ if (!Cache::isStored($cache_id)) {
+ $result = Db::getInstance()->getValue(
+ 'SELECT SUM(hr.`rating`) FROM `'._DB_PREFIX_.'qhr_hotel_review` hr
+ WHERE hr.`id_hotel` = '.(int) ($id_hotel).($validate == '1' ? ' AND hr.`approved` = 1' : '')
+ );
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
+ }
+
+ public static function getReviewCountByIdHotel($id_hotel)
+ {
+ $validate = Configuration::get('QHR_ADMIN_APPROVAL_ENABLED');
+ $cache_id = 'QhrHotelReview::getCountByIdHotel_'.(int) $id_hotel.'-'.(int) $validate;
+ if (!Cache::isStored($cache_id)) {
+ $result = Db::getInstance()->getValue(
+ 'SELECT COUNT(*) FROM `'._DB_PREFIX_.'qhr_hotel_review` hr
+ WHERE hr.`id_hotel` = '.(int) ($id_hotel).($validate == '1' ? ' AND hr.`approved` = 1' : '')
+ );
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
+ }
+
+ public function addCategoryRatings($categoryRatings)
+ {
+ if (!$categoryRatings) {
+ return true;
+ }
+ // delete all first
+ Db::getInstance()->delete('qhr_review_category_rating', 'id_hotel_review = '.(int) $this->id);
+
+ // insert now
+ $rows = array();
+ foreach ($categoryRatings as $idCategory => $rating) {
+ $rows[] = array(
+ 'id_hotel_review' => (int) $this->id,
+ 'id_category' => (int) $idCategory,
+ 'rating' => (float) $rating
+ );
+ }
+ Db::getInstance()->insert('qhr_review_category_rating', $rows);
+ return true;
+ }
+
+ public function addManagementReply($reply, $idEmployee = null)
+ {
+ if (!$reply) {
+ return false;
+ }
+
+ if (!$idEmployee) {
+ $idEmployee = (int) Context::getContext()->employee->id;
+ }
+
+
+ // delete all first
+ Db::getInstance()->delete('qhr_review_reply', 'id_hotel_review = '.(int) $this->id);
+
+ // insert now
+ $row = array(
+ 'id_hotel_review' => (int) $this->id,
+ 'id_employee' => (int) $idEmployee,
+ 'message' => pSQL($reply)
+ );
+
+ Db::getInstance()->insert('qhr_review_reply', $row);
+ return true;
+ }
+
+ public function getCustomer()
+ {
+ if (!$this->id_order) {
+ return false;
+ }
+
+ $objOrder = new Order($this->id_order);
+ return $objOrder->getCustomer();
+ }
+
+ public function getManagementReply()
+ {
+ $sql = new DbQuery();
+ $sql->select('*');
+ $sql->from('qhr_review_reply', 'rr');
+ $sql->where('rr.`id_hotel_review` = '.(int) $this->id);
+ return Db::getInstance()->getRow($sql);
+ }
+
+ public function saveReviewImages()
+ {
+ $files = QhrHotelReviewHelper::fileAttachmentMultiple('images');
+ if (is_array($files) && count($files)) {
+ foreach ($files as $key => $file) {
+ $ext = pathinfo($file['rename'], PATHINFO_EXTENSION);
+ $dir = _PS_MODULE_DIR_.'qlohotelreview/views/img/review/'.(string) $this->id.'/';
+ QhrHotelReviewHelper::createDirectory($dir);
+ $useSameExt = false;
+ if ($useSameExt) {
+ $imgPath = $dir.($key + 1).'.jpg';
+ } else {
+ $imgPath = $dir.($key + 1).'.'.$ext;
+ }
+ ImageManager::resize($file['tmp_name'], $imgPath);
+ }
+ }
+ }
+
+ public function approveReview()
+ {
+ return Db::getInstance()->update(
+ 'qhr_hotel_review',
+ array('approved' => 1),
+ '`id_hotel_review` = '.(int) $this->id
+ );
+ }
+
+ public function unapproveReview()
+ {
+ return Db::getInstance()->update(
+ 'qhr_hotel_review',
+ array('approved' => 0),
+ '`id_hotel_review` = '.(int) $this->id
+ );
+ }
+
+ public static function getByCustomer($id_customer, $id_hotel = null, $id_order = null)
+ {
+ $cache_id = 'QhrHotelReview::getByCustomer_'.(int) $id_customer.'-'.(int) $id_hotel.'-'.(int) $id_order;
+ if (!Cache::isStored($cache_id)) {
+ $result = Db::getInstance()->executeS(
+ 'SELECT * FROM `'._DB_PREFIX_.'qhr_hotel_review` hr
+ LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = hr.`id_order`
+ WHERE o.`id_customer` = '.(int) $id_customer.
+ ($id_hotel ? ' AND hr.`id_hotel` = '.(int) $id_hotel : '').
+ ($id_order ? ' AND hr.`id_order` = '.(int) $id_order : '').'
+ ORDER BY hr.`date_add` DESC'
+ );
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
+ }
+
+ public static function getByIdOrder($id_order)
+ {
+ $cache_id = 'QhrHotelReview::getByIdOrder_'.(int) $id_order;
+ if (!Cache::isStored($cache_id)) {
+ $result = (int) Db::getInstance()->getValue('
+ SELECT `id_hotel_review`
+ FROM `'._DB_PREFIX_.'qhr_hotel_review` hr
+ WHERE hr.`id_order` = '.(int) $id_order
+ );
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
+ }
+
+ public static function getByHotel(
+ $id_hotel,
+ $p = 1,
+ $n = null,
+ $sort_by = self::QHR_SORT_BY_TIME_NEW,
+ $id_customer = null
+ ) {
+ if (!Validate::isUnsignedId($id_hotel)) {
+ return false;
+ }
+
+ $id_lang = Context::getContext()->language->id;
+
+ $validate = Configuration::get('QHR_ADMIN_APPROVAL_ENABLED');
+ $p = (int) $p;
+ $n = $n !== null ? (int) $n : $n; // n = null for no pagination
+ if ($p <= 1) {
+ $p = 1;
+ }
+ if ($n !== null && $n <= 0) {
+ $n = (int) Configuration::get('QHR_REVIEWS_PER_PAGE');
+ }
+
+ $cache_id = 'QhrHotelReview::getByHotel_'.(int) $id_hotel.'-'.(int) $p.'-'.(int) $n.'-'.(int) $sort_by.
+ (int) $id_customer.'-'.(bool) $validate;
+ if (!Cache::isStored($cache_id)) {
+ $sql = 'SELECT hr.*, CONCAT(c.`firstname`, " ", c.`lastname`) as `customer_name`,
+ hbil.`hotel_name`, qrr.`id_employee`, qrr.`message`,
+ (SELECT COUNT(*) FROM `'._DB_PREFIX_.'qhr_review_usefulness` ru
+ WHERE ru.`id_hotel_review` = hr.`id_hotel_review`) AS `total_useful`,
+ (SELECT COUNT(*) FROM `'._DB_PREFIX_.'qhr_review_report` rr
+ WHERE rr.`id_hotel_review` = hr.`id_hotel_review`) AS `total_report`'.
+ ((int) $id_customer ? ', (SELECT COUNT(*) FROM `'._DB_PREFIX_.'qhr_review_usefulness` ru
+ WHERE ru.`id_hotel_review` = hr.`id_hotel_review`
+ AND ru.id_customer = '.(int) $id_customer.') AS `response_helpful`' : '').
+ ((int) $id_customer ? ', (SELECT COUNT(*) FROM `'._DB_PREFIX_.'qhr_review_report` rr
+ WHERE rr.`id_hotel_review` = hr.`id_hotel_review`
+ AND rr.id_customer = '.(int)$id_customer.') AS `response_report` ' : '').'
+ FROM `'._DB_PREFIX_.'qhr_hotel_review` hr
+ LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = hr.`id_order`
+ LEFT JOIN `'._DB_PREFIX_.'customer` c ON c.`id_customer` = o.`id_customer`
+ LEFT JOIN `'._DB_PREFIX_.'qhr_review_reply` qrr ON qrr.`id_hotel_review` = hr.`id_hotel_review`
+ LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbil
+ ON hbil.`id` = hr.`id_hotel` AND hbil.`id_lang` = '.(int) $id_lang.'
+ WHERE hr.`id_hotel` = '.(int) ($id_hotel).($validate == '1' ? ' AND hr.`approved` = 1' : '');
+
+ if ($sort_by == self::QHR_SORT_BY_RELEVENCE) {
+ $sql .= ' ORDER BY `total_useful` DESC ';
+ } elseif ($sort_by == self::QHR_SORT_BY_TIME_NEW) {
+ $sql .= ' ORDER BY hr.`date_add` DESC ';
+ } elseif ($sort_by == self::QHR_SORT_BY_TIME_OLD) {
+ $sql .= ' ORDER BY hr.`date_add` ASC ';
+ } elseif ($sort_by == self::QHR_SORT_BY_RATING_HIGH) {
+ $sql .= ' ORDER BY hr.`rating` DESC ';
+ } elseif ($sort_by == self::QHR_SORT_BY_RATING_LOW) {
+ $sql .= ' ORDER BY hr.`rating` ASC ';
+ }
+
+ $sql .= ($n ? ' LIMIT '.(int) (($p - 1) * $n).', '.(int) ($n) : '');
+ $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
+ }
+
+ public static function hasNextPage($id_hotel, $p, $n)
+ {
+ if (!Validate::isUnsignedId($id_hotel)) {
+ return false;
+ }
+
+ $id_lang = Context::getContext()->language->id;
+
+ $validate = Configuration::get('QHR_ADMIN_APPROVAL_ENABLED');
+ $p = (int) $p + 1; // next page
+ $n = (int) $n;
+
+ $cache_id = 'QhrHotelReview::hasNextPage'.(int) $id_hotel.'-'.(int) $p.'-'.(int) $n.'-'.'-'.(bool) $validate;
+ if (!Cache::isStored($cache_id)) {
+ $sql = 'SELECT *
+ FROM `'._DB_PREFIX_.'qhr_hotel_review` hr
+ WHERE hr.`id_hotel` = '.(int) ($id_hotel).($validate == '1' ? ' AND hr.`approved` = 1' : '');
+ $sql .= ($n ? ' LIMIT '.(int) (($p - 1) * $n).', '.(int) ($n) : '');
+ $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
+ $result = (is_array($result) && count($result)) ? true : false;
+ Cache::store($cache_id, $result);
+ }
+ return Cache::retrieve($cache_id);
+ }
+
+ public static function getSummaryByHotel($id_hotel)
+ {
+ $id_lang = Context::getContext()->language->id;
+ $validate = Configuration::get('QHR_ADMIN_APPROVAL_ENABLED');
+ $sql = 'SELECT (SUM(hr.`rating`) / COUNT(hr.`rating`)) AS `average`, MIN(hr.`rating`) AS `minimum`,
+ MAX(hr.`rating`) AS `maximum`, COUNT(hr.`id_hotel_review`) AS `total_reviews`
+ FROM `'._DB_PREFIX_.'qhr_hotel_review` hr
+ WHERE hr.`id_hotel` = '.(int) ($id_hotel).($validate == '1' ? ' AND hr.`approved` = 1' : '');
+ $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
+
+ $sql2 = 'SELECT rcr.`id_category`, cl.`name`, SUM(rcr.`rating`) / COUNT(rcr.`rating`) AS `average`
+ FROM `'._DB_PREFIX_.'qhr_review_category_rating` rcr
+ LEFT JOIN `'._DB_PREFIX_.'qhr_hotel_review` hr
+ ON hr.`id_hotel_review` = rcr.`id_hotel_review`
+ LEFT JOIN `'._DB_PREFIX_.'qhr_category` c
+ ON c.`id_category` = rcr.`id_category`
+ LEFT JOIN `'._DB_PREFIX_.'qhr_category_lang` cl
+ ON cl.`id_category` = rcr.`id_category` AND cl.`id_lang` = '.(int) $id_lang.'
+ WHERE c.`active` = 1 AND hr.`id_hotel` = '.(int) ($id_hotel).
+ ($validate == '1' ? ' AND hr.`approved` = 1' : '').'
+ GROUP BY hr.`id_hotel`, rcr.`id_category`';
+ $result2 = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql2);
+ $result['categories'] = $result2;
+ return $result;
+ }
+
+ public function getImages()
+ {
+ if (!$this->id) {
+ return false;
+ }
+ return self::getImagesById($this->id);
+ }
+
+ public static function getImagesById($id_hotel_review)
+ {
+ $full_img_dir = _PS_MODULE_DIR_.'qlohotelreview/views/img/review/'.$id_hotel_review.'/';
+ $files = glob($full_img_dir.'*');
+ $files = array_filter($files, function ($item) {
+ return !strpos($item, 'index.php');
+ });
+
+ foreach ($files as &$file) {
+ $file = str_replace(_PS_ROOT_DIR_, '', $file);
+ $file = ltrim($file, '/');
+ $file = Context::getContext()->shop->getBaseUrl().$file;
+ }
+ return $files;
+ }
+
+ public static function getAllImages($id_hotel)
+ {
+ $images = array();
+ $reviews = self::getByHotel($id_hotel);
+ if (is_array($reviews) && count($reviews)) {
+ foreach ($reviews as $review) {
+ $images = array_merge($images, self::getImagesById($review['id_hotel_review']));
+ }
+ }
+ return $images;
+ }
+
+ public static function getCategoryRatings($id_hotel_review)
+ {
+ if (!$id_hotel_review) {
+ return false;
+ }
+
+ $id_lang = Context::getContext()->language->id;
+ return Db::getInstance()->executeS(
+ 'SELECT * FROM `'._DB_PREFIX_.'qhr_category` qc
+ LEFT JOIN `'._DB_PREFIX_.'qhr_category_lang` qcl
+ ON qcl.`id_category` = qc.`id_category` AND qcl.`id_lang` = '.(int) $id_lang.'
+ LEFT JOIN `'._DB_PREFIX_.'qhr_review_category_rating` qrcr
+ ON qrcr.`id_category` = qc.`id_category`
+ WHERE qc.`active` = 1 AND qrcr.`id_hotel_review` = '.(int) $id_hotel_review);
+ }
+
+ public static function isAlreadyMarkedHelpful($id_hotel_review, $id_customer)
+ {
+ return (bool) Db::getInstance()->getValue('
+ SELECT COUNT(*)
+ FROM `'._DB_PREFIX_.'qhr_review_usefulness`
+ WHERE `id_customer` = '.(int) $id_customer.'
+ AND `id_hotel_review` = '.(int) $id_hotel_review
+ );
+ }
+
+ public static function markHelpful($id_hotel_review, $id_customer)
+ {
+ return Db::getInstance()->execute('
+ INSERT INTO `'._DB_PREFIX_.'qhr_review_usefulness` (`id_hotel_review`, `id_customer`)
+ VALUES ('.(int) $id_hotel_review.', '.(int) $id_customer.')'
+ );
+ }
+
+ public static function isAlreadyReportedAbuse($id_hotel_review, $id_customer)
+ {
+ return (bool) Db::getInstance()->getValue('
+ SELECT COUNT(*)
+ FROM `'._DB_PREFIX_.'qhr_review_report`
+ WHERE `id_customer` = '.(int) $id_customer.'
+ AND `id_hotel_review` = '.(int) $id_hotel_review
+ );
+ }
+
+ public static function reportAbuse($id_hotel_review, $id_customer)
+ {
+ return Db::getInstance()->execute('
+ INSERT INTO `'._DB_PREFIX_.'qhr_review_report` (`id_hotel_review`, `id_customer`)
+ VALUES ('.(int) $id_hotel_review.', '.(int) $id_customer.')'
+ );
+ }
+}
diff --git a/modules/qlohotelreview/classes/QhrHotelReviewDb.php b/modules/qlohotelreview/classes/QhrHotelReviewDb.php
new file mode 100644
index 000000000..b39ac628a
--- /dev/null
+++ b/modules/qlohotelreview/classes/QhrHotelReviewDb.php
@@ -0,0 +1,119 @@
+execute(trim($query))) {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ public static function getModuleSqls()
+ {
+ return array(
+ "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."qhr_hotel_review` (
+ `id_hotel_review` INT(10) NOT NULL AUTO_INCREMENT,
+ `id_hotel` INT(10) NOT NULL,
+ `id_order` INT(10) NOT NULL,
+ `rating` FLOAT UNSIGNED NOT NULL,
+ `subject` VARCHAR(255) NOT NULL,
+ `description` TEXT NOT NULL,
+ `approved` TINYINT(1) DEFAULT 0,
+ `date_add` DATETIME NOT NULL,
+ `date_upd` DATETIME NOT NULL,
+ PRIMARY KEY (`id_hotel_review`)
+ ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8",
+
+ "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."qhr_category` (
+ `id_category` INT(10) NOT NULL AUTO_INCREMENT,
+ `active` TINYINT(1) DEFAULT 1,
+ `date_add` DATETIME NOT NULL,
+ `date_upd` DATETIME NOT NULL,
+ PRIMARY KEY (`id_category`)
+ ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8",
+
+ "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."qhr_category_lang` (
+ `id_category` INT(10) NOT NULL,
+ `id_lang` INT(10) NOT NULL,
+ `name` VARCHAR(255) NOT NULL,
+ PRIMARY KEY (`id_category`, `id_lang`)
+ ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8",
+
+ "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."qhr_review_category_rating` (
+ `id_hotel_review` INT(10) NOT NULL,
+ `id_category` INT(10) NOT NULL,
+ `rating` FLOAT UNSIGNED NOT NULL,
+ PRIMARY KEY (`id_hotel_review`, `id_category`)
+ ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8",
+
+ "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."qhr_review_usefulness` (
+ `id_hotel_review` INT(10) NOT NULL,
+ `id_customer` INT(10) NOT NULL,
+ PRIMARY KEY (`id_hotel_review`, `id_customer`)
+ ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8",
+
+ "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."qhr_review_report` (
+ `id_hotel_review` INT(10) NOT NULL,
+ `id_customer` INT(10) NOT NULL,
+ PRIMARY KEY (`id_hotel_review`, `id_customer`)
+ ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8",
+
+ "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."qhr_review_reply` (
+ `id_review_reply` INT(10) NOT NULL AUTO_INCREMENT,
+ `id_hotel_review` INT(10) NOT NULL,
+ `id_employee` INT(10) NOT NULL DEFAULT 0,
+ `message` TEXT NOT NULL,
+ PRIMARY KEY (`id_review_reply`)
+ ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8",
+ );
+ }
+
+ public static function deleteTables()
+ {
+ return DB::getInstance()->execute(
+ "DROP TABLE IF EXISTS
+ `"._DB_PREFIX_."qhr_hotel_review`,
+ `"._DB_PREFIX_."qhr_category`,
+ `"._DB_PREFIX_."qhr_category_lang`,
+ `"._DB_PREFIX_."qhr_review_category_rating`,
+ `"._DB_PREFIX_."qhr_review_usefulness`,
+ `"._DB_PREFIX_."qhr_review_report`,
+ `"._DB_PREFIX_."qhr_review_reply`;"
+ );
+ }
+
+ public static function getModuleDefaultConfig()
+ {
+ return array(
+ 'QHR_ADMIN_APPROVAL_ENABLED' => 1,
+ 'QHR_MAX_IMAGES_PER_REVIEW' => 5,
+ 'QHR_REVIEWS_PER_PAGE' => 3,
+ );
+ }
+}
diff --git a/modules/qlohotelreview/classes/QhrHotelReviewHelper.php b/modules/qlohotelreview/classes/QhrHotelReviewHelper.php
new file mode 100644
index 000000000..682086b66
--- /dev/null
+++ b/modules/qlohotelreview/classes/QhrHotelReviewHelper.php
@@ -0,0 +1,154 @@
+getValue(
+ 'SELECT COUNT(*) FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
+ WHERE hbd.`id_status` != '.(int) HotelBookingDetail::STATUS_CHECKED_OUT.'
+ AND hbd.`id_order` = '.(int) $idOrder
+ );
+ }
+
+ public static function prepareCategoriesData($summary)
+ {
+ if (!$summary) {
+ return false;
+ }
+
+ foreach ($summary['categories'] as &$category) {
+ if ($category['average'] <= (float) 2) {
+ $category['color'] = '#EC4040';
+ } elseif ($category['average'] <= (float) 3.5) {
+ $category['color'] = '#FFBD37';
+ } else {
+ $category['color'] = '#449F3A';
+ }
+ }
+ return $summary;
+ }
+
+ public static function getIsReviewable($idOrder)
+ {
+ if (!$idOrder) {
+ return false;
+ }
+
+ if (self::getIsOrderCheckedOut($idOrder)) {
+ return true;
+ }
+
+ $maxDate = Db::getInstance()->getValue(
+ 'SELECT MAX(DATE(hbd.`date_to`)) FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
+ WHERE hbd.`id_order` = '.(int) $idOrder
+ );
+ return date('Y-m-d') >= $maxDate;
+ }
+
+ public static function sendReviewRequestMail($idOrder)
+ {
+ $objOrder = new Order((int)$idOrder);
+ if (Validate::isLoadedObject($objOrder)) {
+ $context = Context::getContext();
+ $mailVars = array();
+ $objCustomer = new Customer((int)$objOrder->id_customer);
+ $mailVars = array(
+ '{firstname}' => $objCustomer->firstname,
+ '{lastname}' => $objCustomer->lastname,
+ '{hotel_name}' => self::getHotelByOrder($idOrder)['hotel_name'],
+ '{review_link}' => self::generateReviewLink($idOrder),
+ );
+
+ return Mail::Send(
+ $context->language->id,
+ 'review_request',
+ Mail::l('Please review us!', $context->language->id),
+ $mailVars,
+ $objCustomer->email,
+ $objCustomer->firstname.' '.$objCustomer->lastname,
+ null,
+ null,
+ null,
+ null,
+ _PS_MODULE_DIR_.'qlohotelreview/mails/',
+ false,
+ null,
+ null
+ );
+ }
+ return false;
+ }
+
+ public static function generateReviewLink($idOrder)
+ {
+ $objOrder = new Order($idOrder);
+ $objCustomer = new Customer($objOrder->id_customer);
+ if ($objCustomer->isGuest()) {
+ return Context::getContext()->link->getPageLink('guest-tracking', true, null);
+ }
+ return Context::getContext()->link->getPageLink('history', true, null, array('id_order' => $idOrder));
+ }
+
+ public static function getHotelByOrder($idOrder)
+ {
+ return Db::getInstance()->getRow(
+ 'SELECT `id_hotel`, `hotel_name` FROM `'._DB_PREFIX_.'htl_booking_detail`
+ WHERE `id_order` = '.(int) $idOrder
+ );
+ }
+
+ public static function createDirectory($dir)
+ {
+ if (!file_exists($dir)) {
+ if (!mkdir($dir)) {
+ return false;
+ }
+ $src = _PS_MODULE_DIR_.'qlohotelreview/index.php';
+ $dest = $dir.'index.php';
+ copy($src, $dest);
+ }
+ return true;
+ }
+
+ public static function fileAttachmentMultiple($input)
+ {
+ $file_attachments = null;
+ if (isset($_FILES[$input]['tmp_name']) && !empty($_FILES[$input]['tmp_name'])) {
+ foreach ($_FILES[$input]['tmp_name'] as $key => $tmp_name) {
+ $file_attachment = array();
+ $file_attachment['rename'] = uniqid().
+ Tools::strtolower(Tools::substr($_FILES[$input]['name'][$key], -5));
+ $file_attachment['tmp_name'] = $tmp_name;
+ $file_attachment['name'] = $_FILES[$input]['name'][$key];
+ $file_attachment['mime'] = $_FILES[$input]['type'][$key];
+ $file_attachment['error'] = $_FILES[$input]['error'][$key];
+ $file_attachment['size'] = $_FILES[$input]['size'][$key];
+ $file_attachments[] = $file_attachment;
+ }
+ }
+ return $file_attachments;
+ }
+}
diff --git a/modules/qlohotelreview/classes/RequiredFiles.php b/modules/qlohotelreview/classes/RequiredFiles.php
new file mode 100644
index 000000000..ecaa24c85
--- /dev/null
+++ b/modules/qlohotelreview/classes/RequiredFiles.php
@@ -0,0 +1,24 @@
+
-* @copyright 2010-2021 Webkul IN
-* @license https://store.webkul.com/license.html
+* @author Webkul IN
+* @copyright 2010-2022 Webkul IN
+* @license LICENSE.txt
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
diff --git a/modules/qlohotelreview/controllers/admin/AdminHotelReviewCategory.php b/modules/qlohotelreview/controllers/admin/AdminHotelReviewCategory.php
new file mode 100644
index 000000000..1487c0af1
--- /dev/null
+++ b/modules/qlohotelreview/controllers/admin/AdminHotelReviewCategory.php
@@ -0,0 +1,257 @@
+bootstrap = true;
+ $this->className = 'QhrCategory';
+ $this->table = 'qhr_category';
+ $this->identifier = 'id_category';
+ $this->lang = true;
+
+ parent::__construct();
+
+ $this->addRowAction('edit');
+ $this->addRowAction('delete');
+
+ $this->fields_list = array(
+ 'id_category' => array(
+ 'title' => $this->l('ID'),
+ 'hint' => $this->l('ID of the category.'),
+ 'align' => 'center',
+ 'class' => 'fixed-width-xs',
+ ),
+ 'name' => array(
+ 'title' => $this->l('Name'),
+ 'hint' => $this->l('Name of the category.'),
+ 'align' => 'left',
+ ),
+ 'active' => array(
+ 'title' => $this->l('Status'),
+ 'hint' => $this->l('Current status of the category.'),
+ 'type' => 'bool',
+ 'active' => 'status',
+ 'align' => 'center',
+ 'filter_key' => 'a!active',
+ ),
+ );
+
+ $this->list_no_link = true;
+
+ $this->bulk_actions = array(
+ 'enableSelection' => array(
+ 'text' => $this->l('Enable selection'),
+ 'icon' => 'icon-power-off text-success'
+ ),
+ 'disableSelection' => array(
+ 'text' => $this->l('Disable selection'),
+ 'icon' => 'icon-power-off text-danger'
+ ),
+ 'divider' => array(
+ 'text' => 'divider'
+ ),
+ 'delete' => array(
+ 'text' => $this->l('Delete selected'),
+ 'confirm' => $this->l('Delete selected items?'),
+ 'icon' => 'icon-trash'
+ )
+ );
+ }
+
+ public function initToolbar()
+ {
+ parent::initToolbar();
+ if (empty($this->display)) {
+ $this->page_header_toolbar_btn['new'] = array(
+ 'href' => self::$currentIndex.'&add'.$this->table.'&token='.$this->token,
+ 'desc' => $this->l('Add new category')
+ );
+ }
+
+ if ($this->display == 'options') {
+ $this->toolbar_btn = array();
+ $this->toolbar_btn['new'] = array(
+ 'href' => self::$currentIndex.'&add'.$this->table.'&token='.$this->token,
+ 'desc' => $this->l('Add new category')
+ );
+ }
+ }
+
+ public function initToolbarTitle()
+ {
+ parent::initToolbarTitle();
+ if ($this->display == 'add') {
+ $this->toolbar_title = $this->l('Adding new category');
+ } elseif ($this->display == 'edit') {
+ $this->toolbar_title = $this->l('Editing');
+ } elseif ($this->display == '') {
+ $this->toolbar_title = $this->l('Configuration');
+ }
+ }
+
+ public function initContent()
+ {
+ parent::initContent();
+ if ($this->display == 'options') {
+ $this->content = $this->renderOptions();
+ $this->content .= $this->renderList();
+ $this->context->smarty->assign(array('content' => $this->content));
+ }
+ }
+
+ public function renderOptions()
+ {
+ $this->fields_options = array(
+ 'general' => array(
+ 'title' => $this->l('Review Options'),
+ 'icon' => 'icon icon-cog',
+ 'fields' => array(
+ 'QHR_ADMIN_APPROVAL_ENABLED' => array(
+ 'type' => 'bool',
+ 'title' => $this->l('Admin approval'),
+ 'hint' => $this->l('Enable if you want each review to be approved by an employee.'),
+ 'validation' => 'isBool',
+ 'cast' => 'intval',
+ ),
+ 'QHR_MAX_IMAGES_PER_REVIEW' => array(
+ 'type' => 'text',
+ 'title' => $this->l('Maximum images per review'),
+ 'hint' => $this->l('The number of maximum images that can be uploaded with a review.'),
+ 'class' => 'fixed-width-md',
+ 'validation' => 'isUnsignedInt',
+ 'required' => true,
+ 'cast' => 'intval',
+ ),
+ 'QHR_REVIEWS_PER_PAGE' => array(
+ 'type' => 'text',
+ 'title' => $this->l('Reviews per page'),
+ 'hint' => $this->l('The number of reviews that are displayed per page.'),
+ 'class' => 'fixed-width-md',
+ 'validation' => 'isUnsignedInt',
+ 'required' => true,
+ 'cast' => 'intval',
+ ),
+ ),
+ 'submit' => array(
+ 'title' => $this->l('Save'),
+ 'name' => 'submitHotelReviewOptions',
+ )
+ ),
+ );
+ return parent::renderOptions();
+ }
+
+ public function renderList()
+ {
+ $this->tpl_list_vars['title'] = $this->l('Categories');
+ $this->context->smarty->assign(array('icon' => 'icon-list'));
+ return parent::renderList();
+ }
+
+ public function renderForm()
+ {
+ $smartyVars = array();
+ $idCategory = Tools::getValue($this->identifier);
+ $objCategory = $this->loadObject(true);
+
+ $smartyVars['id_category'] = (int)$idCategory;
+ $smartyVars['current_iso_code'] = $this->context->language->iso_code;
+ $smartyVars['currentTab'] = $this;
+ $smartyVars['currentObject'] = $objCategory;
+
+ $this->multiple_fieldsets = 1;
+ $this->fields_form = $this->getFieldsForm();
+ $this->context->smarty->assign($smartyVars);
+ return parent::renderForm();
+ }
+
+ public function getFieldsForm()
+ {
+ $fields_form = array();
+
+ $fields_form[] = array(
+ 'form' => array(
+ 'submit' => array(
+ 'title' => $this->l('Save'),
+ 'name' => 'submitCategory',
+ 'class' => 'btn btn-default pull-right',
+ ),
+ ),
+ );
+
+ return $fields_form;
+ }
+
+ public function postProcess()
+ {
+ if (Tools::isSubmit('submitHotelReviewOptions')) {
+ $imagesPerReview = Tools::getValue('QHR_MAX_IMAGES_PER_REVIEW');
+ $reviewsPerPage = Tools::getValue('QHR_REVIEWS_PER_PAGE');
+
+ if ($imagesPerReview == '') {
+ $this->errors[] = $this->l('Please enter maximum images per review.');
+ }
+ if ($imagesPerReview && !Validate::isUnsignedInt($imagesPerReview)) {
+ $this->errors[] = $this->l('Please enter valid maximum images per review.');
+ }
+
+ if ($reviewsPerPage == '') {
+ $this->errors[] = $this->l('Please enter reviews per page.');
+ }
+ if (($reviewsPerPage == '0') || ($reviewsPerPage && !Validate::isUnsignedInt($reviewsPerPage))) {
+ $this->errors[] = $this->l('Please enter valid reviews per page.');
+ }
+ if (!count($this->errors)) {
+ Configuration::updateValue('QHR_ADMIN_APPROVAL_ENABLED', Tools::getValue('QHR_ADMIN_APPROVAL_ENABLED'));
+ Configuration::updateValue('QHR_MAX_IMAGES_PER_REVIEW', $imagesPerReview);
+ Configuration::updateValue('QHR_REVIEWS_PER_PAGE', $reviewsPerPage);
+ Tools::redirectAdmin(self::$currentIndex.'&conf=6&token='.$this->token);
+ }
+ } elseif (Tools::isSubmit('submitCategory') || Tools::isSubmit('submitCategoryAndStay')) {
+ $idCategory = Tools::getValue($this->identifier);
+ $this->validateRules();
+ if (!count($this->errors)) {
+ $objCategory = new QhrCategory($idCategory);
+ $this->copyFromPost($objCategory, $this->table);
+ if ($objCategory->save()) {
+ $newId = $objCategory->id;
+ if (Tools::isSubmit('submitCategoryAndStay')) {
+ if ($idCategory) {
+ Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token.
+ '&update'.$this->table.'&'.$this->identifier.'='.$newId);
+ } else {
+ Tools::redirectAdmin(self::$currentIndex.'&conf=3&token='.$this->token.
+ '&update'.$this->table.'&'.$this->identifier.'='.$newId);
+ }
+ } else {
+ if ($idCategory) {
+ Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
+ } else {
+ Tools::redirectAdmin(self::$currentIndex.'&conf=3&token='.$this->token);
+ }
+ }
+ }
+ }
+ }
+ parent::postProcess();
+ }
+}
diff --git a/modules/qlohotelreview/controllers/admin/AdminHotelReviewHotelReview.php b/modules/qlohotelreview/controllers/admin/AdminHotelReviewHotelReview.php
new file mode 100644
index 000000000..db5e46460
--- /dev/null
+++ b/modules/qlohotelreview/controllers/admin/AdminHotelReviewHotelReview.php
@@ -0,0 +1,327 @@
+bootstrap = true;
+ $this->className = 'QhrHotelReview';
+ $this->table = 'qhr_hotel_review';
+ $this->identifier = 'id_hotel_review';
+
+ parent::__construct();
+
+ $this->_select .= ' hbl.`hotel_name`, c.`id_customer`,
+ CONCAT(c.`firstname`, " ", c.`lastname`) as `customer_name`,
+ CONVERT(a.`rating`, DECIMAL(10, 1)) AS `rating`,
+ (SELECT COUNT(*) FROM `'._DB_PREFIX_.'qhr_review_report` rr
+ WHERE rr.`id_hotel_review` = a.`id_hotel_review`) AS `total_report`';
+ $this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = a.`id_order`)';
+ $this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = o.`id_customer`)';
+ $this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbl
+ ON (hbl.`id` = a.`id_hotel` AND hbl.`id_lang` = '.(int) $this->context->language->id.')';
+ $this->_orderBy .= 'a.date_add';
+ $this->_orderWay .= 'DESC';
+
+ $this->addRowAction('view');
+ $this->addRowAction('approve');
+ $this->addRowAction('unapprove');
+ $this->addRowAction('delete');
+
+ $this->fields_list = array(
+ 'id_hotel_review' => array(
+ 'title' => $this->l('ID'),
+ 'hint' => $this->l('ID of the review.'),
+ 'align' => 'center',
+ 'class' => 'fixed-width-xs',
+ ),
+ 'hotel_name' => array(
+ 'title' => $this->l('Hotel'),
+ 'hint' => $this->l('Name of the hotel for which this review has been added.'),
+ 'align' => 'center',
+ 'callback' => 'getHotelLink',
+ ),
+ 'rating' => array(
+ 'title' => $this->l('Overall Rating'),
+ 'hint' => $this->l('Overall rating of the review.'),
+ 'align' => 'center',
+ 'havingFilter' => true,
+ 'callback' => 'getOverallRating',
+ ),
+ 'subject' => array(
+ 'title' => $this->l('Subject'),
+ 'hint' => $this->l('Subject of the review.'),
+ 'align' => 'center',
+ 'callback' => 'getSubject',
+ ),
+ 'customer_name' => array(
+ 'title' => $this->l('Customer'),
+ 'hint' => $this->l('Name of the customer who added this review.'),
+ 'align' => 'center',
+ 'callback' => 'getCustomerLink',
+ 'havingFilter' => true,
+ ),
+ 'total_report' => array(
+ 'title' => $this->l('Total Reports'),
+ 'hint' => $this->l('Number of times this review has been reported.'),
+ 'align' => 'center',
+ 'havingFilter' => true,
+ 'class' => 'fixed-width-md',
+ 'callback' => 'getTotalReports',
+ ),
+ 'approved' => array(
+ 'title' => $this->l('Approval Status'),
+ 'hint' => $this->l('Approval status of the review.'),
+ 'align' => 'center',
+ 'callback' => 'getApprovalStatus',
+ 'type' => 'select',
+ 'filter_key' => 'a!approved',
+ 'list' => array(0 => $this->l('Unapproved'), 1 => $this->l('Approved')),
+ ),
+ 'date_add' => array(
+ 'title' => $this->l('Date'),
+ 'hint' => $this->l('Date and time when this review was added.'),
+ 'align' => 'center',
+ 'type' => 'datetime',
+ ),
+ );
+
+ $this->list_no_link = true;
+
+ $this->bulk_actions = array(
+ 'delete' => array(
+ 'text' => $this->l('Delete selected'),
+ 'confirm' => $this->l('Delete selected items?'),
+ 'icon' => 'icon-trash'
+ )
+ );
+
+ $this->_conf[101] = $this->l('Reply has been added successfully.');
+ $this->_conf[102] = $this->l('Review has been approved successfully.');
+ $this->_conf[103] = $this->l('Review has been unapproved successfully.');
+
+ $this->cacheApproved = array();
+ }
+
+ public function getOverallRating($rating)
+ {
+ if ($rating < 2) {
+ return ''.$rating.'';
+ } elseif ($rating < 3.5) {
+ return ''.$rating.'';
+ } else {
+ return ''.$rating.'';
+ }
+ }
+
+ public function getSubject($subject)
+ {
+ return Tools::substr($subject, 0, 50).(Tools::strlen($subject) > 50 ? '...' : '');
+ }
+
+ public function getCustomerLink($fullname, $tr)
+ {
+ $href = $this->context->link->getAdminLink('AdminCustomers').
+ '&viewcustomer&id_customer='.(int) $tr['id_customer'];
+ return "".$fullname." (#".(int) $tr['id_customer'].")";
+ }
+
+ public function getHotelLink($hotelName, $row)
+ {
+ $idHotel = $row['id_hotel'];
+ $link = $this->context->link->getAdminLink('AdminAddHotel').'&id='.$idHotel.'&updatehtl_branch_info';
+ return "$hotelName (#$idHotel)";
+ }
+
+ public function getTotalReports($totalReports, $row)
+ {
+ return "$totalReports";
+ }
+
+ public function getApprovalStatus($approved, $row)
+ {
+ if ($approved) {
+ return ''.$this->l('Approved').'';
+ } else {
+ return ''.$this->l('Unapproved').'';
+ }
+ }
+
+ public function displayApproveLink($token = null, $id, $name = null)
+ {
+ $status = null;
+ if (array_key_exists($id, $this->cacheApproved)) {
+ $status = $this->cacheApproved[$id];
+ } else {
+ $objHotelReview = new QhrHotelReview((int) $id);
+ $status = $objHotelReview->approved;
+ $this->cacheApproved[$id] = $status;
+ }
+
+ if ($status) {
+ $this->addRowActionSkipList('approve', $id);
+ } else {
+ $href = self::$currentIndex.'&'.$this->identifier.'='.$id.'&action=approveHotelReview'.'&token='.
+ ($token != null ? $token : $this->token);
+ $action = $this->l('Approve');
+ return "$action";
+ }
+ }
+
+ public function displayUnapproveLink($token = null, $id, $name = null)
+ {
+ $status = null;
+ if (array_key_exists($id, $this->cacheApproved)) {
+ $status = $this->cacheApproved[$id];
+ } else {
+ $objHotelReview = new QhrHotelReview((int) $id);
+ $status = $objHotelReview->approved;
+ $this->cacheApproved[$id] = $status;
+ }
+
+ if (!$status) {
+ $this->addRowActionSkipList('unapprove', $id);
+ } else {
+ $href = self::$currentIndex.'&'.$this->identifier.'='.$id.'&action=unapproveHotelReview'.'&token='.
+ ($token != null ? $token : $this->token);
+ $action = $this->l('Unapprove');
+ return "$action";
+ }
+ }
+
+ public function initToolbarTitle()
+ {
+ parent::initToolbarTitle();
+ if ($this->display == 'view') {
+ $this->toolbar_title = $this->l('Viewing');
+ } elseif ($this->display == '') {
+ $this->toolbar_title = $this->l('Reviews');
+ }
+ }
+
+ public function renderList()
+ {
+ unset($this->toolbar_btn['new']);
+ $this->context->smarty->assign(array('icon' => 'icon-list'));
+ return parent::renderList();
+ }
+
+ public function renderView()
+ {
+ $this->loadObject();
+ if (!count($this->errors)) {
+ $smartyVars = array();
+
+ $objCustomer = $this->object->getCustomer();
+ $objHotel = new HotelBranchInformation($this->object->id_hotel, (int) $this->context->language->id);
+ $smartyVars['id_hotel_review'] = (int) $this->id_object;
+ $smartyVars['current_iso_code'] = $this->context->language->iso_code;
+ $smartyVars['currentTab'] = $this;
+ $smartyVars['currentObject'] = $this->object;
+ $smartyVars['images'] = $this->object->getImages();
+ $smartyVars['reply'] = $this->object->getManagementReply();
+ $smartyVars['obj_customer'] = $objCustomer;
+ $smartyVars['obj_hotel'] = $objHotel;
+ $smartyVars['img_dir'] = $this->object->img_dir;
+
+ $this->context->smarty->assign($smartyVars);
+ return parent::renderView();
+ }
+ }
+
+ public function postProcess()
+ {
+ if (Tools::isSubmit('submitReply')) {
+ $reply = Tools::getValue('management_reply');
+ if ($reply == '') {
+ $this->errors[] = $this->l('Management reply can not be empty.');
+ } elseif (!Validate::isCleanHtml($reply)) {
+ $this->errors[] = $this->l('Management reply is invalid.');
+ }
+
+ $this->loadObject(false);
+ if (!count($this->errors)) {
+ if ($this->object->addManagementReply($reply)) {
+ Tools::redirectAdmin(self::$currentIndex.'&conf=101&token='.$this->token.
+ '&viewqhr_hotel_review&id_hotel_review='.$this->id_object);
+ } else {
+ $this->display = 'view';
+ }
+ }
+ } elseif (Tools::isSubmit('submitApprove')) {
+ $this->loadObject(false);
+ if (!count($this->errors)) {
+ if ($this->object->approveReview()) {
+ Tools::redirectAdmin(self::$currentIndex.'&conf=102&token='.$this->token.
+ '&viewqhr_hotel_review&id_hotel_review='.$this->id_object);
+ } else {
+ $this->display = 'view';
+ }
+ }
+ } elseif (Tools::isSubmit('submitUnapprove')) {
+ $this->loadObject(false);
+ if (!count($this->errors)) {
+ if ($this->object->unapproveReview()) {
+ Tools::redirectAdmin(self::$currentIndex.'&conf=103&token='.$this->token.
+ '&viewqhr_hotel_review&id_hotel_review='.$this->id_object);
+ } else {
+ $this->display = 'view';
+ }
+ }
+ } elseif (Tools::isSubmit('submitDelete')) {
+ $this->loadObject(false);
+ if (!count($this->errors)) {
+ if ($this->object->delete()) {
+ Tools::redirectAdmin(self::$currentIndex.'&conf=1&token='.$this->token);
+ }
+ }
+ }
+
+ parent::postProcess();
+ }
+
+ public function processApproveHotelReview()
+ {
+ $this->loadObject(false);
+ if (!count($this->errors)) {
+ if ($this->object->approveReview()) {
+ Tools::redirectAdmin(self::$currentIndex.'&conf=102&token='.$this->token);
+ }
+ }
+ }
+
+ public function processUnapproveHotelReview()
+ {
+ $this->loadObject(false);
+ if (!count($this->errors)) {
+ if ($this->object->unapproveReview()) {
+ Tools::redirectAdmin(self::$currentIndex.'&conf=103&token='.$this->token);
+ }
+ }
+ }
+
+ public function setMedia()
+ {
+ parent::setMedia();
+ $this->addCSS($this->module->getPathUri().'views/css/admin/hotel-review.css');
+ $this->addJS($this->module->getPathUri().'views/js/admin/hotel-review.js');
+ }
+}
diff --git a/modules/qlohotelreview/controllers/admin/AdminParentHotelReview.php b/modules/qlohotelreview/controllers/admin/AdminParentHotelReview.php
new file mode 100644
index 000000000..bedc709e7
--- /dev/null
+++ b/modules/qlohotelreview/controllers/admin/AdminParentHotelReview.php
@@ -0,0 +1,28 @@
+context->link->getAdminLink('AdminHotelReviewCategory'));
+ }
+}
diff --git a/modules/qlohotelreview/controllers/admin/index.php b/modules/qlohotelreview/controllers/admin/index.php
new file mode 100644
index 000000000..d6825e437
--- /dev/null
+++ b/modules/qlohotelreview/controllers/admin/index.php
@@ -0,0 +1,29 @@
+content_only = true;
+ }
+
+ public function checkAccess()
+ {
+ return strcmp(Tools::getValue('token', ''), $this->module->secure_key) === 0;
+ }
+
+ public function displayAjaxAddReview()
+ {
+ $idHotel = Tools::getValue('id_hotel');
+ $idOrder = Tools::getValue('id_order');
+ $ratingOverall = Tools::getValue('rating_overall');
+ $ratingCategories = Tools::getValue('rating_categories');
+ $subject = Tools::getValue('subject');
+ $description = Tools::getValue('description');
+
+ $approvalEnabled = Configuration::get('QHR_ADMIN_APPROVAL_ENABLED');
+ $maxImages = (int) Configuration::get('QHR_MAX_IMAGES_PER_REVIEW');
+
+ $status = 'ko';
+ $errors = array('by_key' => array(), 'general' => array());
+ $objModule = new QloHotelReview();
+ $objHotel = new HotelBranchInformation($idHotel);
+ $objOrder = new Order($idOrder);
+
+ // Validations
+ if (!Validate::isLoadedObject($objHotel)) {
+ $errors['general'][] = $objModule->l('Invalid hotel ID.', 'default');
+ }
+
+ if (!Validate::isLoadedObject($objOrder)) {
+ $errors['general'][] = $objModule->l('Invalid order ID.', 'default');
+ }
+
+ if (!$subject) {
+ $errors['by_key']['subject'] = $objModule->l('This field can not be empty.', 'default');
+ } elseif(!Validate::isGenericName($subject)) {
+ $errors['by_key']['subject'] = $objModule->l('This field is invalid.', 'default');
+ }
+
+ if (!$description) {
+ $errors['by_key']['description'] = $objModule->l('Review description can not be empty.', 'default');
+ } elseif(!Validate::isMessage($description)) {
+ $errors['by_key']['description'] = $objModule->l('Review description is invalid.', 'default');
+ }
+
+ if (is_array($_FILES) && array_key_exists('images', $_FILES)) {
+ if (count($_FILES['images']['name']) > $maxImages) {
+ $errors['general'][] = sprintf(
+ $objModule->l('Please upload a maximum of %d images.', 'default'),
+ $maxImages
+ );
+ }
+ }
+
+ if (!count($errors['by_key']) && !count($errors['general'])) {
+ $customerReview = QhrHotelReview::getByCustomer(
+ $objOrder->id_customer,
+ $idHotel,
+ $idOrder
+ );
+ if (!$customerReview) {
+ $objHotelReview = new QhrHotelReview();
+ $objHotelReview->id_hotel = (int) $idHotel;
+ $objHotelReview->id_order = (int) $idOrder;
+ $objHotelReview->description = strip_tags($description);
+ $objHotelReview->subject = $subject;
+ $objHotelReview->rating = $ratingOverall;
+ $objHotelReview->approved = (int) !$approvalEnabled;
+ if ($objHotelReview->save()) {
+ $objHotelReview->addCategoryRatings($ratingCategories);
+ if ($maxImages) {
+ $objHotelReview->saveReviewImages();
+ }
+ $status = 'ok';
+ }
+ } else {
+ $status = 'ko';
+ $errors['general'][] = $objModule->l('Something went wrong.', 'default');
+ }
+ } else {
+ $status = 'ko';
+ }
+
+ if (is_array($errors['general']) && count($errors['general'])) {
+ $html = '';
+ foreach ($errors['general'] as $error) {
+ $html .= '