dolibarr 22.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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
31
40// Get parameters
41$id = GETPOSTINT('id');
42$action = GETPOST('action', 'aZ09');
43$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'usernote'; // To manage different context of search
44
45if (!isset($id) || empty($id)) {
47}
48
49// Load translation files required by page
50$langs->loadLangs(array('companies', 'members', 'bills', 'users'));
51
52$object = new User($db);
53$object->fetch($id, '', '', 1);
54$object->loadRights();
55
56// If user is not user read and no permission to read other users, we stop
57if (($object->id != $user->id) && (!$user->hasRight("user", "user", "read"))) {
59}
60
61// Permissions
62// Writing notes on own record needs the "self" write right, writing on another user's record needs the "user" write right.
63// Without this distinction a user holding only "self" write could edit the notes of any user, including admins.
64$permissionnote = ((($object->id == $user->id) && $user->hasRight("user", "self", "write")) || (($object->id != $user->id) && $user->hasRight("user", "user", "write"))); // Used by the include of actions_setnotes.inc.php
65
66// Security check
67$socid = 0;
68if ($user->socid > 0) {
69 $socid = $user->socid;
70}
71$feature2 = (($socid && $user->hasRight("user", "self", "write")) ? '' : 'user');
72
73// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
74$hookmanager->initHooks(array('usercard', 'usernote', 'globalcard'));
75
76$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
77
78
79/*
80 * Actions
81 */
82$parameters = array('id'=>$socid);
83$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
84if ($reshook < 0) {
85 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
86}
87if (empty($reshook)) {
88 include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be 'include', not 'include_once'
89}
90
91
92/*
93 * View
94 */
95
96llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-user page-card_note');
97
98$form = new Form($db);
99
100if ($id) {
101 $head = user_prepare_head($object);
102
103 $title = $langs->trans("User");
104 print dol_get_fiche_head($head, 'note', $title, -1, 'user');
105
106 $linkback = '';
107
108 if ($user->hasRight("user", "user", "read") || $user->admin) {
109 $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
110 }
111
112 $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">';
113 $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
114 $morehtmlref .= '</a>';
115
116 $urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id);
117 $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->transnoentitiesnoconv("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover');
118
119 dol_banner_tab($object, 'id', $linkback, $user->hasRight("user", "user", "read") || $user->admin, 'rowid', 'ref', $morehtmlref);
120
121 print '<div class="underbanner clearboth"></div>';
122
123 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
124 print '<input type="hidden" name="token" value="'.newToken().'">';
125
126 print '<div class="fichecenter">';
127 print '<table class="border centpercent tableforfield">';
128
129 // Login
130 print '<tr><td class="titlefield">'.$langs->trans("Login").'</td>';
131 if (!empty($object->ldap_sid) && $object->statut == 0) {
132 print '<td class="error">';
133 print $langs->trans("LoginAccountDisableInDolibarr");
134 print '</td>';
135 } else {
136 print '<td>';
137 $addadmin = '';
138 if (property_exists($object, 'admin')) {
139 if (isModEnabled('multicompany') && !empty($object->admin) && empty($object->entity)) {
140 $addadmin .= img_picto($langs->trans("SuperAdministratorDesc"), "redstar", 'class="paddingleft valignmiddle"');
141 } elseif (!empty($object->admin)) {
142 $addadmin .= img_picto($langs->trans("AdministratorDesc"), "star", 'class="paddingleft valignmiddle"');
143 }
144 }
145 print showValueWithClipboardCPButton($object->login).$addadmin;
146 print '</td>';
147 }
148 print '</tr>';
149
150 print "</table>";
151
152 print '</div>';
153
154
155 //print '<br>';
156
157 //print '<div class="underbanner clearboth"></div>';
158 include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
159
160 print dol_get_fiche_end();
161} else {
162 $langs->load("errors");
163 print $langs->trans("ErrorRecordNotFound");
164}
165
166// End of page
167llxFooter();
168$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage generation of HTML components Only common components must be here.
Class to manage Dolibarr users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $jsonclose='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
restrictedArea(User $user, $features, $object=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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
user_prepare_head(User $object)
Prepare array with list of tabs.