dolibarr/htdocs/user/param_ihm.php

280 lines
10 KiB
PHP
Raw Normal View History

<?php
/* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
2012-12-30 15:13:49 +01:00
* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
2013-02-22 09:42:02 +01:00
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro.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 01:19:04 +02:00
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/user/param_ihm.php
* \brief Page to show user setup for display
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
$langs->load("companies");
$langs->load("products");
$langs->load("admin");
$langs->load("users");
2010-02-18 15:39:51 +01:00
$langs->load("languages");
// Defini si peux lire/modifier permisssions
$canreaduser=($user->admin || $user->rights->user->user->lire);
$id = GETPOST('id','int');
$action = GETPOST('action','alpha');
2011-11-02 20:24:51 +01:00
if ($id)
{
2011-11-02 20:24:51 +01:00
// $user est le user qui edite, $id est l'id de l'utilisateur edite
2012-07-28 11:28:37 +02:00
$caneditfield=((($user->id == $id) && $user->rights->user->self->creer)
2011-11-02 20:24:51 +01:00
|| (($user->id != $id) && $user->rights->user->user->creer));
}
// Security check
$socid=0;
if ($user->societe_id > 0) $socid = $user->societe_id;
$feature2 = (($socid && $user->rights->user->self->creer)?'':'user');
2011-11-02 20:24:51 +01:00
if ($user->id == $id) // A user can always read its own card
{
$feature2='';
$canreaduser=1;
}
2012-01-11 15:07:17 +01:00
$result = restrictedArea($user, 'user', $id, '&user', $feature2);
2011-11-02 20:24:51 +01:00
if ($user->id <> $id && ! $canreaduser) accessforbidden();
$dirtop = "../core/menus/standard";
$dirleft = "../core/menus/standard";
2010-02-18 15:39:51 +01:00
// Charge utilisateur edite
$fuser = new User($db);
$fuser->fetch($id);
$fuser->getrights();
2010-02-18 15:39:51 +01:00
// Liste des zone de recherche permanentes supportees
$searchform=array("main_searchform_societe","main_searchform_contact","main_searchform_produitservice");
$searchformconst=array($conf->global->MAIN_SEARCHFORM_SOCIETE,$conf->global->MAIN_SEARCHFORM_CONTACT,$conf->global->MAIN_SEARCHFORM_PRODUITSERVICE);
$searchformtitle=array($langs->trans("Companies"),$langs->trans("Contacts"),$langs->trans("ProductsAndServices"));
$form = new Form($db);
2008-10-25 19:27:15 +02:00
$formadmin=new FormAdmin($db);
/*
* Actions
*/
if ($action == 'update' && ($caneditfield || ! empty($user->admin)))
{
2011-11-02 20:24:51 +01:00
if (! $_POST["cancel"])
{
$tabparam=array();
2009-02-11 03:18:27 +01:00
if ($_POST["check_MAIN_LANG_DEFAULT"]=="on") $tabparam["MAIN_LANG_DEFAULT"]=$_POST["main_lang_default"];
else $tabparam["MAIN_LANG_DEFAULT"]='';
2009-02-11 03:18:27 +01:00
$tabparam["MAIN_MENU_STANDARD"]=$_POST["MAIN_MENU_STANDARD"];
2009-02-11 03:18:27 +01:00
if ($_POST["check_SIZE_LISTE_LIMIT"]=="on") $tabparam["MAIN_SIZE_LISTE_LIMIT"]=$_POST["main_size_liste_limit"];
else $tabparam["MAIN_SIZE_LISTE_LIMIT"]='';
2009-02-11 03:18:27 +01:00
if ($_POST["check_MAIN_THEME"]=="on") $tabparam["MAIN_THEME"]=$_POST["main_theme"];
else $tabparam["MAIN_THEME"]='';
$tabparam["MAIN_SEARCHFORM_CONTACT"]=$_POST["main_searchform_contact"];
$tabparam["MAIN_SEARCHFORM_SOCIETE"]=$_POST["main_searchform_societe"];
$tabparam["MAIN_SEARCHFORM_PRODUITSERVICE"]=$_POST["main_searchform_produitservice"];
2009-02-11 03:18:27 +01:00
2009-05-04 11:47:41 +02:00
$result=dol_set_user_param($db, $conf, $fuser, $tabparam);
$_SESSION["mainmenu"]=""; // Le gestionnaire de menu a pu changer
2009-02-11 03:18:27 +01:00
2012-08-31 05:58:38 +02:00
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
}
/*
2009-08-05 19:19:55 +02:00
* View
*/
2009-08-05 19:19:55 +02:00
llxHeader();
$head = user_prepare_head($fuser);
2009-05-05 02:20:17 +02:00
$title = $langs->trans("User");
2013-04-24 03:56:13 +02:00
if ($action == 'edit')
{
2013-06-05 16:12:07 +02: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">';
print '<input type="hidden" name="id" value="'.$id.'">';
2013-04-24 03:56:13 +02:00
}
2009-08-05 19:19:55 +02:00
dol_fiche_head($head, 'guisetup', $title, 0, 'user');
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="25%" valign="top">'.$langs->trans("Ref").'</td>';
print '<td colspan="2">';
print $form->showrefnav($fuser,'id','',$user->rights->user->user->lire || $user->admin);
print '</td>';
print '</tr>';
2013-02-23 11:42:12 +01:00
// LastName
2009-08-13 21:16:43 +02:00
print '<tr><td width="25%" valign="top">'.$langs->trans("LastName").'</td>';
2013-02-23 11:42:12 +01:00
print '<td colspan="2">'.$fuser->lastname.'</td>';
print "</tr>\n";
2013-02-23 15:26:39 +01:00
// FirstName
2009-08-13 21:16:43 +02:00
print '<tr><td width="25%" valign="top">'.$langs->trans("FirstName").'</td>';
2013-02-23 15:26:39 +01:00
print '<td colspan="2">'.$fuser->firstname.'</td>';
print "</tr>\n";
print '</table><br>';
if ($action == 'edit')
{
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
2012-07-28 09:10:09 +02:00
$("#main_lang_default").change(function() {
$("#check_MAIN_LANG_DEFAULT").attr(\'checked\', true);
});
2012-07-28 09:10:09 +02:00
$("#main_size_liste_limit").keyup(function() {
if ($(this).val().length) $("#check_SIZE_LISTE_LIMIT").attr(\'checked\', true);
else $("#check_SIZE_LISTE_LIMIT").attr(\'checked\', false);
});
});
</script>';
clearstatcache();
$var=true;
2009-02-11 03:18:27 +01:00
print '<table class="noborder" width="100%">';
2005-10-30 01:42:54 +02:00
print '<tr class="liste_titre"><td width="25%">'.$langs->trans("Parameter").'</td><td width="25%">'.$langs->trans("DefaultValue").'</td><td>&nbsp;</td><td>'.$langs->trans("PersonalValue").'</td></tr>';
// Langue par defaut
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("Language").'</td>';
print '<td>';
2010-02-27 17:49:34 +01:00
$s=picto_from_langcode($conf->global->MAIN_LANG_DEFAULT);
print $s?$s.' ':'';
print ($conf->global->MAIN_LANG_DEFAULT=='auto'?$langs->trans("AutoDetectLang"):$langs->trans("Language_".$conf->global->MAIN_LANG_DEFAULT));
print '</td>';
print '<td align="left" class="nowrap" width="20%"><input '.$bc[$var].' name="check_MAIN_LANG_DEFAULT" id="check_MAIN_LANG_DEFAULT" type="checkbox" '.(! empty($fuser->conf->MAIN_LANG_DEFAULT)?" checked":"");
2011-08-31 17:12:09 +02:00
print ! empty($dolibarr_main_demo)?' disabled="disabled"':''; // Disabled for demo
2008-05-13 22:38:21 +02:00
print '> '.$langs->trans("UsePersonalValue").'</td>';
print '<td>';
print $formadmin->select_language((! empty($fuser->conf->MAIN_LANG_DEFAULT)?$fuser->conf->MAIN_LANG_DEFAULT:''),'main_lang_default',1);
print '</td></tr>';
// Taille max des listes
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("MaxSizeList").'</td>';
print '<td>'.$conf->global->MAIN_SIZE_LISTE_LIMIT.'</td>';
print '<td align="left" class="nowrap" width="20%"><input '.$bc[$var].' name="check_SIZE_LISTE_LIMIT" id="check_SIZE_LISTE_LIMIT" type="checkbox" '.(! empty($fuser->conf->MAIN_SIZE_LISTE_LIMIT)?" checked":"");
2011-08-31 17:12:09 +02:00
print ! empty($dolibarr_main_demo)?' disabled="disabled"':''; // Disabled for demo
2008-05-13 22:49:38 +02:00
print '> '.$langs->trans("UsePersonalValue").'</td>';
2013-02-22 09:42:02 +01:00
print '<td><input class="flat" name="main_size_liste_limit" id="main_size_liste_limit" size="4" value="' . (! empty($fuser->conf->MAIN_SIZE_LISTE_LIMIT)?$fuser->conf->MAIN_SIZE_LISTE_LIMIT:'') . '"></td></tr>';
print '</table><br>';
// Theme
2011-09-01 00:33:37 +02:00
show_theme($fuser,(($user->admin || empty($dolibarr_main_demo))?1:0),true);
2013-04-24 03:56:13 +02:00
dol_fiche_end();
print '<center>';
2005-08-24 00:41:12 +02:00
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print ' &nbsp; &nbsp; ';
2005-08-24 00:41:12 +02:00
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</center>';
2013-04-24 03:56:13 +02:00
print '</form>';
2009-02-11 03:18:27 +01:00
}
else
{
$var=true;
print '<table class="noborder" width="100%">';
2005-10-30 01:42:54 +02:00
print '<tr class="liste_titre"><td width="25%">'.$langs->trans("Parameter").'</td><td width="25%">'.$langs->trans("DefaultValue").'</td><td>&nbsp;</td><td>'.$langs->trans("PersonalValue").'</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("Language").'</td>';
print '<td>';
$s=picto_from_langcode($conf->global->MAIN_LANG_DEFAULT);
print ($s?$s.' ':'');
print (isset($conf->global->MAIN_LANG_DEFAULT) && $conf->global->MAIN_LANG_DEFAULT=='auto'?$langs->trans("AutoDetectLang"):$langs->trans("Language_".$conf->global->MAIN_LANG_DEFAULT));
print '</td>';
print '<td align="left" class="nowrap" width="20%"><input '.$bc[$var].' type="checkbox" disabled '.(! empty($fuser->conf->MAIN_LANG_DEFAULT)?" checked":"").'> '.$langs->trans("UsePersonalValue").'</td>';
print '<td>';
$s=(isset($fuser->conf->MAIN_LANG_DEFAULT) ? picto_from_langcode($fuser->conf->MAIN_LANG_DEFAULT) : '');
print ($s?$s.' ':'');
print (isset($fuser->conf->MAIN_LANG_DEFAULT) && $fuser->conf->MAIN_LANG_DEFAULT=='auto'?$langs->trans("AutoDetectLang"):(! empty($fuser->conf->MAIN_LANG_DEFAULT)?$langs->trans("Language_".$fuser->conf->MAIN_LANG_DEFAULT):''));
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("MaxSizeList").'</td>';
print '<td>'.(! empty($conf->global->MAIN_SIZE_LISTE_LIMIT)?$conf->global->MAIN_SIZE_LISTE_LIMIT:'&nbsp;').'</td>';
print '<td align="left" class="nowrap" width="20%"><input '.$bc[$var].' type="checkbox" disabled '.(! empty($fuser->conf->MAIN_SIZE_LISTE_LIMIT)?" checked":"").'> '.$langs->trans("UsePersonalValue").'</td>';
print '<td>' . (! empty($fuser->conf->MAIN_SIZE_LISTE_LIMIT)?$fuser->conf->MAIN_SIZE_LISTE_LIMIT:'&nbsp;') . '</td></tr>';
print '</table><br>';
// Skin
2008-11-26 20:37:25 +01:00
show_theme($fuser,0,true);
2013-04-24 03:56:13 +02:00
dol_fiche_end();
print '<div class="tabsAction">';
2011-09-01 00:33:36 +02:00
if (empty($user->admin) && ! empty($dolibarr_main_demo))
{
print "<a class=\"butActionRefused\" title=\"".$langs->trans("FeatureDisabledInDemo")."\" href=\"#\">".$langs->trans("Modify")."</a>";
}
else
{
if ($caneditfield || ! empty($user->admin)) // Si utilisateur edite = utilisateur courant (pas besoin de droits particulier car il s'agit d'une page de modif d'output et non de données) ou si admin
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&amp;id='.$fuser->id.'">'.$langs->trans("Modify").'</a>';
}
else
{
print "<a class=\"butActionRefused\" title=\"".$langs->trans("NotEnoughPermissions")."\" href=\"#\">".$langs->trans("Modify")."</a>";
}
}
2009-02-11 03:18:27 +01:00
print '</div>';
}
dol_fiche_end();
llxFooter();
$db->close();
?>