From 2c54a1ea4e195dec9b6725bdf3bd0131c12c7b0d Mon Sep 17 00:00:00 2001 From: "abhishek.qlo" Date: Thu, 15 Oct 2026 12:49:55 +0530 Subject: [PATCH] Updated the version and the code for the warnings and error messages --- modules/qlogooglehotelconnector/CHANGELOG.txt | 2 +- modules/qlogooglehotelconnector/README.md | 4 +- .../classes/QghcPropertyService.php | 14 ++++-- .../AdminGoogleHotelConfigController.php | 28 +++++++++++ .../qlogooglehotelconnector.php | 28 ++++++++--- .../views/css/admin/qlo_ghc_admin.css | 3 ++ .../views/templates/admin/config.tpl | 49 +++++++++++++++++-- .../templates/hook/dashboard_notification.tpl | 18 +++---- .../templates/hook/dashboard_top_warning.tpl | 48 ++++++++++++------ .../templates/hook/hotel_form_top_warning.tpl | 23 ++++----- .../templates/hook/hotel_list_warning.tpl | 45 ++++++++++++----- 11 files changed, 192 insertions(+), 70 deletions(-) diff --git a/modules/qlogooglehotelconnector/CHANGELOG.txt b/modules/qlogooglehotelconnector/CHANGELOG.txt index 00f06a35e..775e6979a 100644 --- a/modules/qlogooglehotelconnector/CHANGELOG.txt +++ b/modules/qlogooglehotelconnector/CHANGELOG.txt @@ -1,3 +1,3 @@ --------------------------------------------------------------- -# V1.0.0 | COMPATIBLE:: QloApps V1.8.x +# V4.0.0 | COMPATIBLE:: QloApps V1.8.x --------------------------------------------------------------- diff --git a/modules/qlogooglehotelconnector/README.md b/modules/qlogooglehotelconnector/README.md index 20c773511..107f1dce8 100644 --- a/modules/qlogooglehotelconnector/README.md +++ b/modules/qlogooglehotelconnector/README.md @@ -19,9 +19,9 @@ https://qloapps.com/addons/ ### Module Versions and Compatibility: -- **Current version:** `1.0.0` +- **Current version:** `4.0.0` -- Module version `1.0.0` compatible with QloApps version `1.8.x` +- Module version `4.0.0` compatible with QloApps version `1.8.x` ### Refund Policy: diff --git a/modules/qlogooglehotelconnector/classes/QghcPropertyService.php b/modules/qlogooglehotelconnector/classes/QghcPropertyService.php index fb160a2c0..9ac9e8d88 100644 --- a/modules/qlogooglehotelconnector/classes/QghcPropertyService.php +++ b/modules/qlogooglehotelconnector/classes/QghcPropertyService.php @@ -175,18 +175,26 @@ class QghcPropertyService if ($property) { if ((int) $property->google_status === QghcProperty::GOOGLE_STATUS_FAILED) { return array($property->failure_reason - ? self::l('Google Hotel: Google could not verify this hotel — ') . $property->failure_reason - : self::l('Google Hotel: Google reported an issue connecting this hotel. Please contact support.')); + ? self::l('Google could not verify this hotel — ') . $property->failure_reason + : self::l('Google reported an issue connecting this hotel. Please contact support.')); } return array(); } $errors = self::validateRequiredFields($idHotel, $idLang); if ($errors) { + // Shown as a list under a "Need to fix" heading, so the "Google Hotel: " prefix is redundant. + $prefix = self::l('Google Hotel: '); + foreach ($errors as $key => $error) { + if (strpos($error, $prefix) === 0) { + $errors[$key] = Tools::substr($error, Tools::strlen($prefix)); + } + } + return $errors; } - return array(self::l('Google Hotel: This hotel is not yet enabled for Google Hotel.')); + return array(self::l('This hotel is not yet enabled for Google Hotel.')); } /** diff --git a/modules/qlogooglehotelconnector/controllers/admin/AdminGoogleHotelConfigController.php b/modules/qlogooglehotelconnector/controllers/admin/AdminGoogleHotelConfigController.php index e5cd5c16a..8cc052e85 100644 --- a/modules/qlogooglehotelconnector/controllers/admin/AdminGoogleHotelConfigController.php +++ b/modules/qlogooglehotelconnector/controllers/admin/AdminGoogleHotelConfigController.php @@ -74,6 +74,22 @@ class AdminGoogleHotelConfigController extends ModuleAdminController } } + /** True when the current admin request came over HTTPS (directly or via a TLS-terminating proxy). */ + protected function isSecureRequest() + { + if (Tools::usingSecureMode()) { + return true; + } + + if (empty($_SERVER['HTTP_X_FORWARDED_PROTO'])) { + return false; + } + + $protos = explode(',', $_SERVER['HTTP_X_FORWARDED_PROTO']); + + return strtolower(trim($protos[0])) === 'https'; + } + /** Renders the configuration page into the admin layout. */ public function initContent() { @@ -129,6 +145,8 @@ class AdminGoogleHotelConfigController extends ModuleAdminController 'configs' => $configs, 'ws_key' => $wsKey, 'is_connected' => $isConnected, + 'is_secure' => $this->isSecureRequest(), + 'ssl_settings_url' => $this->context->link->getAdminLink('AdminPreferences'), 'action_url' => $this->context->link->getAdminLink('AdminGoogleHotelConfig'), 'cron_url' => $cronUrl, 'hotel_list_url' => $hotelEditBase, @@ -143,6 +161,11 @@ class AdminGoogleHotelConfigController extends ModuleAdminController return; } + if (!$this->isSecureRequest()) { + $this->errors[] = $this->l('Connection cannot be created from an unsecure (HTTP) server. Please use HTTPS.'); + return; + } + $wsKey = trim(Tools::getValue(QloGoogleHotelConnector::CONFIG_WS_KEY)); $pmsUrl = Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__; @@ -219,6 +242,11 @@ class AdminGoogleHotelConfigController extends ModuleAdminController return; } + if (!$this->isSecureRequest()) { + $this->errors[] = $this->l('The webservice key cannot be regenerated from an unsecure (HTTP) server. Please use HTTPS.'); + return; + } + $newKey = QghcWebserviceSetup::regenerateKey(); if (!$newKey) { $this->errors[] = $this->l('Failed to regenerate the webservice key.'); diff --git a/modules/qlogooglehotelconnector/qlogooglehotelconnector.php b/modules/qlogooglehotelconnector/qlogooglehotelconnector.php index ceb554e58..30fb1b909 100644 --- a/modules/qlogooglehotelconnector/qlogooglehotelconnector.php +++ b/modules/qlogooglehotelconnector/qlogooglehotelconnector.php @@ -42,7 +42,7 @@ class QloGoogleHotelConnector extends Module { $this->name = 'qlogooglehotelconnector'; $this->tab = 'administration'; - $this->version = '1.0.0'; + $this->version = '4.0.0'; $this->author = 'Webkul'; $this->need_instance = 0; $this->bootstrap = true; @@ -387,10 +387,18 @@ class QloGoogleHotelConnector extends Module { $idLang = (int) $this->context->language->id; + $hotelEditBase = $this->context->link->getAdminLink('AdminAddHotel'); + $hotels = array(); + foreach (QghcPropertyService::getHotelsWithIssues($idLang) as $idHotel => $hotelName) { + $hotels[] = array( + 'name' => $hotelName, + 'url' => $hotelEditBase . '&id=' . (int) $idHotel . '&updatehtl_branch_info', + ); + } + $this->context->smarty->assign(array( 'is_connected' => (int) Configuration::get(self::CONFIG_STATUS) === QghcProperty::GOOGLE_STATUS_CONNECTED, - 'hotel_names' => array_values(QghcPropertyService::getHotelsWithIssues($idLang)), - 'hotel_list_url' => $this->context->link->getAdminLink('AdminAddHotel'), + 'hotels' => $hotels, 'config_url' => $this->context->link->getAdminLink('AdminGoogleHotelConfig'), )); @@ -402,16 +410,22 @@ class QloGoogleHotelConnector extends Module { $idLang = (int) $this->context->language->id; $isConnected = (int) Configuration::get(self::CONFIG_STATUS) === QghcProperty::GOOGLE_STATUS_CONNECTED; - $hotelNames = array_values(QghcPropertyService::getHotelsWithIssues($idLang)); + $editBaseUrl = $this->context->link->getAdminLink('AdminAddHotel'); + $hotels = array(); + foreach (QghcPropertyService::getHotelsWithIssues($idLang) as $idHotel => $hotelName) { + $hotels[] = array( + 'hotel_name' => $hotelName, + 'edit_url' => $editBaseUrl . '&id=' . (int) $idHotel . '&updatehtl_branch_info', + ); + } - if ($isConnected && !$hotelNames) { + if ($isConnected && !$hotels) { return ''; } $this->context->smarty->assign(array( 'is_connected' => $isConnected, - 'hotel_names' => $hotelNames, - 'hotel_list_url' => $this->context->link->getAdminLink('AdminAddHotel'), + 'hotels_with_issues' => $hotels, 'config_url' => $this->context->link->getAdminLink('AdminGoogleHotelConfig'), )); diff --git a/modules/qlogooglehotelconnector/views/css/admin/qlo_ghc_admin.css b/modules/qlogooglehotelconnector/views/css/admin/qlo_ghc_admin.css index 6264f8f88..6f7763d8c 100644 --- a/modules/qlogooglehotelconnector/views/css/admin/qlo_ghc_admin.css +++ b/modules/qlogooglehotelconnector/views/css/admin/qlo_ghc_admin.css @@ -110,6 +110,9 @@ table.qghc_api_log th.actions .pull-right { .qlo-ghc-col-padded { padding-top: 6px; } .qlo-ghc-status-label { font-size: 12px; padding: 5px 10px; } .qlo-ghc-missing-list { margin: 8px 0 0 0; padding-left: 20px; } +.qlo-ghc-warning-title { margin-top: 6px; } +.qlo-ghc-warning-title:first-child { margin-top: 0; } +.qlo-ghc-warning-title + .qlo-ghc-missing-list { margin-top: 2px; } .qlo-ghc-switch-disabled { opacity: 0.5; cursor: not-allowed; } /* Double class to out-specify core's ".bootstrap p { margin: ... }" without !important. */ .qlo-ghc-helpblock-top.qlo-ghc-helpblock-top { margin-top: 10px; } diff --git a/modules/qlogooglehotelconnector/views/templates/admin/config.tpl b/modules/qlogooglehotelconnector/views/templates/admin/config.tpl index 68816666c..3b52dda84 100644 --- a/modules/qlogooglehotelconnector/views/templates/admin/config.tpl +++ b/modules/qlogooglehotelconnector/views/templates/admin/config.tpl @@ -20,6 +20,14 @@ * @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 *} +{if !$is_secure} +
+ {l s='Unsecure server detected.' mod='qlogooglehotelconnector'} + {l s='Your store is not running on a secure (HTTPS) server, so the connection with Google Hotel cannot be created or updated.' mod='qlogooglehotelconnector'} + {l s='Please enable HTTPS to continue.' mod='qlogooglehotelconnector'} +
+{/if} + {* ── Google Hotel Setup ───────────────────────────────────────────────── *}
@@ -51,9 +59,10 @@ {l s='Important:' mod='qlogooglehotelconnector'} {l s='This key was automatically generated for the Google Hotel connection. Please do not change the permissions of this webservice key.' mod='qlogooglehotelconnector'} {if !$is_connected} -

