ref #91900 Fix module activation/deactivation (#220)

This commit is contained in:
Kocmonavtik 2023-11-22 12:08:09 +03:00 committed by GitHub
parent 2d2708adbe
commit 3d6edb8b97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 7 deletions

View File

@ -1,3 +1,6 @@
## v3.6.3
* Исправление активации/деактивации модуля
## v3.6.2 ## v3.6.2
* Добавлена валидация валют при настройке модуля * Добавлена валидация валют при настройке модуля

View File

@ -1 +1 @@
3.6.2 3.6.3

View File

@ -71,9 +71,12 @@ class RetailcrmSettings
if ($this->validator->validate(true)) { if ($this->validator->validate(true)) {
$this->settings->updateValueAll(); $this->settings->updateValueAll();
if (array_key_exists('apiKey', $this->settings->getChanged())) { $shopId = Context::getContext()->shop->id;
if (array_key_exists('apiKey', $this->settings->getChanged())
&& !Configuration::get(RetailCRM::CLIENT_ID, null, null, $shopId)) {
$this->setClientId(); $this->setClientId();
RetailCRM::updateCrmModuleState(Context::getContext()->shop->id); RetailCRM::updateCrmModuleState($shopId);
} }
} }
@ -95,10 +98,11 @@ class RetailcrmSettings
private function setClientId() private function setClientId()
{ {
$context = Context::getContext(); $context = Context::getContext();
$clientId = uniqid();
Configuration::updateValue(RetailCRM::CLIENT_ID, hash( Configuration::updateValue(RetailCRM::CLIENT_ID, hash(
'sha256', 'sha256',
$context->shop->id . Configuration::get('PS_SHOP_DOMAIN') $context->shop->id . Configuration::get('PS_SHOP_DOMAIN') . $clientId
)); ));
return true; return true;

View File

@ -48,7 +48,7 @@ require_once dirname(__FILE__) . '/bootstrap.php';
class RetailCRM extends Module class RetailCRM extends Module
{ {
const VERSION = '3.6.2'; const VERSION = '3.6.3';
const API_URL = 'RETAILCRM_ADDRESS'; const API_URL = 'RETAILCRM_ADDRESS';
const API_KEY = 'RETAILCRM_API_TOKEN'; const API_KEY = 'RETAILCRM_API_TOKEN';
@ -309,7 +309,8 @@ class RetailCRM extends Module
if (Shop::isFeatureActive()) { if (Shop::isFeatureActive()) {
$shops = Shop::getShops(); $shops = Shop::getShops();
} else { } else {
$shops[] = Shop::getContext(); $context = Context::getContext();
$shops[]['id_shop'] = $context->shop->id;
} }
foreach ($shops as $shop) { foreach ($shops as $shop) {
@ -371,7 +372,7 @@ class RetailCRM extends Module
return false; return false;
} }
$context = Shop::getContext(); $context = Context::getContext();
self::updateCrmModuleState($context->shop->id, false); self::updateCrmModuleState($context->shop->id, false);