dolibarr 25.0.0-alpha
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-2026 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2026 MDW <mdeweerd@users.noreply.github.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28// Load Dolibarr environment
29require '../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
32
41// Get parameters
42$id = GETPOSTINT('id');
43$action = GETPOST('action', 'aZ09');
44$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'usernote'; // To manage different context of search
45
46if (!isset($id) || empty($id)) {
48}
49
50// Load translation files required by page
51$langs->loadLangs(array('companies', 'members', 'bills', 'users'));
52
53$object = new User($db);
54$object->fetch($id, '', '', 1);
55$object->loadRights();
56
57// If user is not user read and no permission to read other users, we stop
58if (($object->id != $user->id) && (!$user->hasRight("user", "user", "read"))) {
60}
61
62// Permissions
63if ($object->id == $user->id) {
64 $permissionnote = $user->hasRight("user", "self", "write"); // Used by the include of actions_setnotes.inc.php
65} else {
66 $permissionnote = $user->hasRight("user", "user", "write"); // Used by the include of actions_setnotes.inc.php
67}
68
69// Security check
70$socid = 0;
71if ($user->socid > 0) {
72 $socid = $user->socid;
73}
74$feature2 = (($socid && $user->hasRight("user", "self", "write")) ? '' : 'user');
75
76// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
77$hookmanager->initHooks(array('usercard', 'usernote', 'globalcard'));
78
79$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
80
81
82/*
83 * Actions
84 */
85$parameters = array('id' => $socid);
86$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
87if ($reshook < 0) {
88 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
89}
90if (empty($reshook)) {
91 include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be 'include', not 'include_once'
92}
93
94
95/*
96 * View
97 */
98
99llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-user page-card_note');
100
101$form = new Form($db);
102
103if ($id) {
104 $head = user_prepare_head($object);
105
106 $title = $langs->trans("User");
107 print dol_get_fiche_head($head, 'note', $title, -1, 'user');
108
109 $linkback = '';
110
111 if ($user->hasRight("user", "user", "read") || $user->admin) {
112 $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
113 }
114
115 $morehtmlref = '<a href="'.DOL_URL_ROOT.'/user/vcard.php?id='.$object->id.'&output=file&file='.urlencode(dol_sanitizeFileName($object->getFullName($langs).'.vcf')).'" class="refid valignmiddle" rel="noopener">';
116 $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard', 'class="valignmiddle marginleftonly paddingrightonly"');
117 $morehtmlref .= '</a>';
118
119 $urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id);
120 $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->transnoentitiesnoconv("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'refid valignmiddle nohover');
121
122 dol_banner_tab($object, 'id', $linkback, $user->hasRight("user", "user", "read") || $user->admin, 'rowid', 'ref', $morehtmlref);
123
124 print '<div class="underbanner clearboth"></div>';
125
126 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
127 print '<input type="hidden" name="token" value="'.newToken().'">';
128
129 print '<div class="fichecenter">';
130 print '<table class="border centpercent tableforfield">';
131
132 // Login
133 print '<tr><td class="titlefield">'.$langs->trans("Login").'</td>';
134 if (!empty($object->ldap_sid) && $object->statut == 0) {
135 print '<td class="error">';
136 print $langs->trans("LoginAccountDisableInDolibarr");
137 print '</td>';
138 } else {
139 print '<td>';
140 $addadmin = '';
141 if (isModEnabled('multicompany') && !empty($object->admin) && empty($object->entity)) {
142 $addadmin .= img_picto($langs->trans("SuperAdministratorDesc"), "superadmin", 'class="paddingleft valignmiddle"');
143 } elseif (!empty($object->admin)) {
144 $addadmin .= img_picto($langs->trans("AdministratorDesc"), "admin", 'class="paddingleft valignmiddle"');
145 }
146 print showValueWithClipboardCPButton($object->login).$addadmin;
147 print '</td>';
148 }
149 print '</tr>';
150
151 print "</table>";
152
153 print '</div>';
154
155
156 //print '<br>';
157
158 //print '<div class="underbanner clearboth"></div>';
159 include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
160
161 print dol_get_fiche_end();
162} else {
163 $langs->load("errors");
164 print $langs->trans("ErrorRecordNotFound");
165}
166
167// End of page
168llxFooter();
169$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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)
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
isModEnabled($module)
Is Dolibarr module enabled.
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.