dolibarr/htdocs/admin/menus.php

275 lines
9.8 KiB
PHP
Raw Normal View History

<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
2012-12-30 15:13:49 +01:00
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
*
* 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 3 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/>.
*/
/**
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
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
2017-05-16 13:27:32 +02:00
$action=GETPOST('action','aZ09');
$cancel=GETPOST('cancel','alpha');
2018-05-26 18:41:16 +02:00
// Load translation files required by the page
2018-04-22 11:26:59 +02:00
$langs->loadLangs(array("companies","products","admin","users","other"));
2010-02-20 16:07:46 +01:00
// Security check
2012-07-09 18:09:44 +02:00
if (! $user->admin) accessforbidden();
$dirstandard = array();
$dirsmartphone = array();
$dirmenus=array_merge(array("/core/menus/"),(array) $conf->modules_parts['menus']);
foreach($dirmenus as $dirmenu)
{
$dirstandard[]=$dirmenu.'standard';
$dirsmartphone[]=$dirmenu.'smartphone';
}
2012-07-09 18:09:44 +02:00
$error=0;
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);
/*
2010-02-20 16:07:46 +01:00
* Actions
*/
if ($action == 'update' && ! $cancel)
{
2008-01-12 17:55:15 +01:00
$_SESSION["mainmenu"]="home"; // Le gestionnaire de menu a pu changer
2015-01-30 15:47:27 +01:00
2018-08-14 15:34:44 +02: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 18:35:38 +02:00
2018-08-14 15:34:44 +02: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 18:35:38 +02:00
// Define list of menu handlers to initialize
2010-02-20 16:07:46 +01: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;
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 10:45:45 +02:00
// Initialize menu handlers
foreach ($listofmenuhandler as $key => $val)
{
2010-09-29 10:45:45 +02:00
// Load sql init_menu_handler.sql file
$dirmenus=array_merge(array("/core/menus/"),(array) $conf->modules_parts['menus']);
foreach($dirmenus as $dirmenu)
{
2013-02-19 15:23:25 +01:00
$file='init_menu_'.$key.'.sql';
$fullpath=dol_buildpath($dirmenu.$file);
//print 'action='.$action.' Search menu into fullpath='.$fullpath.'<br>';exit;
2015-01-30 15:47:27 +01:00
2013-02-19 15:23:25 +01:00
if (file_exists($fullpath))
{
2013-02-19 15:23:25 +01:00
$db->begin();
2015-01-30 15:47:27 +01:00
2013-02-19 15:23:25 +01:00
$result=run_sql($fullpath,1,'',1,$key,'none');
if ($result > 0)
{
$db->commit();
}
else
{
$error++;
2015-10-28 19:28:18 +01:00
setEventMessages($langs->trans("FailedToInitializeMenu").' '.$key, null, 'errors');
2013-02-19 15:23:25 +01:00
$db->rollback();
}
}
}
}
if (! $error)
{
$db->close();
// We make a header redirect because we need to change menu NOW.
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
}
/*
2010-02-20 16:07:46 +01:00
* View
*/
$form=new Form($db);
$formadmin=new FormAdmin($db);
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);
print load_fiche_titre($langs->trans("Menus"),'','title_setup');
$h = 0;
$head[$h][0] = DOL_URL_ROOT."/admin/menus.php";
$head[$h][1] = $langs->trans("MenuHandlers");
$head[$h][2] = 'handler';
$h++;
$head[$h][0] = DOL_URL_ROOT."/admin/menus/index.php";
$head[$h][1] = $langs->trans("MenuAdmin");
$head[$h][2] = 'editor';
$h++;
2010-10-28 12:22:06 +02:00
$head[$h][0] = DOL_URL_ROOT."/admin/menus/other.php";
2013-03-24 07:11:44 +01:00
$head[$h][1] = $langs->trans("Miscellaneous");
2010-10-28 12:22:06 +02:00
$head[$h][2] = 'misc';
$h++;
2015-01-30 15:47:27 +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">';
dol_fiche_head($head, 'handler', $langs->trans("Menus"), -1);
print $langs->trans("MenusDesc")."<br>\n";
print "<br>\n";
2012-07-09 18:09:44 +02:00
if ($action == 'edit')
{
2010-02-20 16:07:46 +01:00
clearstatcache();
2010-02-20 16:07:46 +01:00
// Gestionnaires de menu
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="35%">'.$langs->trans("Menu").'</td>';
print '<td>';
print $form->textwithpicto($langs->trans("InternalUsers"),$langs->trans("InternalExternalDesc"));
2010-02-20 16:07:46 +01:00
print '</td>';
print '<td>';
print $form->textwithpicto($langs->trans("ExternalUsers"),$langs->trans("InternalExternalDesc"));
2010-02-20 16:07:46 +01:00
print '</td>';
print '</tr>';
// Menu top
print '<tr class="oddeven"><td>'.$langs->trans("DefaultMenuManager").'</td>';
2010-02-20 16:07:46 +01:00
print '<td>';
$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');
2010-02-20 16:07:46 +01:00
print '</td>';
print '<td>';
$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');
2010-02-20 16:07:46 +01:00
print '</td>';
print '</tr>';
// Menu smartphone
print '<tr class="oddeven"><td>'.$langs->trans("DefaultMenuSmartphoneManager").'</td>';
print '<td>';
$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');
print '</td>';
print '<td>';
$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');
print '</td>';
print '</tr>';
2010-02-20 16:07:46 +01:00
print '</table>';
}
else
{
2010-02-20 16:07:46 +01:00
// Gestionnaires de menu
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="35%">'.$langs->trans("Menu").'</td>';
print '<td>';
print $form->textwithpicto($langs->trans("InternalUsers"),$langs->trans("InternalExternalDesc"));
2010-02-20 16:07:46 +01:00
print '</td>';
print '<td>';
print $form->textwithpicto($langs->trans("ExternalUsers"),$langs->trans("InternalExternalDesc"));
2010-02-20 16:07:46 +01:00
print '</td>';
print '</tr>';
print '<tr class="oddeven"><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>';
print '<tr class="oddeven">';
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;
2012-07-09 18:09:44 +02:00
if (! empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && preg_match('/smartphone/', $conf->global->MAIN_MENU_SMARTPHONE_FORCED)
|| (empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && ! empty($conf->global->MAIN_MENU_SMARTPHONE) && preg_match('/smartphone/',$conf->global->MAIN_MENU_SMARTPHONE)))
2011-02-18 09:19:25 +01:00
{
2011-11-02 18:02:31 +01:00
print ' '.img_warning($langs->transnoentitiesnoconv("ThisForceAlsoTheme"));
2011-02-18 09:19:25 +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;
2012-07-09 18:09:44 +02:00
if (! empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && preg_match('/smartphone/',$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)
|| (empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED) && ! empty($conf->global->MAIN_MENU_SMARTPHONE) && preg_match('/smartphone/',$conf->global->MAIN_MENUFRONT_SMARTPHONE)))
2011-02-18 09:19:25 +01:00
{
2011-11-02 18:02:31 +01:00
print ' '.img_warning($langs->transnoentitiesnoconv("ThisForceAlsoTheme"));
2011-02-18 09:19:25 +01:00
}
print '</td>';
print '</tr>';
2010-02-20 16:07:46 +01:00
print '</table>';
}
2015-01-30 15:47:27 +01:00
dol_fiche_end();
if ($action == 'edit')
{
print '<div class="center">';
print '<input class="button" type="submit" name="save" value="'.$langs->trans("Save").'">';
print ' &nbsp; &nbsp; &nbsp; ';
2015-01-30 15:47:27 +01:00
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
}
print '</form>';
2012-07-09 18:09:44 +02:00
if ($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>';
}
2009-08-22 18:35:38 +02:00
2018-07-28 18:03:14 +02:00
// End of page
llxFooter();
$db->close();