dolibarr  16.0.1
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 require '../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
33 
34 // Load translation files required by page
35 $langs->loadLangs(array('users', 'other'));
36 
37 $action = GETPOST('action', 'aZ09');
38 $confirm = GETPOST('confirm');
39 $id = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('id', 'int'));
40 $ref = GETPOST('ref', 'alpha');
41 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'userdoc'; // To manage different context of search
42 
43 // Define value to know what current user can do on users
44 $canadduser = (!empty($user->admin) || $user->rights->user->user->creer);
45 $canreaduser = (!empty($user->admin) || $user->rights->user->user->lire);
46 $canedituser = (!empty($user->admin) || $user->rights->user->user->creer);
47 $candisableuser = (!empty($user->admin) || $user->rights->user->user->supprimer);
48 $canreadgroup = $canreaduser;
49 $caneditgroup = $canedituser;
50 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
51  $canreadgroup = (!empty($user->admin) || $user->rights->user->group_advance->read);
52  $caneditgroup = (!empty($user->admin) || $user->rights->user->group_advance->write);
53 }
54 // Define value to know what current user can do on properties of edited user
55 if ($id) {
56  // $user est le user qui edite, $id est l'id de l'utilisateur edite
57  $caneditfield = ((($user->id == $id) && $user->rights->user->self->creer)
58  || (($user->id != $id) && $user->rights->user->user->creer));
59  $caneditpassword = ((($user->id == $id) && $user->rights->user->self->password)
60  || (($user->id != $id) && $user->rights->user->user->password));
61 }
62 
63 $permissiontoadd = $caneditfield; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles
64 $permtoedit = $caneditfield;
65 
66 // Security check
67 $socid = 0;
68 if ($user->socid > 0) {
69  $socid = $user->socid;
70 }
71 $feature2 = 'user';
72 
73 $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
74 
75 if ($user->id <> $id && !$canreaduser) {
77 }
78 
79 // Get parameters
80 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
81 $sortfield = GETPOST('sortfield', 'aZ09comma');
82 $sortorder = GETPOST('sortorder', 'aZ09comma');
83 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
84 if (empty($page) || $page == -1) {
85  $page = 0;
86 }
87 $offset = $limit * $page;
88 $pageprev = $page - 1;
89 $pagenext = $page + 1;
90 if (!$sortorder) {
91  $sortorder = "ASC";
92 }
93 if (!$sortfield) {
94  $sortfield = "position_name";
95 }
96 
97 $object = new User($db);
98 if ($id > 0 || !empty($ref)) {
99  $result = $object->fetch($id, $ref, '', 1);
100  $object->getrights();
101  //$upload_dir = $conf->user->multidir_output[$object->entity] . "/" . $object->id ;
102  // For users, the upload_dir is always $conf->user->entity for the moment
103  $upload_dir = $conf->user->dir_output."/".$object->id;
104 }
105 
106 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
107 $hookmanager->initHooks(array('usercard', 'userdoc', 'globalcard'));
108 
109 
110 
111 /*
112  * Actions
113  */
114 
115 $parameters = array('id'=>$socid);
116 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
117 if ($reshook < 0) {
118  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
119 }
120 
121 if (empty($reshook)) {
122  include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
123 }
124 
125 
126 /*
127  * View
128  */
129 
130 $form = new Form($db);
131 
132 llxHeader('', $langs->trans("UserCard").' - '.$langs->trans("Files"));
133 
134 if ($object->id) {
135  /*
136  * Affichage onglets
137  */
138  if (!empty($conf->notification->enabled)) {
139  $langs->load("mails");
140  }
141  $head = user_prepare_head($object);
142 
143  print dol_get_fiche_head($head, 'document', $langs->trans("User"), -1, 'user');
144 
145  $linkback = '';
146  if ($user->rights->user->user->lire || $user->admin) {
147  $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
148  }
149 
150  $morehtmlref = '<a href="'.DOL_URL_ROOT.'/user/vcard.php?id='.$object->id.'" class="refid">';
151  $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
152  $morehtmlref .= '</a>';
153 
154  dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin, 'rowid', 'ref', $morehtmlref);
155 
156  print '<div class="fichecenter">';
157  print '<div class="underbanner clearboth"></div>';
158 
159  // Build file list
160  $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
161  $totalsize = 0;
162  foreach ($filearray as $key => $file) {
163  $totalsize += $file['size'];
164  }
165 
166 
167  print '<table class="border tableforfield centpercent">';
168 
169  // Login
170  print '<tr><td class="titlefield">'.$langs->trans("Login").'</td>';
171  if (!empty($object->ldap_sid) && $object->statut == 0) {
172  print '<td class="error">';
173  print $langs->trans("LoginAccountDisableInDolibarr");
174  print '</td>';
175  } else {
176  print '<td>';
177  $addadmin = '';
178  if (property_exists($object, 'admin')) {
179  if (!empty($conf->multicompany->enabled) && !empty($object->admin) && empty($object->entity)) {
180  $addadmin .= img_picto($langs->trans("SuperAdministratorDesc"), "redstar", 'class="paddingleft"');
181  } elseif (!empty($object->admin)) {
182  $addadmin .= img_picto($langs->trans("AdministratorDesc"), "star", 'class="paddingleft"');
183  }
184  }
185  print showValueWithClipboardCPButton($object->login).$addadmin;
186  print '</td>';
187  }
188  print '</tr>';
189 
190  // Nunber of files
191  print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td>'.count($filearray).'</td></tr>';
192 
193  // Total size
194  print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td>'.dol_print_size($totalsize, 1, 1).'</td></tr>';
195 
196  print '</table>';
197  print '</div>';
198 
199  print dol_get_fiche_end();
200 
201  $modulepart = 'user';
202  $param = '&id='.$object->id;
203  include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
204 } else {
205  accessforbidden('', 0, 1);
206 }
207 
208 // End of page
209 llxFooter();
210 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow= '')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
Definition: card.php:142
Class to manage Dolibarr users.
Definition: user.class.php:44
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
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
user_prepare_head(User $object)
Prepare array with list of tabs.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
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 ...
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:60
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.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formated size.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
llxFooter()
Empty footer.
Definition: wrapper.php:73