note.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. if (!isset($id) || empty($id)) {
  33. accessforbidden();
  34. }
  35. // Load translation files required by page
  36. $langs->loadLangs(array('companies', 'members', 'bills', 'users'));
  37. $object = new User($db);
  38. $object->fetch($id, '', '', 1);
  39. $object->getrights();
  40. // If user is not user read and no permission to read other users, we stop
  41. if (($object->id != $user->id) && (!$user->hasRight("user", "user", "read"))) {
  42. accessforbidden();
  43. }
  44. // Permissions
  45. $permissionnote = $user->hasRight("user", "self", "write"); // Used by the include of actions_setnotes.inc.php
  46. // Security check
  47. $socid = 0;
  48. if ($user->socid > 0) {
  49. $socid = $user->socid;
  50. }
  51. $feature2 = (($socid && $user->hasRight("user", "self", "write")) ? '' : 'user');
  52. $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
  53. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  54. $hookmanager->initHooks(array('usercard', 'usernote', 'globalcard'));
  55. /*
  56. * Actions
  57. */
  58. $parameters = array('id'=>$socid);
  59. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  60. if ($reshook < 0) {
  61. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  62. }
  63. if (empty($reshook)) {
  64. include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
  65. }
  66. /*
  67. * View
  68. */
  69. llxHeader();
  70. $form = new Form($db);
  71. if ($id) {
  72. $head = user_prepare_head($object);
  73. $title = $langs->trans("User");
  74. print dol_get_fiche_head($head, 'note', $title, -1, 'user');
  75. $linkback = '';
  76. if ($user->hasRight("user", "user", "read") || $user->admin) {
  77. $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  78. }
  79. $morehtmlref = '<a href="'.DOL_URL_ROOT.'/user/vcard.php?id='.$object->id.'&output=file&file='.urlencode(dol_sanitizeFileName($object->getFullName($langs).'.vcf')).'" class="refid" rel="noopener">';
  80. $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
  81. $morehtmlref .= '</a>';
  82. $urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id);
  83. $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->trans("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover');
  84. dol_banner_tab($object, 'id', $linkback, $user->hasRight("user", "user", "read") || $user->admin, 'rowid', 'ref', $morehtmlref);
  85. print '<div class="underbanner clearboth"></div>';
  86. print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
  87. print '<input type="hidden" name="token" value="'.newToken().'">';
  88. print '<div class="fichecenter">';
  89. print '<table class="border centpercent tableforfield">';
  90. // Login
  91. print '<tr><td class="titlefield">'.$langs->trans("Login").'</td>';
  92. if (!empty($object->ldap_sid) && $object->statut == 0) {
  93. print '<td class="error">';
  94. print $langs->trans("LoginAccountDisableInDolibarr");
  95. print '</td>';
  96. } else {
  97. print '<td>';
  98. $addadmin = '';
  99. if (property_exists($object, 'admin')) {
  100. if (isModEnabled('multicompany') && !empty($object->admin) && empty($object->entity)) {
  101. $addadmin .= img_picto($langs->trans("SuperAdministratorDesc"), "redstar", 'class="paddingleft"');
  102. } elseif (!empty($object->admin)) {
  103. $addadmin .= img_picto($langs->trans("AdministratorDesc"), "star", 'class="paddingleft"');
  104. }
  105. }
  106. print showValueWithClipboardCPButton($object->login).$addadmin;
  107. print '</td>';
  108. }
  109. print '</tr>';
  110. print "</table>";
  111. print '</div>';
  112. //print '<br>';
  113. //print '<div class="underbanner clearboth"></div>';
  114. include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
  115. print dol_get_fiche_end();
  116. } else {
  117. $langs->load("errors");
  118. print $langs->trans("ErrorRecordNotFound");
  119. }
  120. // End of page
  121. llxFooter();
  122. $db->close();