From b261a7646444d9b049a44770407a1f0823e7132b Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Wed, 15 May 2024 20:32:54 +0530 Subject: [PATCH 1/5] Updated: QloApps cleaner | Added hook for data cleaning in other module and fixed minor issues --- modules/qlocleaner/qlocleaner.php | 43 ++++++++++++------- modules/qlocleaner/views/js/index.php | 29 +++++++++++++ .../qlocleaner/views/js/qlocleaner_config.js | 25 +++++++++++ .../classes/QhrHotelReviewDb.php | 14 ++++++ modules/qlohotelreview/qlohotelreview.php | 8 ++++ modules/wkhotelroom/classes/WkHotelRoomDb.php | 7 +++ modules/wkhotelroom/wkhotelroom.php | 12 +++++- 7 files changed, 121 insertions(+), 17 deletions(-) create mode 100644 modules/qlocleaner/views/js/index.php create mode 100644 modules/qlocleaner/views/js/qlocleaner_config.js diff --git a/modules/qlocleaner/qlocleaner.php b/modules/qlocleaner/qlocleaner.php index c934346dd..25c9e601c 100644 --- a/modules/qlocleaner/qlocleaner.php +++ b/modules/qlocleaner/qlocleaner.php @@ -50,6 +50,28 @@ class QloCleaner extends Module $this->secure_key = Tools::encrypt($this->name); } + public function install() + { + if (!parent::install() + || !$this->registerHook('actionAdminControllerSetMedia') + ) { + return false; + } + return true; + } + + public function hookActionAdminControllerSetMedia() + { + if (Tools::getValue('controller') == 'AdminModules' + && Tools::getValue('configure') == $this->name + ) { + Media::addJsDef(array( + 'confirm_txt' => $this->l('Are you sure, you want to perform the following operation?') + )); + $this->context->controller->addJS($this->_path.'views/js/qlocleaner_config.js'); + } + } + public function getContent() { $html = '

'.$this->l('Be really careful with this tool - There is no possible rollback!').'

'; @@ -61,6 +83,7 @@ class QloCleaner extends Module } else { $conf = $this->l('Nothing that need to be fixed please run database cleaning to clean your database'); } + Hook::exec('actionCleanData', array('method' => 'checkAndFix')); $html .= $this->displayConfirmation($conf); } elseif (Tools::isSubmit('submitCleanAndOptimize')) { $logs = self::cleanAndOptimize(); @@ -70,12 +93,15 @@ class QloCleaner extends Module } else { $conf = $this->l('Nothing that need to be cleaned'); } + Hook::exec('actionCleanData', array('method' => 'cleanAndOptimize')); $html .= $this->displayConfirmation($conf); } elseif (Tools::getValue('submitTruncateCatalog') && Tools::getValue('checkTruncateCatalog')) { self::truncate('catalog'); + Hook::exec('actionCleanData', array('method' => 'truncateCatalog')); $html .= $this->displayConfirmation($this->l('Catalog truncated successfuly, please run functional Integrity constraints to clean the database.')); } elseif (Tools::getValue('submitTruncateSales') && Tools::getValue('checkTruncateSales')) { self::truncate('sales'); + Hook::exec('actionCleanData', array('method' => 'truncateSales')); $html .= $this->displayConfirmation($this->l('Orders and customers truncated successfuly, please run functional Integrity constraints to clean the database')); } @@ -314,21 +340,6 @@ class QloCleaner extends Module } } - // Delete Qlo tables - $query = 'DELETE FROM `'._DB_PREFIX_.'htl_order_refund_rules`'; - if (Db::getInstance()->Execute($query)) { - if ($affected_rows = Db::getInstance()->Affected_Rows()) { - $logs[$query] = $affected_rows; - } - } - - $query = 'DELETE FROM `'._DB_PREFIX_.'htl_order_refund_rules_lang`'; - if (Db::getInstance()->Execute($query)) { - if ($affected_rows = Db::getInstance()->Affected_Rows()) { - $logs[$query] = $affected_rows; - } - } - $parents = Db::getInstance()->ExecuteS('SELECT DISTINCT id_parent FROM '._DB_PREFIX_.'tab'); foreach ($parents as $parent) { $children = Db::getInstance()->ExecuteS('SELECT id_tab FROM '._DB_PREFIX_.'tab WHERE id_parent = '.(int)$parent['id_parent'].' ORDER BY IF(class_name IN ("AdminHome", "AdminDashboard"), 1, 2), position ASC'); @@ -845,6 +856,8 @@ class QloCleaner extends Module 'htl_room_type_service_product_order_detail', 'htl_room_type_service_product_cart_detail', 'htl_hotel_service_product_cart_detail', + 'htl_order_refund_rules', + 'htl_order_refund_rules_lang', ); } } diff --git a/modules/qlocleaner/views/js/index.php b/modules/qlocleaner/views/js/index.php new file mode 100644 index 000000000..5d9e49caf --- /dev/null +++ b/modules/qlocleaner/views/js/index.php @@ -0,0 +1,29 @@ +execute('TRUNCATE TABLE `'._DB_PREFIX_.bqSQL($table).'`'); + } + QhrHotelReview::cleanImagesDirectory(); + } + public static function getModuleDefaultConfig() { return array( diff --git a/modules/qlohotelreview/qlohotelreview.php b/modules/qlohotelreview/qlohotelreview.php index e040fa903..619cd2bc5 100644 --- a/modules/qlohotelreview/qlohotelreview.php +++ b/modules/qlohotelreview/qlohotelreview.php @@ -72,6 +72,7 @@ class QloHotelReview extends Module 'displayBookingAction', 'displayBackOfficeHeader', 'displayAdminAfterHeader', + 'actionCleanData', ) ); } @@ -278,6 +279,13 @@ class QloHotelReview extends Module return $this->display(__FILE__, 'product-tab-content.tpl'); } + public function hookActionCleanData($params) + { + if ($params['method'] == 'truncateCatalog' || $params['method'] == 'truncateSales') { + QhrHotelReviewDb::truncateUserData(); + } + } + public function installModuleTabs() { $tabs = array( diff --git a/modules/wkhotelroom/classes/WkHotelRoomDb.php b/modules/wkhotelroom/classes/WkHotelRoomDb.php index a21f82dae..740811ab9 100644 --- a/modules/wkhotelroom/classes/WkHotelRoomDb.php +++ b/modules/wkhotelroom/classes/WkHotelRoomDb.php @@ -56,4 +56,11 @@ class WkHotelRoomDb `'._DB_PREFIX_.'htl_room_block_data`; '); } + + public static function truncateTables() + { + return DB::getInstance()->execute( + 'TRUNCATE TABLE `'._DB_PREFIX_.'htl_room_block_data`; + '); + } } diff --git a/modules/wkhotelroom/wkhotelroom.php b/modules/wkhotelroom/wkhotelroom.php index 2df6101fd..b28c2d028 100644 --- a/modules/wkhotelroom/wkhotelroom.php +++ b/modules/wkhotelroom/wkhotelroom.php @@ -141,6 +141,13 @@ class WkHotelRoom extends Module } } + public function hookActionCleanData($params) + { + if ($params['method'] == 'truncateCatalog') { + WkHotelRoomDb::truncateTables(); + } + } + public function callInstallTab() { //Controllers which are to be used in this modules but we have not to create tab for those controllers... @@ -198,7 +205,8 @@ class WkHotelRoom extends Module 'actionProductDelete', 'displayFooterExploreSectionHook', 'actionProductSave', - 'actionObjectLanguageAddAfter' + 'actionObjectLanguageAddAfter', + 'actionCleanData', ) ); } @@ -220,7 +228,7 @@ class WkHotelRoom extends Module } return true; } - + public function deleteConfigKeys() { $configVars = array( From 0ca116b267dd05a0c10e6819202c0d609cea2cf4 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Wed, 22 May 2024 17:36:29 +0530 Subject: [PATCH 2/5] Fixed: The cleaner module not deleting the hotel images --- modules/qlocleaner/qlocleaner.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/qlocleaner/qlocleaner.php b/modules/qlocleaner/qlocleaner.php index 25c9e601c..4ef3a564c 100644 --- a/modules/qlocleaner/qlocleaner.php +++ b/modules/qlocleaner/qlocleaner.php @@ -270,6 +270,11 @@ class QloCleaner extends Module } } + Image::deleteAllImages(_PS_HOTEL_IMG_DIR_); + if (!file_exists(_PS_HOTEL_IMG_DIR_)) { + mkdir(_PS_HOTEL_IMG_DIR_); + } + // Delete qlo modules's images QcCleanerHelper::deleteFolderImages( _PS_MODULE_DIR_.'wkabouthotelblock/views/img/hotel_interior/' From 4bc7cf7f13c56a208fbde2744e3cfd2c7c37f509 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Wed, 7 Aug 2024 12:58:08 +0530 Subject: [PATCH 3/5] text changes --- modules/qlocleaner/qlocleaner.php | 6 +++--- modules/qlohotelreview/qlohotelreview.php | 2 +- modules/wkhotelroom/wkhotelroom.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/qlocleaner/qlocleaner.php b/modules/qlocleaner/qlocleaner.php index 4ef3a564c..0bc30a76b 100644 --- a/modules/qlocleaner/qlocleaner.php +++ b/modules/qlocleaner/qlocleaner.php @@ -66,7 +66,7 @@ class QloCleaner extends Module && Tools::getValue('configure') == $this->name ) { Media::addJsDef(array( - 'confirm_txt' => $this->l('Are you sure, you want to perform the following operation?') + 'confirm_txt' => $this->l('Are you sure, you want to perform the following action?') )); $this->context->controller->addJS($this->_path.'views/js/qlocleaner_config.js'); } @@ -97,11 +97,11 @@ class QloCleaner extends Module $html .= $this->displayConfirmation($conf); } elseif (Tools::getValue('submitTruncateCatalog') && Tools::getValue('checkTruncateCatalog')) { self::truncate('catalog'); - Hook::exec('actionCleanData', array('method' => 'truncateCatalog')); + Hook::exec('actionCleanData', array('method' => 'catalog')); $html .= $this->displayConfirmation($this->l('Catalog truncated successfuly, please run functional Integrity constraints to clean the database.')); } elseif (Tools::getValue('submitTruncateSales') && Tools::getValue('checkTruncateSales')) { self::truncate('sales'); - Hook::exec('actionCleanData', array('method' => 'truncateSales')); + Hook::exec('actionCleanData', array('method' => 'sales')); $html .= $this->displayConfirmation($this->l('Orders and customers truncated successfuly, please run functional Integrity constraints to clean the database')); } diff --git a/modules/qlohotelreview/qlohotelreview.php b/modules/qlohotelreview/qlohotelreview.php index c3b90987a..e20a25ee1 100644 --- a/modules/qlohotelreview/qlohotelreview.php +++ b/modules/qlohotelreview/qlohotelreview.php @@ -282,7 +282,7 @@ class QloHotelReview extends Module public function hookActionCleanData($params) { - if ($params['method'] == 'truncateCatalog' || $params['method'] == 'truncateSales') { + if ($params['method'] == 'catalog' || $params['method'] == 'sales') { QhrHotelReviewDb::truncateUserData(); } } diff --git a/modules/wkhotelroom/wkhotelroom.php b/modules/wkhotelroom/wkhotelroom.php index b28c2d028..ac5bbcc5c 100644 --- a/modules/wkhotelroom/wkhotelroom.php +++ b/modules/wkhotelroom/wkhotelroom.php @@ -143,7 +143,7 @@ class WkHotelRoom extends Module public function hookActionCleanData($params) { - if ($params['method'] == 'truncateCatalog') { + if ($params['method'] == 'catalog') { WkHotelRoomDb::truncateTables(); } } From b3652d054fa4a0363c896adfbd13203370721a57 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Wed, 7 Aug 2024 17:02:12 +0530 Subject: [PATCH 4/5] update file licence --- modules/qlocleaner/views/js/index.php | 12 ++++++------ modules/qlocleaner/views/js/qlocleaner_config.js | 13 ++++++------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/modules/qlocleaner/views/js/index.php b/modules/qlocleaner/views/js/index.php index 5d9e49caf..16488e369 100644 --- a/modules/qlocleaner/views/js/index.php +++ b/modules/qlocleaner/views/js/index.php @@ -1,21 +1,21 @@ +* @copyright Since 2010 Webkul IN +* @license https://store.webkul.com/license.html */ header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); diff --git a/modules/qlocleaner/views/js/qlocleaner_config.js b/modules/qlocleaner/views/js/qlocleaner_config.js index d2a0b913a..ebd5ce3f4 100644 --- a/modules/qlocleaner/views/js/qlocleaner_config.js +++ b/modules/qlocleaner/views/js/qlocleaner_config.js @@ -1,23 +1,22 @@ /** -* 2010-2024 Webkul. +* Since 2010 Webkul. * * NOTICE OF LICENSE * * All right is reserved, -* Please go through LICENSE.txt file inside our module +* Please go through this link for complete license : https://store.webkul.com/license.html * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade this module to newer * versions in the future. If you wish to customize this module for your -* needs please refer to CustomizationPolicy.txt file inside our module for more information. +* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information. * -* @author Webkul IN -* @copyright 2010-2024 Webkul IN -* @license LICENSE.txt +* @author Webkul IN +* @copyright Since 2010 Webkul IN +* @license https://store.webkul.com/license.html */ - $(document).ready(function () { $('#module_form').on('submit', function() { return confirm(confirm_txt); From 50c0940b8fba46636323766b1d24f04e8b01ffcb Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 16 Aug 2024 19:44:31 +0530 Subject: [PATCH 5/5] prevent deletion of room type features and hotel features during catalog cleaning --- modules/qlocleaner/qlocleaner.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/modules/qlocleaner/qlocleaner.php b/modules/qlocleaner/qlocleaner.php index 0bc30a76b..adfe64e51 100644 --- a/modules/qlocleaner/qlocleaner.php +++ b/modules/qlocleaner/qlocleaner.php @@ -769,12 +769,7 @@ class QloCleaner extends Module 'customization_field', 'customization_field_lang', 'customized_data', - 'feature', - 'feature_lang', 'feature_product', - 'feature_shop', - 'feature_value', - 'feature_value_lang', 'pack', 'search_index', 'search_word', @@ -794,8 +789,6 @@ class QloCleaner extends Module 'htl_branch_info_lang', 'htl_image', 'htl_branch_features', - 'htl_features', - 'htl_features_lang', 'htl_advance_payment', 'htl_branch_refund_rules', 'htl_order_restrict_date',