dolibarr 21.0.0-alpha
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 *
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.'/core/lib/files.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
34
35// Load translation files required by page
36$langs->loadLangs(array('users', 'other'));
37
38$action = GETPOST('action', 'aZ09');
39$confirm = GETPOST('confirm');
40$id = (GETPOSTINT('userid') ? GETPOSTINT('userid') : GETPOSTINT('id'));
41$ref = GETPOST('ref', 'alpha');
42$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'userdoc'; // To manage different context of search
43
44if (!isset($id) || empty($id)) {
46}
47
48// Define value to know what current user can do on users
49$permissiontoadd = (!empty($user->admin) || $user->hasRight("user", "user", "write"));
50$permissiontoread = (!empty($user->admin) || $user->hasRight("user", "user", "read"));
51$permissiontoedit = (!empty($user->admin) || $user->hasRight("user", "user", "write"));
52$permissiontodisable = (!empty($user->admin) || $user->hasRight("user", "user", "delete"));
53$permissiontoreadgroup = $permissiontoread;
54$permissiontoeditgroup = $permissiontoedit;
55if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
56 $permissiontoreadgroup = (!empty($user->admin) || $user->hasRight("user", "group_advance", "read"));
57 $permissiontoeditgroup = (!empty($user->admin) || $user->hasRight("user", "group_advance", "write"));
58}
59// Define value to know what current user can do on properties of edited user
60if ($id) {
61 // $user est le user qui edite, $id est l'id de l'utilisateur edite
62 $permissiontoedit = ((($user->id == $id) && $user->hasRight("user", "self", "write")) || (($user->id != $id) && $user->hasRight("user", "user", "write")));
63 $permissiontoeditpassword = ((($user->id == $id) && $user->hasRight("user", "self", "password")) || (($user->id != $id) && $user->hasRight("user", "user", "password")));
64}
65
66$permissiontoadd = $permissiontoedit; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles
67$permtoedit = $permissiontoedit;
68
69// Security check
70$socid = 0;
71if ($user->socid > 0) {
72 $socid = $user->socid;
73}
74$feature2 = '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', 'userdoc', 'globalcard'));
78
79$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
80
81if ($user->id != $id && !$permissiontoread) {
83}
84
85// Get parameters
86$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
87$sortfield = GETPOST('sortfield', 'aZ09comma');
88$sortorder = GETPOST('sortorder', 'aZ09comma');
89$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
90if (empty($page) || $page == -1) {
91 $page = 0;
92}
93$offset = $limit * $page;
94$pageprev = $page - 1;
95$pagenext = $page + 1;
96if (!$sortorder) {
97 $sortorder = "ASC";
98}
99if (!$sortfield) {
100 $sortfield = "position_name";
101}
102
103$object = new User($db);
104if ($id > 0 || !empty($ref)) {
105 $result = $object->fetch($id, $ref, '', 1);
106 $object->loadRights();
107 //$upload_dir = $conf->user->multidir_output[$object->entity] . "/" . $object->id ;
108 // For users, the upload_dir is always $conf->user->entity for the moment
109 $upload_dir = $conf->user->dir_output."/".$object->id;
110}
111
112/*
113 * Actions
114 */
115
116$parameters = array('id'=>$socid);
117$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
118if ($reshook < 0) {
119 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
120}
121
122if (empty($reshook)) {
123 include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
124}
125
126
127/*
128 * View
129 */
130
131$form = new Form($db);
132
133
134$person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname;
135$title = $person_name." - ".$langs->trans('Documents');
136$help_url = '';
137llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-user page-card_document');
138
139if ($object->id) {
140 /*
141 * Affichage onglets
142 */
143 if (isModEnabled('notification')) {
144 $langs->load("mails");
145 }
146 $head = user_prepare_head($object);
147
148 print dol_get_fiche_head($head, 'document', $langs->trans("User"), -1, 'user');
149
150 $linkback = '';
151 if ($user->hasRight("user", "user", "read") || $user->admin) {
152 $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
153 }
154
155 $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">';
156 $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
157 $morehtmlref .= '</a>';
158
159 $urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id);
160 $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->transnoentitiesnoconv("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover');
161
162 dol_banner_tab($object, 'id', $linkback, $user->hasRight("user", "user", "read") || $user->admin, 'rowid', 'ref', $morehtmlref);
163
164 print '<div class="fichecenter">';
165 print '<div class="underbanner clearboth"></div>';
166
167 // Build file list
168 $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
169 $totalsize = 0;
170 foreach ($filearray as $key => $file) {
171 $totalsize += $file['size'];
172 }
173
174
175 print '<table class="border tableforfield centpercent">';
176
177 // Login
178 print '<tr><td class="titlefield">'.$langs->trans("Login").'</td>';
179 if (!empty($object->ldap_sid) && $object->statut == 0) {
180 print '<td class="error">';
181 print $langs->trans("LoginAccountDisableInDolibarr");
182 print '</td>';
183 } else {
184 print '<td>';
185 $addadmin = '';
186 if (property_exists($object, 'admin')) {
187 if (isModEnabled('multicompany') && !empty($object->admin) && empty($object->entity)) {
188 $addadmin .= img_picto($langs->trans("SuperAdministratorDesc"), "redstar", 'class="paddingleft"');
189 } elseif (!empty($object->admin)) {
190 $addadmin .= img_picto($langs->trans("AdministratorDesc"), "star", 'class="paddingleft"');
191 }
192 }
193 print showValueWithClipboardCPButton($object->login).$addadmin;
194 print '</td>';
195 }
196 print '</tr>';
197
198 // Number of files
199 print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td>'.count($filearray).'</td></tr>';
200
201 // Total size
202 print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td>'.dol_print_size($totalsize, 1, 1).'</td></tr>';
203
204 print '</table>';
205 print '</div>';
206
207 print dol_get_fiche_end();
208
209 $modulepart = 'user';
210 $param = '&id='.$object->id;
211 include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
212} else {
213 accessforbidden('', 0, 1);
214}
215
216// End of page
217llxFooter();
218$db->close();
$id
Definition account.php:39
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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:70
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.
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.