PageRenderTime 22ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/user/param_ihm.php

https://bitbucket.org/speedealing/speedealing
PHP | 271 lines | 175 code | 58 blank | 38 comment | 41 complexity | 99a3e13e4f5f639d4b7b7b07fa955cd2 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  1. <?php
  2. /* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/user/param_ihm.php
  20. * \brief Page to show user setup for display
  21. */
  22. require '../main.inc.php';
  23. require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
  24. require_once DOL_DOCUMENT_ROOT . '/core/lib/usergroups.lib.php';
  25. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formadmin.class.php';
  26. $langs->load("companies");
  27. $langs->load("products");
  28. $langs->load("admin");
  29. $langs->load("users");
  30. $langs->load("languages");
  31. // Defini si peux lire/modifier permisssions
  32. $canreaduser = ($user->admin || $user->rights->user->user->lire);
  33. $id = GETPOST('id', 'alpha');
  34. $action = GETPOST('action');
  35. if ($id) {
  36. // $user est le user qui edite, $id est l'id de l'utilisateur edite
  37. $canedpermsitfield = ((($user->id == $id) && $user->rights->user->self->creer)
  38. || (($user->id != $id) && $user->rights->user->user->creer));
  39. }
  40. // Security check
  41. $socid = 0;
  42. if ($user->societe_id > 0)
  43. $socid = $user->societe_id;
  44. $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
  45. if ($user->id == $id) { // A user can always read its own card
  46. $feature2 = '';
  47. $canreaduser = 1;
  48. }
  49. $result = restrictedArea($user, 'user', $id, '&user', $feature2);
  50. if ($user->id <> $id && !$canreaduser)
  51. accessforbidden();
  52. $dirtop = "../core/menus/standard";
  53. $dirleft = "../core/menus/standard";
  54. // Charge utilisateur edite
  55. $fuser = new User($db);
  56. $fuser->fetch($id);
  57. $fuser->getrights();
  58. // Liste des zone de recherche permanentes supportees
  59. $searchform = array("main_searchform_societe", "main_searchform_contact", "main_searchform_produitservice");
  60. $searchformconst = array($conf->global->MAIN_SEARCHFORM_SOCIETE, $conf->global->MAIN_SEARCHFORM_CONTACT, $conf->global->MAIN_SEARCHFORM_PRODUITSERVICE);
  61. $searchformtitle = array($langs->trans("Companies"), $langs->trans("Contacts"), $langs->trans("ProductsAndServices"));
  62. $form = new Form($db);
  63. $formadmin = new FormAdmin($db);
  64. /*
  65. * Actions
  66. */
  67. if ($action == 'update' && ($caneditfield || $user->admin)) {
  68. if (!$_POST["cancel"]) {
  69. $tabparam = array();
  70. if ($_POST["check_MAIN_LANG_DEFAULT"] == "on")
  71. $tabparam["MAIN_LANG_DEFAULT"] = $_POST["main_lang_default"];
  72. else
  73. $tabparam["MAIN_LANG_DEFAULT"] = '';
  74. $tabparam["MAIN_MENU_STANDARD"] = $_POST["MAIN_MENU_STANDARD"];
  75. if ($_POST["check_SIZE_LISTE_LIMIT"] == "on")
  76. $tabparam["MAIN_SIZE_LISTE_LIMIT"] = $_POST["main_size_liste_limit"];
  77. else
  78. $tabparam["MAIN_SIZE_LISTE_LIMIT"] = '';
  79. if ($_POST["check_MAIN_THEME"] == "on")
  80. $tabparam["MAIN_THEME"] = $_POST["main_theme"];
  81. else
  82. $tabparam["MAIN_THEME"] = '';
  83. $tabparam["MAIN_SEARCHFORM_CONTACT"] = $_POST["main_searchform_contact"];
  84. $tabparam["MAIN_SEARCHFORM_SOCIETE"] = $_POST["main_searchform_societe"];
  85. $tabparam["MAIN_SEARCHFORM_PRODUITSERVICE"] = $_POST["main_searchform_produitservice"];
  86. $result = dol_set_user_param($db, $conf, $fuser, $tabparam);
  87. $_SESSION["mainmenu"] = ""; // Le gestionnaire de menu a pu changer
  88. header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
  89. exit;
  90. }
  91. }
  92. /*
  93. * View
  94. */
  95. llxHeader();
  96. $head = user_prepare_head($fuser);
  97. $title = $langs->trans("User");
  98. print_fiche_titre($title);
  99. print '<div class="with-padding">';
  100. print '<div class="columns">';
  101. print start_box($title, "twelve", "16-User-2.png", false);
  102. dol_fiche_head($head, 'guisetup', $title, 0, 'user');
  103. print '<table class="border" width="100%">';
  104. // Ref
  105. print '<tr><td width="25%" valign="top">' . $langs->trans("Ref") . '</td>';
  106. print '<td colspan="2">';
  107. print $form->showrefnav($fuser, 'id', '', $user->rights->user->user->lire || $user->admin);
  108. print '</td>';
  109. print '</tr>';
  110. // Nom
  111. print '<tr><td width="25%" valign="top">' . $langs->trans("LastName") . '</td>';
  112. print '<td colspan="2">' . $fuser->nom . '</td>';
  113. print "</tr>\n";
  114. // Prenom
  115. print '<tr><td width="25%" valign="top">' . $langs->trans("FirstName") . '</td>';
  116. print '<td colspan="2">' . $fuser->prenom . '</td>';
  117. print "</tr>\n";
  118. print '</table><br>';
  119. if ($action == 'edit') {
  120. print '<script type="text/javascript" language="javascript">
  121. jQuery(document).ready(function() {
  122. $("#main_lang_default").change(function() {
  123. $("#check_MAIN_LANG_DEFAULT").attr(\'checked\', true);
  124. });
  125. $("#main_size_liste_limit").keyup(function() {
  126. if ($(this).val().length) $("#check_SIZE_LISTE_LIMIT").attr(\'checked\', true);
  127. else $("#check_SIZE_LISTE_LIMIT").attr(\'checked\', false);
  128. });
  129. });
  130. </script>';
  131. print '<form method="post" action="' . $_SERVER["PHP_SELF"] . '">';
  132. print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
  133. print '<input type="hidden" name="action" value="update">';
  134. print '<input type="hidden" name="id" value="' . $id . '">';
  135. clearstatcache();
  136. $var = true;
  137. print '<table class="noborder" width="100%">';
  138. 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>';
  139. // Langue par defaut
  140. $var = !$var;
  141. print '<tr ' . $bc[$var] . '><td>' . $langs->trans("Language") . '</td>';
  142. print '<td>';
  143. $s = picto_from_langcode($conf->global->MAIN_LANG_DEFAULT);
  144. print $s ? $s . ' ' : '';
  145. print ($conf->global->MAIN_LANG_DEFAULT == 'auto' ? $langs->trans("AutoDetectLang") : $langs->trans("Language_" . $conf->global->MAIN_LANG_DEFAULT));
  146. print '</td>';
  147. print '<td align="left" nowrap="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" : "");
  148. print !empty($dolibarr_main_demo) ? ' disabled="disabled"' : ''; // Disabled for demo
  149. print '> ' . $langs->trans("UsePersonalValue") . '</td>';
  150. print '<td>';
  151. print $formadmin->select_language((!empty($fuser->conf->MAIN_LANG_DEFAULT) ? $fuser->conf->MAIN_LANG_DEFAULT : ''), 'main_lang_default', 1);
  152. print '</td></tr>';
  153. // Taille max des listes
  154. $var = !$var;
  155. print '<tr ' . $bc[$var] . '><td>' . $langs->trans("MaxSizeList") . '</td>';
  156. print '<td>' . $conf->global->MAIN_SIZE_LISTE_LIMIT . '</td>';
  157. print '<td align="left" nowrap="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" : "");
  158. print !empty($dolibarr_main_demo) ? ' disabled="disabled"' : ''; // Disabled for demo
  159. print '> ' . $langs->trans("UsePersonalValue") . '</td>';
  160. print '<td><input class="flat" name="main_size_liste_limit" id="main_size_liste_limit" size="4" value="' . (!empty($fuser->conf->SIZE_LISTE_LIMIT) ? $fuser->conf->SIZE_LISTE_LIMIT : '') . '"></td></tr>';
  161. print '</table><br>';
  162. // Theme
  163. show_theme($fuser, (($user->admin || empty($dolibarr_main_demo)) ? 1 : 0), true);
  164. print '</div>';
  165. print '<center>';
  166. print '<input type="submit" class="button" name="save" value="' . $langs->trans("Save") . '">';
  167. print ' &nbsp; &nbsp; ';
  168. print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
  169. print '</center>';
  170. print '</form>';
  171. } else {
  172. $var = true;
  173. print '<table class="noborder" width="100%">';
  174. 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>';
  175. $var = !$var;
  176. print '<tr ' . $bc[$var] . '><td>' . $langs->trans("Language") . '</td>';
  177. print '<td>';
  178. $s = picto_from_langcode($conf->global->MAIN_LANG_DEFAULT);
  179. print ($s ? $s . ' ' : '');
  180. print (isset($conf->global->MAIN_LANG_DEFAULT) && $conf->global->MAIN_LANG_DEFAULT == 'auto' ? $langs->trans("AutoDetectLang") : $langs->trans("Language_" . $conf->global->MAIN_LANG_DEFAULT));
  181. print '</td>';
  182. print '<td align="left" nowrap="nowrap" width="20%"><input ' . $bc[$var] . ' type="checkbox" disabled ' . (!empty($fuser->conf->MAIN_LANG_DEFAULT) ? " checked" : "") . '> ' . $langs->trans("UsePersonalValue") . '</td>';
  183. print '<td>';
  184. $s = (isset($fuser->conf->MAIN_LANG_DEFAULT) ? picto_from_langcode($fuser->conf->MAIN_LANG_DEFAULT) : '');
  185. print ($s ? $s . ' ' : '');
  186. 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) : ''));
  187. print '</td></tr>';
  188. $var = !$var;
  189. print '<tr ' . $bc[$var] . '><td>' . $langs->trans("MaxSizeList") . '</td>';
  190. print '<td>' . (!empty($conf->global->MAIN_SIZE_LISTE_LIMIT) ? $conf->global->MAIN_SIZE_LISTE_LIMIT : '&nbsp;') . '</td>';
  191. print '<td align="left" nowrap="nowrap" width="20%"><input ' . $bc[$var] . ' type="checkbox" disabled ' . (!empty($fuser->conf->MAIN_SIZE_LISTE_LIMIT) ? " checked" : "") . '> ' . $langs->trans("UsePersonalValue") . '</td>';
  192. print '<td>' . (!empty($fuser->conf->MAIN_SIZE_LISTE_LIMIT) ? $fuser->conf->MAIN_SIZE_LISTE_LIMIT : '&nbsp;') . '</td></tr>';
  193. print '</table><br>';
  194. // Skin
  195. show_theme($fuser, 0, true);
  196. print '</div>';
  197. print '<div class="tabsAction">';
  198. if (empty($user->admin) && !empty($dolibarr_main_demo)) {
  199. print "<a class=\"butActionRefused\" title=\"" . $langs->trans("FeatureDisabledInDemo") . "\" href=\"#\">" . $langs->trans("Modify") . "</a>";
  200. } else {
  201. if ($user->id == $fuser->id || !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
  202. print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=edit&amp;id=' . $fuser->id . '">' . $langs->trans("Modify") . '</a>';
  203. } else {
  204. print "<a class=\"butActionRefused\" title=\"" . $langs->trans("NotEnoughPermissions") . "\" href=\"#\">" . $langs->trans("Modify") . "</a>";
  205. }
  206. }
  207. print '</div>';
  208. }
  209. print end_box();
  210. print '</div></div>';
  211. $db->close();
  212. llxFooter();
  213. ?>