// Merge -> revision 8984

This commit is contained in:
rMalie
2011-10-03 15:48:07 +00:00
parent b5b2a4ffb6
commit c4780ec67d
60 changed files with 669 additions and 356 deletions
+52
View File
@@ -538,5 +538,57 @@ abstract class PaymentModuleCore extends Module
return false;
return (new Currency($id_currency));
}
/**
* Allows specified payment modules to be used by a specific currency
*
* @since 1.4.5
* @param int $id_currency
* @param array $id_module_list
* @return boolean
*/
public static function addCurrencyPermissions($id_currency, array $id_module_list = array())
{
$values = '';
if (count($id_module_list) == 0)
{
// fetch all installed module ids
$modules = PaymentModuleCore::getInstalledPaymentModules();
foreach ($modules as $module)
$id_module_list[] = $module['id_module'];
}
foreach ($id_module_list as $id_module)
$values .= '('.(int)$id_module.','.(int)$id_currency.'),';
if (!empty($values))
{
return Db::getInstance()->Execute('
INSERT INTO `'._DB_PREFIX_.'module_currency` (`id_module`, `id_currency`)
VALUES '.rtrim($values, ',')
);
}
return true;
}
/**
* List all installed and active payment modules
* @see Module::getPaymentModules() if you need a list of module related to the user context
*
* @since 1.4.5
* @return array module informations
*/
public static function getInstalledPaymentModules()
{
return Db::getInstance()->executeS('
SELECT DISTINCT m.`id_module`, h.`id_hook`, m.`name`, hm.`position`
FROM `'._DB_PREFIX_.'module` m
LEFT JOIN `'._DB_PREFIX_.'hook_module` hm ON hm.`id_module` = m.`id_module`
LEFT JOIN `'._DB_PREFIX_.'hook` h ON hm.`id_hook` = h.`id_hook`
WHERE h.`name` = \'payment\'
AND m.`active` = 1
');
}
}