// Fix bug in AdminPaymentController && added toolbar
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10521 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
1 parent
ad6e5b1cb8
commit
a6b66fb288
3 files changed
+53
-74
No files matched your search
@@ -1,44 +0,0 @@
|
|||||||
{*
|
|
||||||
* 2007-2011 PrestaShop
|
|
||||||
*
|
|
||||||
* NOTICE OF LICENSE
|
|
||||||
*
|
|
||||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
|
||||||
* that is bundled with this package in the file LICENSE.txt.
|
|
||||||
* It is also available through the world-wide-web at this URL:
|
|
||||||
* http://opensource.org/licenses/afl-3.0.php
|
|
||||||
* If you did not receive a copy of the license and are unable to
|
|
||||||
* obtain it through the world-wide-web, please send an email
|
|
||||||
* to license@prestashop.com so we can send you a copy immediately.
|
|
||||||
*
|
|
||||||
* DISCLAIMER
|
|
||||||
*
|
|
||||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
|
||||||
* versions in the future. If you wish to customize PrestaShop for your
|
|
||||||
* needs please refer to http://www.prestashop.com for more information.
|
|
||||||
*
|
|
||||||
* @author PrestaShop SA <contact@prestashop.com>
|
|
||||||
* @copyright 2007-2011 PrestaShop SA
|
|
||||||
* @version Release: $Revision$
|
|
||||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
|
||||||
* International Registered Trademark & Property of PrestaShop SA
|
|
||||||
*}
|
|
||||||
|
|
||||||
<h2 class="space">{l s='Payment modules list'}</h2>
|
|
||||||
{if isset($url_modules)}
|
|
||||||
<input type="button" class="button" onclick="document.location='{$url_modules}'" value="{l s='Click to see the list of payment modules.'}" /><br>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<br />
|
|
||||||
|
|
||||||
{if $display_restrictions}
|
|
||||||
<br /><h2 class="space">{l s='Payment module restrictions'}</h2>
|
|
||||||
{foreach $lists as $list}
|
|
||||||
{include file='payment/restrictions.tpl'}
|
|
||||||
<br />
|
|
||||||
{/foreach}
|
|
||||||
{else}
|
|
||||||
<br />
|
|
||||||
<div class='warn'>{l s='No payment module installed'}</div>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
@@ -700,6 +700,8 @@ abstract class ModuleCore
|
|||||||
$item->is_configurable = isset($tmpModule->is_configurable) ? $tmpModule->is_configurable : 1;
|
$item->is_configurable = isset($tmpModule->is_configurable) ? $tmpModule->is_configurable : 1;
|
||||||
$item->need_instance = isset($tmpModule->need_instance) ? $tmpModule->need_instance : 0;
|
$item->need_instance = isset($tmpModule->need_instance) ? $tmpModule->need_instance : 0;
|
||||||
$item->active = $tmpModule->active;
|
$item->active = $tmpModule->active;
|
||||||
|
$item->currencies = isset($tmpModule->currencies) ? $tmpModule->currencies : null;
|
||||||
|
$item->currencies_mode = isset($tmpModule->currencies_mode) ? $tmpModule->currencies_mode : null;
|
||||||
unset($tmpModule);
|
unset($tmpModule);
|
||||||
|
|
||||||
$moduleList[] = $item;
|
$moduleList[] = $item;
|
||||||
|
|||||||
@@ -27,46 +27,58 @@
|
|||||||
|
|
||||||
class AdminPaymentControllerCore extends AdminController
|
class AdminPaymentControllerCore extends AdminController
|
||||||
{
|
{
|
||||||
public $paymentModules = array();
|
public $payment_modules = array();
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$shopID = Context::getContext()->shop->getID(true);
|
$shop_id = Context::getContext()->shop->getID(true);
|
||||||
|
|
||||||
/* Get all modules then select only payment ones*/
|
/* Get all modules then select only payment ones */
|
||||||
$modules = Module::getModulesOnDisk();
|
$modules = Module::getModulesOnDisk();
|
||||||
foreach ($modules AS $module)
|
|
||||||
|
|
||||||
|
foreach ($modules as $module)
|
||||||
if ($module->tab == 'payments_gateways')
|
if ($module->tab == 'payments_gateways')
|
||||||
{
|
{
|
||||||
if ($module->id)
|
if ($module->id)
|
||||||
{
|
{
|
||||||
if(!get_class($module) == 'SimpleXMLElement')
|
if (!get_class($module) == 'SimpleXMLElement')
|
||||||
$module->country = array();
|
$module->country = array();
|
||||||
$countries = DB::getInstance()->executeS('SELECT id_country FROM '._DB_PREFIX_.'module_country WHERE id_module = '.(int)$module->id.' AND `id_shop`='.$shopID);
|
$countries = DB::getInstance()->executeS('
|
||||||
|
SELECT id_country
|
||||||
|
FROM '._DB_PREFIX_.'module_country
|
||||||
|
WHERE id_module = '.(int)$module->id.' AND `id_shop`='.$shop_id
|
||||||
|
);
|
||||||
foreach ($countries as $country)
|
foreach ($countries as $country)
|
||||||
$module->country[] = $country['id_country'];
|
$module->country[] = $country['id_country'];
|
||||||
|
|
||||||
if(!get_class($module) == 'SimpleXMLElement')
|
if (!get_class($module) == 'SimpleXMLElement')
|
||||||
$module->currency = array();
|
$module->currency = array();
|
||||||
$currencies = DB::getInstance()->executeS('SELECT id_currency FROM '._DB_PREFIX_.'module_currency WHERE id_module = '.(int)$module->id.' AND `id_shop`='.$shopID);
|
$currencies = DB::getInstance()->executeS('
|
||||||
|
SELECT id_currency
|
||||||
|
FROM '._DB_PREFIX_.'module_currency
|
||||||
|
WHERE id_module = '.(int)$module->id.' AND `id_shop`='.$shop_id
|
||||||
|
);
|
||||||
foreach ($currencies as $currency)
|
foreach ($currencies as $currency)
|
||||||
$module->currency[] = $currency['id_currency'];
|
$module->currency[] = $currency['id_currency'];
|
||||||
|
|
||||||
if(!get_class($module) == 'SimpleXMLElement')
|
if (!get_class($module) == 'SimpleXMLElement')
|
||||||
$module->group = array();
|
$module->group = array();
|
||||||
$groups = DB::getInstance()->executeS('SELECT id_group FROM '._DB_PREFIX_.'module_group WHERE id_module = '.(int)$module->id.' AND `id_shop`='.$shopID);
|
$groups = DB::getInstance()->executeS('
|
||||||
|
SELECT id_group
|
||||||
|
FROM '._DB_PREFIX_.'module_group
|
||||||
|
WHERE id_module = '.(int)$module->id.' AND `id_shop`='.$shop_id
|
||||||
|
);
|
||||||
foreach ($groups as $group)
|
foreach ($groups as $group)
|
||||||
$module->group[] = $group['id_group'];
|
$module->group[] = $group['id_group'];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$module->country = NULL;
|
$module->country = null;
|
||||||
$module->currency = NULL;
|
$module->currency = null;
|
||||||
$module->group = NULL;
|
$module->group = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->paymentModules[] = $module;
|
$this->payment_modules[] = $module;
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
@@ -76,36 +88,42 @@ class AdminPaymentControllerCore extends AdminController
|
|||||||
{
|
{
|
||||||
if (Tools::isSubmit('submitModulecountry'))
|
if (Tools::isSubmit('submitModulecountry'))
|
||||||
$this->saveRestrictions('country');
|
$this->saveRestrictions('country');
|
||||||
elseif (Tools::isSubmit('submitModulecurrency'))
|
else if (Tools::isSubmit('submitModulecurrency'))
|
||||||
$this->saveRestrictions('currency');
|
$this->saveRestrictions('currency');
|
||||||
elseif (Tools::isSubmit('submitModulegroup'))
|
else if (Tools::isSubmit('submitModulegroup'))
|
||||||
$this->saveRestrictions('group');
|
$this->saveRestrictions('group');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function saveRestrictions($type)
|
private function saveRestrictions($type)
|
||||||
{
|
{
|
||||||
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'module_'.$type.' WHERE id_shop = '.Context::getContext()->shop->getID(true));
|
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'module_'.$type.' WHERE id_shop = '.Context::getContext()->shop->getID(true));
|
||||||
foreach ($this->paymentModules as $module)
|
foreach ($this->payment_modules as $module)
|
||||||
if ($module->active AND isset($_POST[$module->name.'_'.$type.'']))
|
if ($module->active && isset($_POST[$module->name.'_'.$type.'']))
|
||||||
foreach ($_POST[$module->name.'_'.$type.''] as $selected)
|
foreach ($_POST[$module->name.'_'.$type.''] as $selected)
|
||||||
$values[] = '('.(int)$module->id.', '.Context::getContext()->shop->getID(true).', '.(int)$selected.')';
|
$values[] = '('.(int)$module->id.', '.Context::getContext()->shop->getID(true).', '.(int)$selected.')';
|
||||||
|
|
||||||
if (sizeof($values))
|
if (count($values))
|
||||||
Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'module_'.$type.' (`id_module`, `id_shop`, `id_'.$type.'`) VALUES '.implode(',', $values));
|
Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'module_'.$type.' (`id_module`, `id_shop`, `id_'.$type.'`) VALUES '.implode(',', $values));
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&conf=4'.'&token='.$this->token);
|
Tools::redirectAdmin(self::$currentIndex.'&conf=4'.'&token='.$this->token);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initContent()
|
public function initContent()
|
||||||
|
{
|
||||||
|
$this->display = 'view';
|
||||||
|
return parent::initContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function initView()
|
||||||
{
|
{
|
||||||
// link to modules page
|
// link to modules page
|
||||||
if (isset($this->paymentModules[0]))
|
if (isset($this->payment_modules[0]))
|
||||||
$token_modules = Tools::getAdminToken('AdminModules'.(int)(Tab::getIdFromClassName('AdminModules')).(int)$this->context->employee->id);
|
$token_modules = Tools::getAdminToken('AdminModules'.(int)Tab::getIdFromClassName('AdminModules').(int)$this->context->employee->id);
|
||||||
|
|
||||||
$display_restrictions = false;
|
$display_restrictions = false;
|
||||||
foreach ($this->paymentModules as $module)
|
foreach ($this->payment_modules as $module)
|
||||||
if ($module->active)
|
if ($module->active)
|
||||||
{
|
{
|
||||||
$display_restrictions= true;
|
$display_restrictions = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +148,7 @@ class AdminPaymentControllerCore extends AdminController
|
|||||||
'name_id' => 'country',
|
'name_id' => 'country',
|
||||||
'identifier' => 'id_country',
|
'identifier' => 'id_country',
|
||||||
'icon' => 'world',
|
'icon' => 'world',
|
||||||
),
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($lists as $key_list => $list)
|
foreach ($lists as $key_list => $list)
|
||||||
@@ -139,12 +157,12 @@ class AdminPaymentControllerCore extends AdminController
|
|||||||
foreach ($list['items'] as $key_item => $item)
|
foreach ($list['items'] as $key_item => $item)
|
||||||
{
|
{
|
||||||
$name_id = $list['name_id'];
|
$name_id = $list['name_id'];
|
||||||
foreach ($this->paymentModules as $key_module => $module)
|
foreach ($this->payment_modules as $key_module => $module)
|
||||||
{
|
{
|
||||||
if (isset($module->$name_id) && in_array($item['id_'.$name_id], $module->$name_id))
|
if (isset($module->$name_id) && in_array($item['id_'.$name_id], $module->$name_id))
|
||||||
$list['items'][$key_item]['check_list'][$key_module] = 'checked';
|
$list['items'][$key_item]['check_list'][$key_module] = 'checked';
|
||||||
else
|
else
|
||||||
$list['items'][$key_item]['check_list'][$key_module] = 'unchecked';
|
$list['items'][$key_item]['check_list'][$key_module] = 'unchecked';
|
||||||
|
|
||||||
// If is a country list and the country is limited, remove it from list
|
// If is a country list and the country is limited, remove it from list
|
||||||
if ($name_id == 'country'
|
if ($name_id == 'country'
|
||||||
@@ -158,15 +176,18 @@ class AdminPaymentControllerCore extends AdminController
|
|||||||
$lists[$key_list] = $list;
|
$lists[$key_list] = $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->context->smarty->assign(array(
|
$this->tpl_view_vars = array(
|
||||||
'url_modules' => isset($token_modules) ? 'index.php?tab=AdminModules&token='.$token_modules.'&module_name='.$this->paymentModules[0]->name.'&tab_module=payments_gateways' : null,
|
'url_modules' => isset($token_modules) ? 'index.php?tab=AdminModules&token='.$token_modules.'&&filterCategory=payments_gateways' : null,
|
||||||
'display_restrictions' => $display_restrictions,
|
'display_restrictions' => $display_restrictions,
|
||||||
'lists' => $lists,
|
'lists' => $lists,
|
||||||
'ps_base_uri' => __PS_BASE_URI__,
|
'ps_base_uri' => __PS_BASE_URI__,
|
||||||
'payment_modules' => $this->paymentModules,
|
'payment_modules' => $this->payment_modules,
|
||||||
'url_submit' => self::$currentIndex.'&token='.$this->token,
|
'url_submit' => self::$currentIndex.'&token='.$this->token,
|
||||||
));
|
);
|
||||||
|
|
||||||
|
$this->toolbar_title = $this->l('Paiement');
|
||||||
|
unset($this->toolbar_btn['cancel']);
|
||||||
|
return parent::initView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in new issue
Block a user