dolibarr  x.y.z
card.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
4  * Copyright (C) 2004-2022 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
6  * Copyright (C) 2005-2021 Regis Houssin <regis.houssin@inodbox.com>
7  * Copyright (C) 2005 Lionel Cousteix <etm_ltd@tiscali.co.uk>
8  * Copyright (C) 2011 Herve Prot <herve.prot@symeos.com>
9  * Copyright (C) 2012-2018 Juanjo Menent <jmenent@2byte.es>
10  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
11  * Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
12  * Copyright (C) 2015-2017 Jean-François Ferry <jfefe@aternatik.fr>
13  * Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
14  * Copyright (C) 2015-2018 Charlene Benke <charlie@patas-monkey.com>
15  * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
16  * Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
17  * Copyright (C) 2018 David Beniamine <David.Beniamine@Tetras-Libre.fr>
18  *
19  * This program is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <https://www.gnu.org/licenses/>.
31  */
32 
38 // Load Dolibarr environment
39 require '../main.inc.php';
40 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
41 require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
42 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
43 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
44 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
45 require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
46 require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
47 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
48 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
49 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
50 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
51 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
52 require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
53 if (!empty($conf->ldap->enabled)) {
54  require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
55 }
56 if (isModEnabled('adherent')) {
57  require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
58 }
59 if (isModEnabled('categorie')) {
60  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
61 }
62 if (isModEnabled('stock')) {
63  require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
64 }
65 
66 $id = GETPOST('id', 'int');
67 $action = GETPOST('action', 'aZ09');
68 $mode = GETPOST('mode', 'alpha');
69 $confirm = GETPOST('confirm', 'alpha');
70 $group = GETPOST("group", "int", 3);
71 $cancel = GETPOST('cancel', 'alpha');
72 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'useracard'; // To manage different context of search
73 
74 $dateemployment = dol_mktime(0, 0, 0, GETPOST('dateemploymentmonth', 'int'), GETPOST('dateemploymentday', 'int'), GETPOST('dateemploymentyear', 'int'));
75 $dateemploymentend = dol_mktime(0, 0, 0, GETPOST('dateemploymentendmonth', 'int'), GETPOST('dateemploymentendday', 'int'), GETPOST('dateemploymentendyear', 'int'));
76 $datestartvalidity = dol_mktime(0, 0, 0, GETPOST('datestartvaliditymonth', 'int'), GETPOST('datestartvalidityday', 'int'), GETPOST('datestartvalidityyear', 'int'));
77 $dateendvalidity = dol_mktime(0, 0, 0, GETPOST('dateendvaliditymonth', 'int'), GETPOST('dateendvalidityday', 'int'), GETPOST('dateendvalidityyear', 'int'));
78 $dateofbirth = dol_mktime(0, 0, 0, GETPOST('dateofbirthmonth', 'int'), GETPOST('dateofbirthday', 'int'), GETPOST('dateofbirthyear', 'int'));
79 
80 // Define value to know what current user can do on users
81 $canadduser = (!empty($user->admin) || $user->hasRight("user", "user", "write"));
82 $canreaduser = (!empty($user->admin) || $user->hasRight("user", "user", "read"));
83 $canedituser = (!empty($user->admin) || $user->hasRight("user", "user", "write"));
84 $candisableuser = (!empty($user->admin) || $user->hasRight("user", "user", "delete"));
85 $canreadgroup = $canreaduser;
86 $caneditgroup = $canedituser;
87 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
88  $canreadgroup = (!empty($user->admin) || $user->hasRight("user", "group_advance", "read"));
89  $caneditgroup = (!empty($user->admin) || $user->hasRight("user", "group_advance", "write"));
90 }
91 
92 $childids = $user->getAllChildIds(1); // For later, test on salary visibility
93 
94 // Define value to know what current user can do on properties of edited user
95 if ($id > 0) {
96  // $user is the current logged user, $id is the user we want to edit
97  $caneditfield = ((($user->id == $id) && $user->hasRight("user", "self", "write")) || (($user->id != $id) && $user->hasRight("user", "user", "write")));
98  $caneditpassword = ((($user->id == $id) && $user->hasRight("user", "self", "password")) || (($user->id != $id) && $user->hasRight("user", "user", "password")));
99 }
100 
101 // Security check
102 $socid = 0;
103 if ($user->socid > 0) {
104  $socid = $user->socid;
105 }
106 $feature2 = 'user';
107 $result = restrictedArea($user, 'user', $id, 'user', $feature2);
108 
109 if ($user->id != $id && !$canreaduser) {
110  accessforbidden();
111 }
112 
113 // Load translation files required by page
114 $langs->loadLangs(array('users', 'companies', 'ldap', 'admin', 'hrm', 'stocks', 'other'));
115 
116 $object = new User($db);
117 $extrafields = new ExtraFields($db);
118 
119 // fetch optionals attributes and labels
120 $extrafields->fetch_name_optionals_label($object->table_element);
121 
122 $socialnetworks = getArrayOfSocialNetworks();
123 
124 // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
125 $hookmanager->initHooks(array('usercard', 'globalcard'));
126 
127 $error = 0;
128 
129 $acceptlocallinktomedia = (acceptLocalLinktoMedia() > 0 ? 1 : 0);
130 
131 
132 
137 $parameters = array('id' => $id, 'socid' => $socid, 'group' => $group, 'caneditgroup' => $caneditgroup);
138 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
139 if ($reshook < 0) {
140  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
141 }
142 
143 if (empty($reshook)) {
144  $backurlforlist = DOL_URL_ROOT.'/user/list.php';
145 
146  if (empty($backtopage) || ($cancel && empty($id))) {
147  if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
148  if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
149  $backtopage = $backurlforlist;
150  } else {
151  $backtopage = DOL_URL_ROOT.'/user/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
152  }
153  }
154  }
155 
156  if ($cancel) {
157  if (!empty($backtopageforcancel)) {
158  header("Location: ".$backtopageforcancel);
159  exit;
160  } elseif (!empty($backtopage)) {
161  header("Location: ".$backtopage);
162  exit;
163  }
164  $action = '';
165  }
166 
167  if ($action == 'confirm_disable' && $confirm == "yes" && $candisableuser) {
168  if ($id != $user->id) { // A user can't disable itself
169  $object->fetch($id);
170  if ($object->admin && empty($user->admin)) {
171  // If user to delete is an admin user and if logged user is not admin, we deny the operation.
172  $error++;
173  setEventMessages($langs->trans("OnlyAdminUsersCanDisableAdminUsers"), null, 'errors');
174  } else {
175  $object->setstatus(0);
176  header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id);
177  exit;
178  }
179  }
180  }
181 
182  if ($action == 'confirm_enable' && $confirm == "yes" && $candisableuser) {
183  $error = 0;
184 
185  if ($id != $user->id) {
186  $object->fetch($id);
187 
188  if (!empty($conf->file->main_limit_users)) {
189  $nb = $object->getNbOfUsers("active");
190  if ($nb >= $conf->file->main_limit_users) {
191  $error++;
192  setEventMessages($langs->trans("YourQuotaOfUsersIsReached"), null, 'errors');
193  }
194  }
195 
196  if (!$error) {
197  $object->setstatus(1);
198  header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id);
199  exit;
200  }
201  }
202  }
203 
204  if ($action == 'confirm_delete' && $confirm == "yes" && $candisableuser) {
205  if ($id != $user->id) {
206  if (!GETPOSTISSET('token')) {
207  print 'Error, token required for this critical operation';
208  exit;
209  }
210 
211  $object = new User($db);
212  $object->fetch($id);
213  $object->oldcopy = clone $object;
214 
215  $result = $object->delete($user);
216  if ($result < 0) {
217  $langs->load("errors");
218  setEventMessages($langs->trans("ErrorUserCannotBeDelete"), null, 'errors');
219  } else {
220  setEventMessages($langs->trans("RecordDeleted"), null);
221  header("Location: ".DOL_URL_ROOT."/user/list.php?restore_lastsearch_values=1");
222  exit;
223  }
224  }
225  }
226 
227  // Action Add user
228  if ($action == 'add' && $canadduser) {
229  $error = 0;
230 
231  if (!GETPOST("lastname")) {
232  $error++;
233  setEventMessages($langs->trans("NameNotDefined"), null, 'errors');
234  $action = "create"; // Go back to create page
235  }
236  if (!GETPOST("login")) {
237  $error++;
238  setEventMessages($langs->trans("LoginNotDefined"), null, 'errors');
239  $action = "create"; // Go back to create page
240  }
241 
242  if (!empty($conf->file->main_limit_users)) { // If option to limit users is set
243  $nb = $object->getNbOfUsers("active");
244  if ($nb >= $conf->file->main_limit_users) {
245  $error++;
246  setEventMessages($langs->trans("YourQuotaOfUsersIsReached"), null, 'errors');
247  $action = "create"; // Go back to create page
248  }
249  }
250 
251  if (!$error) {
252  $object->civility_code = GETPOST("civility_code", 'aZ09');
253  $object->lastname = GETPOST("lastname", 'alphanohtml');
254  $object->firstname = GETPOST("firstname", 'alphanohtml');
255  $object->ref_employee = GETPOST("ref_employee", 'alphanohtml');
256  $object->national_registration_number = GETPOST("national_registration_number", 'alphanohtml');
257  $object->login = GETPOST("login", 'alphanohtml');
258  $object->api_key = GETPOST("api_key", 'alphanohtml');
259  $object->gender = GETPOST("gender", 'aZ09');
260  $object->admin = GETPOST("admin", 'int');
261  $object->address = GETPOST('address', 'alphanohtml');
262  $object->zip = GETPOST('zipcode', 'alphanohtml');
263  $object->town = GETPOST('town', 'alphanohtml');
264  $object->country_id = GETPOST('country_id', 'int');
265  $object->state_id = GETPOST('state_id', 'int');
266  $object->office_phone = GETPOST("office_phone", 'alphanohtml');
267  $object->office_fax = GETPOST("office_fax", 'alphanohtml');
268  $object->user_mobile = GETPOST("user_mobile", 'alphanohtml');
269 
270  if (isModEnabled('socialnetworks')) {
271  $object->socialnetworks = array();
272  foreach ($socialnetworks as $key => $value) {
273  if (GETPOST($key, 'alphanohtml')) {
274  $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml');
275  }
276  }
277  }
278 
279  $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alphanohtml'));
280  $object->job = GETPOST("job", 'alphanohtml');
281  $object->signature = GETPOST("signature", 'restricthtml');
282  $object->accountancy_code = GETPOST("accountancy_code", 'alphanohtml');
283  $object->note_public = GETPOST("note_public", 'restricthtml');
284  $object->note_private = GETPOST("note_private", 'restricthtml');
285  $object->ldap_sid = GETPOST("ldap_sid", 'alphanohtml');
286  $object->fk_user = GETPOST("fk_user", 'int') > 0 ? GETPOST("fk_user", 'int') : 0;
287  $object->fk_user_expense_validator = GETPOST("fk_user_expense_validator", 'int') > 0 ? GETPOST("fk_user_expense_validator", 'int') : 0;
288  $object->fk_user_holiday_validator = GETPOST("fk_user_holiday_validator", 'int') > 0 ? GETPOST("fk_user_holiday_validator", 'int') : 0;
289  $object->employee = GETPOST('employee', 'alphanohtml');
290 
291  $object->thm = GETPOST("thm", 'alphanohtml') != '' ? GETPOST("thm", 'alphanohtml') : '';
292  $object->thm = price2num($object->thm);
293  $object->tjm = GETPOST("tjm", 'alphanohtml') != '' ? GETPOST("tjm", 'alphanohtml') : '';
294  $object->tjm = price2num($object->tjm);
295  $object->salary = GETPOST("salary", 'alphanohtml') != '' ? GETPOST("salary", 'alphanohtml') : '';
296  $object->salary = price2num($object->salary);
297  $object->salaryextra = GETPOST("salaryextra", 'alphanohtml') != '' ? GETPOST("salaryextra", 'alphanohtml') : '';
298  $object->weeklyhours = GETPOST("weeklyhours", 'alphanohtml') != '' ? GETPOST("weeklyhours", 'alphanohtml') : '';
299 
300  $object->color = GETPOST("color", 'alphanohtml') != '' ? GETPOST("color", 'alphanohtml') : '';
301 
302  $object->dateemployment = $dateemployment;
303  $object->dateemploymentend = $dateemploymentend;
304  $object->datestartvalidity = $datestartvalidity;
305  $object->dateendvalidity = $dateendvalidity;
306  $object->birth = $dateofbirth;
307 
308  $object->fk_warehouse = GETPOST('fk_warehouse', 'int');
309 
310  $object->lang = GETPOST('default_lang', 'aZ09');
311 
312  // Fill array 'array_options' with data from add form
313  $ret = $extrafields->setOptionalsFromPost(null, $object);
314  if ($ret < 0) {
315  $error++;
316  }
317 
318  // Set entity property
319  $entity = GETPOST('entity', 'int');
320  if (isModEnabled('multicompany')) {
321  if (GETPOST('superadmin', 'int')) {
322  $object->entity = 0;
323  } else {
324  if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
325  $object->entity = 1; // all users are forced into master entity
326  } else {
327  $object->entity = ($entity == '' ? 1 : $entity);
328  }
329  }
330  } else {
331  $object->entity = ($entity == '' ? 1 : $entity);
332  /*if ($user->admin && $user->entity == 0 && GETPOST("admin",'alpha'))
333  {
334  }*/
335  }
336 
337  $db->begin();
338 
339  $id = $object->create($user);
340  if ($id > 0) {
341  $resPass = 0;
342  if (GETPOST('password', 'none')) {
343  $resPass = $object->setPassword($user, GETPOST('password', 'none'));
344  }
345  if ($resPass < 0) {
346  $langs->load("errors");
347  $db->rollback();
348  setEventMessages($object->error, $object->errors, 'errors');
349  $action = "create"; // Go back to create page
350  } else {
351  if (!empty($conf->categorie->enabled)) {
352  // Categories association
353  $usercats = GETPOST('usercats', 'array');
354  $object->setCategories($usercats);
355  }
356  $db->commit();
357 
358  header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id);
359  exit;
360  }
361  } else {
362  $langs->load("errors");
363  $db->rollback();
364  setEventMessages($object->error, $object->errors, 'errors');
365  $action = "create"; // Go back to create page
366  }
367  }
368  }
369 
370  // Action add usergroup
371  if (($action == 'addgroup' || $action == 'removegroup') && $caneditgroup) {
372  if ($group) {
373  $editgroup = new UserGroup($db);
374  $editgroup->fetch($group);
375  $editgroup->oldcopy = clone $editgroup;
376 
377  $object->fetch($id);
378  if ($action == 'addgroup') {
379  $result = $object->SetInGroup($group, $editgroup->entity);
380  }
381  if ($action == 'removegroup') {
382  $result = $object->RemoveFromGroup($group, $editgroup->entity);
383  }
384 
385  if ($result > 0) {
386  $action = '';
387  } else {
388  setEventMessages($object->error, $object->errors, 'errors');
389  }
390  }
391  }
392 
393  if ($action == 'update' && !$cancel) {
394  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
395 
396  if ($caneditfield) { // Case we can edit all field
397  $error = 0;
398 
399  if (!GETPOST("lastname", 'alpha')) {
400  setEventMessages($langs->trans("NameNotDefined"), null, 'errors');
401  $action = "edit"; // Go back to create page
402  $error++;
403  }
404  if (!GETPOST("login", 'alpha')) {
405  setEventMessages($langs->trans("LoginNotDefined"), null, 'errors');
406  $action = "edit"; // Go back to create page
407  $error++;
408  }
409 
410  if (!$error) {
411  $object->fetch($id);
412 
413  $object->oldcopy = clone $object;
414 
415  $db->begin();
416 
417  $object->civility_code = GETPOST("civility_code", 'aZ09');
418  $object->lastname = GETPOST("lastname", 'alphanohtml');
419  $object->firstname = GETPOST("firstname", 'alphanohtml');
420  $object->ref_employee = GETPOST("ref_employee", 'alphanohtml');
421  $object->national_registration_number = GETPOST("national_registration_number", 'alphanohtml');
422  $object->gender = GETPOST("gender", 'aZ09');
423  $object->pass = GETPOST("password", 'none'); // We can keep 'none' for password fields
424  $object->api_key = (GETPOST("api_key", 'alphanohtml')) ? GETPOST("api_key", 'alphanohtml') : $object->api_key;
425  if (!empty($user->admin)) { // admin flag can only be set/unset by an admin user. A test is also done later when forging sql request
426  $object->admin = GETPOST("admin", "int");
427  }
428  if ($user->admin && !$object->ldap_sid) { // same test than on edit page
429  $object->login = GETPOST("login", 'alphanohtml');
430  }
431  $object->address = GETPOST('address', 'alphanohtml');
432  $object->zip = GETPOST('zipcode', 'alphanohtml');
433  $object->town = GETPOST('town', 'alphanohtml');
434  $object->country_id = GETPOST('country_id', 'int');
435  $object->state_id = GETPOST('state_id', 'int');
436  $object->office_phone = GETPOST("office_phone", 'alphanohtml');
437  $object->office_fax = GETPOST("office_fax", 'alphanohtml');
438  $object->user_mobile = GETPOST("user_mobile", 'alphanohtml');
439 
440  if (isModEnabled('socialnetworks')) {
441  $object->socialnetworks = array();
442  foreach ($socialnetworks as $key => $value) {
443  if (GETPOST($key, 'alphanohtml')) {
444  $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml');
445  }
446  }
447  }
448 
449  $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alphanohtml'));
450  $object->job = GETPOST("job", 'alphanohtml');
451  $object->signature = GETPOST("signature", 'restricthtml');
452  $object->accountancy_code = GETPOST("accountancy_code", 'alphanohtml');
453  $object->openid = GETPOST("openid", 'alphanohtml');
454  $object->fk_user = GETPOST("fk_user", 'int') > 0 ? GETPOST("fk_user", 'int') : 0;
455  $object->fk_user_expense_validator = GETPOST("fk_user_expense_validator", 'int') > 0 ? GETPOST("fk_user_expense_validator", 'int') : 0;
456  $object->fk_user_holiday_validator = GETPOST("fk_user_holiday_validator", 'int') > 0 ? GETPOST("fk_user_holiday_validator", 'int') : 0;
457  $object->employee = GETPOST('employee', 'int');
458 
459  $object->thm = GETPOST("thm", 'alphanohtml') != '' ? GETPOST("thm", 'alphanohtml') : '';
460  $object->thm = price2num($object->thm);
461  $object->tjm = GETPOST("tjm", 'alphanohtml') != '' ? GETPOST("tjm", 'alphanohtml') : '';
462  $object->thm = price2num($object->thm);
463  $object->salary = GETPOST("salary", 'alphanohtml') != '' ? GETPOST("salary", 'alphanohtml') : '';
464  $object->salary = price2num($object->salary);
465  $object->salaryextra = GETPOST("salaryextra", 'alphanohtml') != '' ? GETPOST("salaryextra", 'alphanohtml') : '';
466  $object->salaryextra = price2num($object->salaryextra);
467  $object->weeklyhours = GETPOST("weeklyhours", 'alphanohtml') != '' ? GETPOST("weeklyhours", 'alphanohtml') : '';
468  $object->weeklyhours = price2num($object->weeklyhours);
469 
470  $object->color = GETPOST("color", 'alphanohtml') != '' ? GETPOST("color", 'alphanohtml') : '';
471  $object->dateemployment = $dateemployment;
472  $object->dateemploymentend = $dateemploymentend;
473  $object->datestartvalidity = $datestartvalidity;
474  $object->dateendvalidity = $dateendvalidity;
475  $object->birth = $dateofbirth;
476 
477  if (isModEnabled('stock')) {
478  $object->fk_warehouse = GETPOST('fk_warehouse', 'int');
479  }
480 
481  $object->lang = GETPOST('default_lang', 'aZ09');
482 
483  // Do we update also ->entity ?
484  if (isModEnabled('multicompany') && empty($user->entity) && !empty($user->admin)) { // If multicompany is not enabled, we never update the entity of a user.
485  if (GETPOST('superadmin', 'int')) {
486  $object->entity = 0;
487  } else {
488  if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
489  $object->entity = 1; // all users are in master entity
490  } else {
491  // We try to change the entity of user
492  $object->entity = (GETPOSTISSET('entity') ? GETPOSTINT('entity') : $object->entity);
493  }
494  }
495  }
496 
497  // Fill array 'array_options' with data from add form
498  $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
499  if ($ret < 0) {
500  $error++;
501  }
502 
503  if (GETPOST('deletephoto')) {
504  $object->photo = '';
505  }
506  if (!empty($_FILES['photo']['name'])) {
507  $isimage = image_format_supported($_FILES['photo']['name']);
508  if ($isimage > 0) {
509  $object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
510  } else {
511  $error++;
512  $langs->load("errors");
513  setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
514  dol_syslog($langs->transnoentities("ErrorBadImageFormat"), LOG_INFO);
515  }
516  }
517 
518  if (!$error) {
519  $ret = $object->update($user);
520  if ($ret < 0) {
521  $error++;
522  if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
523  $langs->load("errors");
524  setEventMessages($langs->trans("ErrorLoginAlreadyExists", $object->login), null, 'errors');
525  } else {
526  setEventMessages($object->error, $object->errors, 'errors');
527  $action = 'edit';
528  }
529  }
530  }
531 
532  if (!$error && GETPOSTISSET('contactid')) {
533  $contactid = GETPOST('contactid', 'int');
534  $socid = GETPOST('socid', 'int');
535 
536  if ($contactid > 0) { // The 'contactid' is used inpriority over the 'socid'
537  $contact = new Contact($db);
538  $contact->fetch($contactid);
539 
540  $sql = "UPDATE ".MAIN_DB_PREFIX."user";
541  $sql .= " SET fk_socpeople=".((int) $contactid);
542  if (!empty($contact->socid)) {
543  $sql .= ", fk_soc=".((int) $contact->socid);
544  } elseif ($socid > 0) {
545  $sql .= ", fk_soc = null";
546  setEventMessages($langs->trans("WarningUserDifferentContactSocid"), null, 'warnings'); // Add message if post socid != $contact->socid
547  }
548  $sql .= " WHERE rowid = ".((int) $object->id);
549  } elseif ($socid > 0) {
550  $sql = "UPDATE ".MAIN_DB_PREFIX."user";
551  $sql .= " SET fk_socpeople=NULL, fk_soc=".((int) $socid);
552  $sql .= " WHERE rowid = ".((int) $object->id);
553  } else {
554  $sql = "UPDATE ".MAIN_DB_PREFIX."user";
555  $sql .= " SET fk_socpeople=NULL, fk_soc=NULL";
556  $sql .= " WHERE rowid = ".((int) $object->id);
557  }
558  dol_syslog("usercard::update", LOG_DEBUG);
559  $resql = $db->query($sql);
560  if (!$resql) {
561  $error++;
562  setEventMessages($db->lasterror(), null, 'errors');
563  }
564  }
565 
566  if (!$error && !count($object->errors)) {
567  if (GETPOST('deletephoto') && $object->oldcopy->photo) {
568  $fileimg = $conf->user->dir_output.'/'.get_exdir(0, 0, 0, 0, $object, 'user').'photos/'.$object->oldcopy->photo;
569  $dirthumbs = $conf->user->dir_output.'/'.get_exdir(0, 0, 0, 0, $object, 'user').'photos/thumbs';
570  dol_delete_file($fileimg);
571  dol_delete_dir_recursive($dirthumbs);
572  }
573 
574  if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name'])) {
575  $dir = $conf->user->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'user').'/photos';
576 
577  dol_mkdir($dir);
578 
579  if (@is_dir($dir)) {
580  $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
581  $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']);
582 
583  if (!($result > 0)) {
584  setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
585  } else {
586  // Create thumbs
587  $object->addThumbs($newfile);
588  }
589  } else {
590  $error++;
591  $langs->load("errors");
592  setEventMessages($langs->trans("ErrorFailedToCreateDir", $dir), $mesgs, 'errors');
593  }
594  }
595  }
596 
597  if (!$error && !count($object->errors)) {
598  // Then we add the associated categories
599  $categories = GETPOST('usercats', 'array');
600  $object->setCategories($categories);
601  }
602 
603  if (!$error && !count($object->errors)) {
604  setEventMessages($langs->trans("UserModified"), null, 'mesgs');
605  $db->commit();
606 
607  $login = $_SESSION["dol_login"];
608  if ($login && $login == $object->oldcopy->login && $object->oldcopy->login != $object->login) { // Current user has changed its login
609  $error++;
610  $langs->load("errors");
611  setEventMessages($langs->transnoentitiesnoconv("WarningYourLoginWasModifiedPleaseLogin"), null, 'warnings');
612  }
613  } else {
614  $db->rollback();
615  }
616  }
617  } else {
618  if ($caneditpassword) { // Case we can edit only password
619  dol_syslog("Not allowed to change fields, only password");
620 
621  $object->fetch($id);
622 
623  if (GETPOST("password", "none")) { // If pass is empty, we do not change it.
624  $object->oldcopy = clone $object;
625 
626  $ret = $object->setPassword($user, GETPOST("password", "none"));
627  if ($ret < 0) {
628  setEventMessages($object->error, $object->errors, 'errors');
629  }
630  }
631  }
632  }
633  }
634 
635  // Change password with a new generated one
636  if ((($action == 'confirm_password' && $confirm == 'yes')
637  || ($action == 'confirm_passwordsend' && $confirm == 'yes')) && $caneditpassword
638  ) {
639  $object->fetch($id);
640 
641  $newpassword = $object->setPassword($user, ''); // This will generate a new password
642  if ($newpassword < 0) {
643  // Echec
644  setEventMessages($langs->trans("ErrorFailedToSetNewPassword"), null, 'errors');
645  } else {
646  // Succes
647  if ($action == 'confirm_passwordsend' && $confirm == 'yes') {
648  if ($object->send_password($user, $newpassword) > 0) {
649  setEventMessages($langs->trans("PasswordChangedAndSentTo", $object->email), null, 'mesgs');
650  } else {
651  setEventMessages($object->error, $object->errors, 'errors');
652  }
653  } else {
654  setEventMessages($langs->trans("PasswordChangedTo", $newpassword), null, 'warnings');
655  }
656  }
657  }
658 
659  // Action initialisation donnees depuis record LDAP
660  if ($action == 'adduserldap' && $canadduser) {
661  $selecteduser = GETPOST('users');
662 
663  $required_fields = array(
664  $conf->global->LDAP_KEY_USERS,
665  $conf->global->LDAP_FIELD_NAME,
666  $conf->global->LDAP_FIELD_FIRSTNAME,
667  $conf->global->LDAP_FIELD_LOGIN,
668  $conf->global->LDAP_FIELD_LOGIN_SAMBA,
669  $conf->global->LDAP_FIELD_PASSWORD,
670  $conf->global->LDAP_FIELD_PASSWORD_CRYPTED,
671  $conf->global->LDAP_FIELD_PHONE,
672  $conf->global->LDAP_FIELD_FAX,
673  $conf->global->LDAP_FIELD_MOBILE,
674  $conf->global->LDAP_FIELD_SKYPE,
675  $conf->global->LDAP_FIELD_MAIL,
676  $conf->global->LDAP_FIELD_TITLE,
677  $conf->global->LDAP_FIELD_DESCRIPTION,
678  $conf->global->LDAP_FIELD_SID
679  );
680 
681  $ldap = new Ldap();
682  $result = $ldap->connect_bind();
683  if ($result >= 0) {
684  // Remove from required_fields all entries not configured in LDAP (empty) and duplicated
685  $required_fields = array_unique(array_values(array_filter($required_fields, "dol_validElement")));
686 
687  $ldapusers = $ldap->getRecords($selecteduser, $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields);
688  //print_r($ldapusers);
689 
690  if (is_array($ldapusers)) {
691  foreach ($ldapusers as $key => $attribute) {
692  $ldap_lastname = $attribute[$conf->global->LDAP_FIELD_NAME];
693  $ldap_firstname = $attribute[$conf->global->LDAP_FIELD_FIRSTNAME];
694  $ldap_login = $attribute[$conf->global->LDAP_FIELD_LOGIN];
695  $ldap_loginsmb = $attribute[$conf->global->LDAP_FIELD_LOGIN_SAMBA];
696  $ldap_pass = $attribute[$conf->global->LDAP_FIELD_PASSWORD];
697  $ldap_pass_crypted = $attribute[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED];
698  $ldap_phone = $attribute[$conf->global->LDAP_FIELD_PHONE];
699  $ldap_fax = $attribute[$conf->global->LDAP_FIELD_FAX];
700  $ldap_mobile = $attribute[$conf->global->LDAP_FIELD_MOBILE];
701  $ldap_social['skype'] = $attribute[$conf->global->LDAP_FIELD_SKYPE];
702  $ldap_social['twitter'] = $attribute[$conf->global->LDAP_FIELD_TWITTER];
703  $ldap_social['facebook'] = $attribute[$conf->global->LDAP_FIELD_FACEBOOK];
704  $ldap_social['linkedin'] = $attribute[$conf->global->LDAP_FIELD_LINKEDIN];
705  $ldap_mail = $attribute[$conf->global->LDAP_FIELD_MAIL];
706  $ldap_sid = $attribute[$conf->global->LDAP_FIELD_SID];
707  }
708  }
709  } else {
710  setEventMessages($ldap->error, $ldap->errors, 'errors');
711  }
712  }
713 
714  // Actions to send emails
715  $triggersendname = 'USER_SENTBYMAIL';
716  $paramname = 'id'; // Name of param key to open the card
717  $mode = 'emailfromuser';
718  $trackid = 'use'.$id;
719  include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
720 
721  // Actions to build doc
722  $upload_dir = $conf->user->dir_output;
723  $permissiontoadd = $user->hasRight("user", "user", "write");
724  include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
725 }
726 
727 
728 /*
729  * View
730  */
731 
732 $form = new Form($db);
733 $formother = new FormOther($db);
734 $formcompany = new FormCompany($db);
735 $formadmin = new FormAdmin($db);
736 $formfile = new FormFile($db);
737 if (isModEnabled('stock')) {
738  $formproduct = new FormProduct($db);
739 }
740 
741 if ($object->id > 0) {
742  $person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname;
743  $title = $person_name." - ".$langs->trans('Card');
744 } else {
745  $title = $langs->trans("NewUser");
746 }
747 $help_url = '';
748 
749 llxHeader('', $title, $help_url);
750 
751 
752 if ($action == 'create' || $action == 'adduserldap') {
753  print load_fiche_titre($langs->trans("NewUser"), '', 'user');
754 
755  print '<span class="opacitymedium">'.$langs->trans("CreateInternalUserDesc")."</span><br>\n";
756  print "<br>";
757 
758 
759  if (!empty($conf->ldap->enabled) && (isset($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_LDAP_TO_DOLIBARR)) {
760  // Show form to add an account from LDAP if sync LDAP -> Dolibarr is set
761  $ldap = new Ldap();
762  $result = $ldap->connect_bind();
763  if ($result >= 0) {
764  $required_fields = array(
765  $conf->global->LDAP_KEY_USERS,
766  $conf->global->LDAP_FIELD_FULLNAME,
767  $conf->global->LDAP_FIELD_NAME,
768  $conf->global->LDAP_FIELD_FIRSTNAME,
769  $conf->global->LDAP_FIELD_LOGIN,
770  $conf->global->LDAP_FIELD_LOGIN_SAMBA,
771  $conf->global->LDAP_FIELD_PASSWORD,
772  $conf->global->LDAP_FIELD_PASSWORD_CRYPTED,
773  $conf->global->LDAP_FIELD_PHONE,
774  $conf->global->LDAP_FIELD_FAX,
775  $conf->global->LDAP_FIELD_MOBILE,
776  $conf->global->LDAP_FIELD_SKYPE,
777  $conf->global->LDAP_FIELD_MAIL,
778  $conf->global->LDAP_FIELD_TITLE,
779  $conf->global->LDAP_FIELD_DESCRIPTION,
780  $conf->global->LDAP_FIELD_SID
781  );
782 
783  // Remove from required_fields all entries not configured in LDAP (empty) and duplicated
784  $required_fields = array_unique(array_values(array_filter($required_fields, "dol_validElement")));
785 
786  // Get from LDAP database an array of results
787  $ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1);
788 
789  if (is_array($ldapusers)) {
790  $liste = array();
791  foreach ($ldapusers as $key => $ldapuser) {
792  // Define the label string for this user
793  $label = '';
794  foreach ($required_fields as $value) {
795  if ($value === $conf->global->LDAP_FIELD_PASSWORD || $value === $conf->global->LDAP_FIELD_PASSWORD_CRYPTED) {
796  $label .= $value."=******* ";
797  } elseif ($value) {
798  $label .= $value."=".$ldapuser[$value]." ";
799  }
800  }
801  $liste[$key] = $label;
802  }
803  } else {
804  setEventMessages($ldap->error, $ldap->errors, 'errors');
805  }
806  } else {
807  setEventMessages($ldap->error, $ldap->errors, 'errors');
808  }
809 
810  // If user list is full, we show drop-down list
811  print "\n\n<!-- Form liste LDAP debut -->\n";
812 
813  print '<form name="add_user_ldap" action="'.$_SERVER["PHP_SELF"].'" method="post">';
814  print '<input type="hidden" name="token" value="'.newToken().'">';
815  print '<table class="border centpercent"><tr>';
816  print '<td width="160">';
817  print $langs->trans("LDAPUsers");
818  print '</td>';
819  print '<td>';
820  print '<input type="hidden" name="action" value="adduserldap">';
821  if (is_array($liste) && count($liste)) {
822  print $form->selectarray('users', $liste, '', 1, 0, 0, '', 0, 0, 0, '', 'maxwidth500');
823  print ajax_combobox('users');
824  }
825  print '</td><td class="center">';
826  print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans('Get')).'"'.(count($liste) ? '' : ' disabled').'>';
827  print '</td></tr></table>';
828  print '</form>';
829 
830  print "\n<!-- Form liste LDAP fin -->\n\n";
831  print '<br>';
832  }
833 
834 
835  print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST" name="createuser">';
836  print '<input type="hidden" name="token" value="'.newToken().'">';
837  print '<input type="hidden" name="action" value="add">';
838  if (!empty($ldap_sid)) {
839  print '<input type="hidden" name="ldap_sid" value="'.dol_escape_htmltag($ldap_sid).'">';
840  }
841  print '<input type="hidden" name="entity" value="'.$conf->entity.'">';
842 
843  print dol_get_fiche_head('', '', '', 0, '');
844 
845  dol_set_focus('#lastname');
846 
847  print '<table class="border centpercent">';
848 
849  // Civility
850  print '<tr><td><label for="civility_code">'.$langs->trans("UserTitle").'</label></td><td>';
851  print $formcompany->select_civility(GETPOSTISSET("civility_code") ? GETPOST("civility_code", 'aZ09') : $object->civility_code, 'civility_code');
852  print '</td></tr>';
853 
854  // Lastname
855  print '<tr>';
856  print '<td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Lastname").'</span></td>';
857  print '<td>';
858  if (!empty($ldap_lastname)) {
859  print '<input type="hidden" id="lastname" name="lastname" value="'.dol_escape_htmltag($ldap_lastname).'">';
860  print $ldap_lastname;
861  } else {
862  print '<input class="minwidth100 maxwidth150onsmartphone" type="text" id="lastname" name="lastname" value="'.dol_escape_htmltag(GETPOST('lastname', 'alphanohtml')).'">';
863  }
864  print '</td></tr>';
865 
866  // Firstname
867  print '<tr><td>'.$langs->trans("Firstname").'</td>';
868  print '<td>';
869  if (!empty($ldap_firstname)) {
870  print '<input type="hidden" name="firstname" value="'.dol_escape_htmltag($ldap_firstname).'">';
871  print $ldap_firstname;
872  } else {
873  print '<input class="minwidth100 maxwidth150onsmartphone" type="text" name="firstname" value="'.dol_escape_htmltag(GETPOST('firstname', 'alphanohtml')).'">';
874  }
875  print '</td></tr>';
876 
877  // Login
878  print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").'</span></td>';
879  print '<td>';
880  if (!empty($ldap_login)) {
881  print '<input type="hidden" name="login" value="'.dol_escape_htmltag($ldap_login).'">';
882  print $ldap_login;
883  } elseif (!empty($ldap_loginsmb)) {
884  print '<input type="hidden" name="login" value="'.dol_escape_htmltag($ldap_loginsmb).'">';
885  print $ldap_loginsmb;
886  } else {
887  print '<input class="maxwidth200 maxwidth150onsmartphone" maxsize="24" type="text" name="login" value="'.dol_escape_htmltag(GETPOST('login', 'alphanohtml')).'">';
888  }
889  print '</td></tr>';
890 
891  $generated_password = '';
892  if (empty($ldap_sid)) { // ldap_sid is for activedirectory
893  $generated_password = getRandomPassword(false);
894  }
895  $password = (GETPOSTISSET('password') ?GETPOST('password') : $generated_password);
896 
897  // Administrator
898  if (!empty($user->admin)) {
899  print '<tr><td>'.$langs->trans("Administrator").'</td>';
900  print '<td>';
901  print $form->selectyesno('admin', GETPOST('admin'), 1);
902 
903  if (isModEnabled('multicompany') && !$user->entity) {
904  if (!empty($conf->use_javascript_ajax)) {
905  print '<script type="text/javascript">
906  $(function() {
907  $("select[name=admin]").change(function() {
908  if ( $(this).val() == 0 ) {
909  $("input[name=superadmin]")
910  .prop("disabled", true)
911  .prop("checked", false);
912  $("select[name=entity]")
913  .prop("disabled", false);
914  } else {
915  $("input[name=superadmin]")
916  .prop("disabled", false);
917  }
918  });
919  $("input[name=superadmin]").change(function() {
920  if ( $(this).is(":checked") ) {
921  $("select[name=entity]")
922  .prop("disabled", true);
923  } else {
924  $("select[name=entity]")
925  .prop("disabled", false);
926  }
927  });
928  });
929  </script>';
930  }
931  $checked = (GETPOST('superadmin', 'int') ? ' checked' : '');
932  $disabled = (GETPOST('superadmin', 'int') ? '' : ' disabled');
933  print '<input type="checkbox" name="superadmin" id="superadmin" value="1"'.$checked.$disabled.' /> <label for="superadmin">'.$langs->trans("SuperAdministrator").'</span>';
934  }
935  print "</td></tr>\n";
936  }
937 
938  // Gender
939  print '<tr><td>'.$langs->trans("Gender").'</td>';
940  print '<td>';
941  $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"), 'other'=>$langs->trans("Genderother"));
942  print $form->selectarray('gender', $arraygender, GETPOST('gender'), 1);
943  print '</td></tr>';
944 
945  // Employee
946  $defaultemployee = '1';
947  print '<tr>';
948  print '<td>'.$langs->trans('Employee').'</td><td>';
949  print '<input type="checkbox" name="employee" value="1"'.(GETPOST('employee') == '1' ? ' checked="checked"' : (($defaultemployee && !GETPOSTISSET('login')) ? ' checked="checked"' : '')).'>';
950  //print $form->selectyesno("employee", (GETPOST('employee') != '' ?GETPOST('employee') : $defaultemployee), 1);
951  print '</td></tr>';
952 
953  // Hierarchy
954  print '<tr><td class="titlefieldcreate">'.$langs->trans("HierarchicalResponsible").'</td>';
955  print '<td>';
956  print img_picto('', 'user', 'class="pictofixedwidth"').$form->select_dolusers($object->fk_user, 'fk_user', 1, array($object->id), 0, '', 0, $conf->entity, 0, 0, '', 0, '', 'maxwidth300 widthcentpercentminusx');
957  print '</td>';
958  print "</tr>\n";
959 
960  // Expense report validator
961  if (isModEnabled('expensereport')) {
962  print '<tr><td class="titlefieldcreate">';
963  $text = $langs->trans("ForceUserExpenseValidator");
964  print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help');
965  print '</td>';
966  print '<td>';
967  print img_picto('', 'user', 'class="pictofixedwidth"').$form->select_dolusers($object->fk_user_expense_validator, 'fk_user_expense_validator', 1, array($object->id), 0, '', 0, $conf->entity, 0, 0, '', 0, '', 'maxwidth300 widthcentpercentminusx');
968  print '</td>';
969  print "</tr>\n";
970  }
971 
972  // Holiday request validator
973  if (isModEnabled('holiday')) {
974  print '<tr><td class="titlefieldcreate">';
975  $text = $langs->trans("ForceUserHolidayValidator");
976  print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help');
977  print '</td>';
978  print '<td>';
979  print img_picto('', 'user', 'class="pictofixedwidth"').$form->select_dolusers($object->fk_user_holiday_validator, 'fk_user_holiday_validator', 1, array($object->id), 0, '', 0, $conf->entity, 0, 0, '', 0, '', 'maxwidth300 widthcentpercentminusx');
980  print '</td>';
981  print "</tr>\n";
982  }
983 
984  // External user
985  print '<tr><td>'.$langs->trans("ExternalUser").' ?</td>';
986  print '<td>';
987  print $form->textwithpicto($langs->trans("Internal"), $langs->trans("InternalExternalDesc"), 1, 'help', '', 0, 2);
988  print '</td></tr>';
989 
990 
991  print '</table><hr><table class="border centpercent">';
992 
993 
994  // Date validity
995  print '<tr><td class="titlefieldcreate">'.$langs->trans("RangeOfLoginValidity").'</td>';
996  print '<td>';
997  print $form->selectDate($datestartvalidity, 'datestartvalidity', 0, 0, 1, 'formdatestartvalidity', 1, 1);
998 
999  print ' &nbsp; ';
1000 
1001  print $form->selectDate($dateendvalidity, 'dateendvalidity', 0, 0, 1, 'formdateendvalidity', 1, 0);
1002  print '</td>';
1003  print "</tr>\n";
1004 
1005  // Password
1006  print '<tr><td class="fieldrequired">'.$langs->trans("Password").'</td>';
1007  print '<td>';
1008  $valuetoshow = '';
1009  if (preg_match('/ldap/', $dolibarr_main_authentication)) {
1010  $valuetoshow .= ($valuetoshow ? ' + ' : '').$langs->trans("PasswordOfUserInLDAP").' (hidden)';
1011  }
1012  if (preg_match('/http/', $dolibarr_main_authentication)) {
1013  $valuetoshow .= ($valuetoshow ? ' + ' : '').$langs->trans("HTTPBasicPassword");
1014  }
1015  if (preg_match('/dolibarr/', $dolibarr_main_authentication)) {
1016  if (!empty($ldap_pass)) { // For very old system comaptibilty. Now clear password can't be viewed from LDAP read
1017  $valuetoshow .= ($valuetoshow ? ' + ' : '').'<input type="hidden" name="password" value="'.dol_escape_htmltag($ldap_pass).'">'; // Dolibarr password is preffiled with LDAP known password
1018  $valuetoshow .= preg_replace('/./i', '*', $ldap_pass);
1019  } else {
1020  // We do not use a field password but a field text to show new password to use.
1021  $valuetoshow .= ($valuetoshow ? ' + '.$langs->trans("DolibarrPassword") : '').'<input maxsize="32" type="text" name="password" value="'.dol_escape_htmltag($password).'" autocomplete="new-password">';
1022  }
1023  }
1024 
1025  // Other form for user password
1026  $parameters = array('valuetoshow' => $valuetoshow, 'password' => $password);
1027  $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1028  if ($reshook > 0) {
1029  $valuetoshow = $hookmanager->resPrint; // to replace
1030  } else {
1031  $valuetoshow .= $hookmanager->resPrint; // to add
1032  }
1033 
1034  print $valuetoshow;
1035  print '</td></tr>';
1036 
1037  if (!empty($conf->api->enabled)) {
1038  // API key
1039  //$generated_password = getRandomPassword(false);
1040  print '<tr><td>'.$langs->trans("ApiKey").'</td>';
1041  print '<td>';
1042  print '<input class="minwidth300 widthcentpercentminusx" maxsize="32" type="text" id="api_key" name="api_key" value="'.GETPOST('api_key', 'alphanohtml').'" autocomplete="off">';
1043  if (!empty($conf->use_javascript_ajax)) {
1044  print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"');
1045  }
1046  print '</td></tr>';
1047  } else {
1048  // PARTIAL WORKAROUND
1049  $generated_fake_api_key = getRandomPassword(false);
1050  print '<input type="hidden" name="api_key" value="'.$generated_fake_api_key.'">';
1051  }
1052 
1053 
1054  print '</table><hr><table class="border centpercent">';
1055 
1056 
1057  // Address
1058  print '<tr><td class="tdtop titlefieldcreate">'.$form->editfieldkey('Address', 'address', '', $object, 0).'</td>';
1059  print '<td><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
1060  print $object->address;
1061  print '</textarea></td></tr>';
1062 
1063  // Zip
1064  print '<tr><td>'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).'</td><td>';
1065  print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
1066  print '</td></tr>';
1067 
1068  // Town
1069  print '<tr><td>'.$form->editfieldkey('Town', 'town', '', $object, 0).'</td><td>';
1070  print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
1071  print '</td></tr>';
1072 
1073  // Country
1074  print '<tr><td>'.$form->editfieldkey('Country', 'selectcountry_id', '', $object, 0).'</td><td class="maxwidthonsmartphone">';
1075  print img_picto('', 'country', 'class="pictofixedwidth"');
1076  print $form->select_country((GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id));
1077  if ($user->admin) {
1078  print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1079  }
1080  print '</td></tr>';
1081 
1082  // State
1083  if (empty($conf->global->USER_DISABLE_STATE)) {
1084  print '<tr><td>'.$form->editfieldkey('State', 'state_id', '', $object, 0).'</td><td class="maxwidthonsmartphone">';
1085  print img_picto('', 'state', 'class="pictofixedwidth"');
1086  print $formcompany->select_state($object->state_id, $object->country_code, 'state_id');
1087  print '</td></tr>';
1088  }
1089 
1090  // Tel
1091  print '<tr><td>'.$langs->trans("PhonePro").'</td>';
1092  print '<td>';
1093  print img_picto('', 'object_phoning', 'class="pictofixedwidth"');
1094  if (!empty($ldap_phone)) {
1095  print '<input type="hidden" name="office_phone" value="'.dol_escape_htmltag($ldap_phone).'">';
1096  print $ldap_phone;
1097  } else {
1098  print '<input class="maxwidth200 widthcentpercentminusx" type="text" name="office_phone" value="'.dol_escape_htmltag(GETPOST('office_phone', 'alphanohtml')).'">';
1099  }
1100  print '</td></tr>';
1101 
1102  // Tel portable
1103  print '<tr><td>'.$langs->trans("PhoneMobile").'</td>';
1104  print '<td>';
1105  print img_picto('', 'object_phoning_mobile', 'class="pictofixedwidth"');
1106  if (!empty($ldap_mobile)) {
1107  print '<input type="hidden" name="user_mobile" value="'.dol_escape_htmltag($ldap_mobile).'">';
1108  print $ldap_mobile;
1109  } else {
1110  print '<input class="maxwidth200 widthcentpercentminusx" type="text" name="user_mobile" value="'.dol_escape_htmltag(GETPOST('user_mobile', 'alphanohtml')).'">';
1111  }
1112  print '</td></tr>';
1113 
1114  // Fax
1115  print '<tr><td>'.$langs->trans("Fax").'</td>';
1116  print '<td>';
1117  print img_picto('', 'object_phoning_fax', 'class="pictofixedwidth"');
1118  if (!empty($ldap_fax)) {
1119  print '<input type="hidden" name="office_fax" value="'.dol_escape_htmltag($ldap_fax).'">';
1120  print $ldap_fax;
1121  } else {
1122  print '<input class="maxwidth200 widthcentpercentminusx" type="text" name="office_fax" value="'.dol_escape_htmltag(GETPOST('office_fax', 'alphanohtml')).'">';
1123  }
1124  print '</td></tr>';
1125 
1126  // EMail
1127  print '<tr><td'.(!empty($conf->global->USER_MAIL_REQUIRED) ? ' class="fieldrequired"' : '').'>'.$langs->trans("EMail").'</td>';
1128  print '<td>';
1129  print img_picto('', 'object_email', 'class="pictofixedwidth"');
1130  if (!empty($ldap_mail)) {
1131  print '<input type="hidden" name="email" value="'.dol_escape_htmltag($ldap_mail).'">';
1132  print $ldap_mail;
1133  } else {
1134  print '<input type="text" name="email" class="maxwidth500 widthcentpercentminusx" value="'.dol_escape_htmltag(GETPOST('email', 'alphanohtml')).'">';
1135  }
1136  print '</td></tr>';
1137 
1138  // Social networks
1139  if (isModEnabled('socialnetworks')) {
1140  foreach ($socialnetworks as $key => $value) {
1141  if ($value['active']) {
1142  print '<tr><td>'.$langs->trans($value['label']).'</td>';
1143  print '<td>';
1144  if (!empty($value['icon'])) {
1145  print '<span class="fa '.$value['icon'].' pictofixedwidth"></span>';
1146  }
1147  if (!empty($ldap_social[$key])) {
1148  print '<input type="hidden" name="'.$key.'" value="'.$ldap_social[$key].'">';
1149  print $ldap_social[$key];
1150  } else {
1151  print '<input class="maxwidth200 widthcentpercentminusx" type="text" name="'.$key.'" value="'.GETPOST($key, 'alphanohtml').'">';
1152  }
1153  print '</td></tr>';
1154  } else {
1155  // if social network is not active but value exist we do not want to loose it
1156  if (!empty($ldap_social[$key])) {
1157  print '<input type="hidden" name="'.$key.'" value="'.$ldap_social[$key].'">';
1158  } else {
1159  print '<input type="hidden" name="'.$key.'" value="'.GETPOST($key, 'alphanohtml').'">';
1160  }
1161  }
1162  }
1163  }
1164 
1165  // Accountancy code
1166  if (isModEnabled('accounting')) {
1167  print '<tr><td>'.$langs->trans("AccountancyCode").'</td>';
1168  print '<td>';
1169  print '<input type="text" class="maxwidthonsmartphone" name="accountancy_code" value="'.dol_escape_htmltag(GETPOST('accountancy_code', 'alphanohtml')).'">';
1170  print '</td></tr>';
1171  }
1172 
1173  // User color
1174  if (isModEnabled('agenda')) {
1175  print '<tr><td>'.$langs->trans("ColorUser").'</td>';
1176  print '<td>';
1177  print $formother->selectColor(GETPOSTISSET('color') ?GETPOST('color', 'alphanohtml') : $object->color, 'color', null, 1, '', 'hideifnotset');
1178  print '</td></tr>';
1179  }
1180 
1181  // Categories
1182  if (isModEnabled('categorie') && $user->hasRight("categorie", "read")) {
1183  print '<tr><td>'.$form->editfieldkey('Categories', 'usercats', '', $object, 0).'</td><td>';
1184  $cate_arbo = $form->select_all_categories('user', null, 'parent', null, null, 1);
1185  print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('usercats', $cate_arbo, GETPOST('usercats', 'array'), 0, 0, 'maxwdith300 widthcentpercentminusx', 0, '90%');
1186  print "</td></tr>";
1187  }
1188 
1189  if (getDolGlobalInt('MAIN_MULTILANGS')) {
1190  print '<tr><td>'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0, 'string', '', 0, 0, 'id', $langs->trans("WarningNotLangOfInterface", $langs->transnoentitiesnoconv("UserGUISetup"))).'</td>';
1191  print '<td class="maxwidthonsmartphone">'."\n";
1192  print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language(GETPOST('default_lang', 'alpha') ?GETPOST('default_lang', 'alpha') : ($object->lang ? $object->lang : ''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone widthcentpercentminusx');
1193  print '</td>';
1194  print '</tr>';
1195  }
1196 
1197  // Multicompany
1198  if (isModEnabled('multicompany') && is_object($mc)) {
1199  // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module
1200  if (!method_exists($mc, 'formObjectOptions')) {
1201  if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) { // condition must be same for create and edit mode
1202  print "<tr>".'<td>'.$langs->trans("Entity").'</td>';
1203  print "<td>".$mc->select_entities($conf->entity);
1204  print "</td></tr>\n";
1205  } else {
1206  print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
1207  }
1208  }
1209  }
1210 
1211  // Other attributes
1212  $parameters = array();
1213  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
1214 
1215  // Signature
1216  print '<tr><td class="tdtop">'.$langs->trans("Signature").'</td>';
1217  print '<td class="wordbreak">';
1218  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1219 
1220  $doleditor = new DolEditor('signature', GETPOST('signature', 'restricthtml'), '', 138, 'dolibarr_notes', 'In', true, $acceptlocallinktomedia, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4, '90%');
1221  print $doleditor->Create(1);
1222  print '</td></tr>';
1223 
1224  // Note private
1225  print '<tr><td class="tdtop">';
1226  print $langs->trans("NotePublic");
1227  print '</td><td>';
1228  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1229  $doleditor = new DolEditor('note_public', GETPOSTISSET('note_public') ? GETPOST('note_public', 'restricthtml') : '', '', 100, 'dolibarr_notes', '', false, true, getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PUBLIC'), ROWS_3, '90%');
1230  $doleditor->Create();
1231  print "</td></tr>\n";
1232 
1233  // Note private
1234  print '<tr><td class="tdtop">';
1235  print $langs->trans("NotePrivate");
1236  print '</td><td>';
1237  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1238  $doleditor = new DolEditor('note_private', GETPOSTISSET('note_private') ? GETPOST('note_private', 'restricthtml') : '', '', 100, 'dolibarr_notes', '', false, true, getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PRIVATE'), ROWS_3, '90%');
1239  $doleditor->Create();
1240  print "</td></tr>\n";
1241 
1242  print '</table><hr><table class="border centpercent">';
1243 
1244 
1245  // TODO Move this into tab RH (HierarchicalResponsible must be on both tab)
1246 
1247  // Default warehouse
1248  if (isModEnabled('stock') && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
1249  print '<tr><td>'.$langs->trans("DefaultWarehouse").'</td><td>';
1250  print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1);
1251  print '</td></tr>';
1252  }
1253 
1254  // Position/Job
1255  print '<tr><td class="titlefieldcreate">'.$langs->trans("PostOrFunction").'</td>';
1256  print '<td>';
1257  print '<input class="maxwidth200 maxwidth150onsmartphone" type="text" name="job" value="'.dol_escape_htmltag(GETPOST('job', 'alphanohtml')).'">';
1258  print '</td></tr>';
1259 
1260  if ((!empty($conf->salaries->enabled) && $user->hasRight("salaries", "read") && in_array($id, $childids))
1261  || (!empty($conf->salaries->enabled) && $user->hasRight("salaries", "readall"))
1262  || (isModEnabled('hrm') && $user->hasRight("hrm", "employee", "read"))) {
1263  $langs->load("salaries");
1264 
1265  // THM
1266  print '<tr><td>';
1267  $text = $langs->trans("THM");
1268  print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm');
1269  print '</td>';
1270  print '<td>';
1271  print '<input size="8" type="text" name="thm" value="'.dol_escape_htmltag(GETPOST('thm')).'"> '.$langs->getCurrencySymbol($conf->currency);
1272  print '</td>';
1273  print "</tr>\n";
1274 
1275  // TJM
1276  print '<tr><td>';
1277  $text = $langs->trans("TJM");
1278  print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classtjm');
1279  print '</td>';
1280  print '<td>';
1281  print '<input size="8" type="text" name="tjm" value="'.dol_escape_htmltag(GETPOST('tjm')).'"> '.$langs->getCurrencySymbol($conf->currency);
1282  print '</td>';
1283  print "</tr>\n";
1284 
1285  // Salary
1286  print '<tr><td>'.$langs->trans("Salary").'</td>';
1287  print '<td>';
1288  print img_picto('', 'salary', 'class="pictofixedwidth paddingright"').'<input size="8" type="text" name="salary" value="'.dol_escape_htmltag(GETPOST('salary')).'"> '.$langs->getCurrencySymbol($conf->currency);
1289  print '</td>';
1290  print "</tr>\n";
1291  }
1292 
1293  // Weeklyhours
1294  print '<tr><td>'.$langs->trans("WeeklyHours").'</td>';
1295  print '<td>';
1296  print '<input size="8" type="text" name="weeklyhours" value="'.dol_escape_htmltag(GETPOST('weeklyhours')).'">';
1297  print '</td>';
1298  print "</tr>\n";
1299 
1300  // Date employment
1301  print '<tr><td>'.$langs->trans("DateOfEmployment").'</td>';
1302  print '<td>';
1303  print $form->selectDate($dateemployment, 'dateemployment', 0, 0, 1, 'formdateemployment', 1, 1);
1304 
1305  print ' - ';
1306 
1307  print $form->selectDate($dateemploymentend, 'dateemploymentend', 0, 0, 1, 'formdateemploymentend', 1, 0);
1308  print '</td>';
1309  print "</tr>\n";
1310 
1311  // Date birth
1312  print '<tr><td>'.$langs->trans("DateOfBirth").'</td>';
1313  print '<td>';
1314  print $form->selectDate($dateofbirth, 'dateofbirth', 0, 0, 1, 'createuser', 1, 0, 0, '', 0, '', '', 1, '', '', 'tzserver');
1315  print '</td>';
1316  print "</tr>\n";
1317 
1318  print "</table>\n";
1319 
1320  print dol_get_fiche_end();
1321 
1322  print $form->buttonsSaveCancel("CreateUser");
1323 
1324  print "</form>";
1325 } else {
1326  // View and edit mode
1327  if ($id > 0) {
1328  $res = $object->fetch($id, '', '', 1);
1329  if ($res < 0) {
1330  dol_print_error($db, $object->error);
1331  exit;
1332  }
1333  $res = $object->fetch_optionals();
1334 
1335  // Check if user has rights
1336  if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
1337  $object->getrights();
1338  if (empty($object->nb_rights) && $object->statut != 0 && empty($object->admin)) {
1339  setEventMessages($langs->trans('UserHasNoPermissions'), null, 'warnings');
1340  }
1341  }
1342 
1343  // Connexion ldap
1344  // pour recuperer passDoNotExpire et userChangePassNextLogon
1345  if (!empty($conf->ldap->enabled) && !empty($object->ldap_sid)) {
1346  $ldap = new Ldap();
1347  $result = $ldap->connect_bind();
1348  if ($result > 0) {
1349  $userSearchFilter = '('.$conf->global->LDAP_FILTER_CONNECTION.'('.$ldap->getUserIdentifier().'='.$object->login.'))';
1350  $entries = $ldap->fetch($object->login, $userSearchFilter);
1351  if (!$entries) {
1352  setEventMessages($ldap->error, $ldap->errors, 'errors');
1353  }
1354 
1355  $passDoNotExpire = 0;
1356  $userChangePassNextLogon = 0;
1357  $userDisabled = 0;
1358  $statutUACF = '';
1359 
1360  // Check options of user account
1361  if (count($ldap->uacf) > 0) {
1362  foreach ($ldap->uacf as $key => $statut) {
1363  if ($key == 65536) {
1364  $passDoNotExpire = 1;
1365  $statutUACF = $statut;
1366  }
1367  }
1368  } else {
1369  $userDisabled = 1;
1370  $statutUACF = "ACCOUNTDISABLE";
1371  }
1372 
1373  if ($ldap->pwdlastset == 0) {
1374  $userChangePassNextLogon = 1;
1375  }
1376  }
1377  }
1378 
1379  // Show tabs
1380  if ($mode == 'employee') { // For HRM module development
1381  $title = $langs->trans("Employee");
1382  $linkback = '<a href="'.DOL_URL_ROOT.'/hrm/employee/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
1383  } else {
1384  $title = $langs->trans("User");
1385  $linkback = '';
1386 
1387  if ($user->hasRight("user", "user", "read") || $user->admin) {
1388  $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
1389  }
1390  }
1391 
1392  $head = user_prepare_head($object);
1393 
1394  /*
1395  * Confirmation reinitialisation mot de passe
1396  */
1397  if ($action == 'password') {
1398  print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("ReinitPassword"), $langs->trans("ConfirmReinitPassword", $object->login), "confirm_password", '', 0, 1);
1399  }
1400 
1401  /*
1402  * Confirmation envoi mot de passe
1403  */
1404  if ($action == 'passwordsend') {
1405  print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("SendNewPassword"), $langs->trans("ConfirmSendNewPassword", $object->login), "confirm_passwordsend", '', 0, 1);
1406  }
1407 
1408  /*
1409  * Confirm deactivation
1410  */
1411  if ($action == 'disable') {
1412  print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("DisableAUser"), $langs->trans("ConfirmDisableUser", $object->login), "confirm_disable", '', 0, 1);
1413  }
1414 
1415  /*
1416  * Confirm activation
1417  */
1418  if ($action == 'enable') {
1419  print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("EnableAUser"), $langs->trans("ConfirmEnableUser", $object->login), "confirm_enable", '', 0, 1);
1420  }
1421 
1422  /*
1423  * Confirmation suppression
1424  */
1425  if ($action == 'delete') {
1426  print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("DeleteAUser"), $langs->trans("ConfirmDeleteUser", $object->login), "confirm_delete", '', 0, 1);
1427  }
1428 
1429  /*
1430  * Fiche en mode visu
1431  */
1432  if ($action != 'edit') {
1433  print dol_get_fiche_head($head, 'user', $title, -1, 'user');
1434 
1435  $morehtmlref = '<a href="'.DOL_URL_ROOT.'/user/vcard.php?id='.$object->id.'" class="refid">';
1436  $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
1437  $morehtmlref .= '</a>';
1438 
1439  dol_banner_tab($object, 'id', $linkback, $user->hasRight("user", "user", "read") || $user->admin, 'rowid', 'ref', $morehtmlref);
1440 
1441  print '<div class="fichecenter">';
1442  print '<div class="fichehalfleft">';
1443 
1444  print '<div class="underbanner clearboth"></div>';
1445  print '<table class="border tableforfield centpercent">';
1446 
1447  // Login
1448  print '<tr><td class="titlefieldmiddle">'.$langs->trans("Login").'</td>';
1449  if (!empty($object->ldap_sid) && $object->statut == 0) {
1450  print '<td class="error">';
1451  print $langs->trans("LoginAccountDisableInDolibarr");
1452  print '</td>';
1453  } else {
1454  print '<td>';
1455  $addadmin = '';
1456  if (property_exists($object, 'admin')) {
1457  if (isModEnabled('multicompany') && !empty($object->admin) && empty($object->entity)) {
1458  $addadmin .= img_picto($langs->trans("SuperAdministratorDesc"), "redstar", 'class="paddingleft"');
1459  } elseif (!empty($object->admin)) {
1460  $addadmin .= img_picto($langs->trans("AdministratorDesc"), "star", 'class="paddingleft"');
1461  }
1462  }
1463  print showValueWithClipboardCPButton($object->login).$addadmin;
1464  print '</td>';
1465  }
1466  print '</tr>'."\n";
1467 
1468  // Type
1469  print '<tr><td>';
1470  $text = $langs->trans("Type");
1471  print $form->textwithpicto($text, $langs->trans("InternalExternalDesc"));
1472  print '</td><td>';
1473  $type = $langs->trans("Internal");
1474  if ($object->socid > 0) {
1475  $type = $langs->trans("External");
1476  }
1477  print '<span class="badgeneutral">';
1478  print $type;
1479  if ($object->ldap_sid) {
1480  print ' ('.$langs->trans("DomainUser").')';
1481  }
1482  print '</span>';
1483  print '</td></tr>'."\n";
1484 
1485  // Ldap sid
1486  if ($object->ldap_sid) {
1487  print '<tr><td>'.$langs->trans("Type").'</td><td>';
1488  print $langs->trans("DomainUser", $ldap->domainFQDN);
1489  print '</td></tr>'."\n";
1490  }
1491 
1492  // Employee
1493  print '<tr><td>'.$langs->trans("Employee").'</td><td>';
1494  print '<input type="checkbox" disabled name="employee" value="1"'.($object->employee ? ' checked="checked"' : '').'>';
1495  //print yn($object->employee);
1496  print '</td></tr>'."\n";
1497 
1498  // TODO This is also available into the tab RH
1499 
1500  // Hierarchy
1501  print '<tr><td>'.$langs->trans("HierarchicalResponsible").'</td>';
1502  print '<td>';
1503  if (empty($object->fk_user)) {
1504  print '<span class="opacitymedium">'.$langs->trans("None").'</span>';
1505  } else {
1506  $huser = new User($db);
1507  if ($object->fk_user > 0) {
1508  $huser->fetch($object->fk_user);
1509  print $huser->getNomUrl(1);
1510  } else {
1511  print '<span class="opacitymedium">'.$langs->trans("None").'</span>';
1512  }
1513  }
1514  print '</td>';
1515  print "</tr>\n";
1516 
1517  // Expense report validator
1518  if (isModEnabled('expensereport')) {
1519  print '<tr><td>';
1520  $text = $langs->trans("ForceUserExpenseValidator");
1521  print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help');
1522  print '</td>';
1523  print '<td>';
1524  if (!empty($object->fk_user_expense_validator)) {
1525  $evuser = new User($db);
1526  $evuser->fetch($object->fk_user_expense_validator);
1527  print $evuser->getNomUrl(1);
1528  }
1529  print '</td>';
1530  print "</tr>\n";
1531  }
1532 
1533  // Holiday request validator
1534  if (isModEnabled('holiday')) {
1535  print '<tr><td>';
1536  $text = $langs->trans("ForceUserHolidayValidator");
1537  print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help');
1538  print '</td>';
1539  print '<td>';
1540  if (!empty($object->fk_user_holiday_validator)) {
1541  $hvuser = new User($db);
1542  $hvuser->fetch($object->fk_user_holiday_validator);
1543  print $hvuser->getNomUrl(1);
1544  }
1545  print '</td>';
1546  print "</tr>\n";
1547  }
1548 
1549  // Position/Job
1550  print '<tr><td>'.$langs->trans("PostOrFunction").'</td>';
1551  print '<td>'.dol_escape_htmltag($object->job).'</td>';
1552  print '</tr>'."\n";
1553 
1554  // Weeklyhours
1555  print '<tr><td>'.$langs->trans("WeeklyHours").'</td>';
1556  print '<td>';
1557  print price2num($object->weeklyhours);
1558  print '</td>';
1559  print "</tr>\n";
1560 
1561  // Sensitive salary/value information
1562  if ((empty($user->socid) && in_array($id, $childids)) // A user can always see salary/value information for its subordinates
1563  || (!empty($conf->salaries->enabled) && $user->hasRight("salaries", "readall"))
1564  || (isModEnabled('hrm') && $user->hasRight("hrm", "employee", "read"))) {
1565  $langs->load("salaries");
1566 
1567  // Salary
1568  print '<tr><td>'.$langs->trans("Salary").'</td>';
1569  print '<td>';
1570  print ($object->salary != '' ? img_picto('', 'salary', 'class="pictofixedwidth paddingright"').'<span class="amount">'.price($object->salary, '', $langs, 1, -1, -1, $conf->currency) : '').'</span>';
1571  print '</td>';
1572  print "</tr>\n";
1573 
1574  // THM
1575  print '<tr><td>';
1576  $text = $langs->trans("THM");
1577  print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm');
1578  print '</td>';
1579  print '<td>';
1580  print ($object->thm != '' ?price($object->thm, '', $langs, 1, -1, -1, $conf->currency) : '');
1581  print '</td>';
1582  print "</tr>\n";
1583 
1584  // TJM
1585  print '<tr><td>';
1586  $text = $langs->trans("TJM");
1587  print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classtjm');
1588  print '</td>';
1589  print '<td>';
1590  print ($object->tjm != '' ?price($object->tjm, '', $langs, 1, -1, -1, $conf->currency) : '');
1591  print '</td>';
1592  print "</tr>\n";
1593  }
1594 
1595  // Date employment
1596  print '<tr><td>'.$langs->trans("DateOfEmployment").'</td>';
1597  print '<td>';
1598  if ($object->dateemployment) {
1599  print '<span class="opacitymedium">'.$langs->trans("FromDate").'</span> ';
1600  print dol_print_date($object->dateemployment, 'day');
1601  }
1602  if ($object->dateemploymentend) {
1603  print '<span class="opacitymedium"> - '.$langs->trans("To").'</span> ';
1604  print dol_print_date($object->dateemploymentend, 'day');
1605  }
1606  print '</td>';
1607  print "</tr>\n";
1608 
1609  // Date of birth
1610  print '<tr><td>'.$langs->trans("DateOfBirth").'</td>';
1611  print '<td>';
1612  print dol_print_date($object->birth, 'day', 'tzserver');
1613  print '</td>';
1614  print "</tr>\n";
1615 
1616  // Default warehouse
1617  if (isModEnabled('stock') && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
1618  require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
1619  print '<tr><td>'.$langs->trans("DefaultWarehouse").'</td><td>';
1620  if ($object->fk_warehouse > 0) {
1621  $warehousestatic = new Entrepot($db);
1622  $warehousestatic->fetch($object->fk_warehouse);
1623  print $warehousestatic->getNomUrl(1);
1624  }
1625  print '</td></tr>';
1626  }
1627 
1628  print '</table>';
1629 
1630  print '</div>';
1631  print '<div class="fichehalfright">';
1632 
1633  print '<div class="underbanner clearboth"></div>';
1634 
1635  print '<table class="border tableforfield centpercent">';
1636 
1637  // Color user
1638  if (isModEnabled('agenda')) {
1639  print '<tr><td class="titlefield">'.$langs->trans("ColorUser").'</td>';
1640  print '<td>';
1641  print $formother->showColor($object->color, '');
1642  print '</td>';
1643  print "</tr>\n";
1644  }
1645 
1646  // Categories
1647  if (isModEnabled('categorie') && $user->hasRight("categorie", "read")) {
1648  print '<tr><td class="titlefield">'.$langs->trans("Categories").'</td>';
1649  print '<td colspan="3">';
1650  print $form->showCategories($object->id, Categorie::TYPE_USER, 1);
1651  print '</td></tr>';
1652  }
1653 
1654  // Default language
1655  if (getDolGlobalInt('MAIN_MULTILANGS')) {
1656  $langs->load("languages");
1657  require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
1658  print '<tr><td class="titlefield">';
1659  print $form->textwithpicto($langs->trans("DefaultLang"), $langs->trans("WarningNotLangOfInterface", $langs->transnoentitiesnoconv("UserGUISetup")));
1660  print '</td><td>';
1661  //$s=picto_from_langcode($object->default_lang);
1662  //print ($s?$s.' ':'');
1663  $labellang = ($object->lang ? $langs->trans('Language_'.$object->lang) : '');
1664  print picto_from_langcode($object->lang, 'class="paddingrightonly saturatemedium opacitylow"');
1665  print $labellang;
1666  print '</td></tr>';
1667  }
1668 
1669  if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication) && !empty($conf->global->MAIN_OPENIDURL_PERUSER)) {
1670  print '<tr><td>'.$langs->trans("OpenIDURL").'</td>';
1671  print '<td>'.$object->openid.'</td>';
1672  print "</tr>\n";
1673  }
1674 
1675  // Multicompany
1676  if (isModEnabled('multicompany') && is_object($mc)) {
1677  // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module
1678  if (!method_exists($mc, 'formObjectOptions')) {
1679  if (isModEnabled('multicompany') && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
1680  print '<tr><td>'.$langs->trans("Entity").'</td><td>';
1681  if (empty($object->entity)) {
1682  print $langs->trans("AllEntities");
1683  } else {
1684  $mc->getInfo($object->entity);
1685  print $mc->label;
1686  }
1687  print "</td></tr>\n";
1688  }
1689  }
1690  }
1691 
1692  // Other attributes
1693  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
1694 
1695  // Company / Contact
1696  if (isModEnabled("societe")) {
1697  print '<tr><td>'.$langs->trans("LinkToCompanyContact").'</td>';
1698  print '<td>';
1699  $s = '';
1700  if (isset($object->socid) && $object->socid > 0) {
1701  $societe = new Societe($db);
1702  $societe->fetch($object->socid);
1703  if ($societe->id > 0) {
1704  $s .= $societe->getNomUrl(1, '');
1705  }
1706  } else {
1707  $s .= '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ThisUserIsNot").'</span>';
1708  }
1709  if (!empty($object->contact_id)) {
1710  $contact = new Contact($db);
1711  $contact->fetch($object->contact_id);
1712  if ($contact->id > 0) {
1713  if ($object->socid > 0 && $s) {
1714  $s .= ' / ';
1715  } else {
1716  $s .= '<br>';
1717  }
1718  $s .= $contact->getNomUrl(1, '');
1719  }
1720  }
1721  print $s;
1722  print '</td>';
1723  print '</tr>'."\n";
1724  }
1725 
1726  // Module Adherent
1727  if (isModEnabled('adherent')) {
1728  $langs->load("members");
1729  print '<tr><td>'.$langs->trans("LinkedToDolibarrMember").'</td>';
1730  print '<td>';
1731  if ($object->fk_member) {
1732  $adh = new Adherent($db);
1733  $adh->fetch($object->fk_member);
1734  $adh->ref = $adh->getFullname($langs); // Force to show login instead of id
1735  print $adh->getNomUrl(-1);
1736  } else {
1737  print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("UserNotLinkedToMember").'</span>';
1738  }
1739  print '</td>';
1740  print '</tr>'."\n";
1741  }
1742 
1743  // Signature
1744  print '<tr><td class="tdtop">'.$langs->trans('Signature').'</td><td class="wordbreak">';
1745  print dol_htmlentitiesbr($object->signature);
1746  print "</td></tr>\n";
1747 
1748  print "</table>\n";
1749 
1750 
1751  // Credentials
1752  print '<br>';
1753  print '<div class="div-table-responsive-no-min">';
1754  print '<table class="border tableforfield centpercent">';
1755  print '<tr class="liste_titre"><td class="liste_titre">';
1756  print img_picto('', 'security', 'class="paddingleft pictofixedwidth"').$langs->trans("Credentials");
1757  print '</td>';
1758  print '<td class="liste_titre"></td>';
1759  print '</tr>';
1760 
1761  // Date login validity
1762  print '<tr class="nooddeven"><td class="titlefield">'.$langs->trans("RangeOfLoginValidity").'</td>';
1763  print '<td>';
1764  if ($object->datestartvalidity) {
1765  print '<span class="opacitymedium">'.$langs->trans("FromDate").'</span> ';
1766  print dol_print_date($object->datestartvalidity, 'day');
1767  }
1768  if ($object->dateendvalidity) {
1769  print '<span class="opacitymedium"> - '.$langs->trans("To").'</span> ';
1770  print dol_print_date($object->dateendvalidity, 'day');
1771  }
1772  print '</td>';
1773  print "</tr>\n";
1774 
1775  // Password
1776  $valuetoshow = '';
1777  if (preg_match('/ldap/', $dolibarr_main_authentication)) {
1778  if (!empty($object->ldap_sid)) {
1779  if ($passDoNotExpire) {
1780  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("LdapUacf_".$statutUACF);
1781  } elseif ($userChangePassNextLogon) {
1782  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').'<span class="warning">'.$langs->trans("UserMustChangePassNextLogon", $ldap->domainFQDN).'</span>';
1783  } elseif ($userDisabled) {
1784  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').'<span class="warning">'.$langs->trans("LdapUacf_".$statutUACF, $ldap->domainFQDN).'</span>';
1785  } else {
1786  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("PasswordOfUserInLDAP");
1787  }
1788  } else {
1789  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("PasswordOfUserInLDAP");
1790  }
1791  }
1792  if (preg_match('/http/', $dolibarr_main_authentication)) {
1793  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("HTTPBasicPassword");
1794  }
1795  /*
1796  if (preg_match('/dolibarr/', $dolibarr_main_authentication)) {
1797  if ($object->pass) {
1798  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '');
1799  $valuetoshow .= '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
1800  } else {
1801  if ($user->admin && $user->id == $object->id) {
1802  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '');
1803  $valuetoshow .= '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
1804  $valuetoshow .= '<!-- Crypted into '.$object->pass_indatabase_crypted.' -->';
1805  } else {
1806  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '');
1807  $valuetoshow .= '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
1808  }
1809  }
1810  }
1811  */
1812 
1813  // Other form for user password
1814  $parameters = array('valuetoshow' => $valuetoshow);
1815  $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1816  if ($reshook > 0) {
1817  $valuetoshow = $hookmanager->resPrint; // to replace
1818  } else {
1819  $valuetoshow .= $hookmanager->resPrint; // to add
1820  }
1821 
1822  if (dol_string_nohtmltag($valuetoshow)) { // If there is a real visible content to show
1823  print '<tr class="nooddeven"><td class="titlefield">'.$langs->trans("Password").'</td>';
1824  print '<td class="wordbreak">';
1825  print $valuetoshow;
1826  print "</td>";
1827  print '</tr>'."\n";
1828  }
1829 
1830  // API key
1831  if (!empty($conf->api->enabled) && ($user->id == $id || $user->admin || $user->hasRight("api", "apikey", "generate"))) {
1832  print '<tr class="nooddeven"><td>'.$langs->trans("ApiKey").'</td>';
1833  print '<td>';
1834  if (!empty($object->api_key)) {
1835  print '<span class="opacitymedium">';
1836  print showValueWithClipboardCPButton($object->api_key, 1, $langs->trans("Hidden")); // TODO Add an option to also reveal the hash, not only copy paste
1837  print '</span>';
1838  }
1839  print '</td></tr>';
1840  }
1841 
1842  print '<tr class="nooddeven"><td>'.$langs->trans("LastConnexion").'</td>';
1843  print '<td>';
1844  if ($object->datepreviouslogin) {
1845  print dol_print_date($object->datepreviouslogin, "dayhour", "tzuserrel").' <span class="opacitymedium">('.$langs->trans("Previous").')</span>, ';
1846  }
1847  if ($object->datelastlogin) {
1848  print dol_print_date($object->datelastlogin, "dayhour", "tzuserrel").' <span class="opacitymedium">('.$langs->trans("Currently").')</span>';
1849  }
1850  print '</td>';
1851  print "</tr>\n";
1852 
1853  print '</table>';
1854  print '</div>';
1855 
1856  print '</div>';
1857 
1858  print '</div>';
1859  print '<div style="clear:both"></div>';
1860 
1861 
1862  print dol_get_fiche_end();
1863 
1864 
1865  /*
1866  * Buttons actions
1867  */
1868  print '<div class="tabsAction">';
1869 
1870  $parameters = array();
1871  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1872  if (empty($reshook)) {
1873  if (empty($user->socid)) {
1874  $canSendMail = false;
1875  $params = array(
1876  'attr' => array(
1877  'title' => '',
1878  'class' => 'classfortooltip'
1879  )
1880  );
1881  if (!empty($object->email)) {
1882  $langs->load("mails");
1883  $canSendMail = true;
1884  } else {
1885  $langs->load("mails");
1886  $params['attr']['title'] = $langs->trans('NoEMail');
1887  }
1888  print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle', '', $canSendMail, $params);
1889  }
1890 
1891  if ($caneditfield && (!isModEnabled('multicompany') || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1892  $params = array(
1893  'attr' => array(
1894  'title' => '',
1895  'class' => 'classfortooltip'
1896  )
1897  );
1898  if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) {
1899  $params['attr']['title'] = $langs->trans('DisabledInMonoUserMode');
1900  print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params);
1901  } else {
1902  print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit&token='.newToken(), '', true, $params);
1903  }
1904  } elseif ($caneditpassword && !$object->ldap_sid &&
1905  (!isModEnabled('multicompany') || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1906  $params = array(
1907  'attr' => array(
1908  'title' => '',
1909  'class' => 'classfortooltip'
1910  )
1911  );
1912  print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit', '', true, $params);
1913  }
1914 
1915  // Si on a un gestionnaire de generation de mot de passe actif
1916  $params = array(
1917  'attr' => array(
1918  'title' => '',
1919  'class' => 'classfortooltip'
1920  )
1921  );
1922  if ($conf->global->USER_PASSWORD_GENERATED != 'none') {
1923  if ($object->statut == 0) {
1924  $params['attr']['title'] = $langs->trans('UserDisabled');
1925  print dolGetButtonAction($langs->trans('ReinitPassword'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params);
1926  } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid &&
1927  ((!isModEnabled('multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1928  print dolGetButtonAction($langs->trans('ReinitPassword'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=password&token='.newToken(), '', true, $params);
1929  }
1930 
1931  if ($object->statut == 0) {
1932  $params['attr']['title'] = $langs->trans('UserDisabled');
1933  print dolGetButtonAction($langs->trans('SendNewPassword'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params);
1934  } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid &&
1935  ((!isModEnabled('multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1936  if ($object->email) {
1937  print dolGetButtonAction($langs->trans('SendNewPassword'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=passwordsend&token='.newToken(), '', true, $params);
1938  } else {
1939  $params['attr']['title'] = $langs->trans('NoEMail');
1940  print dolGetButtonAction($langs->trans('SendNewPassword'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params);
1941  }
1942  }
1943  }
1944 
1945  // Enable user
1946  $params = array(
1947  'attr' => array(
1948  'title' => '',
1949  'class' => 'classfortooltip'
1950  )
1951  );
1952  if ($user->id <> $id && $candisableuser && $object->statut == 0 &&
1953  ((!isModEnabled('multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1954  print dolGetButtonAction($langs->trans('Reactivate'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=enable&token='.newToken(), '', true, $params);
1955  }
1956  // Disable user
1957  if ($user->id <> $id && $candisableuser && $object->statut == 1 &&
1958  ((!isModEnabled('multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1959  print dolGetButtonAction($langs->trans('DisableUser'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=disable&token='.newToken(), '', true, $params);
1960  } else {
1961  if ($user->id == $id) {
1962  $params['attr']['title'] = $langs->trans('CantDisableYourself');
1963  print dolGetButtonAction($langs->trans('DisableUser'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params);
1964  }
1965  }
1966  // Delete
1967  if ($user->id <> $id && $candisableuser &&
1968  ((!isModEnabled('multicompany') && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) {
1969  if ($user->admin || !$object->admin) { // If user edited is admin, delete is possible on for an admin
1970  print dolGetButtonAction($langs->trans('DeleteUser'), '', 'default', $_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$object->id, '', true, $params);
1971  } else {
1972  $params['attr']['title'] = $langs->trans('MustBeAdminToDeleteOtherAdmin');
1973  print dolGetButtonAction($langs->trans('DeleteUser'), '', 'default', $_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$object->id, '', false, $params);
1974  }
1975  }
1976  }
1977 
1978  print "</div>\n";
1979 
1980 
1981 
1982  // Select mail models is same action as presend
1983  if (GETPOST('modelselected')) {
1984  $action = 'presend';
1985  }
1986 
1987  // Presend form
1988  $modelmail = 'user';
1989  $defaulttopic = 'Information';
1990  $diroutput = $conf->user->dir_output;
1991  $trackid = 'use'.$object->id;
1992 
1993  include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
1994 
1995  if ($action != 'presend' && $action != 'send') {
1996  /*
1997  * List of groups of user
1998  */
1999 
2000  if ($canreadgroup) {
2001  print '<!-- Group section -->'."\n";
2002 
2003  print load_fiche_titre($langs->trans("ListOfGroupsForUser"), '', '');
2004 
2005  // On selectionne les groupes auquel fait parti le user
2006  $exclude = array();
2007 
2008  $usergroup = new UserGroup($db);
2009  $groupslist = $usergroup->listGroupsForUser($object->id, false);
2010 
2011  if (!empty($groupslist)) {
2012  foreach ($groupslist as $groupforuser) {
2013  $exclude[] = $groupforuser->id;
2014  }
2015  }
2016 
2017  // Other form for add user to group
2018  $parameters = array('caneditgroup' => $caneditgroup, 'groupslist' => $groupslist, 'exclude' => $exclude);
2019  $reshook = $hookmanager->executeHooks('formAddUserToGroup', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2020  print $hookmanager->resPrint;
2021 
2022  if (empty($reshook)) {
2023  if ($caneditgroup) {
2024  print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">'."\n";
2025  print '<input type="hidden" name="token" value="'.newToken().'" />';
2026  print '<input type="hidden" name="action" value="addgroup" />';
2027  print '<input type="hidden" name="page_y" value="" />';
2028  }
2029 
2030  print '<table class="noborder centpercent">'."\n";
2031  print '<tr class="liste_titre"><th class="liste_titre">'.$langs->trans("Groups").'</th>'."\n";
2032  print '<th class="liste_titre right">';
2033  if ($caneditgroup) {
2034  print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity);
2035  print ' &nbsp; ';
2036  print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
2037  print '<input type="submit" class="button buttongen button-add reposition" value="'.$langs->trans("Add").'" />';
2038  }
2039  print '</th></tr>'."\n";
2040 
2041  // List of groups of user
2042  if (!empty($groupslist)) {
2043  foreach ($groupslist as $group) {
2044  print '<tr class="oddeven">';
2045  print '<td>';
2046  if ($caneditgroup) {
2047  print $group->getNomUrl(1);
2048  } else {
2049  print img_object($langs->trans("ShowGroup"), "group").' '.$group->name;
2050  }
2051  print '</td>';
2052  print '<td class="right">';
2053  if ($caneditgroup) {
2054  print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=removegroup&token='.newToken().'&group='.((int) $group->id).'">';
2055  print img_picto($langs->trans("RemoveFromGroup"), 'unlink');
2056  print '</a>';
2057  } else {
2058  print "&nbsp;";
2059  }
2060  print "</td></tr>\n";
2061  }
2062  } else {
2063  print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
2064  }
2065 
2066  print "</table>";
2067 
2068  if ($caneditgroup) {
2069  print '</form>';
2070  }
2071  print "<br>";
2072  }
2073  }
2074  }
2075  }
2076 
2077  /*
2078  * Card in edit mode
2079  */
2080  if ($action == 'edit' && ($canedituser || $caneditfield || $caneditpassword || ($user->id == $object->id))) {
2081  print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST" name="updateuser" enctype="multipart/form-data">';
2082  print '<input type="hidden" name="token" value="'.newToken().'">';
2083  print '<input type="hidden" name="action" value="update">';
2084  print '<input type="hidden" name="entity" value="'.$object->entity.'">';
2085 
2086  print dol_get_fiche_head($head, 'user', $title, 0, 'user');
2087 
2088  print '<table class="border centpercent">';
2089 
2090  // Ref/ID
2091  if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
2092  print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td>';
2093  print '<td>';
2094  print $object->id;
2095  print '</td>';
2096  print '</tr>';
2097  }
2098 
2099  // Civility
2100  print '<tr><td class="titlefieldcreate"><label for="civility_code">'.$langs->trans("UserTitle").'</label></td><td>';
2101  if ($caneditfield && !$object->ldap_sid) {
2102  print $formcompany->select_civility(GETPOSTISSET("civility_code") ? GETPOST("civility_code", 'aZ09') : $object->civility_code, 'civility_code');
2103  } elseif ($object->civility_code) {
2104  print $langs->trans("Civility".$object->civility_code);
2105  }
2106  print '</td></tr>';
2107 
2108  // Lastname
2109  print "<tr>";
2110  print '<td class="titlefieldcreate fieldrequired">'.$langs->trans("Lastname").'</td>';
2111  print '<td>';
2112  if ($caneditfield && !$object->ldap_sid) {
2113  print '<input class="minwidth100" type="text" class="flat" name="lastname" value="'.$object->lastname.'">';
2114  } else {
2115  print '<input type="hidden" name="lastname" value="'.$object->lastname.'">';
2116  print $object->lastname;
2117  }
2118  print '</td>';
2119  print '</tr>';
2120 
2121  // Firstname
2122  print '<tr><td>'.$langs->trans("Firstname").'</td>';
2123  print '<td>';
2124  if ($caneditfield && !$object->ldap_sid) {
2125  print '<input class="minwidth100" type="text" class="flat" name="firstname" value="'.$object->firstname.'">';
2126  } else {
2127  print '<input type="hidden" name="firstname" value="'.$object->firstname.'">';
2128  print $object->firstname;
2129  }
2130  print '</td></tr>';
2131 
2132  // Login
2133  print "<tr>".'<td><span class="fieldrequired">'.$langs->trans("Login").'</span></td>';
2134  print '<td>';
2135  if ($user->admin && !$object->ldap_sid) {
2136  print '<input maxlength="50" type="text" class="flat" name="login" value="'.$object->login.'">';
2137  } else {
2138  print '<input type="hidden" name="login" value="'.$object->login.'">';
2139  print $object->login;
2140  }
2141  print '</td>';
2142  print '</tr>';
2143 
2144  // Administrator
2145  print '<tr><td>'.$langs->trans("Administrator").'</td>';
2146  if ($object->socid > 0) {
2147  $langs->load("admin");
2148  print '<td>';
2149  print '<input type="hidden" name="admin" value="'.$object->admin.'">'.yn($object->admin);
2150  print ' ('.$langs->trans("ExternalUser").')';
2151  print '</td></tr>';
2152  } else {
2153  print '<td>';
2154  $nbAdmin = $user->getNbOfUsers('active', '', 1);
2155  $nbSuperAdmin = $user->getNbOfUsers('active', 'superadmin', 1);
2156  //var_dump($nbAdmin);
2157  //var_dump($nbSuperAdmin);
2158  if ($user->admin // Need to be admin to allow downgrade of an admin
2159  && ($user->id != $object->id) // Don't downgrade ourself
2160  && (
2161  (!isModEnabled('multicompany') && $nbAdmin >= 1)
2162  || (isModEnabled('multicompany') && (($object->entity > 0 || ($user->entity == 0 && $object->entity == 0)) || $nbSuperAdmin > 1)) // Don't downgrade a superadmin if alone
2163  )
2164  ) {
2165  print $form->selectyesno('admin', $object->admin, 1);
2166 
2167  if (isModEnabled('multicompany') && !$user->entity) {
2168  if ($conf->use_javascript_ajax) {
2169  print '<script type="text/javascript">
2170  $(function() {
2171  var admin = $("select[name=admin]").val();
2172  if (admin == 0) {
2173  $("input[name=superadmin]")
2174  .prop("disabled", true)
2175  .prop("checked", false);
2176  }
2177  if ($("input[name=superadmin]").is(":checked")) {
2178  $("select[name=entity]")
2179  .prop("disabled", true);
2180  }
2181  $("select[name=admin]").change(function() {
2182  if ( $(this).val() == 0 ) {
2183  $("input[name=superadmin]")
2184  .prop("disabled", true)
2185  .prop("checked", false);
2186  $("select[name=entity]")
2187  .prop("disabled", false);
2188  } else {
2189  $("input[name=superadmin]")
2190  .prop("disabled", false);
2191  }
2192  });
2193  $("input[name=superadmin]").change(function() {
2194  if ( $(this).is(":checked")) {
2195  $("select[name=entity]")
2196  .prop("disabled", true);
2197  } else {
2198  $("select[name=entity]")
2199  .prop("disabled", false);
2200  }
2201  });
2202  });
2203  </script>';
2204  }
2205 
2206  $checked = (($object->admin && !$object->entity) ? ' checked' : '');
2207  print '<input type="checkbox" name="superadmin" id="superadmin" value="1"'.$checked.' /> <label for="superadmin">'.$langs->trans("SuperAdministrator").'</span>';
2208  }
2209  } else {
2210  $yn = yn($object->admin);
2211  print '<input type="hidden" name="admin" value="'.$object->admin.'">';
2212  print '<input type="hidden" name="superadmin" value="'.(empty($object->entity) ? 1 : 0).'">';
2213  if (isModEnabled('multicompany') && empty($object->entity)) {
2214  print $form->textwithpicto($yn, $langs->trans("DontDowngradeSuperAdmin"), 1, 'warning');
2215  } else {
2216  print $yn;
2217  }
2218  }
2219  print '</td></tr>';
2220  }
2221 
2222  // Gender
2223  print '<tr><td>'.$langs->trans("Gender").'</td>';
2224  print '<td>';
2225  $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"), 'other'=>$langs->trans("Genderother"));
2226  if ($caneditfield) {
2227  print $form->selectarray('gender', $arraygender, GETPOSTISSET('gender') ?GETPOST('gender') : $object->gender, 1);
2228  } else {
2229  print $arraygender[$object->gender];
2230  }
2231  print '</td></tr>';
2232 
2233  // Employee
2234  print '<tr>';
2235  print '<td>'.$form->editfieldkey('Employee', 'employee', '', $object, 0).'</td><td>';
2236  if ($caneditfield) {
2237  print '<input type="checkbox" name="employee" value="1"'.($object->employee ? ' checked="checked"' : '').'>';
2238  //print $form->selectyesno("employee", $object->employee, 1);
2239  } else {
2240  print '<input type="checkbox" name="employee" disabled value="1"'.($object->employee ? ' checked="checked"' : '').'>';
2241  /*if ($object->employee) {
2242  print $langs->trans("Yes");
2243  } else {
2244  print $langs->trans("No");
2245  }*/
2246  }
2247  print '</td></tr>';
2248 
2249  // Hierarchy
2250  print '<tr><td class="titlefieldcreate">'.$langs->trans("HierarchicalResponsible").'</td>';
2251  print '<td>';
2252  if ($caneditfield) {
2253  print img_picto('', 'user').$form->select_dolusers($object->fk_user, 'fk_user', 1, array($object->id), 0, '', 0, $object->entity, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300');
2254  } else {
2255  print '<input type="hidden" name="fk_user" value="'.$object->fk_user.'">';
2256  $huser = new User($db);
2257  $huser->fetch($object->fk_user);
2258  print $huser->getNomUrl(1);
2259  }
2260  print '</td>';
2261  print "</tr>\n";
2262 
2263  // Expense report validator
2264  if (isModEnabled('expensereport')) {
2265  print '<tr><td class="titlefieldcreate">';
2266  $text = $langs->trans("ForceUserExpenseValidator");
2267  print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help');
2268  print '</td>';
2269  print '<td>';
2270  if ($caneditfield) {
2271  print img_picto('', 'user').$form->select_dolusers($object->fk_user_expense_validator, 'fk_user_expense_validator', 1, array($object->id), 0, '', 0, $object->entity, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300');
2272  } else {
2273  print '<input type="hidden" name="fk_user_expense_validator" value="'.$object->fk_user_expense_validator.'">';
2274  $evuser = new User($db);
2275  $evuser->fetch($object->fk_user_expense_validator);
2276  print $evuser->getNomUrl(1);
2277  }
2278  print '</td>';
2279  print "</tr>\n";
2280  }
2281 
2282  // Holiday request validator
2283  if (isModEnabled('holiday')) {
2284  print '<tr><td class="titlefieldcreate">';
2285  $text = $langs->trans("ForceUserHolidayValidator");
2286  print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help');
2287  print '</td>';
2288  print '<td>';
2289  if ($caneditfield) {
2290  print img_picto('', 'user').$form->select_dolusers($object->fk_user_holiday_validator, 'fk_user_holiday_validator', 1, array($object->id), 0, '', 0, $object->entity, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300');
2291  } else {
2292  print '<input type="hidden" name="fk_user_holiday_validator" value="'.$object->fk_user_holiday_validator.'">';
2293  $hvuser = new User($db);
2294  $hvuser->fetch($object->fk_user_holiday_validator);
2295  print $hvuser->getNomUrl(1);
2296  }
2297  print '</td>';
2298  print "</tr>\n";
2299  }
2300 
2301  // External user ?
2302  print '<tr><td>'.$langs->trans("ExternalUser").' ?</td>';
2303  print '<td>';
2304  if ($user->id == $object->id || !$user->admin) {
2305  // Read mode
2306  $type = $langs->trans("Internal");
2307  if ($object->socid) {
2308  $type = $langs->trans("External");
2309  }
2310  print $form->textwithpicto($type, $langs->trans("InternalExternalDesc"));
2311  if ($object->ldap_sid) {
2312  print ' ('.$langs->trans("DomainUser").')';
2313  }
2314  } else {
2315  // Select mode
2316  $type = 0;
2317  if ($object->contact_id) {
2318  $type = $object->contact_id;
2319  }
2320 
2321  if ($object->socid > 0 && !($object->contact_id > 0)) { // external user but no link to a contact
2322  print img_picto('', 'company').$form->select_company($object->socid, 'socid', '', '&nbsp;');
2323  print img_picto('', 'contact').$form->selectcontacts(0, 0, 'contactid', 1, '', '', 1, 'maxwidth300', false, 1);
2324  if ($object->ldap_sid) {
2325  print ' ('.$langs->trans("DomainUser").')';
2326  }
2327  } elseif ($object->socid > 0 && $object->contact_id > 0) { // external user with a link to a contact
2328  print img_picto('', 'company').$form->select_company($object->socid, 'socid', '', '&nbsp;'); // We keep thirdparty empty, contact is already set
2329  print img_picto('', 'contact').$form->selectcontacts(0, $object->contact_id, 'contactid', 1, '', '', 1, 'maxwidth300', false, 1);
2330  if ($object->ldap_sid) {
2331  print ' ('.$langs->trans("DomainUser").')';
2332  }
2333  } elseif (!($object->socid > 0) && $object->contact_id > 0) { // internal user with a link to a contact
2334  print img_picto('', 'company').$form->select_company(0, 'socid', '', '&nbsp;'); // We keep thirdparty empty, contact is already set
2335  print img_picto('', 'contact').$form->selectcontacts(0, $object->contact_id, 'contactid', 1, '', '', 1, 'maxwidth300', false, 1);
2336  if ($object->ldap_sid) {
2337  print ' ('.$langs->trans("DomainUser").')';
2338  }
2339  } else { // $object->socid is not > 0 here
2340  print img_picto('', 'company').$form->select_company(0, 'socid', '', '&nbsp;'); // We keep thirdparty empty, contact is already set
2341  print img_picto('', 'contact').$form->selectcontacts(0, 0, 'contactid', 1, '', '', 1, 'maxwidth300', false, 1);
2342  }
2343  }
2344  print '</td></tr>';
2345 
2346 
2347  print '</table>';
2348 
2349  print '<hr>';
2350 
2351  print '<table class="border centpercent">';
2352 
2353  // Date access validity
2354  print '<tr><td>'.$langs->trans("RangeOfLoginValidity").'</td>';
2355  print '<td>';
2356  if ($caneditfield) {
2357  print $form->selectDate($datestartvalidity ? $datestartvalidity : $object->datestartvalidity, 'datestartvalidity', 0, 0, 1, 'formdatestartvalidity', 1, 1, 0, '', '', '', '', 1, '', '');
2358  } else {
2359  print dol_print_date($object->datestartvalidity, 'day');
2360  }
2361 
2362  /*if ($datestartvalidity && $dateendvalidity) {
2363  print ' - ';
2364  }*/
2365  print ' &nbsp; ';
2366 
2367  if ($caneditfield) {
2368  print $form->selectDate($dateendvalidity ? $datendevalidity : $object->dateendvalidity, 'dateendvalidity', 0, 0, 1, 'formdateendvalidity', 1, 0, 0, '', '', '', '', 1, '', '');
2369  } else {
2370  print dol_print_date($object->dateendvalidity, 'day');
2371  }
2372  print '</td>';
2373  print "</tr>\n";
2374 
2375  // Pass
2376  print '<tr><td class="titlefieldcreate">'.$langs->trans("Password").'</td>';
2377  print '<td>';
2378  $valuetoshow = '';
2379  if (preg_match('/ldap/', $dolibarr_main_authentication)) {
2380  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("PasswordOfUserInLDAP");
2381  }
2382  if (preg_match('/http/', $dolibarr_main_authentication)) {
2383  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$form->textwithpicto($text, $langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless", $dolibarr_main_authentication), 1, 'warning');
2384  }
2385  if (preg_match('/dolibarr/', $dolibarr_main_authentication)) {
2386  if ($caneditpassword) {
2387  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').'<input maxlength="128" type="password" class="flat" name="password" value="'.dol_escape_htmltag($object->pass).'" autocomplete="new-password">';
2388  } else {
2389  $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').preg_replace('/./i', '*', $object->pass);
2390  }
2391  }
2392 
2393  // Other form for user password
2394  $parameters = array('valuetoshow' => $valuetoshow, 'caneditpassword' => $caneditpassword);
2395  $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2396  if ($reshook > 0) {
2397  $valuetoshow = $hookmanager->resPrint; // to replace
2398  } else {
2399  $valuetoshow .= $hookmanager->resPrint; // to add
2400  }
2401 
2402  print $valuetoshow;
2403  print "</td></tr>\n";
2404 
2405  // API key
2406  if (!empty($conf->api->enabled) && ($user->id == $id || $user->admin || $user->hasRight("api", "apikey", "generate"))) {
2407  print '<tr><td>'.$langs->trans("ApiKey").'</td>';
2408  print '<td>';
2409  print '<input class="minwidth300" maxsize="32" type="text" id="api_key" name="api_key" value="'.$object->api_key.'" autocomplete="off">';
2410  if (!empty($conf->use_javascript_ajax)) {
2411  print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"');
2412  }
2413  print '</td></tr>';
2414  }
2415 
2416  // OpenID url
2417  if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication) && !empty($conf->global->MAIN_OPENIDURL_PERUSER)) {
2418  print "<tr>".'<td>'.$langs->trans("OpenIDURL").'</td>';
2419  print '<td>';
2420  if ($caneditfield) {
2421  print '<input class="minwidth100" type="url" name="openid" class="flat" value="'.$object->openid.'">';
2422  } else {
2423  print '<input type="hidden" name="openid" value="'.$object->openid.'">';
2424  print $object->openid;
2425  }
2426  print '</td></tr>';
2427  }
2428 
2429  print '</table><hr><table class="border centpercent">';
2430 
2431 
2432  // Address
2433  print '<tr><td class="tdtop titlefieldcreate">'.$form->editfieldkey('Address', 'address', '', $object, 0).'</td>';
2434  print '<td>';
2435  if ($caneditfield) {
2436  print '<textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
2437  }
2438  print $object->address;
2439  if ($caneditfield) {
2440  print '</textarea>';
2441  }
2442  print '</td></tr>';
2443 
2444  // Zip
2445  print '<tr><td>'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).'</td><td>';
2446  if ($caneditfield) {
2447  print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
2448  } else {
2449  print $object->zip;
2450  }
2451  print '</td></tr>';
2452 
2453  // Town
2454  print '<tr><td>'.$form->editfieldkey('Town', 'town', '', $object, 0).'</td><td>';
2455  if ($caneditfield) {
2456  print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
2457  } else {
2458  print $object->town;
2459  }
2460  print '</td></tr>';
2461 
2462  // Country
2463  print '<tr><td>'.$form->editfieldkey('Country', 'selectcounty_id', '', $object, 0).'</td><td>';
2464  if ($caneditfield) {
2465  print $form->select_country((GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id), 'country_id');
2466  if ($user->admin) {
2467  print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2468  }
2469  } else {
2470  $countrylabel = getCountry($object->country_id, '0');
2471  print $countrylabel;
2472  }
2473  print '</td></tr>';
2474 
2475  // State
2476  if (empty($conf->global->USER_DISABLE_STATE)) {
2477  print '<tr><td class="tdoverflow">'.$form->editfieldkey('State', 'state_id', '', $object, 0).'</td><td>';
2478  if ($caneditfield) {
2479  print img_picto('', 'state', 'class="pictofixedwidth"');
2480  print $formcompany->select_state($object->state_id, $object->country_code, 'state_id');
2481  } else {
2482  print $object->state_label;
2483  }
2484  print '</td></tr>';
2485  }
2486 
2487  // Tel pro
2488  print "<tr>".'<td>'.$langs->trans("PhonePro").'</td>';
2489  print '<td>';
2490  print img_picto('', 'phoning', 'class="pictofixedwidth"');
2491  if ($caneditfield && empty($object->ldap_sid)) {
2492  print '<input type="text" name="office_phone" class="flat maxwidth200" value="'.$object->office_phone.'">';
2493  } else {
2494  print '<input type="hidden" name="office_phone" value="'.$object->office_phone.'">';
2495  print $object->office_phone;
2496  }
2497  print '</td></tr>';
2498 
2499  // Tel mobile
2500  print "<tr>".'<td>'.$langs->trans("PhoneMobile").'</td>';
2501  print '<td>';
2502  print img_picto('', 'phoning_mobile', 'class="pictofixedwidth"');
2503  if ($caneditfield && empty($object->ldap_sid)) {
2504  print '<input type="text" name="user_mobile" class="flat maxwidth200" value="'.$object->user_mobile.'">';
2505  } else {
2506  print '<input type="hidden" name="user_mobile" value="'.$object->user_mobile.'">';
2507  print $object->user_mobile;
2508  }
2509  print '</td></tr>';
2510 
2511  // Fax
2512  print "<tr>".'<td>'.$langs->trans("Fax").'</td>';
2513  print '<td>';
2514  print img_picto('', 'phoning_fax', 'class="pictofixedwidth"');
2515  if ($caneditfield && empty($object->ldap_sid)) {
2516  print '<input type="text" name="office_fax" class="flat maxwidth200" value="'.$object->office_fax.'">';
2517  } else {
2518  print '<input type="hidden" name="office_fax" value="'.$object->office_fax.'">';
2519  print $object->office_fax;
2520  }
2521  print '</td></tr>';
2522 
2523  // EMail
2524  print "<tr>".'<td'.(!empty($conf->global->USER_MAIL_REQUIRED) ? ' class="fieldrequired"' : '').'>'.$langs->trans("EMail").'</td>';
2525  print '<td>';
2526  print img_picto('', 'object_email', 'class="pictofixedwidth"');
2527  if ($caneditfield && empty($object->ldap_sid)) {
2528  print '<input class="minwidth100 maxwidth500 widthcentpercentminusx" type="text" name="email" class="flat" value="'.$object->email.'">';
2529  } else {
2530  print '<input type="hidden" name="email" value="'.$object->email.'">';
2531  print $object->email;
2532  }
2533  print '</td></tr>';
2534 
2535  if (isModEnabled('socialnetworks')) {
2536  foreach ($socialnetworks as $key => $value) {
2537  if ($value['active']) {
2538  print '<tr><td>'.$langs->trans($value['label']).'</td>';
2539  print '<td>';
2540  if (!empty($value['icon'])) {
2541  print '<span class="fa '.$value['icon'].' pictofixedwidth"></span>';
2542  }
2543  if ($caneditfield && empty($object->ldap_sid)) {
2544  print '<input type="text" name="'.$key.'" class="flat maxwidth200" value="'.(isset($object->socialnetworks[$key])?$object->socialnetworks[$key]:'').'">';
2545  } else {
2546  print '<input type="hidden" name="'.$key.'" value="'.$object->socialnetworks[$key].'">';
2547  print $object->socialnetworks[$key];
2548  }
2549  print '</td></tr>';
2550  } else {
2551  // if social network is not active but value exist we do not want to loose it
2552  print '<input type="hidden" name="'.$key.'" value="'.(isset($object->socialnetworks[$key])?$object->socialnetworks[$key]:'').'">';
2553  }
2554  }
2555  }
2556 
2557  print '</table><hr><table class="border centpercent">';
2558 
2559  // Default warehouse
2560  if (isModEnabled('stock') && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
2561  print '<tr><td class="titlefield">'.$langs->trans("DefaultWarehouse").'</td><td>';
2562  print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1);
2563  print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&token='.newToken().'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit&token='.newToken()).'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddWarehouse").'"></span></a>';
2564  print '</td></tr>';
2565  }
2566 
2567  // Accountancy code
2568  if (isModEnabled('accounting')) {
2569  print "<tr>";
2570  print '<td class="titlefieldcreate">'.$langs->trans("AccountancyCode").'</td>';
2571  print '<td>';
2572  if ($caneditfield) {
2573  print '<input type="text" class="flat maxwidth300" name="accountancy_code" value="'.$object->accountancy_code.'">';
2574  } else {
2575  print '<input type="hidden" name="accountancy_code" value="'.$object->accountancy_code.'">';
2576  print $object->accountancy_code;
2577  }
2578  print '</td>';
2579  print "</tr>";
2580  }
2581 
2582  // User color
2583  if (isModEnabled('agenda')) {
2584  print '<tr><td class="titlefieldcreate">'.$langs->trans("ColorUser").'</td>';
2585  print '<td>';
2586  if ($caneditfield) {
2587  print $formother->selectColor(GETPOSTISSET('color') ?GETPOST('color', 'alphanohtml') : $object->color, 'color', null, 1, '', 'hideifnotset');
2588  } else {
2589  print $formother->showColor($object->color, '');
2590  }
2591  print '</td></tr>';
2592  }
2593 
2594  // Photo
2595  print '<tr>';
2596  print '<td class="titlefieldcreate">'.$langs->trans("Photo").'</td>';
2597  print '<td>';
2598  print $form->showphoto('userphoto', $object, 60, 0, $caneditfield, 'photowithmargin', 'small', 1, 0, 'user', 1);
2599  print '</td>';
2600  print '</tr>';
2601 
2602  // Categories
2603  if (isModEnabled('categorie') && $user->hasRight("categorie", "read")) {
2604  print '<tr><td>'.$form->editfieldkey('Categories', 'usercats', '', $object, 0).'</td>';
2605  print '<td>';
2606  print img_picto('', 'category', 'class="pictofixedwidth"');
2607  $cate_arbo = $form->select_all_categories(Categorie::TYPE_USER, null, null, null, null, 1);
2608  $c = new Categorie($db);
2609  $cats = $c->containing($object->id, Categorie::TYPE_USER);
2610  $arrayselected = array();
2611  foreach ($cats as $cat) {
2612  $arrayselected[] = $cat->id;
2613  }
2614  if ($caneditfield) {
2615  print $form->multiselectarray('usercats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%');
2616  } else {
2617  print $form->showCategories($object->id, Categorie::TYPE_USER, 1);
2618  }
2619  print "</td></tr>";
2620  }
2621 
2622  // Default language
2623  if (getDolGlobalInt('MAIN_MULTILANGS')) {
2624  print '<tr><td>'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0, 'string', '', 0, 0, 'id', $langs->trans("WarningNotLangOfInterface", $langs->transnoentitiesnoconv("UserGUISetup"))).'</td><td colspan="3">'."\n";
2625  print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language($object->lang, 'default_lang', 0, null, '1', 0, 0, 'widthcentpercentminusx maxwidth300');
2626  print '</td>';
2627  print '</tr>';
2628  }
2629 
2630  // Status
2631  print '<tr><td>'.$langs->trans("Status").'</td>';
2632  print '<td>';
2633  print $object->getLibStatut(4);
2634  print '</td></tr>';
2635 
2636  // Company / Contact
2637  if (isModEnabled("societe")) {
2638  print '<tr><td>'.$langs->trans("LinkToCompanyContact").'</td>';
2639  print '<td>';
2640  if ($object->socid > 0) {
2641  $societe = new Societe($db);
2642  $societe->fetch($object->socid);
2643  print $societe->getNomUrl(1, '');
2644  if ($object->contact_id) {
2645  $contact = new Contact($db);
2646  $contact->fetch($object->contact_id);
2647  print ' / <a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$object->contact_id.'">'.img_object($langs->trans("ShowContact"), 'contact').' '.dol_trunc($contact->getFullName($langs), 32).'</a>';
2648  }
2649  } else {
2650  print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ThisUserIsNot").'</span>';
2651  }
2652  print ' <span class="opacitymedium hideonsmartphone">('.$langs->trans("UseTypeFieldToChange").')</span>';
2653  print '</td>';
2654  print "</tr>\n";
2655  }
2656 
2657  // Module Adherent
2658  if (isModEnabled('adherent')) {
2659  $langs->load("members");
2660  print '<tr><td>'.$langs->trans("LinkedToDolibarrMember").'</td>';
2661  print '<td>';
2662  if ($object->fk_member) {
2663  $adh = new Adherent($db);
2664  $adh->fetch($object->fk_member);
2665  $adh->ref = $adh->login; // Force to show login instead of id
2666  print $adh->getNomUrl(1);
2667  } else {
2668  print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("UserNotLinkedToMember").'</span>';
2669  }
2670  print '</td>';
2671  print "</tr>\n";
2672  }
2673 
2674  // Multicompany
2675  // TODO check if user not linked with the current entity before change entity (thirdparty, invoice, etc.) !!
2676  if (isModEnabled('multicompany') && is_object($mc)) {
2677  // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module
2678  if (!method_exists($mc, 'formObjectOptions')) {
2679  if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && !$user->entity) {
2680  print "<tr>".'<td>'.$langs->trans("Entity").'</td>';
2681  print "<td>".$mc->select_entities($object->entity, 'entity', '', 0, 1, false, false, 1); // last parameter 1 means, show also a choice 0=>'all entities'
2682  print "</td></tr>\n";
2683  } else {
2684  print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
2685  }
2686  }
2687  }
2688 
2689  // Other attributes
2690  $parameters = array('colspan' => ' colspan="2"');
2691  //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; // We do not use common tpl here because we need a special test on $caneditfield
2692  $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2693  print $hookmanager->resPrint;
2694  if (empty($reshook)) {
2695  if ($caneditfield) {
2696  print $object->showOptionals($extrafields, 'edit');
2697  } else {
2698  print $object->showOptionals($extrafields, 'view');
2699  }
2700  }
2701 
2702  // Signature
2703  print '<tr><td class="tdtop">'.$langs->trans("Signature").'</td>';
2704  print '<td>';
2705  if ($caneditfield) {
2706  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
2707 
2708  $doleditor = new DolEditor('signature', $object->signature, '', 138, 'dolibarr_notes', 'In', false, $acceptlocallinktomedia, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4, '90%');
2709  print $doleditor->Create(1);
2710  } else {
2711  print dol_htmlentitiesbr($object->signature);
2712  }
2713  print '</td></tr>';
2714 
2715 
2716  print '</table>';
2717 
2718  print '<hr>';
2719 
2720 
2721  print '<table class="border centpercent">';
2722 
2723 
2724  // TODO Move this into tab RH (HierarchicalResponsible must be on both tab)
2725 
2726  // Position/Job
2727  print '<tr><td class="titlefieldcreate">'.$langs->trans("PostOrFunction").'</td>';
2728  print '<td>';
2729  if ($caneditfield) {
2730  print '<input type="text" class="minwidth300 maxwidth500" name="job" value="'.dol_escape_htmltag($object->job).'">';
2731  } else {
2732  print '<input type="hidden" name="job" value="'.dol_escape_htmltag($object->job).'">';
2733  print dol_escape_htmltag($object->job);
2734  }
2735  print '</td></tr>';
2736 
2737  // Weeklyhours
2738  print '<tr><td>'.$langs->trans("WeeklyHours").'</td>';
2739  print '<td>';
2740  if ($caneditfield) {
2741  print '<input size="8" type="text" name="weeklyhours" value="'.price2num(GETPOST('weeklyhours') ?GETPOST('weeklyhours') : $object->weeklyhours).'">';
2742  } else {
2743  print price2num($object->weeklyhours);
2744  }
2745  print '</td>';
2746  print "</tr>\n";
2747 
2748  // Sensitive salary/value information
2749  if ((empty($user->socid) && in_array($id, $childids)) // A user can always see salary/value information for its subordinates
2750  || (!empty($conf->salaries->enabled) && $user->hasRight("salaries", "readall"))
2751  || (isModEnabled('hrm') && $user->hasRight("hrm", "employee", "read"))) {
2752  $langs->load("salaries");
2753 
2754  // Salary
2755  print '<tr><td>'.$langs->trans("Salary").'</td>';
2756  print '<td>';
2757  print img_picto('', 'salary', 'class="pictofixedwidth paddingright"').'<input size="8" type="text" name="salary" value="'.price2num(GETPOST('salary') ?GETPOST('salary') : $object->salary).'">';
2758  print '</td>';
2759  print "</tr>\n";
2760 
2761  // THM
2762  print '<tr><td>';
2763  $text = $langs->trans("THM");
2764  print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm');
2765  print '</td>';
2766  print '<td>';
2767  if ($caneditfield) {
2768  print '<input size="8" type="text" name="thm" value="'.price2num(GETPOST('thm') ?GETPOST('thm') : $object->thm).'">';
2769  } else {
2770  print ($object->thm != '' ?price($object->thm, '', $langs, 1, -1, -1, $conf->currency) : '');
2771  }
2772  print '</td>';
2773  print "</tr>\n";
2774 
2775  // TJM
2776  print '<tr><td>';
2777  $text = $langs->trans("TJM");
2778  print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classthm');
2779  print '</td>';
2780  print '<td>';
2781  if ($caneditfield) {
2782  print '<input size="8" type="text" name="tjm" value="'.price2num(GETPOST('tjm') ?GETPOST('tjm') : $object->tjm).'">';
2783  } else {
2784  print ($object->tjm != '' ?price($object->tjm, '', $langs, 1, -1, -1, $conf->currency) : '');
2785  }
2786  print '</td>';
2787  print "</tr>\n";
2788  }
2789 
2790  // Date employment
2791  print '<tr><td>'.$langs->trans("DateEmployment").'</td>';
2792  print '<td>';
2793  if ($caneditfield) {
2794  print $form->selectDate($dateemployment ? $dateemployment : $object->dateemployment, 'dateemployment', 0, 0, 1, 'formdateemployment', 1, 1);
2795  } else {
2796  print dol_print_date($object->dateemployment, 'day');
2797  }
2798 
2799  if ($dateemployment && $dateemploymentend) {
2800  print ' - ';
2801  }
2802 
2803  if ($caneditfield) {
2804  print $form->selectDate($dateemploymentend ? $dateemploymentend : $object->dateemploymentend, 'dateemploymentend', 0, 0, 1, 'formdateemploymentend', 1, 0);
2805  } else {
2806  print dol_print_date($object->dateemploymentend, 'day');
2807  }
2808  print '</td>';
2809  print "</tr>\n";
2810 
2811  // Date birth
2812  print '<tr><td>'.$langs->trans("DateOfBirth").'</td>';
2813  print '<td>';
2814  if ($caneditfield) {
2815  echo $form->selectDate($dateofbirth ? $dateofbirth : $object->birth, 'dateofbirth', 0, 0, 1, 'updateuser', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver');
2816  } else {
2817  print dol_print_date($object->birth, 'day', 'tzserver');
2818  }
2819  print '</td>';
2820  print "</tr>\n";
2821 
2822  print '</table>';
2823 
2824  print dol_get_fiche_end();
2825 
2826  print '<div class="center">';
2827  print '<input value="'.$langs->trans("Save").'" class="button button-save" type="submit" name="save">';
2828  print '&nbsp; &nbsp; &nbsp;';
2829  print '<input value="'.$langs->trans("Cancel").'" class="button button-cancel" type="submit" name="cancel">';
2830  print '</div>';
2831 
2832  print '</form>';
2833  }
2834 
2835  if ($action != 'edit' && $action != 'presend') {
2836  print '<div class="fichecenter"><div class="fichehalfleft">';
2837 
2838  // Generated documents
2839  $filename = dol_sanitizeFileName($object->ref);
2840  $filedir = $conf->user->dir_output."/".dol_sanitizeFileName($object->ref);
2841  $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
2842  $genallowed = $user->hasRight("user", "user", "read");
2843  $delallowed = $user->hasRight("user", "user", "write");
2844 
2845  print $formfile->showdocuments('user', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', 0, '', empty($soc->default_lang) ? '' : $soc->default_lang);
2846  $somethingshown = $formfile->numoffiles;
2847 
2848  // Show links to link elements
2849  $linktoelem = $form->showLinkToObjectBlock($object, null, null);
2850  $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
2851 
2852  print '</div><div class="fichehalfright">';
2853 
2854  // List of actions on element
2855  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
2856  $formactions = new FormActions($db);
2857  $somethingshown = $formactions->showactions($object, 'user', $socid, 1, 'listactions', 0, '', '', $object->id);
2858 
2859  print '</div></div>';
2860  }
2861 
2862  if (!empty($conf->ldap->enabled) && !empty($object->ldap_sid)) {
2863  $ldap->unbind();
2864  }
2865  }
2866 }
2867 
2868 if (!empty($conf->api->enabled)) {
2869  $constname = 'api_key';
2870 
2871  // Add button to autosuggest a key
2872  include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
2873  print dolJSToSetRandomPassword($constname, 'generate_api_key');
2874 }
2875 
2876 // End of page
2877 llxFooter();
2878 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif($action=='specimen') elseif($action=='setmodel') elseif($action=='del') elseif($action=='setdoc') $formactions
View.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:449
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage members of a foundation.
Class to manage categories.
Class to manage contact/addresses.
Class to manage a WYSIWYG editor.
Class to manage warehouses.
Class to manage standard extra fields.
Class to manage building of HTML components.
Class to generate html code for admin pages.
Class to build HTML component for third parties management Only common components are here.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Classe permettant la generation de composants html autre Only common components are here.
Class with static methods for building HTML components related to products Only components common to ...
Class to manage LDAP features.
Definition: ldap.class.php:35
const SYNCHRO_LDAP_TO_DOLIBARR
Ldap to Dolibarr synchronization.
Definition: ldap.class.php:138
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage user groups.
Class to manage Dolibarr users.
Definition: user.class.php:45
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
$parameters
Actions.
Definition: card.php:79
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
Definition: files.lib.php:1401
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
Definition: files.lib.php:1250
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles='addedfile', $upload_dir='')
Make control on an uploaded file from an GUI page and move it to final destination.
Definition: files.lib.php:1111
acceptLocalLinktoMedia()
Check the syntax of some PHP code.
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.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
GETPOSTINT($paramname, $method=0)
Return value of a param into GET or POST supervariable.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
getArrayOfSocialNetworks()
Get array of social network dictionary.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
Definition: images.lib.php:58
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token')
Ouput javacript to autoset a generated password using default module into a HTML element.
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
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.