PageRenderTime 52ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/admin/menus.php

https://github.com/asterix14/dolibarr
PHP | 251 lines | 163 code | 48 blank | 40 comment | 20 complexity | 58f4aa9ab7255dd53e78607773c8a321 MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/admin/menus.php
  21. * \ingroup core
  22. * \brief Page to setup menu manager to use
  23. */
  24. require("../main.inc.php");
  25. require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
  26. require_once(DOL_DOCUMENT_ROOT."/core/class/html.formadmin.class.php");
  27. require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
  28. $langs->load("companies");
  29. $langs->load("products");
  30. $langs->load("admin");
  31. $langs->load("users");
  32. $langs->load("other");
  33. // Security check
  34. if (!$user->admin) accessforbidden();
  35. $dirtop = "/core/menus/standard";
  36. $dirleft = "/core/menus/standard";
  37. $dirsmartphone = "/core/menus/smartphone";
  38. // Cette page peut etre longue. On augmente le delai autorise.
  39. // Ne fonctionne que si on est pas en safe_mode.
  40. $err=error_reporting();
  41. error_reporting(0); // Disable all errors
  42. //error_reporting(E_ALL);
  43. @set_time_limit(300); // Need more than 240 on Windows 7/64
  44. error_reporting($err);
  45. /*
  46. * Actions
  47. */
  48. if (isset($_POST["action"]) && $_POST["action"] == 'update' && empty($_POST["cancel"]))
  49. {
  50. $_SESSION["mainmenu"]="home"; // Le gestionnaire de menu a pu changer
  51. dolibarr_set_const($db, "MAIN_MENU_STANDARD", $_POST["MAIN_MENU_STANDARD"],'chaine',0,'',$conf->entity);
  52. dolibarr_set_const($db, "MAIN_MENU_SMARTPHONE", $_POST["MAIN_MENU_SMARTPHONE"],'chaine',0,'',$conf->entity);
  53. dolibarr_set_const($db, "MAIN_MENUFRONT_STANDARD", $_POST["MAIN_MENUFRONT_STANDARD"],'chaine',0,'',$conf->entity);
  54. dolibarr_set_const($db, "MAIN_MENUFRONT_SMARTPHONE",$_POST["MAIN_MENUFRONT_SMARTPHONE"],'chaine',0,'',$conf->entity);
  55. // Define list of menu handlers to initialize
  56. $listofmenuhandler=array();
  57. $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENU_STANDARD"])]=1;
  58. $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENUFRONT_STANDARD"])]=1;
  59. if (isset($_POST["MAIN_MENU_SMARTPHONE"])) $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENU_SMARTPHONE"])]=1;
  60. if (isset($_POST["MAIN_MENUFRONT_SMARTPHONE"])) $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENUFRONT_SMARTPHONE"])]=1;
  61. // Initialize menu handlers
  62. foreach ($listofmenuhandler as $key => $val)
  63. {
  64. // Load sql init_menu_handler.sql file
  65. $dir = "/core/menus/";
  66. $file='init_menu_'.$key.'.sql';
  67. $fullpath=dol_buildpath($dir.$file);
  68. if (file_exists($fullpath))
  69. {
  70. $result=run_sql($fullpath,1,'',1,$key);
  71. }
  72. }
  73. // We make a header redirect because we need to change menu NOW.
  74. header("Location: ".$_SERVER["PHP_SELF"]);
  75. exit;
  76. }
  77. /*
  78. * View
  79. */
  80. $form=new Form($db);
  81. $htmladmin=new FormAdmin($db);
  82. $wikihelp='EN:First_setup|FR:Premiers_paramĂŠtrages|ES:Primeras_configuraciones';
  83. llxHeader('',$langs->trans("Setup"),$wikihelp);
  84. print_fiche_titre($langs->trans("Menus"),'','setup');
  85. print $langs->trans("MenusDesc")."<br>\n";
  86. print "<br>\n";
  87. $h = 0;
  88. $head[$h][0] = DOL_URL_ROOT."/admin/menus.php";
  89. $head[$h][1] = $langs->trans("MenuHandlers");
  90. $head[$h][2] = 'handler';
  91. $h++;
  92. $head[$h][0] = DOL_URL_ROOT."/admin/menus/index.php";
  93. $head[$h][1] = $langs->trans("MenuAdmin");
  94. $head[$h][2] = 'editor';
  95. $h++;
  96. $head[$h][0] = DOL_URL_ROOT."/admin/menus/other.php";
  97. $head[$h][1] = $langs->trans("Miscellanous");
  98. $head[$h][2] = 'misc';
  99. $h++;
  100. dol_fiche_head($head, 'handler', $langs->trans("Menus"));
  101. if (isset($_GET["action"]) && $_GET["action"] == 'edit')
  102. {
  103. print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
  104. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  105. print '<input type="hidden" name="action" value="update">';
  106. clearstatcache();
  107. // Gestionnaires de menu
  108. $var=true;
  109. print '<table class="noborder" width="100%">';
  110. print '<tr class="liste_titre"><td width="35%">'.$langs->trans("Menu").'</td>';
  111. print '<td>';
  112. print $form->textwithpicto($langs->trans("InternalUsers"),$langs->trans("InternalExternalDesc"));
  113. print '</td>';
  114. print '<td>';
  115. print $form->textwithpicto($langs->trans("ExternalUsers"),$langs->trans("InternalExternalDesc"));
  116. print '</td>';
  117. print '</tr>';
  118. // Menu top
  119. $var=!$var;
  120. print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuManager").'</td>';
  121. print '<td>';
  122. print $htmladmin->select_menu(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?$conf->global->MAIN_MENU_STANDARD:$conf->global->MAIN_MENU_STANDARD_FORCED, 'MAIN_MENU_STANDARD', $dirtop, empty($conf->global->MAIN_MENU_STANDARD_FORCED)?'':' disabled="disabled"');
  123. print '</td>';
  124. print '<td>';
  125. print $htmladmin->select_menu(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?$conf->global->MAIN_MENUFRONT_STANDARD:$conf->global->MAIN_MENUFRONT_STANDARD_FORCED, 'MAIN_MENUFRONT_STANDARD', $dirtop, empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?'':' disabled="disabled"');
  126. print '</td>';
  127. print '</tr>';
  128. // Menu smartphone
  129. $var=!$var;
  130. print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuSmartphoneManager").'</td>';
  131. print '<td>';
  132. print $htmladmin->select_menu(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED, 'MAIN_MENU_SMARTPHONE', array($dirtop,$dirsmartphone), empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?'':' disabled="disabled"');
  133. print '</td>';
  134. print '<td>';
  135. print $htmladmin->select_menu(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?$conf->global->MAIN_MENUFRONT_SMARTPHONE:$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED, 'MAIN_MENUFRONT_SMARTPHONE', array($dirtop,$dirsmartphone), empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?'':' disabled="disabled"');
  136. print '</td>';
  137. print '</tr>';
  138. print '</table>';
  139. print '<br><center>';
  140. print '<input class="button" type="submit" name="save" value="'.$langs->trans("Save").'">';
  141. print ' &nbsp; &nbsp; ';
  142. print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
  143. print '</center>';
  144. print '</form>';
  145. }
  146. else
  147. {
  148. // Gestionnaires de menu
  149. $var=true;
  150. print '<table class="noborder" width="100%">';
  151. print '<tr class="liste_titre"><td width="35%">'.$langs->trans("Menu").'</td>';
  152. print '<td>';
  153. print $form->textwithpicto($langs->trans("InternalUsers"),$langs->trans("InternalExternalDesc"));
  154. print '</td>';
  155. print '<td>';
  156. print $form->textwithpicto($langs->trans("ExternalUsers"),$langs->trans("InternalExternalDesc"));
  157. print '</td>';
  158. print '</tr>';
  159. $var=!$var;
  160. print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuManager").'</td>';
  161. print '<td>';
  162. $filelib=preg_replace('/.php$/i','',(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?$conf->global->MAIN_MENU_STANDARD:$conf->global->MAIN_MENU_STANDARD_FORCED));
  163. print $filelib;
  164. print '</td>';
  165. print '<td>';
  166. $filelib=preg_replace('/.php$/i','',(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?$conf->global->MAIN_MENUFRONT_STANDARD:$conf->global->MAIN_MENUFRONT_STANDARD_FORCED));
  167. print $filelib;
  168. print '</td>';
  169. print '</tr>';
  170. $var=!$var;
  171. print '<tr '.$bc[$var].'>';
  172. print '<td>'.$langs->trans("DefaultMenuSmartphoneManager").'</td>';
  173. print '<td>';
  174. $filelib=preg_replace('/.php$/i','',(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED));
  175. print $filelib;
  176. if (preg_match('/smartphone/',$conf->global->MAIN_MENU_SMARTPHONE_FORCED)
  177. || (empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && preg_match('/smartphone/',$conf->global->MAIN_MENU_SMARTPHONE)))
  178. {
  179. print ' '.img_warning($langs->transnoentitiesnoconv("ThisForceAlsoTheme"));
  180. }
  181. print '</td>';
  182. print '<td>';
  183. $filelib=preg_replace('/.php$/i','',(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?$conf->global->MAIN_MENUFRONT_SMARTPHONE:$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED));
  184. print $filelib;
  185. if (preg_match('/smartphone/',$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)
  186. || (empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED) && preg_match('/smartphone/',$conf->global->MAIN_MENUFRONT_SMARTPHONE)))
  187. {
  188. print ' '.img_warning($langs->transnoentitiesnoconv("ThisForceAlsoTheme"));
  189. }
  190. print '</td>';
  191. print '</tr>';
  192. print '</table>';
  193. }
  194. print '</div>';
  195. if (! isset($_GET["action"]) || $_GET["action"] != 'edit')
  196. {
  197. print '<div class="tabsAction">';
  198. print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
  199. print '</div>';
  200. }
  201. $db->close();
  202. llxFooter();
  203. ?>