note.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2015 Regis Houssin <regis.houssin@inodbox.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/user/note.php
  21. * \ingroup usergroup
  22. * \brief Fiche de notes sur un utilisateur Dolibarr
  23. */
  24. // Load Dolibarr environment
  25. require '../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
  28. // Get parameters
  29. $id = GETPOST('id', 'int');
  30. $action = GETPOST('action', 'aZ09');
  31. $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'usernote'; // To manage different context of search
  32. // Load translation files required by page
  33. $langs->loadLangs(array('companies', 'members', 'bills', 'users'));
  34. $object = new User($db);
  35. $object->fetch($id, '', '', 1);
  36. $object->getrights();
  37. // If user is not user read and no permission to read other users, we stop
  38. if (($object->id != $user->id) && (!$user->hasRight("user", "user", "read"))) {
  39. accessforbidden();
  40. }
  41. // Permissions
  42. $permissionnote = $user->hasRight("user", "self", "write"); // Used by the include of actions_setnotes.inc.php
  43. // Security check
  44. $socid = 0;
  45. if ($user->socid > 0) {
  46. $socid = $user->socid;
  47. }
  48. $feature2 = (($socid && $user->hasRight("user", "self", "write")) ? '' : 'user');
  49. $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
  50. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  51. $hookmanager->initHooks(array('usercard', 'usernote', 'globalcard'));
  52. /*
  53. * Actions
  54. */
  55. $parameters = array('id'=>$socid);
  56. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  57. if ($reshook < 0) {
  58. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  59. }
  60. if (empty($reshook)) {
  61. include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
  62. }
  63. /*
  64. * View
  65. */
  66. llxHeader();
  67. $form = new Form($db);
  68. if ($id) {
  69. $head = user_prepare_head($object);
  70. $title = $langs->trans("User");
  71. print dol_get_fiche_head($head, 'note', $title, -1, 'user');
  72. $linkback = '';
  73. if ($user->hasRight("user", "user", "read") || $user->admin) {
  74. $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  75. }
  76. $morehtmlref = '<a href="'.DOL_URL_ROOT.'/user/vcard.php?id='.$object->id.'" class="refid">';
  77. $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
  78. $morehtmlref .= '</a>';
  79. dol_banner_tab($object, 'id', $linkback, $user->hasRight("user", "user", "read") || $user->admin, 'rowid', 'ref', $morehtmlref);
  80. print '<div class="underbanner clearboth"></div>';
  81. print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
  82. print '<input type="hidden" name="token" value="'.newToken().'">';
  83. print '<div class="fichecenter">';
  84. print '<table class="border centpercent tableforfield">';
  85. // Login
  86. print '<tr><td class="titlefield">'.$langs->trans("Login").'</td>';
  87. if (!empty($object->ldap_sid) && $object->statut == 0) {
  88. print '<td class="error">';
  89. print $langs->trans("LoginAccountDisableInDolibarr");
  90. print '</td>';
  91. } else {
  92. print '<td>';
  93. $addadmin = '';
  94. if (property_exists($object, 'admin')) {
  95. if (isModEnabled('multicompany') && !empty($object->admin) && empty($object->entity)) {
  96. $addadmin .= img_picto($langs->trans("SuperAdministratorDesc"), "redstar", 'class="paddingleft"');
  97. } elseif (!empty($object->admin)) {
  98. $addadmin .= img_picto($langs->trans("AdministratorDesc"), "star", 'class="paddingleft"');
  99. }
  100. }
  101. print showValueWithClipboardCPButton($object->login).$addadmin;
  102. print '</td>';
  103. }
  104. print '</tr>';
  105. print "</table>";
  106. print '</div>';
  107. //print '<br>';
  108. //print '<div class="underbanner clearboth"></div>';
  109. include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
  110. print dol_get_fiche_end();
  111. } else {
  112. $langs->load("errors");
  113. print $langs->trans("ErrorRecordNotFound");
  114. }
  115. // End of page
  116. llxFooter();
  117. $db->close();