2007-04-11 02:45:42 +02:00
|
|
|
<?php
|
|
|
|
|
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2012-02-10 16:37:41 +01:00
|
|
|
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
2010-09-23 12:02:27 +02:00
|
|
|
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
2007-04-11 02:45:42 +02: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
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (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
|
2011-08-01 00:21:57 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2007-04-11 02:45:42 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2008-12-04 20:13:40 +01:00
|
|
|
* \file htdocs/admin/menus.php
|
|
|
|
|
* \ingroup core
|
2010-02-20 16:07:46 +01:00
|
|
|
* \brief Page to setup menu manager to use
|
2008-12-04 20:13:40 +01:00
|
|
|
*/
|
2007-04-11 02:45:42 +02:00
|
|
|
|
2010-03-01 10:20:41 +01:00
|
|
|
require("../main.inc.php");
|
2011-10-24 11:25:54 +02:00
|
|
|
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
|
2010-05-03 10:22:35 +02:00
|
|
|
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formadmin.class.php");
|
2011-10-24 11:25:54 +02:00
|
|
|
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
|
2008-01-11 11:25:26 +01:00
|
|
|
|
2012-02-12 15:17:54 +01:00
|
|
|
$action=GETPOST('action');
|
2007-04-11 02:45:42 +02:00
|
|
|
|
|
|
|
|
$langs->load("companies");
|
|
|
|
|
$langs->load("products");
|
|
|
|
|
$langs->load("admin");
|
2010-06-27 16:29:45 +02:00
|
|
|
$langs->load("users");
|
2010-10-28 12:22:06 +02:00
|
|
|
$langs->load("other");
|
2007-04-11 02:45:42 +02:00
|
|
|
|
2010-02-20 16:07:46 +01:00
|
|
|
// Security check
|
|
|
|
|
if (!$user->admin) accessforbidden();
|
2007-04-11 02:45:42 +02:00
|
|
|
|
2012-02-12 15:17:54 +01:00
|
|
|
$dirstandard = array("/core/menus/standard");
|
|
|
|
|
$dirsmartphone = array("/core/menus/smartphone");
|
|
|
|
|
foreach($conf->menus_modules as $dir)
|
|
|
|
|
{
|
2012-02-22 16:18:03 +01:00
|
|
|
$dirstandard[]=$dir.'standard';
|
|
|
|
|
$dirsmartphone[]=$dir.'standard';
|
2012-02-12 15:17:54 +01:00
|
|
|
}
|
2007-04-11 02:45:42 +02:00
|
|
|
|
|
|
|
|
|
2010-09-29 10:40:13 +02:00
|
|
|
// Cette page peut etre longue. On augmente le delai autorise.
|
|
|
|
|
// Ne fonctionne que si on est pas en safe_mode.
|
|
|
|
|
$err=error_reporting();
|
|
|
|
|
error_reporting(0); // Disable all errors
|
|
|
|
|
//error_reporting(E_ALL);
|
|
|
|
|
@set_time_limit(300); // Need more than 240 on Windows 7/64
|
|
|
|
|
error_reporting($err);
|
|
|
|
|
|
|
|
|
|
|
2007-04-11 02:45:42 +02:00
|
|
|
/*
|
2010-02-20 16:07:46 +01:00
|
|
|
* Actions
|
|
|
|
|
*/
|
2007-04-11 02:45:42 +02:00
|
|
|
|
2012-02-12 15:17:54 +01:00
|
|
|
if ($action == 'update' && empty($_POST["cancel"]))
|
2007-04-11 02:45:42 +02:00
|
|
|
{
|
2008-01-12 17:55:15 +01:00
|
|
|
$_SESSION["mainmenu"]="home"; // Le gestionnaire de menu a pu changer
|
|
|
|
|
|
2011-02-13 14:22:54 +01:00
|
|
|
dolibarr_set_const($db, "MAIN_MENU_STANDARD", $_POST["MAIN_MENU_STANDARD"],'chaine',0,'',$conf->entity);
|
2011-02-18 09:38:02 +01:00
|
|
|
dolibarr_set_const($db, "MAIN_MENU_SMARTPHONE", $_POST["MAIN_MENU_SMARTPHONE"],'chaine',0,'',$conf->entity);
|
2009-08-22 18:35:38 +02:00
|
|
|
|
2011-02-13 14:22:54 +01:00
|
|
|
dolibarr_set_const($db, "MAIN_MENUFRONT_STANDARD", $_POST["MAIN_MENUFRONT_STANDARD"],'chaine',0,'',$conf->entity);
|
2011-02-18 09:38:02 +01:00
|
|
|
dolibarr_set_const($db, "MAIN_MENUFRONT_SMARTPHONE",$_POST["MAIN_MENUFRONT_SMARTPHONE"],'chaine',0,'',$conf->entity);
|
2009-08-22 18:35:38 +02:00
|
|
|
|
2008-01-09 01:33:08 +01:00
|
|
|
// Define list of menu handlers to initialize
|
2010-02-20 16:07:46 +01:00
|
|
|
$listofmenuhandler=array();
|
2011-02-13 14:22:54 +01:00
|
|
|
$listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENU_STANDARD"])]=1;
|
|
|
|
|
$listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENUFRONT_STANDARD"])]=1;
|
2011-02-18 09:38:02 +01:00
|
|
|
if (isset($_POST["MAIN_MENU_SMARTPHONE"])) $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENU_SMARTPHONE"])]=1;
|
|
|
|
|
if (isset($_POST["MAIN_MENUFRONT_SMARTPHONE"])) $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENUFRONT_SMARTPHONE"])]=1;
|
2010-09-29 10:45:45 +02:00
|
|
|
|
|
|
|
|
// Initialize menu handlers
|
2012-02-10 17:09:13 +01:00
|
|
|
$error=0; $errmsgs=array();
|
2008-01-09 01:33:08 +01:00
|
|
|
foreach ($listofmenuhandler as $key => $val)
|
|
|
|
|
{
|
2010-09-29 10:45:45 +02:00
|
|
|
// Load sql init_menu_handler.sql file
|
2011-10-24 14:11:49 +02:00
|
|
|
$dir = "/core/menus/";
|
2011-01-23 16:08:21 +01:00
|
|
|
$file='init_menu_'.$key.'.sql';
|
|
|
|
|
$fullpath=dol_buildpath($dir.$file);
|
|
|
|
|
|
|
|
|
|
if (file_exists($fullpath))
|
2010-09-23 14:35:09 +02:00
|
|
|
{
|
2012-02-10 16:37:41 +01:00
|
|
|
$db->begin();
|
2012-02-12 15:17:54 +01:00
|
|
|
|
2012-02-10 17:09:13 +01:00
|
|
|
$result=run_sql($fullpath,1,'',1,$key,'none');
|
2012-02-10 16:37:41 +01:00
|
|
|
if ($result > 0)
|
|
|
|
|
{
|
|
|
|
|
$db->commit();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-02-10 17:09:13 +01:00
|
|
|
$error++;
|
2012-02-10 16:37:41 +01:00
|
|
|
$errmsgs[]='Failed to initialize menu '.$key.'.';
|
|
|
|
|
$db->rollback();
|
|
|
|
|
}
|
2010-09-23 14:35:09 +02:00
|
|
|
}
|
2008-01-09 01:33:08 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-10 17:09:13 +01:00
|
|
|
if (! $error)
|
|
|
|
|
{
|
|
|
|
|
$db->close();
|
2012-02-12 15:17:54 +01:00
|
|
|
|
2012-02-10 17:09:13 +01:00
|
|
|
// We make a header redirect because we need to change menu NOW.
|
|
|
|
|
header("Location: ".$_SERVER["PHP_SELF"]);
|
|
|
|
|
exit;
|
|
|
|
|
}
|
2007-04-11 02:45:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2010-02-20 16:07:46 +01:00
|
|
|
* View
|
|
|
|
|
*/
|
2007-04-11 02:45:42 +02:00
|
|
|
|
2011-11-08 10:18:45 +01:00
|
|
|
$form=new Form($db);
|
2012-02-12 15:17:54 +01:00
|
|
|
$formadmin=new FormAdmin($db);
|
2007-04-11 02:45:42 +02:00
|
|
|
|
2009-08-22 18:35:38 +02:00
|
|
|
$wikihelp='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
|
2010-05-26 13:42:29 +02:00
|
|
|
llxHeader('',$langs->trans("Setup"),$wikihelp);
|
2007-04-11 02:45:42 +02:00
|
|
|
|
|
|
|
|
print_fiche_titre($langs->trans("Menus"),'','setup');
|
|
|
|
|
|
|
|
|
|
|
2007-05-07 18:44:27 +02: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 19:48:12 +01: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 18:44:27 +02:00
|
|
|
|
2010-10-28 12:22:06 +02:00
|
|
|
$head[$h][0] = DOL_URL_ROOT."/admin/menus/other.php";
|
|
|
|
|
$head[$h][1] = $langs->trans("Miscellanous");
|
|
|
|
|
$head[$h][2] = 'misc';
|
|
|
|
|
$h++;
|
|
|
|
|
|
2007-05-07 18:44:27 +02:00
|
|
|
|
2009-02-20 23:53:15 +01:00
|
|
|
dol_fiche_head($head, 'handler', $langs->trans("Menus"));
|
2007-05-07 18:44:27 +02:00
|
|
|
|
2012-02-12 15:17:54 +01:00
|
|
|
print $langs->trans("MenusDesc")."<br>\n";
|
|
|
|
|
print "<br>\n";
|
|
|
|
|
|
2007-04-11 02:45:42 +02:00
|
|
|
|
|
|
|
|
if (isset($_GET["action"]) && $_GET["action"] == 'edit')
|
|
|
|
|
{
|
2010-02-20 16:07:46 +01:00
|
|
|
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
|
|
|
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
|
|
|
|
print '<input type="hidden" name="action" value="update">';
|
2007-04-11 02:45:42 +02:00
|
|
|
|
2010-02-20 16:07:46 +01:00
|
|
|
clearstatcache();
|
2007-04-11 02:45:42 +02:00
|
|
|
|
2010-02-20 16:07:46 +01:00
|
|
|
// Gestionnaires de menu
|
|
|
|
|
$var=true;
|
2007-04-11 02:45:42 +02:00
|
|
|
|
2010-02-20 16:07:46 +01:00
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
|
|
print '<tr class="liste_titre"><td width="35%">'.$langs->trans("Menu").'</td>';
|
|
|
|
|
print '<td>';
|
2011-11-08 10:18:45 +01:00
|
|
|
print $form->textwithpicto($langs->trans("InternalUsers"),$langs->trans("InternalExternalDesc"));
|
2010-02-20 16:07:46 +01:00
|
|
|
print '</td>';
|
|
|
|
|
print '<td>';
|
2011-11-08 10:18:45 +01:00
|
|
|
print $form->textwithpicto($langs->trans("ExternalUsers"),$langs->trans("InternalExternalDesc"));
|
2010-02-20 16:07:46 +01:00
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
|
|
|
|
|
// Menu top
|
|
|
|
|
$var=!$var;
|
2010-09-29 12:10:33 +02:00
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuManager").'</td>';
|
2010-02-20 16:07:46 +01:00
|
|
|
print '<td>';
|
2012-02-12 15:17:54 +01:00
|
|
|
print $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="disabled"');
|
2010-02-20 16:07:46 +01:00
|
|
|
print '</td>';
|
|
|
|
|
print '<td>';
|
2012-02-12 15:17:54 +01:00
|
|
|
print $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="disabled"');
|
2010-02-20 16:07:46 +01:00
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
|
2010-09-23 12:02:27 +02:00
|
|
|
// Menu smartphone
|
2011-02-16 20:59:16 +01:00
|
|
|
$var=!$var;
|
|
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuSmartphoneManager").'</td>';
|
|
|
|
|
print '<td>';
|
2012-02-12 15:17:54 +01:00
|
|
|
print $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="disabled"');
|
2011-02-16 20:59:16 +01:00
|
|
|
print '</td>';
|
|
|
|
|
print '<td>';
|
2012-02-12 15:17:54 +01:00
|
|
|
print $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="disabled"');
|
2011-02-16 20:59:16 +01:00
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
2010-02-20 16:07:46 +01:00
|
|
|
|
|
|
|
|
print '</table>';
|
2009-08-22 18:35:38 +02:00
|
|
|
|
2007-04-11 02:45:42 +02:00
|
|
|
print '<br><center>';
|
2010-02-20 16:07:46 +01:00
|
|
|
print '<input class="button" type="submit" name="save" value="'.$langs->trans("Save").'">';
|
|
|
|
|
print ' ';
|
2009-10-25 16:36:45 +01:00
|
|
|
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
|
2010-02-20 16:07:46 +01:00
|
|
|
print '</center>';
|
2007-04-11 02:45:42 +02:00
|
|
|
|
2010-02-20 16:07:46 +01:00
|
|
|
print '</form>';
|
2007-04-11 02:45:42 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2010-02-20 16:07:46 +01:00
|
|
|
// Gestionnaires de menu
|
|
|
|
|
$var=true;
|
2007-04-11 02:45:42 +02:00
|
|
|
|
2010-02-20 16:07:46 +01:00
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
|
|
print '<tr class="liste_titre"><td width="35%">'.$langs->trans("Menu").'</td>';
|
|
|
|
|
print '<td>';
|
2011-11-08 10:18:45 +01:00
|
|
|
print $form->textwithpicto($langs->trans("InternalUsers"),$langs->trans("InternalExternalDesc"));
|
2010-02-20 16:07:46 +01:00
|
|
|
print '</td>';
|
|
|
|
|
print '<td>';
|
2011-11-08 10:18:45 +01:00
|
|
|
print $form->textwithpicto($langs->trans("ExternalUsers"),$langs->trans("InternalExternalDesc"));
|
2010-02-20 16:07:46 +01:00
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
|
|
|
|
|
$var=!$var;
|
2010-09-29 12:10:33 +02:00
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuManager").'</td>';
|
2010-02-20 16:07:46 +01:00
|
|
|
print '<td>';
|
2011-02-13 16:50:42 +01:00
|
|
|
$filelib=preg_replace('/.php$/i','',(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?$conf->global->MAIN_MENU_STANDARD:$conf->global->MAIN_MENU_STANDARD_FORCED));
|
2010-02-20 16:07:46 +01:00
|
|
|
print $filelib;
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '<td>';
|
2011-02-13 16:50:42 +01:00
|
|
|
$filelib=preg_replace('/.php$/i','',(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?$conf->global->MAIN_MENUFRONT_STANDARD:$conf->global->MAIN_MENUFRONT_STANDARD_FORCED));
|
2010-02-20 16:07:46 +01:00
|
|
|
print $filelib;
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
|
2011-02-17 00:00:45 +01:00
|
|
|
$var=!$var;
|
|
|
|
|
print '<tr '.$bc[$var].'>';
|
|
|
|
|
print '<td>'.$langs->trans("DefaultMenuSmartphoneManager").'</td>';
|
|
|
|
|
print '<td>';
|
|
|
|
|
$filelib=preg_replace('/.php$/i','',(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED));
|
|
|
|
|
print $filelib;
|
2011-11-02 18:02:31 +01:00
|
|
|
if (preg_match('/smartphone/',$conf->global->MAIN_MENU_SMARTPHONE_FORCED)
|
2011-02-18 09:19:25 +01:00
|
|
|
|| (empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && preg_match('/smartphone/',$conf->global->MAIN_MENU_SMARTPHONE)))
|
|
|
|
|
{
|
2011-11-02 18:02:31 +01:00
|
|
|
print ' '.img_warning($langs->transnoentitiesnoconv("ThisForceAlsoTheme"));
|
2011-02-18 09:19:25 +01:00
|
|
|
}
|
2011-02-17 00:00:45 +01:00
|
|
|
print '</td>';
|
|
|
|
|
print '<td>';
|
|
|
|
|
$filelib=preg_replace('/.php$/i','',(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?$conf->global->MAIN_MENUFRONT_SMARTPHONE:$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED));
|
|
|
|
|
print $filelib;
|
2011-02-18 09:19:25 +01:00
|
|
|
if (preg_match('/smartphone/',$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)
|
|
|
|
|
|| (empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED) && preg_match('/smartphone/',$conf->global->MAIN_MENUFRONT_SMARTPHONE)))
|
|
|
|
|
{
|
2011-11-02 18:02:31 +01:00
|
|
|
print ' '.img_warning($langs->transnoentitiesnoconv("ThisForceAlsoTheme"));
|
2011-02-18 09:19:25 +01:00
|
|
|
}
|
2011-02-17 00:00:45 +01:00
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
2010-02-20 16:07:46 +01:00
|
|
|
|
|
|
|
|
print '</table>';
|
2007-05-07 18:44:27 +02:00
|
|
|
}
|
2007-04-11 02:45:42 +02:00
|
|
|
|
2007-05-07 18:44:27 +02:00
|
|
|
print '</div>';
|
|
|
|
|
|
|
|
|
|
|
2012-02-10 17:09:13 +01:00
|
|
|
dol_htmloutput_errors('',$errmsgs);
|
2012-02-10 16:37:41 +01:00
|
|
|
|
|
|
|
|
|
2007-05-07 18:44:27 +02:00
|
|
|
if (! isset($_GET["action"]) || $_GET["action"] != 'edit')
|
|
|
|
|
{
|
2010-02-20 16:07:46 +01:00
|
|
|
print '<div class="tabsAction">';
|
|
|
|
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
|
|
|
|
|
print '</div>';
|
2007-04-11 02:45:42 +02:00
|
|
|
}
|
2009-08-22 18:35:38 +02:00
|
|
|
|
2007-04-11 02:45:42 +02:00
|
|
|
|
2011-08-27 16:24:16 +02:00
|
|
|
llxFooter();
|
2012-02-10 16:37:41 +01:00
|
|
|
|
|
|
|
|
$db->close();
|
2007-04-11 02:45:42 +02:00
|
|
|
?>
|