note.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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@capnetworks.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 <http://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. $langs->load("companies");
  31. $langs->load("members");
  32. $langs->load("bills");
  33. $langs->load("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->rights->user->user->lire)) accessforbidden();
  39. // Security check
  40. $socid=0;
  41. if ($user->societe_id > 0) $socid = $user->societe_id;
  42. $feature2 = (($socid && $user->rights->user->self->creer)?'':'user');
  43. if ($user->id == $id) $feature2=''; // A user can always read its own card
  44. $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
  45. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  46. $hookmanager->initHooks(array('usercard','usernote','globalcard'));
  47. /*
  48. * Actions
  49. */
  50. $parameters=array('id'=>$socid);
  51. $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
  52. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  53. if (empty($reshook)) {
  54. if ($action == 'update' && $user->rights->user->user->creer && !$_POST["cancel"]) {
  55. $db->begin();
  56. $res = $object->update_note(dol_html_entity_decode(GETPOST('note_private','none'), ENT_QUOTES));
  57. if ($res < 0) {
  58. $mesg = '<div class="error">'.$adh->error.'</div>';
  59. $db->rollback();
  60. } else {
  61. $db->commit();
  62. }
  63. }
  64. }
  65. /*
  66. * View
  67. */
  68. llxHeader();
  69. $form = new Form($db);
  70. if ($id)
  71. {
  72. $head = user_prepare_head($object);
  73. $title = $langs->trans("User");
  74. dol_fiche_head($head, 'note', $title, -1, 'user');
  75. $linkback = '';
  76. if ($user->rights->user->user->lire || $user->admin) {
  77. $linkback = '<a href="'.DOL_URL_ROOT.'/user/index.php">'.$langs->trans("BackToList").'</a>';
  78. }
  79. dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin);
  80. print '<div class="underbanner clearboth"></div>';
  81. print "<form method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">";
  82. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  83. print '<div class="fichecenter">';
  84. print '<table class="border" width="100%">';
  85. // Login
  86. print '<tr><td class="titlefield">'.$langs->trans("Login").'</td><td class="valeur">'.$object->login.'&nbsp;</td></tr>';
  87. // Note
  88. print '<tr><td class="tdtop">'.$langs->trans("Note").'</td>';
  89. print '<td>';
  90. if ($action == 'edit' && $user->rights->user->user->creer)
  91. {
  92. print "<input type=\"hidden\" name=\"action\" value=\"update\">";
  93. print "<input type=\"hidden\" name=\"id\" value=\"".$object->id."\">";
  94. // Editeur wysiwyg
  95. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  96. $doleditor=new DolEditor('note_private',$object->note,'',280,'dolibarr_notes','In',true,false,$conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_8,'90%');
  97. $doleditor->Create();
  98. }
  99. else
  100. {
  101. print dol_htmlentitiesbr($object->note);
  102. }
  103. print "</td></tr>";
  104. print "</table>";
  105. print '</div>';
  106. dol_fiche_end();
  107. if ($action == 'edit')
  108. {
  109. print '<div class="center">';
  110. print '<input type="submit" class="button" name="update" value="'.$langs->trans("Save").'">';
  111. print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  112. print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
  113. print '</div>';
  114. }
  115. /*
  116. * Actions
  117. */
  118. print '<div class="tabsAction">';
  119. if ($user->rights->user->user->creer && $action != 'edit')
  120. {
  121. print "<a class=\"butAction\" href=\"note.php?id=".$object->id."&amp;action=edit\">".$langs->trans('Modify')."</a>";
  122. }
  123. print "</div>";
  124. print "</form>\n";
  125. }
  126. llxFooter();
  127. $db->close();