note.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
  26. require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
  27. $id = GETPOST('id', 'int');
  28. $action = GETPOST('action', 'aZ09');
  29. $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'usernote'; // To manage different context of search
  30. // Load translation files required by page
  31. $langs->loadLangs(array('companies', 'members', 'bills', 'users'));
  32. $object = new User($db);
  33. $object->fetch($id, '', '', 1);
  34. $object->getrights();
  35. // If user is not user read and no permission to read other users, we stop
  36. if (($object->id != $user->id) && (!$user->rights->user->user->lire)) {
  37. accessforbidden();
  38. }
  39. // Security check
  40. $socid = 0;
  41. if ($user->socid > 0) {
  42. $socid = $user->socid;
  43. }
  44. $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
  45. $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
  46. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  47. $hookmanager->initHooks(array('usercard', 'usernote', 'globalcard'));
  48. /*
  49. * Actions
  50. */
  51. $parameters = array('id'=>$socid);
  52. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  53. if ($reshook < 0) {
  54. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  55. }
  56. if (empty($reshook)) {
  57. if ($action == 'update' && $user->rights->user->user->creer && !GETPOST("cancel")) {
  58. $db->begin();
  59. $res = $object->update_note(dol_html_entity_decode(GETPOST('note_private', 'restricthtml'), ENT_QUOTES | ENT_HTML5));
  60. if ($res < 0) {
  61. $mesg = '<div class="error">'.$adh->error.'</div>';
  62. $db->rollback();
  63. } else {
  64. $db->commit();
  65. }
  66. }
  67. }
  68. /*
  69. * View
  70. */
  71. llxHeader();
  72. $form = new Form($db);
  73. if ($id) {
  74. $head = user_prepare_head($object);
  75. $title = $langs->trans("User");
  76. print dol_get_fiche_head($head, 'note', $title, -1, 'user');
  77. $linkback = '';
  78. if ($user->rights->user->user->lire || $user->admin) {
  79. $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  80. }
  81. $morehtmlref = '<a href="'.DOL_URL_ROOT.'/user/vcard.php?id='.$object->id.'" class="refid">';
  82. $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
  83. $morehtmlref .= '</a>';
  84. dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $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 (!empty($conf->multicompany->enabled) && !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. $editenabled = (($action == 'edit') && !empty($user->rights->user->user->creer));
  111. // Note
  112. print '<tr><td class="tdtop">'.$langs->trans("Note").'</td>';
  113. print '<td class="'.($editenabled ? '' : 'sensiblehtmlcontent').'">';
  114. if ($editenabled) {
  115. print "<input type=\"hidden\" name=\"action\" value=\"update\">";
  116. print "<input type=\"hidden\" name=\"id\" value=\"".$object->id."\">";
  117. // Editeur wysiwyg
  118. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  119. $doleditor = new DolEditor('note_private', $object->note_private, '', 280, 'dolibarr_notes', 'In', true, false, getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_8, '90%');
  120. $doleditor->Create();
  121. } else {
  122. print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private));
  123. }
  124. print "</td></tr>";
  125. print "</table>";
  126. print '</div>';
  127. print dol_get_fiche_end();
  128. if ($action == 'edit') {
  129. print $form->buttonsSaveCancel();
  130. }
  131. /*
  132. * Actions
  133. */
  134. print '<div class="tabsAction">';
  135. if ($user->rights->user->user->creer && $action != 'edit') {
  136. print '<a class="butAction" href="note.php?id='.$object->id.'&action=edit&token='.newToken().'">'.$langs->trans('Modify')."</a>";
  137. }
  138. print "</div>";
  139. print "</form>\n";
  140. }
  141. // End of page
  142. llxFooter();
  143. $db->close();