dolibarr  16.0.5
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)) {
44 }
45 
46 // Security check
47 $socid = 0;
48 if ($user->socid > 0) {
49  $socid = $user->socid;
50 }
51 $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
52 
53 $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
54 
55 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
56 $hookmanager->initHooks(array('usercard', 'usernote', 'globalcard'));
57 
58 
59 /*
60  * Actions
61  */
62 
63 $parameters = array('id'=>$socid);
64 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
65 if ($reshook < 0) {
66  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
67 }
68 
69 if (empty($reshook)) {
70  if ($action == 'update' && $user->rights->user->user->creer && !GETPOST("cancel")) {
71  $db->begin();
72 
73  $res = $object->update_note(dol_html_entity_decode(GETPOST('note_private', 'restricthtml'), ENT_QUOTES | ENT_HTML5));
74  if ($res < 0) {
75  $mesg = '<div class="error">'.$adh->error.'</div>';
76  $db->rollback();
77  } else {
78  $db->commit();
79  }
80  }
81 }
82 
83 
84 /*
85  * View
86  */
87 
88 llxHeader();
89 
90 $form = new Form($db);
91 
92 if ($id) {
93  $head = user_prepare_head($object);
94 
95  $title = $langs->trans("User");
96  print dol_get_fiche_head($head, 'note', $title, -1, 'user');
97 
98  $linkback = '';
99 
100  if ($user->rights->user->user->lire || $user->admin) {
101  $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
102  }
103 
104  $morehtmlref = '<a href="'.DOL_URL_ROOT.'/user/vcard.php?id='.$object->id.'" class="refid">';
105  $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
106  $morehtmlref .= '</a>';
107 
108  dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin, 'rowid', 'ref', $morehtmlref);
109 
110  print '<div class="underbanner clearboth"></div>';
111 
112  print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
113  print '<input type="hidden" name="token" value="'.newToken().'">';
114 
115  print '<div class="fichecenter">';
116  print '<table class="border centpercent tableforfield">';
117 
118  // Login
119  print '<tr><td class="titlefield">'.$langs->trans("Login").'</td>';
120  if (!empty($object->ldap_sid) && $object->statut == 0) {
121  print '<td class="error">';
122  print $langs->trans("LoginAccountDisableInDolibarr");
123  print '</td>';
124  } else {
125  print '<td>';
126  $addadmin = '';
127  if (property_exists($object, 'admin')) {
128  if (!empty($conf->multicompany->enabled) && !empty($object->admin) && empty($object->entity)) {
129  $addadmin .= img_picto($langs->trans("SuperAdministratorDesc"), "redstar", 'class="paddingleft"');
130  } elseif (!empty($object->admin)) {
131  $addadmin .= img_picto($langs->trans("AdministratorDesc"), "star", 'class="paddingleft"');
132  }
133  }
134  print showValueWithClipboardCPButton($object->login).$addadmin;
135  print '</td>';
136  }
137  print '</tr>';
138 
139  $editenabled = (($action == 'edit') && !empty($user->rights->user->user->creer));
140 
141  // Note
142  print '<tr><td class="tdtop">'.$langs->trans("Note").'</td>';
143  print '<td class="'.($editenabled ? '' : 'sensiblehtmlcontent').'">';
144  if ($editenabled) {
145  print "<input type=\"hidden\" name=\"action\" value=\"update\">";
146  print "<input type=\"hidden\" name=\"id\" value=\"".$object->id."\">";
147  // Editeur wysiwyg
148  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
149  $doleditor = new DolEditor('note_private', $object->note_private, '', 280, 'dolibarr_notes', 'In', true, false, getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_8, '90%');
150  $doleditor->Create();
151  } else {
152  print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private));
153  }
154  print "</td></tr>";
155 
156  print "</table>";
157  print '</div>';
158 
159  print dol_get_fiche_end();
160 
161  if ($action == 'edit') {
162  print $form->buttonsSaveCancel();
163  }
164 
165 
166  /*
167  * Actions
168  */
169 
170  print '<div class="tabsAction">';
171 
172  if ($user->rights->user->user->creer && $action != 'edit') {
173  print '<a class="butAction" href="note.php?id='.$object->id.'&action=edit&token='.newToken().'">'.$langs->trans('Modify')."</a>";
174  }
175 
176  print "</div>";
177 
178  print "</form>\n";
179 }
180 
181 // End of page
182 llxFooter();
183 $db->close();
restrictedArea
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
user_prepare_head
user_prepare_head(User $object)
Prepare array with list of tabs.
Definition: usergroups.lib.php:35
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
dol_banner_tab
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.
Definition: functions.lib.php:2046
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
showValueWithClipboardCPButton
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
Definition: functions.lib.php:11087
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
User
Class to manage Dolibarr users.
Definition: user.class.php:44
dol_html_entity_decode
dol_html_entity_decode($a, $b, $c='UTF-8', $keepsomeentities=0)
Replace html_entity_decode functions to manage errors.
Definition: functions.lib.php:7052
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_htmlentitiesbr
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...
Definition: functions.lib.php:6991
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
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 ...
Definition: security.lib.php:933
getDolGlobalInt
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
Definition: functions.lib.php:93
dol_string_onlythesehtmltags
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0)
Clean a string to keep only desirable HTML tags.
Definition: functions.lib.php:6760
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
DolEditor
Class to manage a WYSIWYG editor.
Definition: doleditor.class.php:30