Fix: Menu editor
This commit is contained in:
parent
7367a2472c
commit
95098a9b59
@ -68,7 +68,7 @@ error_reporting($err);
|
||||
if ($action == 'update' && empty($_POST["cancel"]))
|
||||
{
|
||||
$_SESSION["mainmenu"]="home"; // Le gestionnaire de menu a pu changer
|
||||
|
||||
|
||||
dolibarr_set_const($db, "MAIN_MENU_STANDARD", $_POST["MAIN_MENU_STANDARD"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_MENU_SMARTPHONE", $_POST["MAIN_MENU_SMARTPHONE"],'chaine',0,'',$conf->entity);
|
||||
|
||||
@ -77,29 +77,37 @@ if ($action == 'update' && empty($_POST["cancel"]))
|
||||
|
||||
// Define list of menu handlers to initialize
|
||||
$listofmenuhandler=array();
|
||||
$listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i','',$_POST["MAIN_MENU_STANDARD"])]=1;
|
||||
$listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i','',$_POST["MAIN_MENUFRONT_STANDARD"])]=1;
|
||||
if (isset($_POST["MAIN_MENU_SMARTPHONE"])) $listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i','',$_POST["MAIN_MENU_SMARTPHONE"])]=1;
|
||||
if (isset($_POST["MAIN_MENUFRONT_SMARTPHONE"])) $listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i','',$_POST["MAIN_MENUFRONT_SMARTPHONE"])]=1;
|
||||
|
||||
// Initialize menu handlers
|
||||
foreach ($listofmenuhandler as $key => $val)
|
||||
{
|
||||
// Load sql init_menu_handler.sql file
|
||||
$dir = "/core/menus/";
|
||||
$file='init_menu_'.$key.'.sql';
|
||||
$fullpath=dol_buildpath($dir.$file);
|
||||
|
||||
if (file_exists($fullpath))
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$result=run_sql($fullpath,1,'',1,$key,'none');
|
||||
if ($result > 0)
|
||||
$dirmenus=array_merge(array("/core/menus/"),(array) $conf->modules_parts['menus']);
|
||||
foreach($dirmenus as $dirmenu)
|
||||
{
|
||||
$file='init_menu_'.$key.'.sql';
|
||||
$fullpath=dol_buildpath($dirmenu.$file);
|
||||
//print 'action='.$action.' Search menu into fullpath='.$fullpath.'<br>';exit;
|
||||
|
||||
if (file_exists($fullpath))
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$errmsgs[]='Failed to initialize menu '.$key.'.';
|
||||
$db->rollback();
|
||||
$db->begin();
|
||||
|
||||
$result=run_sql($fullpath,1,'',1,$key,'none');
|
||||
if ($result > 0)
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$errmsgs[]='Failed to initialize menu '.$key.'.';
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,20 +47,24 @@ $mesg=GETPOST('mesg');
|
||||
|
||||
$menu_handler_top=$conf->global->MAIN_MENU_STANDARD;
|
||||
$menu_handler_smartphone=$conf->global->MAIN_MENU_SMARTPHONE;
|
||||
$menu_handler_top=preg_replace('/_backoffice.php/i','',$menu_handler_top);
|
||||
$menu_handler_top=preg_replace('/_frontoffice.php/i','',$menu_handler_top);
|
||||
$menu_handler_smartphone=preg_replace('/_backoffice.php/i','',$menu_handler_smartphone);
|
||||
$menu_handler_smartphone=preg_replace('/_frontoffice.php/i','',$menu_handler_smartphone);
|
||||
$menu_handler_top=preg_replace('/(_backoffice\.php|_menu\.php)/i','',$menu_handler_top);
|
||||
$menu_handler_top=preg_replace('/(_frontoffice\.php|_menu\.php)/i','',$menu_handler_top);
|
||||
$menu_handler_smartphone=preg_replace('/(_backoffice\.php|_menu\.php)/i','',$menu_handler_smartphone);
|
||||
$menu_handler_smartphone=preg_replace('/(_frontoffice\.php|_menu\.php)/i','',$menu_handler_smartphone);
|
||||
|
||||
$menu_handler=$menu_handler_top;
|
||||
|
||||
|
||||
if (GETPOST("handler_origine")) $menu_handler=GETPOST("handler_origine");
|
||||
if (GETPOST("menu_handler")) $menu_handler=GETPOST("menu_handler");
|
||||
|
||||
$menu_handler_to_search=preg_replace('/(_backoffice|_menu)?(\.php)?/i','',$menu_handler);
|
||||
$menu_handler_to_search=preg_replace('/(_frontoffice|_menu)?(\.php)?/i','',$menu_handler);
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'up')
|
||||
{
|
||||
@ -89,7 +93,7 @@ if ($action == 'up')
|
||||
$sql = "SELECT m.rowid, m.position";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
|
||||
$sql.= " WHERE (m.position < ".($current['order'])." OR (m.position = ".($current['order'])." AND rowid < ".$_GET["menuId"]."))";
|
||||
$sql.= " AND m.menu_handler='".$menu_handler."'";
|
||||
$sql.= " AND m.menu_handler='".$menu_handler_to_search."'";
|
||||
$sql.= " AND m.entity = ".$conf->entity;
|
||||
$sql.= " AND m.type = '".$current['type']."'";
|
||||
$sql.= " AND m.fk_menu = '".$current['fk_menu']."'";
|
||||
@ -145,7 +149,7 @@ elseif ($action == 'down')
|
||||
$sql = "SELECT m.rowid, m.position";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
|
||||
$sql.= " WHERE (m.position > ".($current['order'])." OR (m.position = ".($current['order'])." AND rowid > ".$_GET["menuId"]."))";
|
||||
$sql.= " AND m.menu_handler='".$menu_handler."'";
|
||||
$sql.= " AND m.menu_handler='".$menu_handler_to_search."'";
|
||||
$sql.= " AND m.entity = ".$conf->entity;
|
||||
$sql.= " AND m.type = '".$current['type']."'";
|
||||
$sql.= " AND m.fk_menu = '".$current['fk_menu']."'";
|
||||
@ -255,7 +259,7 @@ if ($action == 'delete')
|
||||
print '<form name="newmenu" class="nocellnopadd" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" action="change_menu_handler">';
|
||||
print $langs->trans("MenuHandler").': ';
|
||||
print $formadmin->select_menu_families($menu_handler,'menu_handler',array_merge($dirstandard,$dirsmartphone));
|
||||
print $formadmin->select_menu_families($menu_handler.(preg_match('/_menu/',$menu_handler)?'':'_menu'),'menu_handler',array_merge($dirstandard,$dirsmartphone));
|
||||
print ' <input type="submit" class="button" value="'.$langs->trans("Refresh").'">';
|
||||
print '</form>';
|
||||
|
||||
@ -294,7 +298,7 @@ if ($conf->use_javascript_ajax)
|
||||
|
||||
$sql = "SELECT m.rowid, m.titre, m.langs, m.mainmenu, m.leftmenu, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
|
||||
$sql.= " WHERE menu_handler = '".$menu_handler."'";
|
||||
$sql.= " WHERE menu_handler = '".$menu_handler_to_search."'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$sql.= " AND fk_menu >= 0";
|
||||
$sql.= " ORDER BY m.position, m.rowid"; // Order is position then rowid (because we need a sort criteria when position is same)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user