27 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
31 $action =
GETPOST(
'action',
'aZ09');
32 $cancel =
GETPOST(
'cancel',
'alpha');
35 $langs->loadLangs(array(
"companies",
"products",
"admin",
"users",
"other"));
42 $dirstandard = array();
43 $dirsmartphone = array();
44 $dirmenus = array_merge(array(
"/core/menus/"), (array) $conf->modules_parts[
'menus']);
45 foreach ($dirmenus as $dirmenu) {
46 $dirstandard[] = $dirmenu.
'standard';
47 $dirsmartphone[] = $dirmenu.
'smartphone';
54 $err = error_reporting();
58 error_reporting($err);
65 if ($action ==
'update' && !$cancel) {
66 $_SESSION[
"mainmenu"] =
"home";
69 dolibarr_set_const($db,
"MAIN_MENU_SMARTPHONE",
GETPOST(
'MAIN_MENU_SMARTPHONE',
'alpha'),
'chaine', 0,
'', $conf->entity);
71 dolibarr_set_const($db,
"MAIN_MENUFRONT_STANDARD",
GETPOST(
'MAIN_MENUFRONT_STANDARD',
'alpha'),
'chaine', 0,
'', $conf->entity);
72 dolibarr_set_const($db,
"MAIN_MENUFRONT_SMARTPHONE",
GETPOST(
'MAIN_MENUFRONT_SMARTPHONE',
'alpha'),
'chaine', 0,
'', $conf->entity);
75 $listofmenuhandler = array();
76 $listofmenuhandler[preg_replace(
'/(_backoffice|_frontoffice|_menu)?\.php/i',
'',
GETPOST(
'MAIN_MENU_STANDARD',
'alpha'))] = 1;
77 $listofmenuhandler[preg_replace(
'/(_backoffice|_frontoffice|_menu)?\.php/i',
'',
GETPOST(
'MAIN_MENUFRONT_STANDARD',
'alpha'))] = 1;
78 if (
GETPOST(
'MAIN_MENU_SMARTPHONE',
'alpha')) {
79 $listofmenuhandler[preg_replace(
'/(_backoffice|_frontoffice|_menu)?\.php/i',
'',
GETPOST(
'MAIN_MENU_SMARTPHONE',
'alpha'))] = 1;
81 if (
GETPOST(
'MAIN_MENUFRONT_SMARTPHONE',
'alpha')) {
82 $listofmenuhandler[preg_replace(
'/(_backoffice|_frontoffice|_menu)?\.php/i',
'',
GETPOST(
'MAIN_MENUFRONT_SMARTPHONE',
'alpha'))] = 1;
86 foreach ($listofmenuhandler as $key => $val) {
88 $dirmenus = array_merge(array(
"/core/menus/"), (array) $conf->modules_parts[
'menus']);
89 foreach ($dirmenus as $dirmenu) {
90 $file =
'init_menu_'.$key.
'.sql';
94 if (file_exists($fullpath)) {
97 $result =
run_sql($fullpath, 1,
'', 1, $key,
'none');
102 setEventMessages($langs->trans(
"FailedToInitializeMenu").
' '.$key,
null,
'errors');
113 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
126 $wikihelp =
'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
134 $head[$h][0] = DOL_URL_ROOT.
"/admin/menus.php";
135 $head[$h][1] = $langs->trans(
"MenuHandlers");
136 $head[$h][2] =
'handler';
139 $head[$h][0] = DOL_URL_ROOT.
"/admin/menus/index.php";
140 $head[$h][1] = $langs->trans(
"MenuAdmin");
141 $head[$h][2] =
'editor';
144 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
145 print
'<input type="hidden" name="token" value="'.newToken().
'">';
146 print
'<input type="hidden" name="action" value="update">';
150 print
'<span class="opacitymedium">'.$langs->trans(
"MenusDesc").
"</span><br>\n";
157 print
'<table class="noborder centpercent">';
158 print
'<tr class="liste_titre"><td width="35%">'.$langs->trans(
"Menu").
'</td>';
160 print
$form->textwithpicto($langs->trans(
"InternalUsers"), $langs->trans(
"InternalExternalDesc"));
163 print
$form->textwithpicto($langs->trans(
"ExternalUsers"), $langs->trans(
"InternalExternalDesc"));
168 print
'<tr class="oddeven"><td>'.$langs->trans(
"DefaultMenuManager").
'</td>';
170 $formadmin->select_menu(empty($conf->global->MAIN_MENU_STANDARD_FORCED) ? $conf->global->MAIN_MENU_STANDARD : $conf->global->MAIN_MENU_STANDARD_FORCED,
'MAIN_MENU_STANDARD', $dirstandard, empty($conf->global->MAIN_MENU_STANDARD_FORCED) ?
'' :
' disabled');
173 $formadmin->select_menu(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED) ? $conf->global->MAIN_MENUFRONT_STANDARD : $conf->global->MAIN_MENUFRONT_STANDARD_FORCED,
'MAIN_MENUFRONT_STANDARD', $dirstandard, empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED) ?
'' :
' disabled');
178 print
'<tr class="oddeven"><td>'.$langs->trans(
"DefaultMenuSmartphoneManager").
'</td>';
180 $formadmin->select_menu(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) ? $conf->global->MAIN_MENU_SMARTPHONE : $conf->global->MAIN_MENU_SMARTPHONE_FORCED,
'MAIN_MENU_SMARTPHONE', array_merge($dirstandard, $dirsmartphone), empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) ?
'' :
' disabled');
182 if (!empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && preg_match(
'/smartphone/', $conf->global->MAIN_MENU_SMARTPHONE_FORCED)
183 || (empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && !empty($conf->global->MAIN_MENU_SMARTPHONE) && preg_match(
'/smartphone/', $conf->global->MAIN_MENU_SMARTPHONE))) {
184 print
' '.img_warning($langs->transnoentitiesnoconv(
"ThisForceAlsoTheme"));
189 $formadmin->select_menu(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED) ? $conf->global->MAIN_MENUFRONT_SMARTPHONE : $conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED,
'MAIN_MENUFRONT_SMARTPHONE', array_merge($dirstandard, $dirsmartphone), empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED) ?
'' :
' disabled');
191 if (!empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && preg_match(
'/smartphone/', $conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)
192 || (empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED) && !empty($conf->global->MAIN_MENU_SMARTPHONE) && preg_match(
'/smartphone/', $conf->global->MAIN_MENUFRONT_SMARTPHONE))) {
193 print
' '.img_warning($langs->transnoentitiesnoconv(
"ThisForceAlsoTheme"));
203 print
'<div class="center">';
204 print
'<input class="button button-save" type="submit" name="save" value="'.$langs->trans(
"Save").
'">';