dolibarr 21.0.0-beta
document.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2015 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
7 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
35
44// Load translation files required by page
45$langs->loadLangs(array('users', 'other'));
46
47$action = GETPOST('action', 'aZ09');
48$confirm = GETPOST('confirm');
49$id = (GETPOSTINT('userid') ? GETPOSTINT('userid') : GETPOSTINT('id'));
50$ref = GETPOST('ref', 'alpha');
51$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'userdoc'; // To manage different context of search
52
53if (!isset($id) || empty($id)) {
55}
56
57// Define value to know what current user can do on users
58$permissiontoadd = (!empty($user->admin) || $user->hasRight("user", "user", "write"));
59$permissiontoread = (!empty($user->admin) || $user->hasRight("user", "user", "read"));
60$permissiontoedit = (!empty($user->admin) || $user->hasRight("user", "user", "write"));
61$permissiontodisable = (!empty($user->admin) || $user->hasRight("user", "user", "delete"));
62$permissiontoreadgroup = $permissiontoread;
63$permissiontoeditgroup = $permissiontoedit;
64if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
65 $permissiontoreadgroup = (!empty($user->admin) || $user->hasRight("user", "group_advance", "read"));
66 $permissiontoeditgroup = (!empty($user->admin) || $user->hasRight("user", "group_advance", "write"));
67}
68// Define value to know what current user can do on properties of edited user
69if ($id) {
70 // $user est le user qui edite, $id est l'id de l'utilisateur edite
71 $permissiontoedit = ((($user->id == $id) && $user->hasRight("user", "self", "write")) || (($user->id != $id) && $user->hasRight("user", "user", "write")));
72 $permissiontoeditpassword = ((($user->id == $id) && $user->hasRight("user", "self", "password")) || (($user->id != $id) && $user->hasRight("user", "user", "password")));
73}
74
75$permissiontoadd = $permissiontoedit; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles
76$permtoedit = $permissiontoedit;
77
78// Security check
79$socid = 0;
80if ($user->socid > 0) {
81 $socid = $user->socid;
82}
83$feature2 = 'user';
84
85// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
86$hookmanager->initHooks(array('usercard', 'userdoc', 'globalcard'));
87
88$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
89
90if ($user->id != $id && !$permissiontoread) {
92}
93
94// Get parameters
95$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
96$sortfield = GETPOST('sortfield', 'aZ09comma');
97$sortorder = GETPOST('sortorder', 'aZ09comma');
98$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
99if (empty($page) || $page == -1) {
100 $page = 0;
101}
102$offset = $limit * $page;
103$pageprev = $page - 1;
104$pagenext = $page + 1;
105if (!$sortorder) {
106 $sortorder = "ASC";
107}
108if (!$sortfield) {
109 $sortfield = "position_name";
110}
111
112$object = new User($db);
113if ($id > 0 || !empty($ref)) {
114 $result = $object->fetch($id, $ref, '', 1);
115 $object->loadRights();
116 //$upload_dir = $conf->user->multidir_output[$object->entity] . "/" . $object->id ;
117 // For users, the upload_dir is always $conf->user->entity for the moment
118 $upload_dir = $conf->user->dir_output."/".$object->id;
119}
120
121/*
122 * Actions
123 */
124
125$parameters = array('id'=>$socid);
126$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
127if ($reshook < 0) {
128 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
129}
130
131if (empty($reshook)) {
132 include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
133}
134
135
136/*
137 * View
138 */
139
140$form = new Form($db);
141
142
143$person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname;
144$title = $person_name." - ".$langs->trans('Documents');
145$help_url = '';
146llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-user page-card_document');
147
148if ($object->id) {
149 /*
150 * Show tabs
151 */
152 if (isModEnabled('notification')) {
153 $langs->load("mails");
154 }
155 $head = user_prepare_head($object);
156
157 print dol_get_fiche_head($head, 'document', $langs->trans("User"), -1, 'user');
158
159 $linkback = '';
160 if ($user->hasRight("user", "user", "read") || $user->admin) {
161 $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
162 }
163
164 $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">';
165 $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
166 $morehtmlref .= '</a>';
167
168 $urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id);
169 $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->transnoentitiesnoconv("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover');
170
171 dol_banner_tab($object, 'id', $linkback, $user->hasRight("user", "user", "read") || $user->admin, 'rowid', 'ref', $morehtmlref);
172
173 print '<div class="fichecenter">';
174 print '<div class="underbanner clearboth"></div>';
175
176 // Build file list
177 $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
178 $totalsize = 0;
179 foreach ($filearray as $key => $file) {
180 $totalsize += $file['size'];
181 }
182
183
184 print '<table class="border tableforfield centpercent">';
185
186 // Login
187 print '<tr><td class="titlefield">'.$langs->trans("Login").'</td>';
188 if (!empty($object->ldap_sid) && $object->statut == 0) {
189 print '<td class="error">';
190 print $langs->trans("LoginAccountDisableInDolibarr");
191 print '</td>';
192 } else {
193 print '<td>';
194 $addadmin = '';
195 if (property_exists($object, 'admin')) {
196 if (isModEnabled('multicompany') && !empty($object->admin) && empty($object->entity)) {
197 $addadmin .= img_picto($langs->trans("SuperAdministratorDesc"), "redstar", 'class="paddingleft"');
198 } elseif (!empty($object->admin)) {
199 $addadmin .= img_picto($langs->trans("AdministratorDesc"), "star", 'class="paddingleft"');
200 }
201 }
202 print showValueWithClipboardCPButton($object->login).$addadmin;
203 print '</td>';
204 }
205 print '</tr>';
206
207 // Number of files
208 print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td>'.count($filearray).'</td></tr>';
209
210 // Total size
211 print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td>'.dol_print_size($totalsize, 1, 1).'</td></tr>';
212
213 print '</table>';
214 print '</div>';
215
216 print dol_get_fiche_end();
217
218 $modulepart = 'user';
219 $param = '&id='.$object->id;
220 include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
221} else {
222 accessforbidden('', 0, 1);
223}
224
225// End of page
226llxFooter();
227$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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:71
Class to manage generation of HTML components Only common components must be here.
Class to manage Dolibarr users.
llxFooter()
Footer empty.
Definition document.php:107
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:63
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formatted size.
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)
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)
Show tabs of a record.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $backtopagejsfields='', $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)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.