dolibarr  13.0.2
note.php
Go to the documentation of this file.
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 
26 require '../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
28 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
29 
30 $id = GETPOST('id', 'int');
31 $action = GETPOST('action', 'aZ09');
32 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'usernote'; // To manage different context of search
33 
34 // Load translation files required by page
35 $langs->loadLangs(array('companies', 'members', 'bills', 'users'));
36 
37 $object = new User($db);
38 $object->fetch($id, '', '', 1);
39 $object->getrights();
40 
41 // If user is not user read and no permission to read other users, we stop
42 if (($object->id != $user->id) && (!$user->rights->user->user->lire)) accessforbidden();
43 
44 // Security check
45 $socid = 0;
46 if ($user->socid > 0) $socid = $user->socid;
47 $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
48 
49 $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
50 
51 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
52 $hookmanager->initHooks(array('usercard', 'usernote', 'globalcard'));
53 
54 
55 /*
56  * Actions
57  */
58 
59 $parameters = array('id'=>$socid);
60 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
61 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
62 
63 if (empty($reshook)) {
64  if ($action == 'update' && $user->rights->user->user->creer && !$_POST["cancel"]) {
65  $db->begin();
66 
67  $res = $object->update_note(dol_html_entity_decode(GETPOST('note_private', 'restricthtml'), ENT_QUOTES | ENT_HTML5));
68  if ($res < 0) {
69  $mesg = '<div class="error">'.$adh->error.'</div>';
70  $db->rollback();
71  } else {
72  $db->commit();
73  }
74  }
75 }
76 
77 
78 /*
79  * View
80  */
81 
82 llxHeader();
83 
84 $form = new Form($db);
85 
86 if ($id)
87 {
88  $head = user_prepare_head($object);
89 
90  $title = $langs->trans("User");
91  print dol_get_fiche_head($head, 'note', $title, -1, 'user');
92 
93  $linkback = '';
94 
95  if ($user->rights->user->user->lire || $user->admin) {
96  $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
97  }
98 
99  dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin);
100 
101  print '<div class="underbanner clearboth"></div>';
102 
103  print "<form method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">";
104  print '<input type="hidden" name="token" value="'.newToken().'">';
105 
106  print '<div class="fichecenter">';
107  print '<table class="border centpercent tableforfield">';
108 
109  // Login
110  print '<tr><td class="titlefield">'.$langs->trans("Login").'</td><td class="valeur">'.$object->login.'&nbsp;</td></tr>';
111 
112  $editenabled = (($action == 'edit') && !empty($user->rights->user->user->creer));
113 
114  // Note
115  print '<tr><td class="tdtop">'.$langs->trans("Note").'</td>';
116  print '<td class="'.($editenabled ? '' : 'sensiblehtmlcontent').'">';
117  if ($editenabled)
118  {
119  print "<input type=\"hidden\" name=\"action\" value=\"update\">";
120  print "<input type=\"hidden\" name=\"id\" value=\"".$object->id."\">";
121  // Editeur wysiwyg
122  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
123  $doleditor = new DolEditor('note_private', $object->note_private, '', 280, 'dolibarr_notes', 'In', true, false, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_8, '90%');
124  $doleditor->Create();
125  } else {
126  print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private));
127  }
128  print "</td></tr>";
129 
130  print "</table>";
131  print '</div>';
132 
134 
135  if ($action == 'edit')
136  {
137  print '<div class="center">';
138  print '<input type="submit" class="button button-save" name="update" value="'.$langs->trans("Save").'">';
139  print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
140  print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
141  print '</div>';
142  }
143 
144 
145  /*
146  * Actions
147  */
148 
149  print '<div class="tabsAction">';
150 
151  if ($user->rights->user->user->creer && $action != 'edit')
152  {
153  print "<a class=\"butAction\" href=\"note.php?id=".$object->id."&amp;action=edit\">".$langs->trans('Modify')."</a>";
154  }
155 
156  print "</div>";
157 
158  print "</form>\n";
159 }
160 
161 // End of page
162 llxFooter();
163 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
user_prepare_head($object)
Prepare array with list of tabs.
dol_html_entity_decode($a, $b, $c= 'UTF-8', $keepsomeentities=0)
Replace html_entity_decode functions to manage errors.
Class to manage Dolibarr users.
Definition: user.class.php:44
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom= 'UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0)
Clean a string to keep only desirable HTML tags.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Class to manage a WYSIWYG editor.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
llxFooter()
Empty footer.
Definition: wrapper.php:59