- {l s='To complete the setup, click' mod='qlogooglehotelconnector'} - {l s='Create Connection' mod='qlogooglehotelconnector'}. +
+ {l s='To complete the setup, click' mod='qlogooglehotelconnector'} + {l s='Create Connection' mod='qlogooglehotelconnector'}. +
{/if}
@@ -70,7 +79,7 @@ placeholder="{l s='Enter your webservice key' mod='qlogooglehotelconnector'}" /> {if $ws_key}

- @@ -112,7 +121,7 @@ {else} {/if} - + {if !$is_connected} + {l s='Connect to Google Hotel to get more commission-free direct bookings.' mod='qlogooglehotelconnector'} +  {l s='Connect in Google Hotel Setup' mod='qlogooglehotelconnector'} + {/if} - {if !empty($hotel_names)} -

- {l s='The following hotels are not listed on Google Hotel:' mod='qlogooglehotelconnector'} + {if !empty($hotels_with_issues)} +
{l s='The following hotels are not listed on Google Hotel:' mod='qlogooglehotelconnector'}
- {l s='View Hotel List' mod='qlogooglehotelconnector'} -
- {/if} + {/if} + + diff --git a/modules/qlogooglehotelconnector/views/templates/hook/hotel_form_top_warning.tpl b/modules/qlogooglehotelconnector/views/templates/hook/hotel_form_top_warning.tpl index 8fdb2b71e..fca379cce 100644 --- a/modules/qlogooglehotelconnector/views/templates/hook/hotel_form_top_warning.tpl +++ b/modules/qlogooglehotelconnector/views/templates/hook/hotel_form_top_warning.tpl @@ -20,22 +20,19 @@ * @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 *}
- {if !$is_connected} -
- {l s='Not connected to the Google Hotel Center.' mod='qlogooglehotelconnector'} - {l s='Hotels cannot sync with Google Hotel Ads until this is fixed.' mod='qlogooglehotelconnector'} -  {l s='Fix in Google Hotel Setup' mod='qlogooglehotelconnector'} -
- {/if} +
+ {if !$is_connected} + {l s='Connect to Google Hotel to get more commission-free direct bookings.' mod='qlogooglehotelconnector'} +  {l s='Connect in Google Hotel Setup' mod='qlogooglehotelconnector'} + {/if} - {if !empty($issue_reasons)} -
- {l s='This hotel is not listed on Google Hotel:' mod='qlogooglehotelconnector'} + {if !empty($issue_reasons)} +
{l s='Need to fix the below mentioned issues:' mod='qlogooglehotelconnector'}
    {foreach from=$issue_reasons item=reason} -
  • {$reason|escape:'html':'UTF-8'} {l s='Use the Google Hotel tab below to enable it.' mod='qlogooglehotelconnector'}
  • +
  • {$reason|escape:'html':'UTF-8'}
  • {/foreach}
