2007-04-11 00:45:42 +00:00
|
|
|
<?php
|
|
|
|
|
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2012-02-10 15:37:41 +00:00
|
|
|
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
2018-10-27 12:43:12 +00:00
|
|
|
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
|
2007-04-11 00:45:42 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2013-01-16 14:36:08 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2007-04-11 00:45:42 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2019-09-23 19:55:30 +00:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2007-04-11 00:45:42 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2008-12-04 19:13:40 +00:00
|
|
|
* \file htdocs/admin/menus.php
|
|
|
|
|
* \ingroup core
|
2010-02-20 15:07:46 +00:00
|
|
|
* \brief Page to setup menu manager to use
|
2008-12-04 19:13:40 +00:00
|
|
|
*/
|
2007-04-11 00:45:42 +00:00
|
|
|
|
2012-08-22 21:24:21 +00:00
|
|
|
require '../main.inc.php';
|
2012-08-22 21:11:24 +00:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
2008-01-11 10:25:26 +00:00
|
|
|
|
2020-04-10 08:59:32 +00:00
|
|
|
$action = GETPOST('action', 'aZ09');
|
|
|
|
|
$cancel = GETPOST('cancel', 'alpha');
|
2007-04-11 00:45:42 +00:00
|
|
|
|
2018-05-26 16:41:16 +00:00
|
|
|
// Load translation files required by the page
|
2020-04-10 08:59:32 +00:00
|
|
|
$langs->loadLangs(array("companies", "products", "admin", "users", "other"));
|
2007-04-11 00:45:42 +00:00
|
|
|
|
2010-02-20 15:07:46 +00:00
|
|
|
// Security check
|
2021-02-26 21:04:03 +00:00
|
|
|
if (!$user->admin) {
|
|
|
|
|
accessforbidden();
|
|
|
|
|
}
|
2007-04-11 00:45:42 +00:00
|
|
|
|
2012-06-12 16:35:29 +00:00
|
|
|
$dirstandard = array();
|
|
|
|
|
$dirsmartphone = array();
|
2020-04-10 08:59:32 +00:00
|
|
|
$dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
|
2021-02-26 21:04:03 +00:00
|
|
|
foreach ($dirmenus as $dirmenu) {
|
2020-04-10 08:59:32 +00:00
|
|
|
$dirstandard[] = $dirmenu.'standard';
|
|
|
|
|
$dirsmartphone[] = $dirmenu.'smartphone';
|
2012-02-12 14:17:54 +00:00
|
|
|
}
|
2007-04-11 00:45:42 +00:00
|
|
|
|
2020-04-10 08:59:32 +00:00
|
|
|
$error = 0;
|
2007-04-11 00:45:42 +00:00
|
|
|
|
2010-09-29 08:40:13 +00:00
|
|
|
// Cette page peut etre longue. On augmente le delai autorise.
|
|
|
|
|
// Ne fonctionne que si on est pas en safe_mode.
|
2020-04-10 08:59:32 +00:00
|
|
|
$err = error_reporting();
|
|
|
|
|
error_reporting(0); // Disable all errors
|
2010-09-29 08:40:13 +00:00
|
|
|
//error_reporting(E_ALL);
|
2020-04-10 08:59:32 +00:00
|
|
|
@set_time_limit(300); // Need more than 240 on Windows 7/64
|
2010-09-29 08:40:13 +00:00
|
|
|
error_reporting($err);
|
|
|
|
|
|
|
|
|
|
|
2007-04-11 00:45:42 +00:00
|
|
|
/*
|
2010-02-20 15:07:46 +00:00
|
|
|
* Actions
|
|
|
|
|
*/
|
2007-04-11 00:45:42 +00:00
|
|
|
|
2021-02-26 21:04:03 +00:00
|
|
|
if ($action == 'update' && !$cancel) {
|
2020-04-10 08:59:32 +00:00
|
|
|
$_SESSION["mainmenu"] = "home"; // Le gestionnaire de menu a pu changer
|
2015-01-30 14:47:27 +00:00
|
|
|
|
2019-01-27 10:55:16 +00:00
|
|
|
dolibarr_set_const($db, "MAIN_MENU_STANDARD", GETPOST('MAIN_MENU_STANDARD', 'alpha'), 'chaine', 0, '', $conf->entity);
|
|
|
|
|
dolibarr_set_const($db, "MAIN_MENU_SMARTPHONE", GETPOST('MAIN_MENU_SMARTPHONE', 'alpha'), 'chaine', 0, '', $conf->entity);
|
2009-08-22 16:35:38 +00:00
|
|
|
|
2019-01-27 10:55:16 +00:00
|
|
|
dolibarr_set_const($db, "MAIN_MENUFRONT_STANDARD", GETPOST('MAIN_MENUFRONT_STANDARD', 'alpha'), 'chaine', 0, '', $conf->entity);
|
|
|
|
|
dolibarr_set_const($db, "MAIN_MENUFRONT_SMARTPHONE", GETPOST('MAIN_MENUFRONT_SMARTPHONE', 'alpha'), 'chaine', 0, '', $conf->entity);
|
2009-08-22 16:35:38 +00:00
|
|
|
|
2008-01-09 00:33:08 +00:00
|
|
|
// Define list of menu handlers to initialize
|
2020-04-10 08:59:32 +00:00
|
|
|
$listofmenuhandler = array();
|
|
|
|
|
$listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i', '', GETPOST('MAIN_MENU_STANDARD', 'alpha'))] = 1;
|
|
|
|
|
$listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i', '', GETPOST('MAIN_MENUFRONT_STANDARD', 'alpha'))] = 1;
|
2021-02-26 21:04:03 +00:00
|
|
|
if (GETPOST('MAIN_MENU_SMARTPHONE', 'alpha')) {
|
|
|
|
|
$listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i', '', GETPOST('MAIN_MENU_SMARTPHONE', 'alpha'))] = 1;
|
|
|
|
|
}
|
|
|
|
|
if (GETPOST('MAIN_MENUFRONT_SMARTPHONE', 'alpha')) {
|
|
|
|
|
$listofmenuhandler[preg_replace('/(_backoffice|_frontoffice|_menu)?\.php/i', '', GETPOST('MAIN_MENUFRONT_SMARTPHONE', 'alpha'))] = 1;
|
|
|
|
|
}
|
2010-09-29 08:45:45 +00:00
|
|
|
|
|
|
|
|
// Initialize menu handlers
|
2021-02-26 21:04:03 +00:00
|
|
|
foreach ($listofmenuhandler as $key => $val) {
|
2010-09-29 08:45:45 +00:00
|
|
|
// Load sql init_menu_handler.sql file
|
2020-04-10 08:59:32 +00:00
|
|
|
$dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
|
2021-02-26 21:04:03 +00:00
|
|
|
foreach ($dirmenus as $dirmenu) {
|
2020-04-10 08:59:32 +00:00
|
|
|
$file = 'init_menu_'.$key.'.sql';
|
|
|
|
|
$fullpath = dol_buildpath($dirmenu.$file);
|
2020-03-23 14:54:02 +00:00
|
|
|
//print 'action='.$action.' Search menu into fullpath='.$fullpath.'<br>';exit;
|
2015-01-30 14:47:27 +00:00
|
|
|
|
2021-02-26 21:04:03 +00:00
|
|
|
if (file_exists($fullpath)) {
|
2013-02-19 14:23:25 +00:00
|
|
|
$db->begin();
|
2015-01-30 14:47:27 +00:00
|
|
|
|
2020-04-10 08:59:32 +00:00
|
|
|
$result = run_sql($fullpath, 1, '', 1, $key, 'none');
|
2021-02-26 21:04:03 +00:00
|
|
|
if ($result > 0) {
|
2013-02-19 14:23:25 +00:00
|
|
|
$db->commit();
|
2020-05-21 07:35:30 +00:00
|
|
|
} else {
|
2013-02-19 14:23:25 +00:00
|
|
|
$error++;
|
2015-10-28 18:28:18 +00:00
|
|
|
setEventMessages($langs->trans("FailedToInitializeMenu").' '.$key, null, 'errors');
|
2013-02-19 14:23:25 +00:00
|
|
|
$db->rollback();
|
|
|
|
|
}
|
2012-02-10 15:37:41 +00:00
|
|
|
}
|
2010-09-23 12:35:09 +00:00
|
|
|
}
|
2008-01-09 00:33:08 +00:00
|
|
|
}
|
|
|
|
|
|
2021-02-26 21:04:03 +00:00
|
|
|
if (!$error) {
|
2012-02-10 16:09:13 +00:00
|
|
|
$db->close();
|
2012-02-12 14:17:54 +00:00
|
|
|
|
2012-02-10 16:09:13 +00:00
|
|
|
// We make a header redirect because we need to change menu NOW.
|
|
|
|
|
header("Location: ".$_SERVER["PHP_SELF"]);
|
|
|
|
|
exit;
|
|
|
|
|
}
|
2007-04-11 00:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2010-02-20 15:07:46 +00:00
|
|
|
* View
|
|
|
|
|
*/
|
2007-04-11 00:45:42 +00:00
|
|
|
|
2020-04-10 08:59:32 +00:00
|
|
|
$form = new Form($db);
|
|
|
|
|
$formadmin = new FormAdmin($db);
|
2007-04-11 00:45:42 +00:00
|
|
|
|
2020-04-10 08:59:32 +00:00
|
|
|
$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
|
2019-01-27 10:55:16 +00:00
|
|
|
llxHeader('', $langs->trans("Setup"), $wikihelp);
|
2007-04-11 00:45:42 +00:00
|
|
|
|
2019-01-27 10:55:16 +00:00
|
|
|
print load_fiche_titre($langs->trans("Menus"), '', 'title_setup');
|
2007-04-11 00:45:42 +00:00
|
|
|
|
|
|
|
|
|
2007-05-07 16:44:27 +00:00
|
|
|
$h = 0;
|
|
|
|
|
|
|
|
|
|
$head[$h][0] = DOL_URL_ROOT."/admin/menus.php";
|
|
|
|
|
$head[$h][1] = $langs->trans("MenuHandlers");
|
|
|
|
|
$head[$h][2] = 'handler';
|
|
|
|
|
$h++;
|
|
|
|
|
|
2008-01-08 18:48:12 +00:00
|
|
|
$head[$h][0] = DOL_URL_ROOT."/admin/menus/index.php";
|
|
|
|
|
$head[$h][1] = $langs->trans("MenuAdmin");
|
|
|
|
|
$head[$h][2] = 'editor';
|
|
|
|
|
$h++;
|
2007-05-07 16:44:27 +00:00
|
|
|
|
2015-01-30 14:47:27 +00:00
|
|
|
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
2019-12-18 22:12:31 +00:00
|
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
2015-01-30 14:47:27 +00:00
|
|
|
print '<input type="hidden" name="action" value="update">';
|
|
|
|
|
|
2020-10-22 20:50:03 +00:00
|
|
|
print dol_get_fiche_head($head, 'handler', '', -1);
|
2007-05-07 16:44:27 +00:00
|
|
|
|
2019-03-13 14:04:38 +00:00
|
|
|
print '<span class="opacitymedium">'.$langs->trans("MenusDesc")."</span><br>\n";
|
2012-02-12 14:17:54 +00:00
|
|
|
print "<br>\n";
|
|
|
|
|
|
2007-04-11 00:45:42 +00:00
|
|
|
|
2019-10-11 12:42:55 +00:00
|
|
|
clearstatcache();
|
|
|
|
|
|
|
|
|
|
// Gestionnaires de menu
|
2019-11-05 20:24:41 +00:00
|
|
|
print '<table class="noborder centpercent">';
|
2019-10-11 12:42:55 +00:00
|
|
|
print '<tr class="liste_titre"><td width="35%">'.$langs->trans("Menu").'</td>';
|
|
|
|
|
print '<td>';
|
|
|
|
|
print $form->textwithpicto($langs->trans("InternalUsers"), $langs->trans("InternalExternalDesc"));
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '<td>';
|
|
|
|
|
print $form->textwithpicto($langs->trans("ExternalUsers"), $langs->trans("InternalExternalDesc"));
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
|
|
|
|
|
// Menu top
|
|
|
|
|
print '<tr class="oddeven"><td>'.$langs->trans("DefaultMenuManager").'</td>';
|
|
|
|
|
print '<td>';
|
2020-04-10 08:59:32 +00:00
|
|
|
$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');
|
2019-10-11 12:42:55 +00:00
|
|
|
print '</td>';
|
|
|
|
|
print '<td>';
|
2020-04-10 08:59:32 +00:00
|
|
|
$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');
|
2019-10-11 12:42:55 +00:00
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
|
|
|
|
|
// Menu smartphone
|
|
|
|
|
print '<tr class="oddeven"><td>'.$langs->trans("DefaultMenuSmartphoneManager").'</td>';
|
|
|
|
|
print '<td>';
|
2020-04-10 08:59:32 +00:00
|
|
|
$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');
|
2019-10-11 12:42:55 +00:00
|
|
|
|
2020-04-10 08:59:32 +00:00
|
|
|
if (!empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && preg_match('/smartphone/', $conf->global->MAIN_MENU_SMARTPHONE_FORCED)
|
2021-02-26 21:04:03 +00:00
|
|
|
|| (empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && !empty($conf->global->MAIN_MENU_SMARTPHONE) && preg_match('/smartphone/', $conf->global->MAIN_MENU_SMARTPHONE))) {
|
2019-10-11 12:42:55 +00:00
|
|
|
print ' '.img_warning($langs->transnoentitiesnoconv("ThisForceAlsoTheme"));
|
2007-05-07 16:44:27 +00:00
|
|
|
}
|
2007-04-11 00:45:42 +00:00
|
|
|
|
2019-10-11 12:42:55 +00:00
|
|
|
print '</td>';
|
|
|
|
|
print '<td>';
|
2020-04-10 08:59:32 +00:00
|
|
|
$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');
|
2015-01-30 14:47:27 +00:00
|
|
|
|
2020-04-10 08:59:32 +00:00
|
|
|
if (!empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && preg_match('/smartphone/', $conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)
|
2021-02-26 21:04:03 +00:00
|
|
|
|| (empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED) && !empty($conf->global->MAIN_MENU_SMARTPHONE) && preg_match('/smartphone/', $conf->global->MAIN_MENUFRONT_SMARTPHONE))) {
|
2019-10-11 12:42:55 +00:00
|
|
|
print ' '.img_warning($langs->transnoentitiesnoconv("ThisForceAlsoTheme"));
|
2015-01-30 14:47:27 +00:00
|
|
|
}
|
|
|
|
|
|
2019-10-11 12:42:55 +00:00
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
2015-01-30 14:47:27 +00:00
|
|
|
|
2019-10-11 12:42:55 +00:00
|
|
|
print '</table>';
|
2015-01-30 14:47:27 +00:00
|
|
|
|
2020-10-27 17:19:31 +00:00
|
|
|
print dol_get_fiche_end();
|
2019-10-11 12:42:55 +00:00
|
|
|
|
|
|
|
|
print '<div class="center">';
|
2020-11-19 19:23:38 +00:00
|
|
|
print '<input class="button button-save" type="submit" name="save" value="'.$langs->trans("Save").'">';
|
2019-10-11 12:42:55 +00:00
|
|
|
print '</div>';
|
|
|
|
|
|
|
|
|
|
print '</form>';
|
2009-08-22 16:35:38 +00:00
|
|
|
|
2018-07-28 16:03:14 +00:00
|
|
|
// End of page
|
2011-08-27 14:24:16 +00:00
|
|
|
llxFooter();
|
2012-02-10 15:37:41 +00:00
|
|
|
$db->close();
|