From dab830fccef62e2f3b5e9fed136c277708077703 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 20 Sep 2023 19:10:11 +0530 Subject: [PATCH 1/5] Update working of options Features and Customer Groups --- controllers/admin/AdminGroupsController.php | 9 +++- .../admin/AdminPPreferencesController.php | 2 + .../admin/AdminPerformanceController.php | 42 +++++++++---------- .../views/templates/hook/htlfilterblock.tpl | 2 +- .../wkhotelfilterblock/wkhotelfilterblock.php | 1 + 5 files changed, 33 insertions(+), 23 deletions(-) diff --git a/controllers/admin/AdminGroupsController.php b/controllers/admin/AdminGroupsController.php index 54ea51ffd..8aa6af2a8 100644 --- a/controllers/admin/AdminGroupsController.php +++ b/controllers/admin/AdminGroupsController.php @@ -126,7 +126,7 @@ class AdminGroupsControllerCore extends AdminController public function initPageHeaderToolbar() { - if (empty($this->display)) { + if (empty($this->display) && Configuration::get('PS_GROUP_FEATURE_ACTIVE')) { $this->page_header_toolbar_btn['new_group'] = array( 'href' => self::$currentIndex.'&addgroup&token='.$this->token, 'desc' => $this->l('Add new group', null, null, false), @@ -542,6 +542,13 @@ class AdminGroupsControllerCore extends AdminController public function renderList() { + if (!Configuration::get('PS_GROUP_FEATURE_ACTIVE')) { + $this->displayWarning(sprintf( + $this->l('The feature Customer Groups has been disabled. You can enable it from %s page.'), + ''.$this->l('Advanced Parameters > Performance').'' + )); + } + $unidentified = new Group(Configuration::get('PS_UNIDENTIFIED_GROUP')); $guest = new Group(Configuration::get('PS_GUEST_GROUP')); $default = new Group(Configuration::get('PS_CUSTOMER_GROUP')); diff --git a/controllers/admin/AdminPPreferencesController.php b/controllers/admin/AdminPPreferencesController.php index 1ea8b3f50..eb5b36a45 100644 --- a/controllers/admin/AdminPPreferencesController.php +++ b/controllers/admin/AdminPPreferencesController.php @@ -400,8 +400,10 @@ class AdminPPreferencesControllerCore extends AdminController 'hint' => $this->l('Enable to display Amenities filter.'), 'validation' => 'isBool', 'cast' => 'intval', + 'disabled' => (bool) !Configuration::get('PS_FEATURE_FEATURE_ACTIVE'), 'required' => false, 'type' => 'bool', + 'desc' => (bool) !Configuration::get('PS_FEATURE_FEATURE_ACTIVE') ? sprintf($this->l('The feature Features/Amenities has been disabled. You can enable it from %s page.'), ''.$this->l('Advanced Parameters > Performance').'') : '', ), 'SHOW_PRICE_FILTER' => array( 'title' => $this->l('Show Price filter'), diff --git a/controllers/admin/AdminPerformanceController.php b/controllers/admin/AdminPerformanceController.php index 4a0b4b123..ac7f60298 100644 --- a/controllers/admin/AdminPerformanceController.php +++ b/controllers/admin/AdminPerformanceController.php @@ -212,27 +212,27 @@ class AdminPerformanceControllerCore extends AdminController 'type' => 'hidden', 'name' => 'features_detachables_up' ), - array( - 'type' => 'switch', - 'label' => $this->l('Combinations'), - 'name' => 'combination', - 'is_bool' => true, - 'disabled' => Combination::isCurrentlyUsed(), - 'values' => array( - array( - 'id' => 'combination_1', - 'value' => 1, - 'label' => $this->l('Yes'), - ), - array( - 'id' => 'combination_0', - 'value' => 0, - 'label' => $this->l('No') - ) - ), - 'hint' => $this->l('Choose "No" to disable Product Combinations.'), - 'desc' => Combination::isCurrentlyUsed() ? $this->l('You cannot set this parameter to No when combinations are already used by some of your products') : null - ), + // array( + // 'type' => 'switch', + // 'label' => $this->l('Combinations'), + // 'name' => 'combination', + // 'is_bool' => true, + // 'disabled' => Combination::isCurrentlyUsed(), + // 'values' => array( + // array( + // 'id' => 'combination_1', + // 'value' => 1, + // 'label' => $this->l('Yes'), + // ), + // array( + // 'id' => 'combination_0', + // 'value' => 0, + // 'label' => $this->l('No') + // ) + // ), + // 'hint' => $this->l('Choose "No" to disable Product Combinations.'), + // 'desc' => Combination::isCurrentlyUsed() ? $this->l('You cannot set this parameter to No when combinations are already used by some of your products') : null + // ), array( 'type' => 'switch', 'label' => $this->l('Features'), diff --git a/modules/wkhotelfilterblock/views/templates/hook/htlfilterblock.tpl b/modules/wkhotelfilterblock/views/templates/hook/htlfilterblock.tpl index 7db81900d..6e5a207a7 100644 --- a/modules/wkhotelfilterblock/views/templates/hook/htlfilterblock.tpl +++ b/modules/wkhotelfilterblock/views/templates/hook/htlfilterblock.tpl @@ -19,7 +19,7 @@
- {if isset($config) && $config['SHOW_AMENITIES_FILTER']} + {if isset($config) && $config['PS_FEATURE_FEATURE_ACTIVE'] && $config['SHOW_AMENITIES_FILTER']}
diff --git a/modules/wkhotelfilterblock/wkhotelfilterblock.php b/modules/wkhotelfilterblock/wkhotelfilterblock.php index e2fa40f38..46df60044 100644 --- a/modules/wkhotelfilterblock/wkhotelfilterblock.php +++ b/modules/wkhotelfilterblock/wkhotelfilterblock.php @@ -153,6 +153,7 @@ class wkhotelfilterblock extends Module return array( 'SHOW_AMENITIES_FILTER' => Configuration::get('SHOW_AMENITIES_FILTER'), 'SHOW_PRICE_FILTER' => Configuration::get('SHOW_PRICE_FILTER'), + 'PS_FEATURE_FEATURE_ACTIVE' => Configuration::get('PS_FEATURE_FEATURE_ACTIVE'), ); } } From dc0d8dda64c527050828d6200e3edc4338d9390b Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 15 Nov 2023 15:21:39 +0530 Subject: [PATCH 2/5] Optimize feature check calls --- controllers/admin/AdminGroupsController.php | 4 ++-- controllers/admin/AdminPPreferencesController.php | 4 ++-- modules/wkhotelfilterblock/wkhotelfilterblock.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/controllers/admin/AdminGroupsController.php b/controllers/admin/AdminGroupsController.php index 8aa6af2a8..4c4e4596e 100644 --- a/controllers/admin/AdminGroupsController.php +++ b/controllers/admin/AdminGroupsController.php @@ -126,7 +126,7 @@ class AdminGroupsControllerCore extends AdminController public function initPageHeaderToolbar() { - if (empty($this->display) && Configuration::get('PS_GROUP_FEATURE_ACTIVE')) { + if (empty($this->display) && Group::isFeatureActive()) { $this->page_header_toolbar_btn['new_group'] = array( 'href' => self::$currentIndex.'&addgroup&token='.$this->token, 'desc' => $this->l('Add new group', null, null, false), @@ -542,7 +542,7 @@ class AdminGroupsControllerCore extends AdminController public function renderList() { - if (!Configuration::get('PS_GROUP_FEATURE_ACTIVE')) { + if (!Group::isFeatureActive()) { $this->displayWarning(sprintf( $this->l('The feature Customer Groups has been disabled. You can enable it from %s page.'), ''.$this->l('Advanced Parameters > Performance').'' diff --git a/controllers/admin/AdminPPreferencesController.php b/controllers/admin/AdminPPreferencesController.php index eb5b36a45..e671522e2 100644 --- a/controllers/admin/AdminPPreferencesController.php +++ b/controllers/admin/AdminPPreferencesController.php @@ -400,10 +400,10 @@ class AdminPPreferencesControllerCore extends AdminController 'hint' => $this->l('Enable to display Amenities filter.'), 'validation' => 'isBool', 'cast' => 'intval', - 'disabled' => (bool) !Configuration::get('PS_FEATURE_FEATURE_ACTIVE'), + 'disabled' => (bool) !Feature::isFeatureActive(), 'required' => false, 'type' => 'bool', - 'desc' => (bool) !Configuration::get('PS_FEATURE_FEATURE_ACTIVE') ? sprintf($this->l('The feature Features/Amenities has been disabled. You can enable it from %s page.'), ''.$this->l('Advanced Parameters > Performance').'') : '', + 'desc' => (bool) !Feature::isFeatureActive() ? sprintf($this->l('The feature Features/Amenities has been disabled. You can enable it from %s page.'), ''.$this->l('Advanced Parameters > Performance').'') : '', ), 'SHOW_PRICE_FILTER' => array( 'title' => $this->l('Show Price filter'), diff --git a/modules/wkhotelfilterblock/wkhotelfilterblock.php b/modules/wkhotelfilterblock/wkhotelfilterblock.php index 46df60044..f93fb05d8 100644 --- a/modules/wkhotelfilterblock/wkhotelfilterblock.php +++ b/modules/wkhotelfilterblock/wkhotelfilterblock.php @@ -153,7 +153,7 @@ class wkhotelfilterblock extends Module return array( 'SHOW_AMENITIES_FILTER' => Configuration::get('SHOW_AMENITIES_FILTER'), 'SHOW_PRICE_FILTER' => Configuration::get('SHOW_PRICE_FILTER'), - 'PS_FEATURE_FEATURE_ACTIVE' => Configuration::get('PS_FEATURE_FEATURE_ACTIVE'), + 'PS_FEATURE_FEATURE_ACTIVE' => Feature::isFeatureActive(), ); } } From abe3b69056cd60fc61d9905cf1db8ac4ca4d2efd Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 18 Dec 2023 19:48:40 +0530 Subject: [PATCH 3/5] Undo changes in Features option and Update Groups option --- controllers/admin/AdminGroupsController.php | 26 +++++++++++++++++++ .../admin/AdminPPreferencesController.php | 2 -- .../views/templates/hook/htlfilterblock.tpl | 2 +- .../wkhotelfilterblock/wkhotelfilterblock.php | 1 - 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/controllers/admin/AdminGroupsController.php b/controllers/admin/AdminGroupsController.php index 4c4e4596e..2be4a8c85 100644 --- a/controllers/admin/AdminGroupsController.php +++ b/controllers/admin/AdminGroupsController.php @@ -148,8 +148,32 @@ class AdminGroupsControllerCore extends AdminController parent::initProcess(); } + public function initContent() + { + if (!Group::isFeatureActive()) { + parent::initContent(); + + $content = $this->displayWarning(sprintf( + $this->l('The feature Customer Groups has been disabled. You can enable it from %s page.'), + ''.$this->l('Advanced Parameters > Performance').'' + )); + + $this->context->smarty->assign(array( + 'content' => $content, + )); + + return; + } + + parent::initContent(); + } + public function postProcess() { + if (!Group::isFeatureActive()) { + return; + } + if (isset($_POST['submitResetcustomer_group'])) { $this->processResetFilters('customer_group'); } @@ -547,6 +571,8 @@ class AdminGroupsControllerCore extends AdminController $this->l('The feature Customer Groups has been disabled. You can enable it from %s page.'), ''.$this->l('Advanced Parameters > Performance').'' )); + + return; } $unidentified = new Group(Configuration::get('PS_UNIDENTIFIED_GROUP')); diff --git a/controllers/admin/AdminPPreferencesController.php b/controllers/admin/AdminPPreferencesController.php index e671522e2..1ea8b3f50 100644 --- a/controllers/admin/AdminPPreferencesController.php +++ b/controllers/admin/AdminPPreferencesController.php @@ -400,10 +400,8 @@ class AdminPPreferencesControllerCore extends AdminController 'hint' => $this->l('Enable to display Amenities filter.'), 'validation' => 'isBool', 'cast' => 'intval', - 'disabled' => (bool) !Feature::isFeatureActive(), 'required' => false, 'type' => 'bool', - 'desc' => (bool) !Feature::isFeatureActive() ? sprintf($this->l('The feature Features/Amenities has been disabled. You can enable it from %s page.'), ''.$this->l('Advanced Parameters > Performance').'') : '', ), 'SHOW_PRICE_FILTER' => array( 'title' => $this->l('Show Price filter'), diff --git a/modules/wkhotelfilterblock/views/templates/hook/htlfilterblock.tpl b/modules/wkhotelfilterblock/views/templates/hook/htlfilterblock.tpl index 6e5a207a7..7db81900d 100644 --- a/modules/wkhotelfilterblock/views/templates/hook/htlfilterblock.tpl +++ b/modules/wkhotelfilterblock/views/templates/hook/htlfilterblock.tpl @@ -19,7 +19,7 @@
- {if isset($config) && $config['PS_FEATURE_FEATURE_ACTIVE'] && $config['SHOW_AMENITIES_FILTER']} + {if isset($config) && $config['SHOW_AMENITIES_FILTER']}
diff --git a/modules/wkhotelfilterblock/wkhotelfilterblock.php b/modules/wkhotelfilterblock/wkhotelfilterblock.php index f93fb05d8..e2fa40f38 100644 --- a/modules/wkhotelfilterblock/wkhotelfilterblock.php +++ b/modules/wkhotelfilterblock/wkhotelfilterblock.php @@ -153,7 +153,6 @@ class wkhotelfilterblock extends Module return array( 'SHOW_AMENITIES_FILTER' => Configuration::get('SHOW_AMENITIES_FILTER'), 'SHOW_PRICE_FILTER' => Configuration::get('SHOW_PRICE_FILTER'), - 'PS_FEATURE_FEATURE_ACTIVE' => Feature::isFeatureActive(), ); } } From 82f3a47735b7103ff87e04eee0f07feaff94a02e Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 18 Dec 2023 19:50:15 +0530 Subject: [PATCH 4/5] Update renderList() --- controllers/admin/AdminGroupsController.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/controllers/admin/AdminGroupsController.php b/controllers/admin/AdminGroupsController.php index 2be4a8c85..10cb702be 100644 --- a/controllers/admin/AdminGroupsController.php +++ b/controllers/admin/AdminGroupsController.php @@ -566,15 +566,6 @@ class AdminGroupsControllerCore extends AdminController public function renderList() { - if (!Group::isFeatureActive()) { - $this->displayWarning(sprintf( - $this->l('The feature Customer Groups has been disabled. You can enable it from %s page.'), - ''.$this->l('Advanced Parameters > Performance').'' - )); - - return; - } - $unidentified = new Group(Configuration::get('PS_UNIDENTIFIED_GROUP')); $guest = new Group(Configuration::get('PS_GUEST_GROUP')); $default = new Group(Configuration::get('PS_CUSTOMER_GROUP')); From 0c7c310f7e43485c760ec377898159517b867aea Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 15 Jan 2024 18:58:47 +0530 Subject: [PATCH 5/5] Fix Groups issue for Catalog and Advanced Price Rules --- classes/SpecificPrice.php | 10 ++++++++-- .../classes/HotelCartBookingData.php | 18 +++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/classes/SpecificPrice.php b/classes/SpecificPrice.php index 38119ed81..b09fcb80e 100644 --- a/classes/SpecificPrice.php +++ b/classes/SpecificPrice.php @@ -175,6 +175,12 @@ class SpecificPriceCore extends ObjectModel $select = '('; $priority = SpecificPrice::getPriority($id_product); + if (!Group::isFeatureActive()) { + if (($key = array_search('id_group', $priority)) !== false) { + unset($priority[$key]); + } + } + foreach (array_reverse($priority) as $k => $field) { if (!empty($field)) { $select .= ' IF (`'.bqSQL($field).'` = '.(int)$$field.', '.pow(2, $k + 1).', 0) + '; @@ -353,8 +359,8 @@ class SpecificPriceCore extends ObjectModel WHERE `id_shop` '.self::formatIntInQuery(0, $id_shop).' AND `id_currency` '.self::formatIntInQuery(0, $id_currency).' AND - `id_country` '.self::formatIntInQuery(0, $id_country).' AND - `id_group` '.self::formatIntInQuery(0, $id_group).' '.$query_extra.' + `id_country` '.self::formatIntInQuery(0, $id_country). + (Group::isFeatureActive() ? ' AND `id_group` '.self::formatIntInQuery(0, $id_group) : '').' '.$query_extra.' AND IF(`from_quantity` > 1, `from_quantity`, 0) <= '; $query .= (Configuration::get('PS_QTY_DISCOUNT_ON_COMBINATION') || !$id_cart || !$real_quantity) ? (int)$quantity : max(1, (int)$real_quantity); diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php index afae39dcb..9c2bc63ea 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -1138,9 +1138,9 @@ class HotelCartBookingData extends ObjectModel foreach ($featurePricePriority as $priority) { if ($priority == 'specific_date') { if ($featurePrice = Db::getInstance()->getRow( - 'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp - INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg - ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.') + 'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp'. + (Group::isFeatureActive() ? ' INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg + ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')' : '').' WHERE fp.`id_cart` = 0 AND fp.`id_product`='.(int) $id_product.' AND fp.`active`=1 AND fp.`date_selection_type` = '.(int) HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_SPECIFIC.' AND fp.`date_from` = \''.pSQL($date).'\'' )) { @@ -1148,9 +1148,9 @@ class HotelCartBookingData extends ObjectModel } } elseif ($priority == 'special_day') { if ($featurePrice = Db::getInstance()->executeS( - 'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp - INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg - ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.') + 'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp'. + (Group::isFeatureActive() ? ' INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg + ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')' : '').' WHERE fp.`id_cart` = 0 AND fp.`id_product`='.(int) $id_product.' AND fp.`is_special_days_exists`=1 AND fp.`active`=1 AND fp.`date_from` <= \''.pSQL($date).'\' AND fp.`date_to` >= \''.pSQL($date).'\'' @@ -1164,9 +1164,9 @@ class HotelCartBookingData extends ObjectModel } } elseif ($priority == 'date_range') { if ($featurePrice = Db::getInstance()->getRow( - 'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp - INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg - ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.') + 'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` fp'. + (Group::isFeatureActive() ? ' INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` fpg + ON (fp.`id_feature_price` = fpg.`id_feature_price` AND fpg.`id_group` = '.(int) $id_group.')' : '').' WHERE fp.`id_cart` = 0 AND fp.`id_product`='.(int) $id_product.' AND fp.`date_selection_type` = '.(int) HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE.' AND `is_special_days_exists`=0 AND `active`=1 AND fp.`date_from` <= \''.pSQL($date).'\' AND fp.`date_to` >= \''.pSQL($date).'\''