-
- {/if} + {/if} +
diff --git a/modules/qlogooglehotelconnector/views/templates/hook/hotel_list_warning.tpl b/modules/qlogooglehotelconnector/views/templates/hook/hotel_list_warning.tpl index 28aed7f98..2fb0bfae1 100644 --- a/modules/qlogooglehotelconnector/views/templates/hook/hotel_list_warning.tpl +++ b/modules/qlogooglehotelconnector/views/templates/hook/hotel_list_warning.tpl @@ -19,21 +19,40 @@ * @copyright Since 2010 Webkul * @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 *} -{if !$is_connected} -
- {l s='Not connected to the Google Hotel Center.' mod='qlogooglehotelconnector'} - {l s='Hotels cannot sync with Google Hotel Ads until this is fixed.' mod='qlogooglehotelconnector'} -  {l s='Fix in Google Hotel Setup' mod='qlogooglehotelconnector'} -
-{/if} +
+ + {if !$is_connected} + {l s='Connect to Google Hotel to get more commission-free direct bookings.' mod='qlogooglehotelconnector'} +  {l s='Connect in Google Hotel Setup' mod='qlogooglehotelconnector'} + {/if} -{if !empty($hotels_with_issues)} -
- {l s='The following hotels are not listed on Google Hotel:' mod='qlogooglehotelconnector'} + {if !empty($hotels_with_issues)} +
{l s='The following hotels are not listed on Google Hotel:' mod='qlogooglehotelconnector'}
-
-{/if} + {/if} +
+