diff --git a/.htaccess b/.htaccess
new file mode 100644
index 0000000..6d66d9b
--- /dev/null
+++ b/.htaccess
@@ -0,0 +1,15 @@
+# Apache 2.2
+
+ Order deny,allow
+ Deny from all
+
+ Allow from all
+
+
+# Apache 2.4
+
+ Require all denied
+
+ Require all granted
+
+
\ No newline at end of file
diff --git a/backward_compatibility/Context.php b/backward_compatibility/Context.php
index 0051db4..88751ba 100644
--- a/backward_compatibility/Context.php
+++ b/backward_compatibility/Context.php
@@ -24,6 +24,10 @@
* International Registered Trademark & Property of PrestaShop SA
*/
+if (!defined('_PS_VERSION_')) {
+ exit;
+}
+
if ((bool)Configuration::get('PS_MOBILE_DEVICE')) {
require_once(_PS_MODULE_DIR_ . '/mobile_theme/Mobile_Detect.php');
}
diff --git a/backward_compatibility/Display.php b/backward_compatibility/Display.php
index 6ff27f1..0bb1da7 100644
--- a/backward_compatibility/Display.php
+++ b/backward_compatibility/Display.php
@@ -24,6 +24,10 @@
* International Registered Trademark & Property of PrestaShop SA
*/
+if (!defined('_PS_VERSION_')) {
+ exit;
+}
+
/**
* Class allow to display tpl on the FO
*/
diff --git a/backward_compatibility/backward.php b/backward_compatibility/backward.php
index 10d67e0..410ec83 100644
--- a/backward_compatibility/backward.php
+++ b/backward_compatibility/backward.php
@@ -29,6 +29,10 @@
* Need to be called for each module in 1.4
*/
+if (!defined('_PS_VERSION_')) {
+ exit;
+}
+
// Get out if the context is already defined
if (!in_array('Context', get_declared_classes())) {
require_once(dirname(__FILE__).'/Context.php');
diff --git a/composer.json b/composer.json
index 8d8dfaf..ca794a1 100644
--- a/composer.json
+++ b/composer.json
@@ -10,7 +10,10 @@
"require": {
"php": ">=5.6.0",
"smartsupp/chat-code-generator": "^1.0",
- "smartsupp/php-partner-client": "^1.0"
+ "smartsupp/php-partner-client": "^1.0",
+ "prestashop/prestashop-accounts-installer": "^1.0.1",
+ "prestashop/module-lib-service-container": "v2.0",
+ "prestashop/module-lib-mbo-installer": "^3.0.0"
},
"autoload": {
"psr-4": {
diff --git a/composer.lock b/composer.lock
index 509e8be..9e60e34 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,27 +4,222 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "8c62af103569bb882c558226bd17bdcd",
+ "content-hash": "02a96e9f067ad2b321bee380e3b9e910",
"packages": [
+ {
+ "name": "prestashop/module-lib-cache-directory-provider",
+ "version": "v1.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/PrestaShopCorp/module-lib-cache-directory-provider.git",
+ "reference": "34a577b66a7e52ae16d6f40efd1db17290bad453"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/PrestaShopCorp/module-lib-cache-directory-provider/zipball/34a577b66a7e52ae16d6f40efd1db17290bad453",
+ "reference": "34a577b66a7e52ae16d6f40efd1db17290bad453",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.6.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~5.7"
+ },
+ "type": "project",
+ "autoload": {
+ "psr-4": {
+ "PrestaShop\\ModuleLibCacheDirectoryProvider\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "AFL-3.0"
+ ],
+ "authors": [
+ {
+ "name": "PrestaShop SA",
+ "email": "contact@prestashop.com"
+ }
+ ],
+ "description": "Cache directory provider to use on prestashop modules",
+ "keywords": [
+ "composer",
+ "modules",
+ "package",
+ "prestashop"
+ ],
+ "support": {
+ "issues": "https://github.com/PrestaShopCorp/module-lib-cache-directory-provider/issues",
+ "source": "https://github.com/PrestaShopCorp/module-lib-cache-directory-provider/tree/master"
+ },
+ "time": "2020-09-08T14:13:23+00:00"
+ },
+ {
+ "name": "prestashop/module-lib-mbo-installer",
+ "version": "v3.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/PrestaShopCorp/module-lib-mbo-installer.git",
+ "reference": "46fbb457e9241b4f8b0c3f9fdabcb9feba0d0303"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/PrestaShopCorp/module-lib-mbo-installer/zipball/46fbb457e9241b4f8b0c3f9fdabcb9feba0d0303",
+ "reference": "46fbb457e9241b4f8b0c3f9fdabcb9feba0d0303",
+ "shasum": ""
+ },
+ "require": {
+ "ext-json": "*",
+ "php": ">=5.6"
+ },
+ "require-dev": {
+ "phpstan/phpstan": "^1.9",
+ "phpunit/phpunit": "^9.5|^8.5|^5.7",
+ "prestashop/php-dev-tools": "^4.2|^3.16"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Prestashop\\ModuleLibMboInstaller\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "AFL-3.0"
+ ],
+ "authors": [
+ {
+ "name": "PrestaShop SA",
+ "email": "contact@prestashop.com"
+ },
+ {
+ "name": "Mikatux",
+ "email": "mickael@mayeur.eu"
+ }
+ ],
+ "description": "A helper to ease the download PS MBO from the Addons Marketplace",
+ "support": {
+ "issues": "https://github.com/PrestaShopCorp/module-lib-mbo-installer/issues",
+ "source": "https://github.com/PrestaShopCorp/module-lib-mbo-installer/tree/v3.0.0"
+ },
+ "time": "2025-02-24T15:19:05+00:00"
+ },
+ {
+ "name": "prestashop/module-lib-service-container",
+ "version": "v2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/PrestaShopCorp/module-lib-service-container.git",
+ "reference": "5525b56513d9ddad6e4232dfd93a24e028efdca7"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/PrestaShopCorp/module-lib-service-container/zipball/5525b56513d9ddad6e4232dfd93a24e028efdca7",
+ "reference": "5525b56513d9ddad6e4232dfd93a24e028efdca7",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.6.0",
+ "prestashop/module-lib-cache-directory-provider": "^1.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~5.7"
+ },
+ "suggest": {
+ "symfony/config": "Needed when the running PrestaShop does not already run with Symfony",
+ "symfony/dependency-injection": "Needed when the running PrestaShop does not already run with Symfony",
+ "symfony/expression-language": "Needed when the running PrestaShop does not already run with Symfony",
+ "symfony/yaml": "Needed when the running PrestaShop does not already run with Symfony"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "PrestaShop\\ModuleLibServiceContainer\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "AFL-3.0"
+ ],
+ "authors": [
+ {
+ "name": "PrestaShop SA",
+ "email": "contact@prestashop.com"
+ }
+ ],
+ "description": "Service container to use on prestashop modules",
+ "keywords": [
+ "composer",
+ "modules",
+ "package",
+ "prestashop"
+ ],
+ "support": {
+ "issues": "https://github.com/PrestaShopCorp/module-lib-service-container/issues",
+ "source": "https://github.com/PrestaShopCorp/module-lib-service-container/tree/v2.0"
+ },
+ "time": "2022-06-20T08:30:47+00:00"
+ },
+ {
+ "name": "prestashop/prestashop-accounts-installer",
+ "version": "v1.0.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/PrestaShopCorp/prestashop-accounts-installer.git",
+ "reference": "0ad934bc540558db3944a9a1e5b08b852bb46e8b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/PrestaShopCorp/prestashop-accounts-installer/zipball/0ad934bc540558db3944a9a1e5b08b852bb46e8b",
+ "reference": "0ad934bc540558db3944a9a1e5b08b852bb46e8b",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.6"
+ },
+ "require-dev": {
+ "friendsofphp/php-cs-fixer": "^2.16",
+ "fzaninotto/faker": "^1.9",
+ "phpunit/phpunit": "^5.7",
+ "prestashop/php-dev-tools": "3.*"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "PrestaShop\\PsAccountsInstaller\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "Utility package to install `ps_accounts` module or present data to trigger manual install from psx configuration page.",
+ "support": {
+ "issues": "https://github.com/PrestaShopCorp/prestashop-accounts-installer/issues",
+ "source": "https://github.com/PrestaShopCorp/prestashop-accounts-installer/tree/v1.0.4"
+ },
+ "time": "2023-05-04T07:24:48+00:00"
+ },
{
"name": "smartsupp/chat-code-generator",
- "version": "1.0.1",
+ "version": "1.0.3",
"source": {
"type": "git",
"url": "https://github.com/smartsupp/chat-code-generator.git",
- "reference": "1f63b44aeb90a1cd9e37b260a35b0ccb3377feea"
+ "reference": "5c92d0c531365df8641996652cec8aedb4f7cc15"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/smartsupp/chat-code-generator/zipball/1f63b44aeb90a1cd9e37b260a35b0ccb3377feea",
- "reference": "1f63b44aeb90a1cd9e37b260a35b0ccb3377feea",
+ "url": "https://api.github.com/repos/smartsupp/chat-code-generator/zipball/5c92d0c531365df8641996652cec8aedb4f7cc15",
+ "reference": "5c92d0c531365df8641996652cec8aedb4f7cc15",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"require-dev": {
- "phpunit/phpunit": "4.7.*"
+ "phpunit/phpunit": "4.8.*"
},
"type": "library",
"extra": {
@@ -49,7 +244,12 @@
"keywords": [
"chat"
],
- "time": "2018-11-08T15:36:32+00:00"
+ "support": {
+ "issues": "https://github.com/smartsupp/chat-code-generator/issues",
+ "source": "https://github.com/smartsupp/chat-code-generator",
+ "wiki": "https://github.com/smartsupp/chat-code-generator/wiki"
+ },
+ "time": "2025-06-06T07:36:42+00:00"
},
{
"name": "smartsupp/php-partner-client",
@@ -89,6 +289,11 @@
"keywords": [
"chat"
],
+ "support": {
+ "issues": "https://github.com/smartsupp/php-partner-client/issues",
+ "source": "https://github.com/smartsupp/php-partner-client",
+ "wiki": "https://github.com/smartsupp/php-partner-client/wiki"
+ },
"time": "2019-09-30T15:08:09+00:00"
}
],
@@ -101,5 +306,6 @@
"platform": {
"php": ">=5.6.0"
},
- "platform-dev": []
+ "platform-dev": [],
+ "plugin-api-version": "2.2.0"
}
diff --git a/config/admin/index.php b/config/admin/index.php
new file mode 100644
index 0000000..ed66748
--- /dev/null
+++ b/config/admin/index.php
@@ -0,0 +1,30 @@
+
+ * @link http://www.smartsupp.com
+ * @copyright 2016 Smartsupp.com
+ * @license GPL-2.0+
+ *
+ * Plugin Name: Smartsupp Live Chat
+ * Plugin URI: http://www.smartsupp.com
+ * Description: Adds Smartsupp Live Chat code to PrestaShop.
+ * Version: 2.2.0
+ * Author: Smartsupp
+ * Author URI: http://www.smartsupp.com
+ * Text Domain: smartsupp
+ * License: GPL-2.0+
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
+ */
+
+header('Expires: Mon, 26 Jul 1998 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;
diff --git a/config/admin/services.yml b/config/admin/services.yml
new file mode 100644
index 0000000..a39ee22
--- /dev/null
+++ b/config/admin/services.yml
@@ -0,0 +1,2 @@
+imports:
+ - { resource: ../common.yml }
\ No newline at end of file
diff --git a/config/common.yml b/config/common.yml
new file mode 100644
index 0000000..e925501
--- /dev/null
+++ b/config/common.yml
@@ -0,0 +1,12 @@
+services:
+ PrestaShop\PsAccountsInstaller\Installer\Installer:
+ class: 'PrestaShop\PsAccountsInstaller\Installer\Installer'
+ public: true
+ arguments:
+ - "7.0.0"
+
+ PrestaShop\PsAccountsInstaller\Installer\Facade\PsAccounts:
+ class: 'PrestaShop\PsAccountsInstaller\Installer\Facade\PsAccounts'
+ public: true
+ arguments:
+ - '@PrestaShop\PsAccountsInstaller\Installer\Installer'
\ No newline at end of file
diff --git a/config/index.php b/config/index.php
new file mode 100644
index 0000000..ed66748
--- /dev/null
+++ b/config/index.php
@@ -0,0 +1,30 @@
+
+ * @link http://www.smartsupp.com
+ * @copyright 2016 Smartsupp.com
+ * @license GPL-2.0+
+ *
+ * Plugin Name: Smartsupp Live Chat
+ * Plugin URI: http://www.smartsupp.com
+ * Description: Adds Smartsupp Live Chat code to PrestaShop.
+ * Version: 2.2.0
+ * Author: Smartsupp
+ * Author URI: http://www.smartsupp.com
+ * Text Domain: smartsupp
+ * License: GPL-2.0+
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
+ */
+
+header('Expires: Mon, 26 Jul 1998 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;
diff --git a/controllers/admin/AdminSmartsuppAjax.php b/controllers/admin/AdminSmartsuppAjax.php
index bf9a8a7..e39ad31 100644
--- a/controllers/admin/AdminSmartsuppAjax.php
+++ b/controllers/admin/AdminSmartsuppAjax.php
@@ -22,6 +22,10 @@
use Smartsupp\Auth\Api;
use Smartsupp\LiveChat\Validator\UserCredentialsValidator;
+if (!defined('_PS_VERSION_')) {
+ exit;
+}
+
class AdminSmartsuppAjaxController extends ModuleAdminController
{
const FILE_NAME = 'AdminSmartsuppAjaxController';
diff --git a/module_dependencies.json b/module_dependencies.json
new file mode 100644
index 0000000..1d1d8cb
--- /dev/null
+++ b/module_dependencies.json
@@ -0,0 +1,10 @@
+{
+ "dependencies": [
+ {
+ "name" : "ps_accounts"
+ },
+ {
+ "name" : "ps_eventbus"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/smartsupp.php b/smartsupp.php
old mode 100755
new mode 100644
index 44d6996..71544cc
--- a/smartsupp.php
+++ b/smartsupp.php
@@ -11,7 +11,7 @@
* Plugin Name: Smartsupp Live Chat
* Plugin URI: http://www.smartsupp.com
* Description: Adds Smartsupp Live Chat code to PrestaShop.
- * Version: 2.2.3
+ * Version: 2.2.5
* Author: Smartsupp
* Author URI: http://www.smartsupp.com
* Text Domain: smartsupp
@@ -19,22 +19,39 @@
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
+use PrestaShop\Module\PsEventbus\Service\PresenterService;
+use PrestaShop\PsAccountsInstaller\Installer\Facade\PsAccounts;
+use Smartsupp\LiveChat\Utility\PriceUtility;
use Smartsupp\LiveChat\Utility\VersionUtility;
if (!defined('_PS_VERSION_')) {
exit;
}
+if (file_exists(__DIR__ . '/vendor/autoload.php')) {
+ require_once __DIR__ . '/vendor/autoload.php';
+}
+
class Smartsupp extends Module
{
+ const PRESTASHOP_CLOUDSYNC_CDC = 'https://assets.prestashop3.com/ext/cloudsync-merchant-sync-consent/latest/cloudsync-cdc.js';
+
+ /**
+ * @var PrestaShop\ModuleLibServiceContainer\DependencyInjection\ServiceContainer
+ */
+ private $serviceContainer;
+
public function __construct()
{
+ // Parameter for cloudsync consent component
+ $this->useLightMode = true;
+
$this->name = 'smartsupp';
$this->tab = 'advertising_marketing';
- $this->version = '2.2.3';
+ $this->version = '2.2.5';
$this->author = 'Smartsupp';
$this->need_instance = 0;
- $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
+ $this->ps_versions_compliancy = ['min' => '1.6', 'max' => _PS_VERSION_];
$this->bootstrap = true;
$this->module_key = 'da5110815a9ea717be24a57b804d24fb';
@@ -49,8 +66,6 @@ public function __construct()
include _PS_MODULE_DIR_ . $this->name . '/backward_compatibility/backward.php';
}
- $this->autoload();
-
if (!Configuration::get('SMARTSUPP_KEY')) {
$this->warning = $this->l('No Smartsupp key provided.');
}
@@ -58,44 +73,59 @@ public function __construct()
public function install()
{
+ // Must succeed before proceeding
+ if (!parent::install()) {
+ return false;
+ }
+
if (version_compare(_PS_VERSION_, '1.6', '>=') && Shop::isFeatureActive()) {
Shop::setContext(Shop::CONTEXT_ALL);
}
+ // Register appropriate hook
+ $hookRegistered = version_compare(_PS_VERSION_, '1.6', '>=')
+ ? $this->registerHook('displayBackOfficeHeader')
+ : $this->registerHook('backOfficeHeader');
+
+ if (!$hookRegistered || !$this->registerHook('displayHeader')) {
+ return false;
+ }
+
+ // Create Tab
$tab = new Tab();
$tab->active = 1;
$tab->class_name = 'AdminSmartsuppAjax';
- $tab->name = array();
+ $tab->name = [];
+
foreach (Language::getLanguages(true) as $lang) {
$tab->name[$lang['id_lang']] = 'Smartsupp';
}
+
$tab->id_parent = -1;
$tab->module = $this->name;
- $backOfficeHookSuccess = false;
-
- if (VersionUtility::isPsVersionGreaterThan('1.6')) {
- $backOfficeHookSuccess = $this->registerHook('displayBackOfficeHeader');
- } else {
- $backOfficeHookSuccess = $this->registerHook('backOfficeHeader');
+ if (!$tab->add()) {
+ return false;
}
- if (!$tab->add()
- || !parent::install()
- || !$this->registerHook('displayHeader')
- || !$backOfficeHookSuccess
- || !Configuration::updateValue('SMARTSUPP_KEY', '')
- || !Configuration::updateValue('SMARTSUPP_EMAIL', '')
- || !Configuration::updateValue('SMARTSUPP_CUSTOMER_ID', '1')
- || !Configuration::updateValue('SMARTSUPP_CUSTOMER_NAME', '1')
- || !Configuration::updateValue('SMARTSUPP_CUSTOMER_EMAIL', '1')
- || !Configuration::updateValue('SMARTSUPP_CUSTOMER_PHONE', '1')
- || !Configuration::updateValue('SMARTSUPP_CUSTOMER_ROLE', '1')
- || !Configuration::updateValue('SMARTSUPP_CUSTOMER_SPENDINGS', '1')
- || !Configuration::updateValue('SMARTSUPP_CUSTOMER_ORDERS', '1')
- || !Configuration::updateValue('SMARTSUPP_OPTIONAL_API', '')
- ) {
- return false;
+ // Configuration values to be stored
+ $configValues = [
+ 'SMARTSUPP_KEY' => '',
+ 'SMARTSUPP_EMAIL' => '',
+ 'SMARTSUPP_CUSTOMER_ID' => '1',
+ 'SMARTSUPP_CUSTOMER_NAME' => '1',
+ 'SMARTSUPP_CUSTOMER_EMAIL' => '1',
+ 'SMARTSUPP_CUSTOMER_PHONE' => '1',
+ 'SMARTSUPP_CUSTOMER_ROLE' => '1',
+ 'SMARTSUPP_CUSTOMER_SPENDINGS' => '1',
+ 'SMARTSUPP_CUSTOMER_ORDERS' => '1',
+ 'SMARTSUPP_OPTIONAL_API' => '',
+ ];
+
+ foreach ($configValues as $key => $value) {
+ if (!Configuration::updateValue($key, $value)) {
+ return false;
+ }
}
return true;
@@ -114,7 +144,7 @@ public function uninstall()
$tab->delete();
}
- if (VersionUtility::isPsVersionGreaterThan('1.6')) {
+ if (VersionUtility::isPsVersionGreaterOrEqualTo('1.6')) {
$this->unregisterHook('displayBackOfficeHeader');
} else {
$this->unregisterHook('backOfficeHeader');
@@ -124,14 +154,14 @@ public function uninstall()
|| !$this->unregisterHook('displayHeader')
|| !Configuration::deleteByName('SMARTSUPP_KEY')
|| !Configuration::deleteByName('SMARTSUPP_EMAIL')
- || !Configuration::deleteByName('SMARTSUPP_CUSTOMER_ID', '')
- || !Configuration::deleteByName('SMARTSUPP_CUSTOMER_NAME', '')
- || !Configuration::deleteByName('SMARTSUPP_CUSTOMER_EMAIL', '')
- || !Configuration::deleteByName('SMARTSUPP_CUSTOMER_PHONE', '')
- || !Configuration::deleteByName('SMARTSUPP_CUSTOMER_ROLE', '')
- || !Configuration::deleteByName('SMARTSUPP_CUSTOMER_SPENDINGS', '')
- || !Configuration::deleteByName('SMARTSUPP_CUSTOMER_ORDERS', '')
- || !Configuration::deleteByName('SMARTSUPP_OPTIONAL_API', '')
+ || !Configuration::deleteByName('SMARTSUPP_CUSTOMER_ID')
+ || !Configuration::deleteByName('SMARTSUPP_CUSTOMER_NAME')
+ || !Configuration::deleteByName('SMARTSUPP_CUSTOMER_EMAIL')
+ || !Configuration::deleteByName('SMARTSUPP_CUSTOMER_PHONE')
+ || !Configuration::deleteByName('SMARTSUPP_CUSTOMER_ROLE')
+ || !Configuration::deleteByName('SMARTSUPP_CUSTOMER_SPENDINGS')
+ || !Configuration::deleteByName('SMARTSUPP_CUSTOMER_ORDERS')
+ || !Configuration::deleteByName('SMARTSUPP_OPTIONAL_API')
) {
return false;
}
@@ -204,6 +234,31 @@ public function displayForm()
public function getContent()
{
+ $psDependencies = '';
+
+ try {
+ if (VersionUtility::isPsVersionGreaterOrEqualTo('1.7.0')) {
+ $mboInstaller = new Prestashop\ModuleLibMboInstaller\DependencyBuilder($this);
+
+ if (!$mboInstaller->areDependenciesMet()) {
+ $dependencies = $mboInstaller->handleDependencies();
+ $this->context->smarty->assign('dependencies', $dependencies);
+
+ $psDependencies = $this->context->smarty->fetch($this->getLocalPath() . 'views/templates/admin/dependency_builder.tpl');
+ }
+ }
+
+ $this->loadPsAccounts();
+ $this->loadCloudSync();
+
+ $psDependencies .= $this->context->smarty->fetch($this->getLocalPath() . 'views/templates/admin/ps_accounts.tpl');
+ $psDependencies .= $this->context->smarty->fetch($this->getLocalPath() . '/views/templates/admin/cloudsync.tpl');
+
+ } catch (\Exception $exception) {
+ $this->errors[] = $this->l('Unable to load your PrestaShop accounts details.', 'SmartsUpp');
+ \PrestaShopLogger::addLog($exception->getMessage(), 3, null, 'SmartsUpp', null, true);
+ }
+
$output = '';
if (Tools::isSubmit('submit' . $this->name)) {
$smartsupp_key = Configuration::get('SMARTSUPP_KEY');
@@ -226,7 +281,8 @@ public function getContent()
)
);
- return $this->display(__FILE__, 'views/templates/admin/landing_page.tpl') .
+ return $psDependencies .
+ $this->display(__FILE__, 'views/templates/admin/landing_page.tpl') .
$this->display(__FILE__, 'views/templates/admin/connect_account.tpl') .
$this->display(__FILE__, 'views/templates/admin/configuration.tpl') .
$output;
@@ -298,7 +354,7 @@ protected function getSmartsuppJs($smartsupp_key)
$chat->setVariable(
'spending',
$this->l('Spendings'),
- Tools::displayPrice(
+ PriceUtility::displayPrice(
$spending,
$this->context->currency->id
)
@@ -310,17 +366,16 @@ protected function getSmartsuppJs($smartsupp_key)
}
}
- $custom_code = '';
-
- return $chat->render() . $custom_code;
+ return $chat->render();
}
public function hookDisplayHeader()
{
$smartsupp_key = Configuration::get('SMARTSUPP_KEY');
- $this->smarty->assign(array('smartsupp_js' => $this->getSmartsuppJs($smartsupp_key)));
+ $this->smarty->assign([
+ 'smartsupp_js' => $this->getSmartsuppJs($smartsupp_key),
+ 'smartsupp_optional_api' => $smartsupp_key ? trim(Configuration::get('SMARTSUPP_OPTIONAL_API')) : '',
+ ]);
return $this->display(__FILE__, './views/templates/front/chat_widget.tpl');
}
@@ -336,10 +391,11 @@ public function hookBackOfficeHeader()
],
]);
- $path = $this->_path;
- $js .= '';
- $js .= ' ';
- $js .= ' ';
+ $this->context->smarty->assign([
+ 'smartsupp_module_path' => $this->_path,
+ ]);
+
+ $js .= $this->display(__FILE__, 'views/templates/admin/backoffice_header.tpl');
}
return $js;
@@ -357,7 +413,11 @@ public function hookDisplayBackOfficeHeader()
]);
$path = $this->_path;
- $this->context->controller->addJquery();
+
+ if (!VersionUtility::isPsVersionGreaterOrEqualTo('9.0.0')) {
+ $this->context->controller->addJquery();
+ }
+
$this->context->controller->addJs($path . 'views/js/smartsupp.js');
$this->context->controller->addCSS($path . 'views/css/smartsupp.css');
$this->context->controller->addCSS($path . 'views/css/smartsupp-nobootstrap.css');
@@ -366,13 +426,95 @@ public function hookDisplayBackOfficeHeader()
return $js;
}
- protected function getAdminDir()
+ /**
+ * @return string
+ *
+ * @throws \PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleNotInstalledException
+ * @throws \PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleVersionException
+ */
+ private function loadPsAccounts()
{
- return basename(_PS_ADMIN_DIR_);
+ /** @var PsAccounts $accountsFacade */
+ $accountsFacade = $this->getService(PsAccounts::class);
+
+ $psAccountsPresenter = $accountsFacade->getPsAccountsPresenter();
+ $psAccountsService = $accountsFacade->getPsAccountsService();
+
+ $smartsuppVar = $this->context->smarty->getTemplateVars('smartsupp');
+ $existing = $smartsuppVar !== null ? $smartsuppVar : [];
+
+ $this->context->smarty->assign('smartsupp', array_merge_recursive($existing, [
+ 'url' => [
+ 'psAccountsCdnUrl' => $psAccountsService->getAccountsCdn(),
+ ],
+ ]));
+
+ $previousJsDef = isset(\Media::getJsDef()['smartsupp']) ? \Media::getJsDef()['smartsupp'] : [];
+
+ \Media::addJsDef([
+ 'contextPsAccounts' => $psAccountsPresenter->present(),
+ 'smartsupp' => array_merge($previousJsDef, [
+ 'isPsAccountsLinked' => $psAccountsService->isAccountLinked(),
+ ]),
+ ]);
}
- private function autoload()
+ /**
+ * @return void
+ *
+ * @throws PrestaShopException
+ */
+ private function loadCloudSync()
{
- include_once "{$this->getLocalPath()}vendor/autoload.php";
+ $eventbusModule = \Module::getInstanceByName('ps_eventbus');
+
+ if (!$eventbusModule) {
+ \PrestaShopLogger::addLog('Module ps_eventbus not found', 3, null, 'SmartsUpp', null, true);
+ return;
+ }
+
+ /** @var PresenterService $eventbusPresenterService */
+ $eventbusPresenterService = $eventbusModule->getService(PresenterService::class);
+
+ $smartsuppVar = $this->context->smarty->getTemplateVars('smartsupp');
+ $existing = $smartsuppVar !== null ? $smartsuppVar : [];
+
+ $this->context->smarty->assign('smartsupp', array_merge_recursive($existing, [
+ 'url' => [
+ 'cloudSyncPathCDC' => defined('self::PRESTASHOP_CLOUDSYNC_CDC')
+ ? self::PRESTASHOP_CLOUDSYNC_CDC
+ : '',
+ ],
+ ]));
+
+ $previousJsDef = isset(\Media::getJsDef()['smartsupp']) ? \Media::getJsDef()['smartsupp'] : [];
+
+ \Media::addJsDef([
+ 'contextPsEventbus' => $eventbusPresenterService->expose($this, ['info']),
+ 'smartsupp' => array_merge($previousJsDef, [
+ 'url' => [
+ 'cloudSyncPathCDC' => defined('self::PRESTASHOP_CLOUDSYNC_CDC')
+ ? self::PRESTASHOP_CLOUDSYNC_CDC
+ : '',
+ ],
+ ]),
+ ]);
+ }
+
+ /**
+ * @param string $serviceName
+ *
+ * @return mixed
+ */
+ public function getService($serviceName)
+ {
+ if ($this->serviceContainer === null) {
+ $this->serviceContainer = new \PrestaShop\ModuleLibServiceContainer\DependencyInjection\ServiceContainer(
+ $this->name . str_replace(['.', '-', '+'], '', $this->version),
+ $this->getLocalPath()
+ );
+ }
+
+ return $this->serviceContainer->getService($serviceName);
}
}
diff --git a/src/Utility/PriceUtility.php b/src/Utility/PriceUtility.php
new file mode 100644
index 0000000..9da3748
--- /dev/null
+++ b/src/Utility/PriceUtility.php
@@ -0,0 +1,52 @@
+
+ * @link http://www.smartsupp.com
+ * @copyright 2016 Smartsupp.com
+ * @license GPL-2.0+
+ *
+ * Plugin Name: Smartsupp Live Chat
+ * Plugin URI: http://www.smartsupp.com
+ * Description: Adds Smartsupp Live Chat code to PrestaShop.
+ * Version: 2.2.0
+ * Author: Smartsupp
+ * Author URI: http://www.smartsupp.com
+ * Text Domain: smartsupp
+ * License: GPL-2.0+
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
+ */
+
+namespace Smartsupp\LiveChat\Utility;
+
+if (!defined('_PS_VERSION_')) {
+ exit;
+}
+
+class PriceUtility
+{
+ public static function displayPrice($price, $currency = null)
+ {
+ if (VersionUtility::isPsVersionGreaterOrEqualTo('9.0.0')) {
+ $context = \Context::getContext();
+ $isoCode = $currency && isset($currency->iso_code)
+ ? $currency->iso_code
+ : $context->currency->iso_code;
+
+ $locale = $context->getCurrentLocale();
+
+ if (!$locale) {
+ return (string) $price;
+ }
+
+ return $locale->formatPrice(
+ $price,
+ $isoCode
+ );
+ }
+
+ return \Tools::displayPrice($price, $currency);
+ }
+}
\ No newline at end of file
diff --git a/src/Utility/VersionUtility.php b/src/Utility/VersionUtility.php
index 7c49b3d..ee75108 100644
--- a/src/Utility/VersionUtility.php
+++ b/src/Utility/VersionUtility.php
@@ -21,6 +21,10 @@
namespace Smartsupp\LiveChat\Utility;
+if (!defined('_PS_VERSION_')) {
+ exit;
+}
+
class VersionUtility
{
public static function isPsVersionGreaterThan($version)
diff --git a/src/Validator/UserCredentialsValidator.php b/src/Validator/UserCredentialsValidator.php
index d7e5e71..ef88d8f 100644
--- a/src/Validator/UserCredentialsValidator.php
+++ b/src/Validator/UserCredentialsValidator.php
@@ -21,6 +21,10 @@
namespace Smartsupp\LiveChat\Validator;
+if (!defined('_PS_VERSION_')) {
+ exit;
+}
+
class UserCredentialsValidator
{
const FILE_NAME = 'UserCredentialsValidator';
diff --git a/src/Validator/index.php b/src/Validator/index.php
new file mode 100644
index 0000000..ed66748
--- /dev/null
+++ b/src/Validator/index.php
@@ -0,0 +1,30 @@
+
+ * @link http://www.smartsupp.com
+ * @copyright 2016 Smartsupp.com
+ * @license GPL-2.0+
+ *
+ * Plugin Name: Smartsupp Live Chat
+ * Plugin URI: http://www.smartsupp.com
+ * Description: Adds Smartsupp Live Chat code to PrestaShop.
+ * Version: 2.2.0
+ * Author: Smartsupp
+ * Author URI: http://www.smartsupp.com
+ * Text Domain: smartsupp
+ * License: GPL-2.0+
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
+ */
+
+header('Expires: Mon, 26 Jul 1998 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;
diff --git a/translations/cs.php b/translations/cs.php
old mode 100755
new mode 100644
diff --git a/upgrade/upgrade-2.2.0.php b/upgrade/upgrade-2.2.0.php
index ebdfb59..8d08dff 100644
--- a/upgrade/upgrade-2.2.0.php
+++ b/upgrade/upgrade-2.2.0.php
@@ -21,6 +21,10 @@
use Smartsupp\LiveChat\Utility\VersionUtility;
+if (!defined('_PS_VERSION_')) {
+ exit;
+}
+
/**
* @param Module $module
*
diff --git a/upgrade/upgrade-2.2.5.php b/upgrade/upgrade-2.2.5.php
new file mode 100644
index 0000000..a36c747
--- /dev/null
+++ b/upgrade/upgrade-2.2.5.php
@@ -0,0 +1,40 @@
+
+ * @copyright 2016 Smartsupp.com
+ * @license GPL-2.0+
+ * @package Smartsupp
+ * @link http://www.smartsupp.com
+ *
+ * Plugin Name: Smartsupp Live Chat
+ * Plugin URI: http://www.smartsupp.com
+ * Description: Adds Smartsupp Live Chat code to PrestaShop.
+ * Version: 2.2.5
+ * Text Domain: smartsupp
+ * Author: Smartsupp
+ * Author URI: http://www.smartsupp.com
+ * License: GPL-2.0+
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
+ */
+
+use Smartsupp\LiveChat\Utility\VersionUtility;
+
+if (!defined('_PS_VERSION_')) {
+ exit;
+}
+
+/**
+ * @param Module $module
+ *
+ * @return bool
+ */
+function upgrade_module_2_2_5($module)
+{
+ if (VersionUtility::isPsVersionGreaterThan('1.6')) {
+ $module->unregisterHook('header');
+ }
+
+ return true;
+}
diff --git a/views/css/smartsupp.css b/views/css/smartsupp.css
old mode 100755
new mode 100644
diff --git a/views/img/all-changes-saved.png b/views/img/all-changes-saved.png
old mode 100755
new mode 100644
diff --git a/views/img/all-done.png b/views/img/all-done.png
old mode 100755
new mode 100644
diff --git a/views/img/avatar-grey.png b/views/img/avatar-grey.png
old mode 100755
new mode 100644
diff --git a/views/img/chatbot asset.png b/views/img/chatbot asset.png
old mode 100755
new mode 100644
diff --git a/views/img/chatbot.png b/views/img/chatbot.png
old mode 100755
new mode 100644
diff --git a/views/img/dashboard.png b/views/img/dashboard.png
old mode 100755
new mode 100644
diff --git a/views/img/done.png b/views/img/done.png
old mode 100755
new mode 100644
diff --git a/views/img/icon-20x20.png b/views/img/icon-20x20.png
old mode 100755
new mode 100644
diff --git a/views/img/index.php b/views/img/index.php
old mode 100755
new mode 100644
diff --git a/views/img/insportline.png b/views/img/insportline.png
old mode 100755
new mode 100644
diff --git a/views/img/logo.png b/views/img/logo.png
old mode 100755
new mode 100644
diff --git a/views/img/mobile.png b/views/img/mobile.png
old mode 100755
new mode 100644
diff --git a/views/img/motorgarten.png b/views/img/motorgarten.png
old mode 100755
new mode 100644
diff --git a/views/img/multichannel.png b/views/img/multichannel.png
old mode 100755
new mode 100644
diff --git a/views/img/redfox.png b/views/img/redfox.png
old mode 100755
new mode 100644
diff --git a/views/img/smartsupp_logo.png b/views/img/smartsupp_logo.png
old mode 100755
new mode 100644
diff --git a/views/img/tablet-screen.png b/views/img/tablet-screen.png
old mode 100755
new mode 100644
diff --git a/views/img/travelking.png b/views/img/travelking.png
old mode 100755
new mode 100644
diff --git a/views/js/smartsupp.js b/views/js/smartsupp.js
old mode 100755
new mode 100644
diff --git a/views/templates/admin/backoffice_header.tpl b/views/templates/admin/backoffice_header.tpl
new file mode 100644
index 0000000..a4d6cfc
--- /dev/null
+++ b/views/templates/admin/backoffice_header.tpl
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/views/templates/admin/cloudsync.tpl b/views/templates/admin/cloudsync.tpl
new file mode 100644
index 0000000..d3fb630
--- /dev/null
+++ b/views/templates/admin/cloudsync.tpl
@@ -0,0 +1,16 @@
+
+
+{if isset($smartsupp.url.cloudSyncPathCDC)}
+
+{/if}
+
+
\ No newline at end of file
diff --git a/views/templates/admin/configuration.tpl b/views/templates/admin/configuration.tpl
old mode 100755
new mode 100644
diff --git a/views/templates/admin/connect_account.tpl b/views/templates/admin/connect_account.tpl
old mode 100755
new mode 100644
diff --git a/views/templates/admin/dependency_builder.tpl b/views/templates/admin/dependency_builder.tpl
new file mode 100644
index 0000000..e00cceb
--- /dev/null
+++ b/views/templates/admin/dependency_builder.tpl
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/views/templates/admin/includes/clients.tpl b/views/templates/admin/includes/clients.tpl
old mode 100755
new mode 100644
diff --git a/views/templates/admin/includes/features.tpl b/views/templates/admin/includes/features.tpl
old mode 100755
new mode 100644
diff --git a/views/templates/admin/landing_page.tpl b/views/templates/admin/landing_page.tpl
old mode 100755
new mode 100644
diff --git a/views/templates/admin/ps_accounts.tpl b/views/templates/admin/ps_accounts.tpl
new file mode 100644
index 0000000..5bbbdc7
--- /dev/null
+++ b/views/templates/admin/ps_accounts.tpl
@@ -0,0 +1,6 @@
+
+
+
+
\ No newline at end of file
diff --git a/views/templates/front/chat_widget.tpl b/views/templates/front/chat_widget.tpl
old mode 100755
new mode 100644
index 8e2428d..8336718
--- a/views/templates/front/chat_widget.tpl
+++ b/views/templates/front/chat_widget.tpl
@@ -15,4 +15,9 @@
**/
?>
-{$smartsupp_js nofilter}
\ No newline at end of file
+{$smartsupp_js nofilter}
+{if isset($smartsupp_optional_api) && $smartsupp_optional_api}
+
+{/if}
\ No newline at end of file