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} +
-