diff --git a/ChangeLog b/ChangeLog index 68d0122bd81..ed0366d8bbe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ English Dolibarr ChangeLog +***** ChangeLog for 3.1 compared to 3.0 ***** + +For developers: +- New: External modules can add their menu manager + + ***** ChangeLog for 3.0 compared to 2.9 ***** For users: diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php index 23dc54262ed..88f5383250a 100644 --- a/htdocs/admin/menus.php +++ b/htdocs/admin/menus.php @@ -40,9 +40,9 @@ $langs->load("other"); // Security check if (!$user->admin) accessforbidden(); -$dirtop = "../includes/menus/standard"; -$dirleft = "../includes/menus/standard"; -$dirsmartphone = "../includes/menus/smartphone"; +$dirtop = "/includes/menus/standard"; +$dirleft = "/includes/menus/standard"; +$dirsmartphone = "/includes/menus/smartphone"; // Cette page peut etre longue. On augmente le delai autorise. @@ -78,13 +78,14 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update' && empty($_POST["can // Initialize menu handlers foreach ($listofmenuhandler as $key => $val) { - $dir = DOL_DOCUMENT_ROOT."/includes/menus/"; - // Load sql init_menu_handler.sql file - $file='init_menu_'.$key.'.sql'; - if (file_exists($dir.$file)) + $dir = "/includes/menus/"; + $file='init_menu_'.$key.'.sql'; + $fullpath=dol_buildpath($dir.$file); + + if (file_exists($fullpath)) { - $result=run_sql($dir.$file,1,'',1,$key); + $result=run_sql($fullpath,1,'',1,$key); } } diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index daad5e7fa4f..b4f6d107ef0 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -35,9 +35,9 @@ $langs->load("admin"); if (! $user->admin) accessforbidden(); -$dirtop = "../../includes/menus/standard"; -$dirleft = "../../includes/menus/standard"; -$dirsmartphone = "../../includes/menus/smartphone"; +$dirtop = "/includes/menus/standard"; +$dirleft = "/includes/menus/standard"; +$dirsmartphone = "/includes/menus/smartphone"; $dirmenu = array($dirleft,$dirsmartphone); @@ -349,7 +349,7 @@ elseif (isset($_GET["action"]) && $_GET["action"] == 'edit') $menu = new Menubase($db); $result=$menu->fetch($_GET['menuId']); //var_dump($menu); - + // MenuId Parent print ''.$langs->trans('MenuIdParent').''; //$menu_handler diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php index e44b1c1aea1..57ad0296eea 100644 --- a/htdocs/admin/menus/index.php +++ b/htdocs/admin/menus/index.php @@ -35,9 +35,9 @@ $langs->load("admin"); if (! $user->admin) accessforbidden(); -$dirtop = "../../includes/menus/standard"; -$dirleft = "../../includes/menus/standard"; -$dirsmartphone = "../../includes/menus/smartphone"; +$dirtop = "/includes/menus/standard"; +$dirleft = "/includes/menus/standard"; +$dirsmartphone = "/includes/menus/smartphone"; $dirmenu = array($dirleft,$dirsmartphone); diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index 4186ee6f08c..e7e465a92a1 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -134,30 +134,34 @@ class FormAdmin if ($selected == 'eldy.php') $selected='eldy_backoffice.php'; // For compatibility $menuarray=array(); - $handle=opendir($dirmenu); - if (is_resource($handle)) + foreach ($conf->file->dol_document_root as $dirroot) { - while (($file = readdir($handle))!==false) + $dir=$dirroot.$dirmenu; + $handle=opendir($dir); + if (is_resource($handle)) { - if (is_file($dirmenu."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') + while (($file = readdir($handle))!==false) { - if (preg_match('/lib\.php$/i',$file)) continue; // We exclude library files - $filelib=preg_replace('/\.php$/i','',$file); - $prefix=''; - if (preg_match('/^eldy|^iphone/i',$file)) $prefix='0'; // 0=Recommanded, 1=Experimental, 2=Other - else $prefix='2'; + if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') + { + if (preg_match('/lib\.php$/i',$file)) continue; // We exclude library files + $filelib=preg_replace('/\.php$/i','',$file); + $prefix=''; + if (preg_match('/^eldy|^iphone/i',$file)) $prefix='0'; // 0=Recommanded, 1=Experimental, 2=Other + else $prefix='2'; - if ($file == $selected) - { - $menuarray[$prefix.'_'.$file]=''; - } - else - { - $menuarray[$prefix.'_'.$file]=''; + if ($file == $selected) + { + $menuarray[$prefix.'_'.$file]=''; + } + else + { + $menuarray[$prefix.'_'.$file]=''; + } } } + closedir($handle); } - closedir($handle); } ksort($menuarray); @@ -199,24 +203,28 @@ class FormAdmin foreach($dirmenuarray as $dirmenu) { - $handle=opendir($dirmenu); - if (is_resource($handle)) + foreach ($conf->file->dol_document_root as $dirroot) { - while (($file = readdir($handle))!==false) - { - if (is_file($dirmenu."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') - { - $filelib=preg_replace('/(_backoffice|_frontoffice)?\.php$/i','',$file); - if (preg_match('/^default/i',$filelib)) continue; - if (preg_match('/^empty/i',$filelib)) continue; - if (preg_match('/\.lib/i',$filelib)) continue; - if (empty($conf->global->MAIN_FEATURES_LEVEL) && in_array($file,$expdevmenu)) continue; + $dir=$dirroot.$dirmenu; + $handle=opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') + { + $filelib=preg_replace('/(_backoffice|_frontoffice)?\.php$/i','',$file); + if (preg_match('/^default/i',$filelib)) continue; + if (preg_match('/^empty/i',$filelib)) continue; + if (preg_match('/\.lib/i',$filelib)) continue; + if (empty($conf->global->MAIN_FEATURES_LEVEL) && in_array($file,$expdevmenu)) continue; - $menuarray[$filelib]=1; - } - $menuarray['all']=1; - } - closedir($handle); + $menuarray[$filelib]=1; + } + $menuarray['all']=1; + } + closedir($handle); + } } } diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index a923a89207e..e363dbdcaa4 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -87,7 +87,7 @@ function dol_getprefix() function dol_include_once($relpath) { global $conf,$langs,$user,$mysoc; // Other global var must be retreived with $GLOBALS['var'] - return include_once(dol_buildpath($relpath)); + return @include_once(dol_buildpath($relpath)); } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 3e97479ca3a..aa0a8168dbd 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -951,7 +951,6 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a if (! $conf->top_menu) $conf->top_menu ='eldy_backoffice.php'; - // For backward compatibility with old modules if (empty($conf->headerdone)) top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); @@ -1051,11 +1050,11 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a if (GETPOST('menu')) $top_menu=GETPOST('menu'); // menu=eldy_backoffice.php // Load the top menu manager - $result=@include_once(DOL_DOCUMENT_ROOT ."/includes/menus/standard/".$top_menu); + $result=dol_include_once("/includes/menus/standard/".$top_menu); if (! $result) // If failed to include, we try with standard { $top_menu='eldy_backoffice.php'; - include_once(DOL_DOCUMENT_ROOT ."/includes/menus/standard/".$top_menu); + include_once(DOL_DOCUMENT_ROOT."/includes/menus/standard/".$top_menu); } print "\n".''."\n"; @@ -1068,7 +1067,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a $menutop = new MenuTop($db); $menutop->atarget=$target; $menutop->showmenu(); - + print "\n\n"; // Link to login card @@ -1125,11 +1124,11 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a $logouttext.=' alt="'.dol_escape_htmltag($langs->trans("Logout")).'" title=""'; $logouttext.='>'; } - + print '
'."\n"; print $html->textwithtooltip('',$loginhtmltext,2,1,$logintext); - + // Select entity if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) { @@ -1243,7 +1242,7 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me if (GETPOST('menu')) $left_menu=GETPOST('menu'); // menu=eldy_backoffice.php // Load the left menu manager - $result=@include_once(DOL_DOCUMENT_ROOT ."/includes/menus/standard/".$left_menu); + $result=dol_include_once("/includes/menus/standard/".$left_menu); if (! $result) // If menu manager removed or not found { $left_menu='eldy_backoffice.php';