[-] BO : Fixing module restrictions in multishop context
This commit is contained in:
1 parent
b8062cbb77
commit
5ef796e1ff
1 file changed
+54
-9
@@ -40,25 +40,19 @@ abstract class PaymentModuleCore extends Module
|
|||||||
// Insert currencies availability
|
// Insert currencies availability
|
||||||
if ($this->currencies_mode == 'checkbox')
|
if ($this->currencies_mode == 'checkbox')
|
||||||
{
|
{
|
||||||
if (!Db::getInstance()->execute('
|
if (!$this->addCheckboxCurrencyRestrictionsForModule(Shop::getShops(true, null, true)))
|
||||||
INSERT INTO `'._DB_PREFIX_.'module_currency` (id_module, id_currency)
|
|
||||||
SELECT '.(int)$this->id.', id_currency FROM `'._DB_PREFIX_.'currency` WHERE deleted = 0'))
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
elseif ($this->currencies_mode == 'radio')
|
elseif ($this->currencies_mode == 'radio')
|
||||||
{
|
{
|
||||||
if (!Db::getInstance()->execute('
|
if (!$this->addRadioCurrencyRestrictionsForModule(Shop::getShops(true, null, true)))
|
||||||
INSERT INTO `'._DB_PREFIX_.'module_currency` (id_module, id_currency)
|
|
||||||
VALUES ('.(int)$this->id.', -2)'))
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Tools::displayError('No currency mode for payment module');
|
Tools::displayError('No currency mode for payment module');
|
||||||
|
|
||||||
// Insert countries availability
|
// Insert countries availability
|
||||||
$return = Db::getInstance()->execute('
|
$return = $this->addCheckboxCountryRestrictionsForModule(Shop::getShops(true, null, true));
|
||||||
INSERT INTO `'._DB_PREFIX_.'module_country` (id_module, id_country)
|
|
||||||
SELECT '.(int)$this->id.', id_country FROM `'._DB_PREFIX_.'country` WHERE active = 1');
|
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
@@ -72,6 +66,57 @@ abstract class PaymentModuleCore extends Module
|
|||||||
return parent::uninstall();
|
return parent::uninstall();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add checkbox currency restrictions for a new module
|
||||||
|
* @param integer id_module
|
||||||
|
* @param array $shops
|
||||||
|
*/
|
||||||
|
public function addCheckboxCurrencyRestrictionsForModule($shops = array(1))
|
||||||
|
{
|
||||||
|
foreach ($shops as $s)
|
||||||
|
{
|
||||||
|
if (!Db::getInstance()->execute('
|
||||||
|
INSERT INTO `'._DB_PREFIX_.'module_currency` (`id_module`, `id_shop`, `id_currency`)
|
||||||
|
SELECT '.(int)$this->id.', "'.(int)$s.'", `id_currency` FROM `'._DB_PREFIX_.'currency` WHERE deleted = 0'))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add radio currency restrictions for a new module
|
||||||
|
* @param integer id_module
|
||||||
|
* @param array $shops
|
||||||
|
*/
|
||||||
|
public function addRadioCurrencyRestrictionsForModule($shops = array(1))
|
||||||
|
{
|
||||||
|
foreach ($shops as $s)
|
||||||
|
if (!Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'module_currency` (`id_module`, `id_shop`, `id_currency`)
|
||||||
|
VALUES ('.(int)$this->id.', "'.(int)$s.'", -2)'))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add checkbox country restrictions for a new module
|
||||||
|
* @param integer id_module
|
||||||
|
* @param array $shops
|
||||||
|
*/
|
||||||
|
public function addCheckboxCountryRestrictionsForModule($shops = array(1))
|
||||||
|
{
|
||||||
|
foreach ($shops as $s)
|
||||||
|
{
|
||||||
|
if (!Db::getInstance()->execute('
|
||||||
|
INSERT INTO `'._DB_PREFIX_.'module_country` (`id_module`, `id_shop`, `id_country`)
|
||||||
|
SELECT '.(int)$this->id.', "'.(int)$s.'", `id_country` FROM `'._DB_PREFIX_.'country` WHERE active = 1'))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate an order in database
|
* Validate an order in database
|
||||||
* Function called from a payment module
|
* Function called from a payment module
|
||||||
|
|||||||
Reference in new issue
Block a user