[+] BO : new display of module list in all BO tabs
This commit is contained in:
@@ -42,6 +42,8 @@ class TabCore extends ObjectModel
|
||||
|
||||
/** @var integer active */
|
||||
public $active = true;
|
||||
|
||||
const TAB_MODULE_LIST_URL = 'api.prestashop.com/xml/tab_modules_list.xml';
|
||||
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
@@ -503,4 +505,35 @@ class TabCore extends ObjectModel
|
||||
{
|
||||
return Db::getInstance()->getValue('SELECT class_name FROM '._DB_PREFIX_.'tab WHERE id_tab = '.(int)$id_tab);
|
||||
}
|
||||
|
||||
public static function getTabModulesList($id_tab)
|
||||
{
|
||||
$modules_list = array();
|
||||
$xml_tab_modules_list = false;
|
||||
$db_tab_module_list = Db::getInstance()->executeS('
|
||||
SELECT module
|
||||
FROM '._DB_PREFIX_.'tab_module_preference
|
||||
WHERE `id_tab` = '.(int)$id_tab.'
|
||||
AND `id_employee` = '.(int)Context::getContext()->employee->id
|
||||
);
|
||||
|
||||
if (file_exists(_PS_ROOT_DIR_.Module::CACHE_FILE_TAB_MODULES_LIST))
|
||||
$xml_tab_modules_list = @simplexml_load_file(_PS_ROOT_DIR_.Module::CACHE_FILE_TAB_MODULES_LIST);
|
||||
|
||||
if ($xml_tab_modules_list)
|
||||
foreach ($xml_tab_modules_list->children() as $tab)
|
||||
foreach($tab->attributes() as $key => $value)
|
||||
if ($key == 'class_name' && Tab::getIdFromClassName((string)$value) == $id_tab)
|
||||
foreach ($tab->children() as $module)
|
||||
foreach ($module->attributes() as $k => $v)
|
||||
if ($k == 'name')
|
||||
$modules_list[] = (string)$v;
|
||||
|
||||
//merge tab modules preferences from db with xml
|
||||
foreach($db_tab_module_list as $m)
|
||||
if (!in_array($m, $modules_list))
|
||||
$modules_list[] = $m['module'];
|
||||
|
||||
return $modules_list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1368,6 +1368,7 @@ class AdminControllerCore extends Controller
|
||||
$this->getLanguages();
|
||||
// toolbar (save, cancel, new, ..)
|
||||
$this->initToolbar();
|
||||
$this->initTabModuleList();
|
||||
if ($this->display == 'edit' || $this->display == 'add')
|
||||
{
|
||||
if (!$this->loadObject(true))
|
||||
@@ -1384,7 +1385,6 @@ class AdminControllerCore extends Controller
|
||||
}
|
||||
elseif (!$this->ajax)
|
||||
{
|
||||
|
||||
$this->content .= $this->renderList();
|
||||
$this->content .= $this->renderOptions();
|
||||
|
||||
@@ -1398,6 +1398,27 @@ class AdminControllerCore extends Controller
|
||||
'url_post' => self::$currentIndex.'&token='.$this->token,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* init tab modules list and add button in toolbar
|
||||
*/
|
||||
protected function initTabModuleList()
|
||||
{
|
||||
$tab_modules_list = array();
|
||||
if (!$this->isFresh(Module::CACHE_FILE_TAB_MODULES_LIST, 604800))
|
||||
$this->refresh(Module::CACHE_FILE_TAB_MODULES_LIST, 'http://'.Tab::TAB_MODULE_LIST_URL);
|
||||
|
||||
$tab_modules_list = Tab::getTabModulesList($this->id);
|
||||
if ($tab_modules_list)
|
||||
$this->toolbar_btn['modules-list'] = array(
|
||||
'href' => '#',
|
||||
'desc' => $this->l('Modules List')
|
||||
);
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'tab_modules_list' => implode(',', $tab_modules_list),
|
||||
'admin_module_ajax_url' => $this->context->link->getAdminLink('AdminModules')));
|
||||
}
|
||||
|
||||
/**
|
||||
* initialize the invalid doom page of death
|
||||
|
||||
@@ -122,6 +122,8 @@ abstract class ModuleCore
|
||||
|
||||
const CACHE_FILE_MODULES_LIST = '/config/xml/modules_list.xml';
|
||||
|
||||
const CACHE_FILE_TAB_MODULES_LIST = '/config/xml/tab_modules_list.xml';
|
||||
|
||||
const CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST = '/config/xml/default_country_modules_list.xml';
|
||||
|
||||
const CACHE_FILE_CUSTOMER_MODULES_LIST = '/config/xml/customer_modules_list.xml';
|
||||
|
||||
Reference in New Issue
Block a user