From 7d9ca8d486eaa9cc860d7b528255bae341f1fbef Mon Sep 17 00:00:00 2001 From: rMalie Date: Tue, 22 May 2012 12:12:50 +0000 Subject: [PATCH] // Code review for the change paymentModule git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15612 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/PaymentModule.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 5c3e9bf1e..791574805 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -40,19 +40,19 @@ abstract class PaymentModuleCore extends Module // Insert currencies availability if ($this->currencies_mode == 'checkbox') { - if (!$this->addCheckboxCurrencyRestrictionsForModule(Shop::getShops(true, null, true))) + if (!$this->addCheckboxCurrencyRestrictionsForModule()) return false; } elseif ($this->currencies_mode == 'radio') { - if (!$this->addRadioCurrencyRestrictionsForModule(Shop::getShops(true, null, true))) + if (!$this->addRadioCurrencyRestrictionsForModule()) return false; } else Tools::displayError('No currency mode for payment module'); // Insert countries availability - $return = $this->addCheckboxCountryRestrictionsForModule(Shop::getShops(true, null, true)); + $return = $this->addCheckboxCountryRestrictionsForModule(); return $return; } @@ -72,8 +72,11 @@ abstract class PaymentModuleCore extends Module * @param integer id_module * @param array $shops */ - public function addCheckboxCurrencyRestrictionsForModule($shops = array(1)) + public function addCheckboxCurrencyRestrictionsForModule(array $shops = array()) { + if (!$shops) + $shops = Shop::getShops(true, null, true); + foreach ($shops as $s) { if (!Db::getInstance()->execute(' @@ -89,8 +92,11 @@ abstract class PaymentModuleCore extends Module * @param integer id_module * @param array $shops */ - public function addRadioCurrencyRestrictionsForModule($shops = array(1)) + public function addRadioCurrencyRestrictionsForModule(array $shops = array()) { + if (!$shops) + $shops = Shop::getShops(true, null, true); + 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)')) @@ -103,8 +109,11 @@ abstract class PaymentModuleCore extends Module * @param integer id_module * @param array $shops */ - public function addCheckboxCountryRestrictionsForModule($shops = array(1)) + public function addCheckboxCountryRestrictionsForModule(array $shops = array()) { + if (!$shops) + $shops = Shop::getShops(true, null, true); + foreach ($shops as $s) { if (!Db::getInstance()->execute('