diff --git a/classes/AdminController.php b/classes/AdminController.php
index 59496c045..8460e26e3 100644
--- a/classes/AdminController.php
+++ b/classes/AdminController.php
@@ -73,6 +73,7 @@ class AdminControllerCore extends Controller
/** @var string Default ORDER BY clause when $_orderBy is not defined */
protected $_defaultOrderBy = false;
+ protected $_defaultOrderWay = 'ASC';
public $tpl_form_vars = array();
public $tpl_list_vars = array();
@@ -1954,7 +1955,7 @@ class AdminControllerCore extends Controller
if (empty($order_by))
$order_by = $this->context->cookie->__get($this->table.'Orderby') ? $this->context->cookie->__get($this->table.'Orderby') : $this->_defaultOrderBy;
if (empty($order_way))
- $order_way = $this->context->cookie->__get($this->table.'Orderway') ? $this->context->cookie->__get($this->table.'Orderway') : 'ASC';
+ $order_way = $this->context->cookie->__get($this->table.'Orderway') ? $this->context->cookie->__get($this->table.'Orderway') : $this->_defaultOrderWay;
$limit = (int)Tools::getValue('pagination', $limit);
$this->context->cookie->{$this->table.'_pagination'} = $limit;
diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php
index ad5abfe6b..4a087f2eb 100644
--- a/controllers/admin/AdminCustomersController.php
+++ b/controllers/admin/AdminCustomersController.php
@@ -28,6 +28,9 @@
class AdminCustomersControllerCore extends AdminController
{
protected $delete_mode;
+
+ protected $_defaultOrderBy = 'date_add';
+ protected $_defaultOrderWay = 'DESC';
public function __construct()
{
@@ -406,7 +409,6 @@ class AdminCustomersControllerCore extends AdminController
array_splice($this->fields_form['input'], $k, 1);
}
-
if (Shop::isFeatureActive())
{
$this->fields_form['input'][] = array(
@@ -514,7 +516,8 @@ class AdminCustomersControllerCore extends AdminController
}
foreach ($groups as $group)
- $this->fields_value['groupBox_'.$group['id_group']] = Tools::getValue('groupBox_'.$group['id_group'], in_array($group['id_group'], $customer_groups_ids));
+ $this->fields_value['groupBox_'.$group['id_group']] =
+ Tools::getValue('groupBox_'.$group['id_group'], in_array($group['id_group'], $customer_groups_ids));
return parent::renderForm();
}
@@ -644,6 +647,7 @@ class AdminCustomersControllerCore extends AdminController
for ($i = 0; $i < $total_referrers; $i++)
$referrers[$i]['date_add'] = Tools::displayDate($referrers[$i]['date_add'], $this->default_form_language, true);
+ $shop = new Shop($customer->id_shop);
$this->tpl_view_vars = array(
'customer' => $customer,
'gender_image' => $gender_image,
@@ -654,7 +658,7 @@ class AdminCustomersControllerCore extends AdminController
'last_visit' => Tools::displayDate($customer_stats['last_visit'], $this->default_form_language, true),
'count_better_customers' => $count_better_customers,
'shop_is_feature_active' => Shop::isFeatureActive(),
- 'name_shop' => Shop::getInstance($customer->id_shop)->name,
+ 'name_shop' => $shop->name,
'customer_birthday' => Tools::displayDate($customer->birthday, $this->default_form_language),
'last_update' => Tools::displayDate($customer->date_upd, $this->default_form_language, true),
'customer_exists' => Customer::customerExists($customer->email),
@@ -712,7 +716,7 @@ class AdminCustomersControllerCore extends AdminController
$this->deleted = true;
else
{
- $this->errors[] = Tools::displayError('Unknown delete mode:'.' '.$this->deleted);
+ $this->errors[] = Tools::displayError('Unknown delete mode:').' '.$this->deleted;
return;
}
@@ -764,9 +768,9 @@ class AdminCustomersControllerCore extends AdminController
return parent::processSave($token);
}
- public function afterDelete($object, $oldId)
+ public function afterDelete($object, $old_id)
{
- $customer = new Customer($oldId);
+ $customer = new Customer($old_id);
$addresses = $customer->getAddresses($this->default_form_language);
foreach ($addresses as $k => $v)
{
@@ -826,32 +830,19 @@ class AdminCustomersControllerCore extends AdminController
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
}
- public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = null)
- {
- return parent::getList(
- Context::getContext()->language->id,
- !Tools::getValue($this->table.'Orderby') ? 'date_add' : null,
- !Tools::getValue($this->table.'Orderway') ? 'DESC' : null
- );
- }
-
public static function printNewsIcon($id_customer, $tr)
{
- $customer = new Customer($tr['id_customer']);
- if (!Validate::isLoadedObject($customer))
- return;
- return '
- '.($customer->newsletter ? '
' : '
').
+ return '
+ '.($tr['newsletter'] ? '
' : '
').
'';
}
public static function printOptinIcon($id_customer, $tr)
{
- $customer = new Customer($tr['id_customer']);
- if (!Validate::isLoadedObject($customer))
- return;
- return '
- '.($customer->optin ? '
' : '
').
+ return ';
+ '.($tr['optin'] ? '
' : '
').
'';
}
@@ -880,8 +871,11 @@ class AdminCustomersControllerCore extends AdminController
}
/**
- * Search customers
- */
+ * add to $this->content the result of Customer::SearchByName
+ * (encoded in json)
+ *
+ * @return void
+ */
public function ajaxProcessSearchCustomers()
{
if ($customers = Customer::searchByName(pSQL(Tools::getValue('customer_search'))))
diff --git a/controllers/admin/AdminGroupShopController.php b/controllers/admin/AdminGroupShopController.php
index 1551b899f..bd2d6788c 100644
--- a/controllers/admin/AdminGroupShopController.php
+++ b/controllers/admin/AdminGroupShopController.php
@@ -122,7 +122,8 @@ class AdminGroupShopControllerCore extends AdminController
'label' => $this->l('Disabled')
)
),
- 'desc' => $this->l('Share orders and carts between shops of this group (you can share orders only if you share customers and available quantities)')
+ 'desc' =>
+ $this->l('Share orders and carts between shops of this group (you can share orders only if you share customers and available quantities)')
),
array(
'type' => 'radio',
@@ -226,10 +227,11 @@ class AdminGroupShopControllerCore extends AdminController
'desc' => $this->l('Use this option to associate data (products, modules, etc.) the same way as the selected shop')
);
+ $default_group_shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
$this->tpl_form_vars = array(
'disabled' => $disabled,
'checked' => (Tools::getValue('addgroup_shop') !== false) ? true : false,
- 'defaultGroup' => Shop::getInstance(Configuration::get('PS_SHOP_DEFAULT'))->getGroupID(),
+ 'defaultGroup' => $default_group_shop->getGroupID(),
);
if (isset($this->fields_import_form))
$this->tpl_form_vars = array_merge($this->tpl_form_vars, array('form_import' => $this->fields_import_form));
diff --git a/controllers/admin/AdminModulesPositionsController.php b/controllers/admin/AdminModulesPositionsController.php
index 1ea88e206..290fb3579 100644
--- a/controllers/admin/AdminModulesPositionsController.php
+++ b/controllers/admin/AdminModulesPositionsController.php
@@ -27,26 +27,26 @@
class AdminModulesPositionsControllerCore extends AdminController
{
- private $displayKey = 0;
+ private $display_key = 0;
public function postProcess()
{
// Getting key value for display
if (Tools::getValue('show_modules') && strval(Tools::getValue('show_modules')) != 'all')
- $this->displayKey = (int)(Tools::getValue('show_modules'));
+ $this->display_key = (int)Tools::getValue('show_modules');
// Change position in hook
if (array_key_exists('changePosition', $_GET))
{
if ($this->tabAccess['edit'] === '1')
- {
- $id_module = (int)(Tools::getValue('id_module'));
- $id_hook = (int)(Tools::getValue('id_hook'));
+ {
+ $id_module = (int)Tools::getValue('id_module');
+ $id_hook = (int)Tools::getValue('id_hook');
$module = Module::getInstanceById($id_module);
if (Validate::isLoadedObject($module))
{
- $module->updatePosition($id_hook, (int)(Tools::getValue('direction')));
- Tools::redirectAdmin(self::$currentIndex.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token);
+ $module->updatePosition($id_hook, (int)Tools::getValue('direction'));
+ Tools::redirectAdmin(self::$currentIndex.($this->display_key ? '&show_modules='.$this->display_key : '').'&token='.$this->token);
}
else
$this->errors[] = Tools::displayError('module cannot be loaded');
@@ -58,12 +58,12 @@ class AdminModulesPositionsControllerCore extends AdminController
// Add new module in hook
elseif (Tools::isSubmit('submitAddToHook'))
{
- if ($this->tabAccess['add'] === '1')
+ if ($this->tabAccess['add'] === '1')
{
// Getting vars...
- $id_module = (int)(Tools::getValue('id_module'));
+ $id_module = (int)Tools::getValue('id_module');
$module = Module::getInstanceById($id_module);
- $id_hook = (int)(Tools::getValue('id_hook'));
+ $id_hook = (int)Tools::getValue('id_hook');
$hook = new Hook($id_hook);
if (!$id_module || !Validate::isLoadedObject($module))
@@ -94,7 +94,7 @@ class AdminModulesPositionsControllerCore extends AdminController
}
if (!$this->errors)
- Tools::redirectAdmin(self::$currentIndex.'&conf=16'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token);
+ Tools::redirectAdmin(self::$currentIndex.'&conf=16'.($this->display_key ? '&show_modules='.$this->display_key : '').'&token='.$this->token);
}
}
else
@@ -104,12 +104,12 @@ class AdminModulesPositionsControllerCore extends AdminController
// Edit module from hook
elseif (Tools::isSubmit('submitEditGraft'))
{
- if ($this->tabAccess['add'] === '1')
+ if ($this->tabAccess['add'] === '1')
{
// Getting vars...
- $id_module = (int)(Tools::getValue('id_module'));
+ $id_module = (int)Tools::getValue('id_module');
$module = Module::getInstanceById($id_module);
- $id_hook = (int)(Tools::getValue('id_hook'));
+ $id_hook = (int)Tools::getValue('id_hook');
$hook = new Hook($id_hook);
if (!$id_module || !Validate::isLoadedObject($module))
@@ -138,7 +138,7 @@ class AdminModulesPositionsControllerCore extends AdminController
$this->errors[] = Tools::displayError('An error occurred while transplanting module to hook.');
if (!$this->errors)
- Tools::redirectAdmin(self::$currentIndex.'&conf=16'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token);
+ Tools::redirectAdmin(self::$currentIndex.'&conf=16'.($this->display_key ? '&show_modules='.$this->display_key : '').'&token='.$this->token);
}
else
{
@@ -153,7 +153,7 @@ class AdminModulesPositionsControllerCore extends AdminController
if (!$module->editExceptions($id_hook, $exceptions, Context::getContext()->shop->getListOfID()))
$this->errors[] = Tools::displayError('An error occurred while transplanting module to hook.');
else
- Tools::redirectAdmin(self::$currentIndex.'&conf=16'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token);
+ Tools::redirectAdmin(self::$currentIndex.'&conf=16'.($this->display_key ? '&show_modules='.$this->display_key : '').'&token='.$this->token);
}
}
}
@@ -164,11 +164,11 @@ class AdminModulesPositionsControllerCore extends AdminController
// Delete module from hook
elseif (array_key_exists('deleteGraft', $_GET))
{
- if ($this->tabAccess['delete'] === '1')
- {
- $id_module = (int)(Tools::getValue('id_module'));
+ if ($this->tabAccess['delete'] === '1')
+ {
+ $id_module = (int)Tools::getValue('id_module');
$module = Module::getInstanceById($id_module);
- $id_hook = (int)(Tools::getValue('id_hook'));
+ $id_hook = (int)Tools::getValue('id_hook');
$hook = new Hook($id_hook);
if (!Validate::isLoadedObject($module))
$this->errors[] = Tools::displayError('module cannot be loaded');
@@ -176,10 +176,11 @@ class AdminModulesPositionsControllerCore extends AdminController
$this->errors[] = Tools::displayError('Hook cannot be loaded.');
else
{
- if (!$module->unregisterHook($id_hook, Context::getContext()->shop->getListOfID()) || !$module->unregisterExceptions($id_hook, Context::getContext()->shop->getListOfID()))
+ if (!$module->unregisterHook($id_hook, Context::getContext()->shop->getListOfID())
+ || !$module->unregisterExceptions($id_hook, Context::getContext()->shop->getListOfID()))
$this->errors[] = Tools::displayError('An error occurred while deleting module from hook.');
else
- Tools::redirectAdmin(self::$currentIndex.'&conf=17'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token);
+ Tools::redirectAdmin(self::$currentIndex.'&conf=17'.($this->display_key ? '&show_modules='.$this->display_key : '').'&token='.$this->token);
}
}
else
@@ -196,20 +197,20 @@ class AdminModulesPositionsControllerCore extends AdminController
$explode = explode('_', $unhook);
$id_hook = $explode[0];
$id_module = $explode[1];
- $module = Module::getInstanceById((int)($id_module));
- $hook = new Hook((int)($id_hook));
+ $module = Module::getInstanceById((int)$id_module);
+ $hook = new Hook((int)$id_hook);
if (!Validate::isLoadedObject($module))
$this->errors[] = Tools::displayError('module cannot be loaded');
elseif (!$id_hook || !Validate::isLoadedObject($hook))
$this->errors[] = Tools::displayError('Hook cannot be loaded.');
else
{
- if (!$module->unregisterHook((int)($id_hook)) || !$module->unregisterExceptions((int)($id_hook)))
+ if (!$module->unregisterHook((int)$id_hook) || !$module->unregisterExceptions((int)$id_hook))
$this->errors[] = Tools::displayError('An error occurred while deleting module from hook.');
}
}
if (!count($this->errors))
- Tools::redirectAdmin(self::$currentIndex.'&conf=17'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token);
+ Tools::redirectAdmin(self::$currentIndex.'&conf=17'.($this->display_key ? '&show_modules='.$this->display_key : '').'&token='.$this->token);
}
}
}
@@ -239,19 +240,19 @@ class AdminModulesPositionsControllerCore extends AdminController
$assoc_modules_id = array();
foreach ($modules as $module)
- if ($tmpInstance = Module::getInstanceById((int)$module['id_module']))
+ if ($tmp_instance = Module::getInstanceById((int)$module['id_module']))
{
// We want to be able to sort modules by display name
- $module_instances[$tmpInstance->displayName] = $tmpInstance;
+ $module_instances[$tmp_instance->displayName] = $tmp_instance;
// But we also want to associate hooks to modules using the modules IDs
- $assoc_modules_id[(int)$module['id_module']] = $tmpInstance->displayName;
+ $assoc_modules_id[(int)$module['id_module']] = $tmp_instance->displayName;
}
ksort($module_instances);
- $hooks = Hook::getHooks(!(int)(Tools::getValue('hook_position')));
+ $hooks = Hook::getHooks(!(int)Tools::getValue('hook_position'));
foreach ($hooks as $key => $hook)
{
// Get all modules for this hook or only the filtered module
- $hooks[$key]['modules'] = Hook::getModulesFromHook($hook['id_hook'], $this->displayKey);
+ $hooks[$key]['modules'] = Hook::getModulesFromHook($hook['id_hook'], $this->display_key);
$hooks[$key]['module_count'] = count($hooks[$key]['modules']);
// If modules were found, link to the previously created Module instances
if (is_array($hooks[$key]['modules']) && !empty($hooks[$key]['modules']))
@@ -263,7 +264,7 @@ class AdminModulesPositionsControllerCore extends AdminController
$this->addJqueryPlugin('tablednd');
$this->toolbar_btn['save'] = array(
- 'href' => self::$currentIndex.'&addToHook'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token,
+ 'href' => self::$currentIndex.'&addToHook'.($this->display_key ? '&show_modules='.$this->display_key : '').'&token='.$this->token,
'desc' => $this->l('Transplant a module')
);
@@ -275,11 +276,13 @@ class AdminModulesPositionsControllerCore extends AdminController
'token' => $this->token,
'url_show_modules' => self::$currentIndex.'&token='.$this->token.'&show_modules=',
'modules' => $module_instances,
- 'url_show_invisible' => self::$currentIndex.'&token='.$this->token.'&show_modules='.(int)(Tools::getValue('show_modules')).'&hook_position=',
+ 'url_show_invisible' => self::$currentIndex.'&token='.$this->token.'&show_modules='.(int)Tools::getValue('show_modules').'&hook_position=',
'hook_position' => Tools::getValue('hook_position'),
'live_edit' => Shop::isFeatureActive() && $this->context->shop->getContextType() != Shop::CONTEXT_SHOP,
- 'url_live_edit' => $this->context->link->getPageLink('index', false, null, 'live_edit&ad='.$admin_dir.'&liveToken='.sha1($admin_dir._COOKIE_KEY_).((Shop::isFeatureActive()) ? '&id_shop='.Context::getContext()->shop->getID() : '')),
- 'display_key' => $this->displayKey,
+ 'url_live_edit' => $this->context->link->getPageLink('index', false, null,
+ 'live_edit&ad='.$admin_dir.'&liveToken='.sha1($admin_dir._COOKIE_KEY_)
+ .(Shop::isFeatureActive()?'&id_shop='.Context::getContext()->shop->getID() : '')),
+ 'display_key' => $this->display_key,
'hooks' => $hooks,
'url_submit' => self::$currentIndex.'&token='.$this->token,
'can_move' => (Shop::isFeatureActive() && $this->context->shop->getContextType() != Shop::CONTEXT_SHOP) ? false : true,
@@ -294,8 +297,8 @@ class AdminModulesPositionsControllerCore extends AdminController
$this->initToolbarTitle();
// toolbar (save, cancel, new, ..)
$this->initToolbar();
- $id_module = (int)(Tools::getValue('id_module'));
- $id_hook = (int)(Tools::getValue('id_hook'));
+ $id_module = (int)Tools::getValue('id_module');
+ $id_hook = (int)Tools::getValue('id_hook');
if (Tools::isSubmit('editGraft'))
{
// Check auth for this page
@@ -310,39 +313,39 @@ class AdminModulesPositionsControllerCore extends AdminController
if (!Db::getInstance()->getValue($sql))
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
- $slModule = Module::getInstanceById($id_module);
- $exceptsList = $slModule->getExceptions($id_hook, true);
- $exceptsDiff = false;
+ $sl_module = Module::getInstanceById($id_module);
+ $excepts_list = $sl_module->getExceptions($id_hook, true);
+ $excepts_diff = false;
$excepts = '';
- if ($exceptsList)
+ if ($excepts_list)
{
- $first = current($exceptsList);
- foreach ($exceptsList as $k => $v)
+ $first = current($excepts_list);
+ foreach ($excepts_list as $k => $v)
if (array_diff($v, $first) || array_diff($first, $v))
- $exceptsDiff = true;
+ $excepts_diff = true;
- if (!$exceptsDiff)
+ if (!$excepts_diff)
$excepts = implode(', ', $first);
}
}
else
{
- $exceptsDiff = false;
- $exceptsList = Tools::getValue('exceptions', array(array()));
+ $excepts_diff = false;
+ $excepts_list = Tools::getValue('exceptions', array(array()));
}
$modules = Module::getModulesInstalled(0);
$instances = array();
foreach ($modules as $module)
- if ($tmpInstance = Module::getInstanceById($module['id_module']))
- $instances[$tmpInstance->displayName] = $tmpInstance;
+ if ($tmp_instance = Module::getInstanceById($module['id_module']))
+ $instances[$tmp_instance->displayName] = $tmp_instance;
ksort($instances);
$modules = $instances;
$hooks = Hook::getHooks(0);
$exception_list_diff = array();
- foreach ($exceptsList as $shopID => $fileList)
- $exception_list_diff[] = $this->displayModuleExceptionList($fileList, $shopID);
+ foreach ($excepts_list as $shop_id => $file_list)
+ $exception_list_diff[] = $this->displayModuleExceptionList($file_list, $shop_id);
$tpl = $this->createTemplate('form.tpl');
$tpl->assign(array(
@@ -352,10 +355,10 @@ class AdminModulesPositionsControllerCore extends AdminController
'id_hook' => (int)Tools::getValue('id_hook'),
'show_modules' => Tools::getValue('show_modules'),
'hooks' => $hooks,
- 'exception_list' => $this->displayModuleExceptionList(array_shift($exceptsList), 0),
+ 'exception_list' => $this->displayModuleExceptionList(array_shift($excepts_list), 0),
'exception_list_diff' => $exception_list_diff,
- 'except_diff' => isset($exceptsDiff) ? $exceptsDiff : null,
- 'display_key' => $this->displayKey,
+ 'except_diff' => isset($excepts_diff) ? $excepts_diff : null,
+ 'display_key' => $this->display_key,
'modules' => $modules,
'show_toolbar' => true,
'toolbar_btn' => $this->toolbar_btn,
@@ -366,23 +369,26 @@ class AdminModulesPositionsControllerCore extends AdminController
return $tpl->fetch();
}
- public function displayModuleExceptionList($fileList, $shopID)
+ public function displayModuleExceptionList($file_list, $shop_id)
{
- if (!is_array($fileList))
- $fileList = ($fileList) ? array($fileList) : array();
+ if (!is_array($file_list))
+ $file_list = ($file_list) ? array($file_list) : array();
- $content = '';
- if ($shopID)
- $content .= ' ('.Shop::getInstance($shopID)->name.')';
- $content .= '
+
';
return $content;
}