40require_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/commonpeople.class.php';
56 public $element =
'user';
61 public $table_element =
'user';
66 public $fk_element =
'fk_user';
71 public $picto =
'user';
110 public $civility_code;
135 public $email_oauth2;
140 public $personal_email;
145 public $socialnetworks;
160 public $office_phone;
175 public $personal_mobile;
200 public $pass_crypted;
205 public $pass_indatabase;
210 public $pass_indatabase_crypted;
220 public $force_pass_change = 0;
259 public $fk_user_expense_validator;
264 public $fk_user_holiday_validator;
269 public $clicktodial_url;
274 public $clicktodial_login;
279 public $clicktodial_password;
284 public $clicktodial_poste;
289 public $clicktodial_loaded;
295 public $datelastpassvalidation;
299 public $datelastlogin;
303 public $datepreviouslogin;
307 public $flagdelsessionsbefore;
315 public $ippreviouslogin;
319 public $datestartvalidity;
323 public $dateendvalidity;
343 public $all_permissions_are_loaded;
353 public $user_group_list;
358 private $_tab_loaded = array();
368 public $default_values;
373 public $lastsearch_values_tmp;
377 public $lastsearch_values;
382 public $users = array();
390 private $cache_childids;
396 public $accountancy_code_user_general;
401 public $accountancy_code;
433 public $dateemployment;
437 public $dateemploymentend;
442 public $default_c_exp_tax_cat;
447 public $ref_employee;
452 public $national_registration_number;
457 public $default_range;
462 public $fk_warehouse;
467 public $fk_establishment;
472 public $label_establishment;
478 public $usergroup_entity;
480 public $fields = array(
481 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -2,
'notnull' => 1,
'index' => 1,
'position' => 1,
'comment' =>
'Id'),
482 'lastname' => array(
'type' =>
'varchar(50)',
'label' =>
'Lastname',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'showoncombobox' => 1,
'index' => 1,
'position' => 20,
'searchall' => 1),
483 'firstname' => array(
'type' =>
'varchar(50)',
'label' =>
'Firstname',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'showoncombobox' => 1,
'index' => 1,
'position' => 10,
'searchall' => 1),
484 'ref_employee' => array(
'type' =>
'varchar(50)',
'label' =>
'RefEmployee',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'showoncombobox' => 1,
'index' => 1,
'position' => 30,
'searchall' => 1),
485 'national_registration_number' => array(
'type' =>
'varchar(50)',
'label' =>
'NationalRegistrationNumber',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'showoncombobox' => 1,
'index' => 1,
'position' => 40,
'searchall' => 1)
488 const STATUS_DISABLED = 0;
489 const STATUS_ENABLED = 1;
500 $this->ismultientitymanaged = 1;
501 $this->isextrafieldmanaged = 1;
503 $this->clicktodial_loaded = 0;
506 $this->all_permissions_are_loaded = 0;
507 $this->nb_rights = 0;
515 $this->rights->user =
new stdClass();
516 $this->rights->user->user =
new stdClass();
517 $this->rights->user->self =
new stdClass();
518 $this->rights->user->user_advance =
new stdClass();
519 $this->rights->user->self_advance =
new stdClass();
520 $this->rights->user->group_advance =
new stdClass();
537 public function fetch($id = 0, $login =
'', $sid =
'', $loadpersonalconf = 0, $entity = -1, $email =
'', $fk_socpeople = 0, $use_email_oauth2 = 0)
542 $login = trim($login);
545 $sql =
"SELECT u.rowid, u.lastname, u.firstname, u.employee, u.gender, u.civility as civility_code, u.birth, u.job,";
546 $sql .=
" u.email, u.email_oauth2, u.personal_email,";
547 $sql .=
" u.socialnetworks,";
548 $sql .=
" u.signature, u.office_phone, u.office_fax, u.user_mobile, u.personal_mobile,";
549 $sql .=
" u.address, u.zip, u.town, u.fk_state as state_id, u.fk_country as country_id,";
550 $sql .=
" u.admin, u.login, u.note_private, u.note_public,";
551 $sql .=
" u.pass, u.pass_crypted, u.pass_temp, u.force_pass_change, u.api_key,";
552 $sql .=
" u.fk_soc, u.fk_socpeople, u.fk_member, u.fk_user, u.ldap_sid, u.fk_user_expense_validator, u.fk_user_holiday_validator,";
553 $sql .=
" fk_user_creat as user_creation_id, fk_user_modif as user_modification_id,";
554 $sql .=
" u.statut as status, u.lang, u.entity,";
555 $sql .=
" u.datec as datec,";
556 $sql .=
" GREATEST(u.tms, uef.tms) as datem,";
557 $sql .=
" u.datelastlogin as datel,";
558 $sql .=
" u.datepreviouslogin as datep,";
559 $sql .=
" u.flagdelsessionsbefore,";
560 $sql .=
" u.iplastlogin,";
561 $sql .=
" u.ippreviouslogin,";
562 $sql .=
" u.datelastpassvalidation,";
563 $sql .=
" u.datestartvalidity,";
564 $sql .=
" u.dateendvalidity,";
565 $sql .=
" u.photo as photo,";
566 $sql .=
" u.openid as openid,";
567 $sql .=
" u.accountancy_code_user_general,";
568 $sql .=
" u.accountancy_code,";
571 $sql .=
" u.salary,";
572 $sql .=
" u.salaryextra,";
573 $sql .=
" u.weeklyhours,";
575 $sql .=
" u.dateemployment, u.dateemploymentend,";
576 $sql .=
" u.fk_warehouse,";
577 $sql .=
" u.ref_ext,";
578 $sql .=
" u.default_range, u.default_c_exp_tax_cat,";
579 $sql .=
" u.national_registration_number,";
580 $sql .=
" u.ref_employee,";
581 $sql .=
" c.code as country_code, c.label as country,";
582 $sql .=
" d.code_departement as state_code, d.nom as state,";
583 $sql .=
" s.label as label_establishment, u.fk_establishment";
584 $sql .=
" FROM ".$this->db->prefix().
"user as u";
585 $sql .=
" LEFT JOIN ".$this->db->prefix().
"user_extrafields as uef ON uef.fk_object = u.rowid";
586 $sql .=
" LEFT JOIN ".$this->db->prefix().
"c_country as c ON u.fk_country = c.rowid";
587 $sql .=
" LEFT JOIN ".$this->db->prefix().
"c_departements as d ON u.fk_state = d.rowid";
588 $sql .=
" LEFT JOIN ".$this->db->prefix().
"establishment as s ON u.fk_establishment = s.rowid";
591 $sql .=
" WHERE u.rowid = ".((int) $id);
595 $sql .=
" WHERE u.entity IN (0, " . ((int)
$conf->entity) .
")";
597 $sql .=
" WHERE u.entity IS NOT NULL";
602 $sql .=
" WHERE u.entity IS NOT NULL";
604 if ($entity !=
'' && $entity == 0) {
605 $sql .=
" WHERE u.entity = 0";
607 $sql .=
" WHERE u.entity IN (0, " . ((int) ($entity > 0 ? ((
int) $entity) : ((int)
$conf->entity))) .
")";
615 $sql .=
" AND (u.ldap_sid = '".$this->db->escape($sid).
"' OR u.login = '".$this->db->escape($login).
"')";
617 $sql .=
" AND u.login = '".$this->db->escape($login).
"'";
619 $sql .=
" AND (u.email = '".$this->db->escape($email).
"'";
620 if ($use_email_oauth2) {
621 $sql .=
" OR u.email_oauth2 = '".$this->db->escape($email).
"'";
624 } elseif ($fk_socpeople > 0) {
625 $sql .=
" AND u.fk_socpeople = ".((int) $fk_socpeople);
628 $sql .=
" ORDER BY u.entity ASC";
632 $sql .=
' '.$this->db->plimit(1);
635 $resql = $this->db->query($sql);
637 $num = $this->db->num_rows($resql);
639 $this->
error =
"USERDUPLICATEFOUND";
640 dol_syslog(get_class($this).
"::fetch more than 1 user found", LOG_WARNING);
642 $this->db->free($resql);
646 $obj = $this->db->fetch_object($resql);
648 $this->
id = $obj->rowid;
649 $this->
ref = $obj->rowid;
651 $this->ref_ext = $obj->ref_ext;
653 $this->ldap_sid = $obj->ldap_sid;
654 $this->civility_code = $obj->civility_code;
655 $this->lastname = $obj->lastname;
656 $this->firstname = $obj->firstname;
657 $this->ref_employee = $obj->ref_employee;
658 $this->national_registration_number = $obj->national_registration_number;
660 $this->employee = $obj->employee;
662 $this->login = $obj->login;
663 $this->gender = $obj->gender;
664 $this->birth = $this->db->jdate($obj->birth);
665 $this->pass_indatabase = $obj->pass;
666 $this->pass_indatabase_crypted = $obj->pass_crypted;
667 $this->pass = $obj->pass;
668 $this->pass_temp = $obj->pass_temp;
670 $this->force_pass_change = $obj->force_pass_change;
671 $this->datelastpassvalidation = $this->db->jdate($obj->datelastpassvalidation);
675 $this->
address = $obj->address;
676 $this->zip = $obj->zip;
677 $this->town = $obj->town;
679 $this->country_id = $obj->country_id;
680 $this->country_code = $obj->country_id ? $obj->country_code :
'';
683 $this->state_id = $obj->state_id;
684 $this->state_code = $obj->state_code;
685 $this->state = ($obj->state !=
'-' ? $obj->state :
'');
687 $this->office_phone = $obj->office_phone;
688 $this->office_fax = $obj->office_fax;
689 $this->user_mobile = $obj->user_mobile;
690 $this->personal_mobile = $obj->personal_mobile;
691 $this->
email = $obj->email;
692 $this->email_oauth2 = $obj->email_oauth2;
693 $this->personal_email = $obj->personal_email;
694 $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks,
true) : array());
695 $this->user_creation_id = $obj->user_creation_id;
696 $this->user_modification_id = $obj->user_modification_id;
698 $this->job = $obj->job;
699 $this->signature = $obj->signature;
700 $this->admin = $obj->admin;
701 $this->note_public = $obj->note_public;
702 $this->note_private = $obj->note_private;
704 $this->statut = $obj->status;
705 $this->
status = $obj->status;
707 $this->photo = $obj->photo;
708 $this->openid = $obj->openid;
709 $this->lang = $obj->lang;
710 $this->entity = $obj->entity;
712 $this->accountancy_code_user_general = $obj->accountancy_code_user_general;
713 $this->accountancy_code = $obj->accountancy_code;
715 $this->thm = $obj->thm;
716 $this->tjm = $obj->tjm;
717 $this->salary = $obj->salary;
718 $this->salaryextra = $obj->salaryextra;
719 $this->weeklyhours = $obj->weeklyhours;
720 $this->color = $obj->color;
721 $this->dateemployment = $this->db->jdate($obj->dateemployment);
722 $this->dateemploymentend = $this->db->jdate($obj->dateemploymentend);
724 $this->datec = $this->db->jdate($obj->datec);
725 $this->datem = $this->db->jdate($obj->datem);
726 $this->datelastlogin = $this->db->jdate($obj->datel);
727 $this->datepreviouslogin = $this->db->jdate($obj->datep);
728 $this->flagdelsessionsbefore = $this->db->jdate($obj->flagdelsessionsbefore,
'gmt');
729 $this->iplastlogin = $obj->iplastlogin;
730 $this->ippreviouslogin = $obj->ippreviouslogin;
731 $this->datestartvalidity = $this->db->jdate($obj->datestartvalidity);
732 $this->dateendvalidity = $this->db->jdate($obj->dateendvalidity);
734 $this->socid = $obj->fk_soc;
735 $this->contact_id = $obj->fk_socpeople;
736 $this->fk_member = $obj->fk_member;
737 $this->fk_user = $obj->fk_user;
738 $this->fk_user_expense_validator = $obj->fk_user_expense_validator;
739 $this->fk_user_holiday_validator = $obj->fk_user_holiday_validator;
741 $this->default_range = $obj->default_range;
742 $this->default_c_exp_tax_cat = $obj->default_c_exp_tax_cat;
743 $this->fk_warehouse = $obj->fk_warehouse;
744 $this->fk_establishment = $obj->fk_establishment;
745 $this->label_establishment = $obj->label_establishment;
749 if (!
isModEnabled(
'multicompany') && $this->admin && $this->entity == 1) {
757 $this->db->free($resql);
759 $this->
error =
"USERNOTFOUND";
760 dol_syslog(get_class($this).
"::fetch user not found", LOG_DEBUG);
762 $this->db->free($resql);
766 $this->
error = $this->db->lasterror();
771 if ($loadpersonalconf) {
777 $this->
error = $this->db->lasterror();
784 if (
GETPOSTINT(
'forceexternaluser') && $this->admin && empty($this->socid)) {
785 $this->socid =
GETPOSTINT(
'forceexternaluser');
803 $sql =
"SELECT param, value FROM ".$this->db->prefix().
"user_param";
804 $sql .=
" WHERE fk_user = ".((int) $this->
id);
806 $sql .=
" AND entity IN (0, ".((int)
$conf->entity).
")";
808 $sql .=
" AND entity = ".((int) $entity);
812 $resql = $this->db->query($sql);
814 $num = $this->db->num_rows($resql);
817 $obj = $this->db->fetch_object($resql);
818 $p = (!empty($obj->param) ? $obj->param :
'');
820 $this->
conf->$p = $obj->value;
824 $this->db->free($resql);
828 $this->
error = $this->db->lasterror();
845 require_once DOL_DOCUMENT_ROOT.
'/core/class/defaultvalues.class.php';
848 $result = $defaultValues->fetchAll(
'',
'', 0, 0,
'(t.user_id:in:0,'.$this->
id.
') AND (entity:in:'.(isset($this->entity) ? $this->entity :
$conf->entity).
','.
$conf->entity.
')');
851 if (!is_array($result) && $result < 0) {
855 } elseif (count($result) > 0) {
856 foreach ($result as $defval) {
857 if (!empty($defval->page) && !empty($defval->type) && !empty($defval->param)) {
858 $pagewithoutquerystring = $defval->page;
861 if (preg_match(
'/^([^\?]+)\?(.*)$/', $pagewithoutquerystring, $reg)) {
862 $pagewithoutquerystring = $reg[1];
863 $pagequeries = $reg[2];
865 $this->default_values[$pagewithoutquerystring][$defval->type][$pagequeries ? $pagequeries :
'_noquery_'][$defval->param] = $defval->value;
869 if (!empty($this->default_values)) {
870 foreach ($this->default_values as $a => $b) {
871 foreach ($b as
$c => $d) {
872 krsort($this->default_values[$a][
$c]);
913 public function hasRight($module, $permlevel1, $permlevel2 =
'')
916 $moduletomoduletouse = array(
917 'category' =>
'categorie',
918 'compta' =>
'comptabilite',
919 'contract' =>
'contrat',
920 'member' =>
'adherent',
922 'order' =>
'commande',
923 'produit' =>
'product',
924 'productlot' =>
'product',
925 'project' =>
'projet',
926 'propale' =>
'propal',
927 'shipping' =>
'expedition',
928 'task' =>
'task@projet',
929 'fichinter' =>
'ficheinter',
930 'intervention' =>
'ficheinter',
931 'inventory' =>
'stock',
932 'invoice' =>
'facture',
933 'invoice_supplier' =>
'facture@fournisseur',
934 'order_supplier' =>
'fournisseur',
935 'knowledgerecord' =>
'knowledgerecord@knowledgemanagement',
936 'skill@hrm' =>
'all@hrm',
937 'job@hrm' =>
'all@hrm',
938 'position@hrm' =>
'all@hrm',
939 'facturerec' =>
'facture',
940 'margins' =>
'margin',
943 if (!empty($moduletomoduletouse[$module])) {
944 $module = $moduletomoduletouse[$module];
955 $supplierNewToLegacy = array(
956 'supplier_order' => array(
'fournisseur',
'commande'),
957 'supplier_invoice' => array(
'fournisseur',
'facture'),
960 if (isset($supplierNewToLegacy[$module])) {
963 $permlevel2 = $permlevel1;
964 $permlevel1 = $supplierNewToLegacy[$module][1];
965 $module = $supplierNewToLegacy[$module][0];
970 $supplierLegacyCompat = array(
971 'supplier_order' =>
'fournisseur',
972 'supplier_invoice' =>
'fournisseur',
975 if (isset($supplierLegacyCompat[$module])) {
977 $module = $supplierLegacyCompat[$module];
981 $moduleRightsMapping = array(
982 'product' =>
'produit',
983 'margin' =>
'margins',
984 'comptabilite' =>
'compta'
987 $rightsPath = $module;
988 if (!empty($moduleRightsMapping[$rightsPath])) {
989 $rightsPath = $moduleRightsMapping[$rightsPath];
993 $tmp = explode(
'@', $rightsPath, 2);
994 if (!empty($tmp[1])) {
995 if (strpos($module,
'@') !==
false) {
998 if ($tmp[0] != $tmp[1]) {
1000 $rightsPath = $tmp[1];
1001 $permlevel2 = $permlevel1;
1002 $permlevel1 = $tmp[0];
1005 $rightsPath = $tmp[1];
1020 if (!empty($this->socid)) {
1021 if ($module ==
'societe' && ($permlevel1 ==
'creer' || $permlevel1 ==
'write')) {
1024 if ($module ==
'societe' && $permlevel1 ==
'client' && $permlevel2 ==
'voir') {
1027 if ($module ==
'societe' && $permlevel1 ==
'export') {
1030 if ($module ==
'societe' && ($permlevel1 ==
'supprimer' || $permlevel1 ==
'delete')) {
1036 if ($permlevel1 ==
'propale') {
1037 $permlevel1 =
'propal';
1039 if ($permlevel1 ==
'member') {
1040 $permlevel1 =
'adherent';
1042 if ($permlevel1 ==
'recruitmentcandidature') {
1043 $permlevel1 =
'recruitmentjobposition';
1048 if (empty($rightsPath) || empty($this->rights) || empty($this->rights->$rightsPath) || empty($permlevel1)) {
1053 if (!empty($this->rights->$rightsPath->$permlevel1)) {
1054 if (!empty($this->rights->$rightsPath->$permlevel1->$permlevel2)) {
1055 return $this->rights->$rightsPath->$permlevel1->$permlevel2;
1059 if ($permlevel2 ==
'read' && !empty($this->rights->$rightsPath->$permlevel1->lire)) {
1060 return $this->rights->$rightsPath->$permlevel1->lire;
1062 if ($permlevel2 ==
'write' && !empty($this->rights->$rightsPath->$permlevel1->creer)) {
1063 return $this->rights->$rightsPath->$permlevel1->creer;
1065 if ($permlevel2 ==
'write' && !empty($this->rights->$rightsPath->$permlevel1->create)) {
1066 return $this->rights->$rightsPath->$permlevel1->create;
1068 if ($permlevel2 ==
'delete' && !empty($this->rights->$rightsPath->$permlevel1->supprimer)) {
1069 return $this->rights->$rightsPath->$permlevel1->supprimer;
1073 if (!empty($this->rights->$rightsPath->$permlevel1)) {
1074 return $this->rights->$rightsPath->$permlevel1;
1078 if ($permlevel1 ==
'read' && !empty($this->rights->$rightsPath->lire)) {
1079 return $this->rights->$rightsPath->lire;
1081 if ($permlevel1 ==
'write' && !empty($this->rights->$rightsPath->creer)) {
1082 return $this->rights->$rightsPath->creer;
1084 if ($permlevel1 ==
'write' && !empty($this->rights->$rightsPath->create)) {
1085 return $this->rights->$rightsPath->create;
1087 if ($permlevel1 ==
'delete' && !empty($this->rights->$rightsPath->supprimer)) {
1088 return $this->rights->$rightsPath->supprimer;
1106 public function addrights($rid, $allmodule =
'', $allperms =
'', $entity = 0, $notrigger = 0)
1108 global $conf, $user, $langs;
1110 $entity = (empty($entity) ?
$conf->entity : $entity);
1112 dol_syslog(get_class($this).
"::addrights $rid, $allmodule, $allperms, $entity, $notrigger for user id=".$this->
id);
1114 if (empty($this->
id)) {
1115 $this->
error =
'Try to call addrights on an object user with an empty id';
1125 $module = $perms = $subperms =
'';
1128 $sql =
"SELECT module, perms, subperms";
1129 $sql .=
" FROM ".$this->db->prefix().
"rights_def";
1130 $sql .=
" WHERE id = ".((int) $rid);
1131 $sql .=
" AND entity = ".((int) $entity);
1133 $result = $this->db->query($sql);
1135 $obj = $this->db->fetch_object($result);
1138 $module = $obj->module;
1139 $perms = $obj->perms;
1140 $subperms = $obj->subperms;
1148 $whereforadd =
"id=".((int) $rid);
1150 if (!empty($subperms)) {
1151 $whereforadd .=
" OR (module='".$this->db->escape($module).
"' AND perms='".$this->db->escape($perms).
"' AND (subperms='lire' OR subperms='read'))";
1152 } elseif (!empty($perms)) {
1153 $whereforadd .=
" OR (module='".$this->db->escape($module).
"' AND (perms='lire' OR perms='read') AND (subperms IS NULL or subperms = ''))";
1159 if (!empty($allmodule)) {
1160 if ($allmodule ==
'allmodules') {
1161 $whereforadd =
'allmodules';
1163 $whereforadd =
"module='".$this->db->escape($allmodule).
"'";
1164 if (!empty($allperms)) {
1165 $whereforadd .=
" AND perms='".$this->db->escape($allperms).
"'";
1173 if (!empty($whereforadd)) {
1176 $sql .=
" FROM ".$this->db->prefix().
"rights_def";
1177 $sql .=
" WHERE entity = ".((int) $entity);
1178 if (!empty($whereforadd) && $whereforadd !=
'allmodules') {
1179 $sql .=
" AND (".$whereforadd.
")";
1182 $sqldelete =
"DELETE FROM ".$this->db->prefix().
"user_rights";
1183 $sqldelete .=
" WHERE fk_user = ".((int) $this->
id).
" AND fk_id IN (";
1185 $sqldelete .=
") AND entity = ".((int) $entity);
1186 if (!$this->db->query($sqldelete)) {
1191 $resql = $this->db->query($sql);
1193 $num = $this->db->num_rows($resql);
1196 $obj = $this->db->fetch_object($resql);
1201 $sql =
"INSERT INTO ".$this->db->prefix().
"user_rights (entity, fk_user, fk_id) VALUES (".((int) $entity).
", ".((int) $this->
id).
", ".((int) $nid).
")";
1202 if (!$this->db->query($sql)) {
1216 if (!$error && !$notrigger) {
1217 $langs->load(
"other");
1218 $this->context = array(
'audit' => $langs->trans(
"PermissionsAdd").($rid ?
' (id='.$rid.
')' :
''));
1221 $result = $this->call_trigger(
'USER_MODIFY', $user);
1229 $this->db->rollback();
1232 $this->db->commit();
1249 public function delrights($rid, $allmodule =
'', $allperms =
'', $entity = 0, $notrigger = 0)
1251 global $conf, $user, $langs;
1255 $entity = (!empty($entity) ? $entity :
$conf->entity);
1260 $module = $perms = $subperms =
'';
1264 $sql =
"SELECT module, perms, subperms";
1265 $sql .=
" FROM ".$this->db->prefix().
"rights_def";
1266 $sql .=
" WHERE id = ".((int) $rid);
1267 $sql .=
" AND entity IN (".$this->db->sanitize($entity, 0, 0, 0, 0).
")";
1269 $result = $this->db->query($sql);
1271 $obj = $this->db->fetch_object($result);
1274 $module = $obj->module;
1275 $perms = $obj->perms;
1276 $subperms = $obj->subperms;
1284 $wherefordel =
"id=".((int) $rid);
1286 if ($subperms ==
'lire' || $subperms ==
'read') {
1287 $wherefordel .=
" OR (module='".$this->db->escape($module).
"' AND perms='".$this->db->escape($perms).
"' AND subperms IS NOT NULL)";
1289 if ($perms ==
'lire' || $perms ==
'read') {
1290 $wherefordel .=
" OR (module='".$this->db->escape($module).
"')";
1296 if (!empty($allmodule)) {
1297 if ($allmodule ==
'allmodules') {
1298 $wherefordel =
'allmodules';
1300 $wherefordel =
"module='".$this->db->escape($allmodule).
"'";
1301 if (!empty($allperms)) {
1302 $wherefordel .=
" AND perms='".$this->db->escape($allperms).
"'";
1309 if (!empty($wherefordel)) {
1312 $sql .=
" FROM ".$this->db->prefix().
"rights_def";
1313 $sql .=
" WHERE entity IN (".$this->db->sanitize($entity, 0, 0, 0, 0).
")";
1314 if (!empty($wherefordel) && $wherefordel !=
'allmodules') {
1315 $sql .=
" AND (".$wherefordel.
")";
1319 if ($this->admin == 1) {
1320 $sql .=
" AND id NOT IN (251, 252, 253, 254, 255, 256)";
1321 $sql .=
" AND id NOT IN (341, 342, 343, 344)";
1322 $sql .=
" AND id NOT IN (351, 352, 353, 354)";
1323 $sql .=
" AND id NOT IN (358)";
1326 $sqldelete =
"DELETE FROM ".$this->db->prefix().
"user_rights";
1327 $sqldelete .=
" WHERE fk_user = ".((int) $this->
id).
" AND fk_id IN (";
1330 $sqldelete .=
" AND entity IN (".$this->db->sanitize($entity, 0, 0, 0, 0).
")";
1332 $resql = $this->db->query($sqldelete);
1339 if (!$error && !$notrigger) {
1340 $langs->load(
"other");
1341 $this->context = array(
'audit' => $langs->trans(
"PermissionsDelete").($rid ?
' (id='.$rid.
')' :
''));
1344 $result = $this->call_trigger(
'USER_MODIFY', $user);
1352 $this->db->rollback();
1355 $this->db->commit();
1369 dol_syslog(get_class($this).
"::clearrights reset user->rights");
1371 $this->nb_rights = 0;
1372 $this->all_permissions_are_loaded = 0;
1373 $this->_tab_loaded = array();
1389 $alreadyloaded =
false;
1391 if (empty($forcereload)) {
1392 if ($moduletag && isset($this->_tab_loaded[$moduletag]) && $this->_tab_loaded[$moduletag]) {
1394 $alreadyloaded =
true;
1397 if (!empty($this->all_permissions_are_loaded)) {
1399 $alreadyloaded =
true;
1404 if (!isset($this->rights) || !is_object($this->rights)) {
1407 if (!isset($this->rights->user) || !is_object($this->rights->user)) {
1408 $this->rights->user =
new stdClass();
1413 if (!$alreadyloaded) {
1415 $sql =
"SELECT DISTINCT r.module, r.perms, r.subperms";
1416 $sql .=
" FROM ".$this->db->prefix().
"user_rights as ur,";
1417 $sql .=
" ".$this->db->prefix().
"rights_def as r";
1418 $sql .=
" WHERE r.id = ur.fk_id";
1424 $sql .=
" AND r.entity IN (0,".(isModEnabled(
'multicompany') &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') ?
"1," :
"").((
int)
$conf->entity).
")";
1428 $sql .=
" AND r.entity = ".((int)
$conf->entity).
" AND ur.entity = ".((int)
$conf->entity);
1430 $sql .=
" AND ur.fk_user = ".((int) $this->
id);
1431 $sql .=
" AND r.perms IS NOT NULL";
1433 $sql .=
" AND r.perms NOT LIKE '%_advance'";
1436 $sql .=
" AND r.module = '".$this->db->escape($moduletag).
"'";
1439 $resql = $this->db->query($sql);
1441 $num = $this->db->num_rows($resql);
1444 $obj = $this->db->fetch_object($resql);
1447 $module = $obj->module;
1448 $perms = $obj->perms;
1449 $subperms = $obj->subperms;
1451 if (!empty($perms)) {
1452 if (!empty($module)) {
1453 if (!isset($this->rights->$module) || !is_object($this->rights->$module)) {
1454 $this->rights->$module =
new stdClass();
1456 if (!empty($subperms)) {
1457 if (!isset($this->rights->$module->$perms) || !is_object($this->rights->$module->$perms)) {
1458 $this->rights->$module->$perms =
new stdClass();
1460 if (empty($this->rights->$module->$perms->$subperms)) {
1463 $this->rights->$module->$perms->$subperms = 1;
1465 if (empty($this->rights->$module->$perms)) {
1468 $this->rights->$module->$perms = 1;
1475 $this->db->free($resql);
1479 $sql =
"SELECT DISTINCT r.module, r.perms, r.subperms, r.entity";
1480 $sql .=
" FROM ".$this->db->prefix().
"usergroup_rights as gr,";
1481 $sql .=
" ".$this->db->prefix().
"usergroup_user as gu,";
1482 $sql .=
" ".$this->db->prefix().
"rights_def as r";
1483 $sql .=
" WHERE r.id = gr.fk_id";
1489 $sql .=
" AND gu.entity IN (0,".((int)
$conf->entity).
")";
1491 $sql .=
" AND r.entity = ".((int)
$conf->entity);
1494 $sql .=
" AND gr.entity = ".((int)
$conf->entity);
1498 $sql .=
" AND gu.entity IN (0,".((int)
$conf->entity).
")";
1499 $sql .=
" AND r.entity = ".((int)
$conf->entity);
1502 $sql .=
" AND gr.fk_usergroup = gu.fk_usergroup";
1503 $sql .=
" AND gu.fk_user = ".((int) $this->
id);
1504 $sql .=
" AND r.perms IS NOT NULL";
1506 $sql .=
" AND r.perms NOT LIKE '%_advance'";
1509 $sql .=
" AND r.module = '".$this->db->escape($moduletag).
"'";
1512 $resql = $this->db->query($sql);
1514 $num = $this->db->num_rows($resql);
1517 $obj = $this->db->fetch_object($resql);
1520 $module = $obj->module;
1521 $perms = $obj->perms;
1522 $subperms = $obj->subperms;
1524 if (!empty($perms)) {
1525 if (!empty($module)) {
1526 if (!isset($this->rights->$module) || !is_object($this->rights->$module)) {
1527 $this->rights->$module =
new stdClass();
1529 if (!empty($subperms)) {
1530 if (!isset($this->rights->$module->$perms) || !is_object($this->rights->$module->$perms)) {
1531 $this->rights->$module->$perms =
new stdClass();
1533 if (empty($this->rights->$module->$perms->$subperms)) {
1536 $this->rights->$module->$perms->$subperms = 1;
1539 if (!isset($this->rights->$module->$perms) || !is_object($this->rights->$module->$perms)) {
1540 if (empty($this->rights->$module->$perms)) {
1543 $this->rights->$module->$perms = 1;
1551 $this->db->free($resql);
1555 if (!empty($this->admin)) {
1556 if (empty($this->rights->user->user)) {
1557 $this->rights->user->user =
new stdClass();
1559 $listofpermtotest = array(
'lire',
'creer',
'password',
'supprimer',
'export');
1560 foreach ($listofpermtotest as $permtotest) {
1561 if (empty($this->rights->user->user->$permtotest)) {
1562 $this->rights->user->user->$permtotest = 1;
1566 if (empty($this->rights->user->self)) {
1567 $this->rights->user->self =
new stdClass();
1569 $listofpermtotest = array(
'creer',
'password');
1570 foreach ($listofpermtotest as $permtotest) {
1571 if (empty($this->rights->user->self->$permtotest)) {
1572 $this->rights->user->self->$permtotest = 1;
1578 if (empty($this->rights->user->user_advance)) {
1579 $this->rights->user->user_advance =
new stdClass();
1581 $listofpermtotest = array(
'readperms',
'write');
1582 foreach ($listofpermtotest as $permtotest) {
1583 if (empty($this->rights->user->user_advance->$permtotest)) {
1584 $this->rights->user->user_advance->$permtotest = 1;
1588 if (empty($this->rights->user->self_advance)) {
1589 $this->rights->user->self_advance =
new stdClass();
1591 $listofpermtotest = array(
'readperms',
'writeperms');
1592 foreach ($listofpermtotest as $permtotest) {
1593 if (empty($this->rights->user->self_advance->$permtotest)) {
1594 $this->rights->user->self_advance->$permtotest = 1;
1598 if (empty($this->rights->user->group_advance)) {
1599 $this->rights->user->group_advance =
new stdClass();
1601 $listofpermtotest = array(
'read',
'readperms',
'write',
'delete');
1602 foreach ($listofpermtotest as $permtotest) {
1603 if (empty($this->rights->user) || empty($this->rights->user->group_advance->$permtotest)) {
1604 $this->rights->user->group_advance->$permtotest = 1;
1612 if (isset($this->rights->propale) && !isset($this->rights->propal)) {
1613 $this->rights->propal = $this->rights->propale;
1615 if (isset($this->rights->propal) && !isset($this->rights->propale)) {
1616 $this->rights->propale = $this->rights->propal;
1623 $this->all_permissions_are_loaded = 1;
1626 $this->_tab_loaded[$moduletag] = 1;
1643 public function getrights($moduletag =
'', $forcereload = 0)
1656 global $conf, $langs, $user;
1661 if (isset($this->statut)) {
1662 if ($this->statut == $status) {
1665 } elseif (isset($this->
status) && $this->
status == $status) {
1672 $sql =
"UPDATE ".$this->db->prefix().
"user";
1673 $sql .=
" SET statut = ".((int) $status);
1674 $sql .=
" WHERE rowid = ".((int) $this->
id);
1675 $result = $this->db->query($sql);
1677 dol_syslog(get_class($this).
"::setstatus", LOG_DEBUG);
1680 $this->context[
'actionmsg'] =
'User '.$this->login.
' disabled';
1682 $this->context[
'actionmsg'] =
'User '.$this->login.
' enabled';
1685 $result = $this->call_trigger(
'USER_ENABLEDISABLE', $user);
1693 $this->db->rollback();
1697 $this->statut = $status;
1698 $this->db->commit();
1714 $value = (int) $value;
1717 if ($this->force_pass_change == $value) {
1724 $sql =
"UPDATE ".$this->db->prefix().
"user";
1725 $sql .=
" SET force_pass_change = ".((int) $value);
1726 $sql .=
" WHERE rowid = ".((int) $this->
id);
1727 $result = $this->db->query($sql);
1729 dol_syslog(get_class($this).
"::setForcePasswordChange", LOG_DEBUG);
1731 $this->force_pass_change = $value;
1733 $result = $this->call_trigger(
'USER_MODIFY', $user);
1740 $this->
error = $this->db->lasterror();
1744 $this->db->rollback();
1747 $this->db->commit();
1764 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1765 return parent::setCategoriesCommon($categories, Categorie::TYPE_USER);
1780 $this->
fetch($this->
id);
1782 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1785 $sql =
"DELETE FROM ".$this->db->prefix().
"user_rights WHERE fk_user = ".((int) $this->
id);
1787 if (!$error && !$this->db->query($sql)) {
1789 $this->
error = $this->db->lasterror();
1793 $sql =
"DELETE FROM ".$this->db->prefix().
"usergroup_user WHERE fk_user = ".((int) $this->
id);
1794 if (!$error && !$this->db->query($sql)) {
1796 $this->
error = $this->db->lasterror();
1800 $sql =
"DELETE FROM ".$this->db->prefix().
"user_param WHERE fk_user = ".((int) $this->
id);
1801 if (!$error && !$this->db->query($sql)) {
1803 $this->
error = $this->db->lasterror();
1807 if ($this->contact_id > 0) {
1808 $sql =
"UPDATE ".$this->db->prefix().
"socpeople SET fk_user_creat = null WHERE rowid = ".((int) $this->contact_id);
1809 if (!$error && !$this->db->query($sql)) {
1811 $this->
error = $this->db->lasterror();
1820 dol_syslog(get_class($this).
"::delete error -4 ".$this->
error, LOG_ERR);
1826 $sql =
"DELETE FROM ".$this->db->prefix().
"user WHERE rowid = ".((int) $this->
id);
1827 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1828 if (!$this->db->query($sql)) {
1830 $this->
error = $this->db->lasterror();
1836 $result = $this->call_trigger(
'USER_DELETE', $user);
1839 $this->db->rollback();
1844 $this->db->commit();
1847 $this->db->rollback();
1859 public function create($user, $notrigger = 0)
1861 global $conf, $langs;
1867 $this->civility_code = trim((
string) $this->civility_code);
1868 $this->login = trim((
string) $this->login);
1869 $this->user_creation_id = (int) $user->id;
1870 if (!isset($this->entity)) {
1871 $this->entity =
$conf->entity;
1873 dol_syslog(get_class($this).
"::create login=".$this->login.
", user=".(is_object($user) ? $user->id :
''), LOG_DEBUG);
1879 $langs->load(
"errors");
1880 $this->
error = $langs->trans(
"ErrorBadEMail", $this->
email);
1883 if (empty($this->login)) {
1884 $langs->load(
"errors");
1885 $this->
error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Login"));
1887 } elseif ($badCharUnauthorizedIntoLoginName !==
'' && preg_match(
'/['.preg_quote($badCharUnauthorizedIntoLoginName,
'/').
']/', $this->login)) {
1888 $langs->load(
"errors");
1889 $this->
error = $langs->trans(
"ErrorBadCharIntoLoginName", $langs->transnoentitiesnoconv(
"Login"));
1900 $sqltochecklogin =
"SELECT COUNT(*) as nb FROM ".$this->db->prefix().
"user WHERE entity IN (".$this->db->sanitize(((
int) $this->entity).
", 0").
") AND login = '".$this->db->escape($this->login).
"'";
1901 $resqltochecklogin = $this->db->query($sqltochecklogin);
1902 if ($resqltochecklogin) {
1903 $objtochecklogin = $this->db->fetch_object($resqltochecklogin);
1904 if ($objtochecklogin && $objtochecklogin->nb > 0) {
1905 $langs->load(
"errors");
1906 $this->
error = $langs->trans(
"ErrorLoginAlreadyExists", $this->login);
1908 $this->db->rollback();
1911 $this->db->free($resqltochecklogin);
1914 if (!empty($this->
email)) {
1915 $sqltochecklogin =
"SELECT COUNT(*) as nb FROM ".$this->db->prefix().
"user WHERE entity IN (".$this->db->sanitize(((
int) $this->entity).
", 0").
") AND email = '".$this->db->escape($this->
email).
"'";
1916 $resqltochecklogin = $this->db->query($sqltochecklogin);
1917 if ($resqltochecklogin) {
1918 $objtochecklogin = $this->db->fetch_object($resqltochecklogin);
1919 if ($objtochecklogin && $objtochecklogin->nb > 0) {
1920 $langs->load(
"errors");
1921 $this->
error = $langs->trans(
"ErrorEmailAlreadyExists", $this->
email);
1923 $this->db->rollback();
1926 $this->db->free($resqltochecklogin);
1931 $sql =
"INSERT INTO ".$this->db->prefix().
"user (datec, login, ldap_sid, fk_user_creat, entity)";
1932 $sql .=
" VALUES('".$this->db->idate($this->datec).
"', '".$this->db->escape($this->login).
"', '".$this->db->escape($this->ldap_sid).
"', ".(int) $this->user_creation_id.
", ".((
int) $this->entity).
")";
1933 $result = $this->db->query($sql);
1935 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
1937 $this->
id = $this->db->last_insert_id($this->db->prefix().
"user");
1941 $this->
error =
'ErrorFailedToSetDefaultRightOfUser';
1942 $this->db->rollback();
1947 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
1948 $langs->load(
"stocks");
1950 $entrepot =
new Entrepot($this->db);
1951 $entrepot->label = $langs->trans(
"PersonalStock", $this->
getFullName($langs));
1952 $entrepot->libelle = $entrepot->label;
1953 $entrepot->description = $langs->trans(
"ThisWarehouseIsPersonalStock", $this->
getFullName($langs));
1954 $entrepot->statut = 1;
1955 $entrepot->country_id =
$mysoc->country_id;
1957 $warehouseid = $entrepot->create($user);
1959 $this->fk_warehouse = $warehouseid;
1963 $result = $this->
update($user, 1, 1);
1965 $this->db->rollback();
1971 $result = $this->call_trigger(
'USER_CREATE', $user);
1979 $this->db->commit();
1984 $this->db->rollback();
1988 $this->
error = $this->db->lasterror();
1989 $this->db->rollback();
2013 $this->civility_code = $contact->civility_code;
2014 $this->lastname = $contact->lastname;
2015 $this->firstname = $contact->firstname;
2017 $this->
email = $contact->email;
2018 $this->socialnetworks = $contact->socialnetworks;
2019 $this->office_phone = $contact->phone_pro;
2020 $this->office_fax = $contact->fax;
2021 $this->user_mobile = $contact->phone_mobile;
2022 $this->
address = $contact->address;
2023 $this->zip = $contact->zip;
2024 $this->town = $contact->town;
2026 $this->state_id = $contact->state_id;
2027 $this->country_id = $contact->country_id;
2028 $this->employee = 0;
2030 if (empty($login)) {
2031 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2032 $login =
dol_buildlogin($contact->lastname, $contact->firstname);
2034 $this->login = $login;
2039 $result = $this->
create($user, 1);
2041 $sql =
"UPDATE ".$this->db->prefix().
"user";
2042 $sql .=
" SET fk_socpeople=".((int) $contact->id);
2043 $sql .=
", civility='".$this->db->escape($contact->civility_code).
"'";
2044 if ($contact->socid > 0) {
2045 $sql .=
", fk_soc=".((int) $contact->socid);
2047 $sql .=
" WHERE rowid=".((int) $this->
id);
2049 $resql = $this->db->query($sql);
2051 dol_syslog(get_class($this).
"::create_from_contact", LOG_DEBUG);
2053 $this->context[
'createfromcontact'] =
'createfromcontact';
2056 $result = $this->call_trigger(
'USER_CREATE', $user);
2059 $this->db->rollback();
2064 $this->db->commit();
2067 $this->
error = $this->db->error();
2069 $this->db->rollback();
2074 dol_syslog(get_class($this).
"::create_from_contact - 0");
2076 $this->db->rollback();
2097 $this->civility_code = $member->civility_code;
2098 $this->lastname = $member->lastname;
2099 $this->firstname = $member->firstname;
2100 $this->gender = $member->gender;
2101 $this->
email = $member->email;
2102 $this->fk_member = $member->id;
2103 $this->
address = $member->address;
2104 $this->zip = $member->zip;
2105 $this->town = $member->town;
2107 $this->state_id = $member->state_id;
2108 $this->country_id = $member->country_id;
2109 $this->socialnetworks = $member->socialnetworks;
2111 $this->pass = $member->pass;
2112 $this->pass_crypted = $member->pass_indatabase_crypted;
2114 if (empty($login)) {
2115 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2118 $this->login = $login;
2123 $result = $this->
create($user);
2125 if (!empty($this->pass)) {
2126 $newpass = $this->
setPassword($user, $this->pass);
2127 if (is_int($newpass) && $newpass < 0) {
2130 } elseif (!empty($this->pass_crypted)) {
2131 $sql =
"UPDATE ".$this->db->prefix().
"user";
2132 $sql .=
" SET pass_crypted = '".$this->db->escape($this->pass_crypted).
"'";
2133 $sql .=
" WHERE rowid=".((int) $this->
id);
2135 $resql = $this->db->query($sql);
2141 if ($result > 0 && $member->socid) {
2142 $sql =
"UPDATE ".$this->db->prefix().
"user";
2143 $sql .=
" SET fk_soc=".((int) $member->socid);
2144 $sql .=
" WHERE rowid=".((int) $this->
id);
2146 dol_syslog(get_class($this).
"::create_from_member", LOG_DEBUG);
2147 $resql = $this->db->query($sql);
2149 $this->db->commit();
2152 $this->
error = $this->db->lasterror();
2154 $this->db->rollback();
2161 $this->db->commit();
2165 $this->db->rollback();
2183 $sql =
"SELECT id FROM ".$this->db->prefix().
"rights_def";
2184 $sql .=
" WHERE bydefault = 1";
2185 $sql .=
" AND entity = ".((int)
$conf->entity);
2187 $resql = $this->db->query($sql);
2189 $num = $this->db->num_rows($resql);
2192 $row = $this->db->fetch_row($resql);
2196 $this->db->free($resql);
2200 $sql =
"DELETE FROM ".$this->db->prefix().
"user_rights WHERE fk_user = ".((int) $this->
id).
" AND fk_id=".((int) $rd[$i]);
2201 $result = $this->db->query($sql);
2203 $sql =
"INSERT INTO ".$this->db->prefix().
"user_rights (fk_user, fk_id) VALUES (".((int) $this->
id).
", ".((int) $rd[$i]).
")";
2204 $result = $this->db->query($sql);
2224 public function update($user, $notrigger = 0, $nosyncmember = 0, $nosyncmemberpass = 0, $nosynccontact = 0)
2228 if (empty($this->country_id) && !empty($this->country_code)) {
2229 $country_id =
getCountry($this->country_code,
'3');
2230 $this->country_id = is_int($country_id) ? $country_id : 0;
2233 $nbrowsaffected = 0;
2236 dol_syslog(get_class($this).
"::update notrigger=".$notrigger.
", nosyncmember=".$nosyncmember.
", nosyncmemberpass=".$nosyncmemberpass);
2239 $this->civility_code = trim((
string) $this->civility_code);
2240 $this->lastname = trim((
string) $this->lastname);
2241 $this->firstname = trim((
string) $this->firstname);
2242 $this->ref_employee = trim((
string) $this->ref_employee);
2243 $this->national_registration_number = trim((
string) $this->national_registration_number);
2244 $this->employee = ($this->employee > 0 ? $this->employee : 0);
2245 $this->login = trim((
string) $this->login);
2246 $this->gender = trim((
string) $this->gender);
2248 $this->pass = trim((
string) $this->pass);
2249 $this->api_key = trim((
string) $this->api_key);
2250 $this->datestartvalidity = empty($this->datestartvalidity) ?
'' : $this->datestartvalidity;
2251 $this->dateendvalidity = empty($this->dateendvalidity) ?
'' : $this->dateendvalidity;
2254 $this->zip = trim((
string) $this->zip);
2255 $this->town = trim((
string) $this->town);
2257 $this->state_id = ($this->state_id > 0 ? $this->state_id : 0);
2258 $this->country_id = ($this->country_id > 0 ? $this->country_id : 0);
2259 $this->office_phone = trim((
string) $this->office_phone);
2260 $this->office_fax = trim((
string) $this->office_fax);
2261 $this->user_mobile = trim((
string) $this->user_mobile);
2262 $this->personal_mobile = trim((
string) $this->personal_mobile);
2264 $this->personal_email = trim((
string) $this->personal_email);
2266 $this->job = trim((
string) $this->job);
2267 $this->signature = trim((
string) $this->signature);
2268 $this->note_public = trim((
string) $this->note_public);
2269 $this->note_private = trim((
string) $this->note_private);
2270 $this->openid = trim((
string) $this->openid);
2271 $this->admin = ($this->admin > 0 ? $this->admin : 0);
2272 $this->user_modification_id = $user->id;
2274 $this->accountancy_code_user_general = trim((
string) $this->accountancy_code_user_general);
2275 $this->accountancy_code = trim((
string) $this->accountancy_code);
2276 $this->color = trim(str_replace(
'#',
'', (
string) $this->color));
2277 $this->dateemployment = empty($this->dateemployment) ?
'' : $this->dateemployment;
2278 $this->dateemploymentend = empty($this->dateemploymentend) ?
'' : $this->dateemploymentend;
2280 $this->birth = empty($this->birth) ?
'' : $this->birth;
2281 $this->fk_warehouse = (int) $this->fk_warehouse;
2282 $this->fk_establishment = (int) $this->fk_establishment;
2290 $langs->load(
"errors");
2291 $this->
error = $langs->trans(
"ErrorBadEMail", $this->email);
2294 if (empty($this->login)) {
2295 $langs->load(
"errors");
2296 $this->
error = $langs->trans(
"ErrorFieldRequired",
'Login');
2298 } elseif ($badCharUnauthorizedIntoLoginName !==
'' && preg_match(
'/['.preg_quote($badCharUnauthorizedIntoLoginName,
'/').
']/', $this->login)) {
2299 $langs->load(
"errors");
2300 $this->
error = $langs->trans(
"ErrorBadCharIntoLoginName", $langs->transnoentitiesnoconv(
"Login"));
2307 if (is_object($this->oldcopy) && !$this->oldcopy->isEmpty() && $this->oldcopy->login != $this->login) {
2308 $sqltochecklogin =
"SELECT COUNT(*) as nb FROM ".$this->db->prefix().
"user WHERE entity IN (".$this->db->sanitize(((
int) $this->entity).
", 0").
") AND login = '".$this->db->escape($this->login).
"'";
2309 $resqltochecklogin = $this->db->query($sqltochecklogin);
2310 if ($resqltochecklogin) {
2311 $objtochecklogin = $this->db->fetch_object($resqltochecklogin);
2312 if ($objtochecklogin && $objtochecklogin->nb > 0) {
2313 $langs->load(
"errors");
2314 $this->
error = $langs->trans(
"ErrorLoginAlreadyExists", $this->login);
2316 $this->db->rollback();
2321 if (is_object($this->oldcopy) && !$this->oldcopy->isEmpty() && !empty($this->email) && $this->oldcopy->email != $this->email) {
2322 $sqltochecklogin =
"SELECT COUNT(*) as nb FROM ".$this->db->prefix().
"user WHERE entity IN (".$this->db->sanitize(((
int) $this->entity).
", 0").
") AND email = '".$this->db->escape($this->email).
"'";
2323 $resqltochecklogin = $this->db->query($sqltochecklogin);
2324 if ($resqltochecklogin) {
2325 $objtochecklogin = $this->db->fetch_object($resqltochecklogin);
2326 if ($objtochecklogin && $objtochecklogin->nb > 0) {
2327 $langs->load(
"errors");
2328 $this->
error = $langs->trans(
"ErrorEmailAlreadyExists", $this->email);
2330 $this->db->rollback();
2337 $sql =
"UPDATE ".$this->db->prefix().
"user SET";
2338 $sql .=
" civility = '".$this->db->escape($this->civility_code).
"'";
2339 $sql .=
", lastname = '".$this->db->escape($this->lastname).
"'";
2340 $sql .=
", firstname = '".$this->db->escape($this->firstname).
"'";
2341 $sql .=
", ref_employee = '".$this->db->escape($this->ref_employee).
"'";
2342 $sql .=
", national_registration_number = '".$this->db->escape($this->national_registration_number).
"'";
2343 $sql .=
", employee = ".(int) $this->employee;
2344 $sql .=
", login = '".$this->db->escape($this->login).
"'";
2345 $sql .=
", api_key = ".($this->api_key ?
"'".$this->db->escape(
dolEncrypt($this->api_key,
'',
'',
'dolibarr')).
"'" :
"null");
2346 $sql .=
", gender = ".($this->gender != -1 ?
"'".$this->db->escape($this->gender).
"'" :
"null");
2347 $sql .=
", birth=".(strval($this->birth) !=
'' ?
"'".$this->db->idate($this->birth,
'tzserver').
"'" :
'null');
2348 if (!empty($user->admin)) {
2349 $sql .=
", admin = ".(int) $this->admin;
2351 $sql .=
", address = '".$this->db->escape($this->address).
"'";
2352 $sql .=
", zip = '".$this->db->escape($this->zip).
"'";
2353 $sql .=
", town = '".$this->db->escape($this->town).
"'";
2354 $sql .=
", fk_state = ".((!empty($this->state_id) && $this->state_id > 0) ? ((
int) $this->state_id) :
"null");
2355 $sql .=
", fk_country = ".((!empty($this->country_id) && $this->country_id > 0) ? ((
int) $this->country_id) :
"null");
2356 $sql .=
", office_phone = '".$this->db->escape($this->office_phone).
"'";
2357 $sql .=
", office_fax = '".$this->db->escape($this->office_fax).
"'";
2358 $sql .=
", user_mobile = '".$this->db->escape($this->user_mobile).
"'";
2359 $sql .=
", personal_mobile = '".$this->db->escape($this->personal_mobile).
"'";
2360 $sql .=
", email = '".$this->db->escape($this->email).
"'";
2361 $sql .=
", personal_email = '".$this->db->escape($this->personal_email).
"'";
2362 $sql .=
", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks)).
"'";
2363 $sql .=
", job = '".$this->db->escape($this->job).
"'";
2364 $sql .=
", signature = '".$this->db->escape($this->signature).
"'";
2365 $sql .=
", accountancy_code_user_general = '".$this->db->escape($this->accountancy_code_user_general).
"'";
2366 $sql .=
", accountancy_code = '".$this->db->escape($this->accountancy_code).
"'";
2367 $sql .=
", color = '".$this->db->escape($this->color).
"'";
2368 $sql .=
", dateemployment=".(strval($this->dateemployment) !=
'' ?
"'".$this->db->idate($this->dateemployment).
"'" :
'null');
2369 $sql .=
", dateemploymentend=".(strval($this->dateemploymentend) !=
'' ?
"'".$this->db->idate($this->dateemploymentend).
"'" :
'null');
2370 $sql .=
", datestartvalidity=".(strval($this->datestartvalidity) !=
'' ?
"'".$this->db->idate($this->datestartvalidity).
"'" :
'null');
2371 $sql .=
", dateendvalidity=".(strval($this->dateendvalidity) !=
'' ?
"'".$this->db->idate($this->dateendvalidity).
"'" :
'null');
2372 $sql .=
", note_private = '".$this->db->escape($this->note_private).
"'";
2373 $sql .=
", note_public = '".$this->db->escape($this->note_public).
"'";
2374 $sql .=
", photo = ".($this->photo ?
"'".$this->db->escape($this->photo).
"'" :
"null");
2375 $sql .=
", openid = ".($this->openid ?
"'".$this->db->escape($this->openid).
"'" :
"null");
2376 $sql .=
", fk_user = ".($this->fk_user > 0 ? ((int) $this->fk_user) :
"null");
2377 $sql .=
", fk_user_modif = ".($this->user_modification_id > 0 ? ((int) $this->user_modification_id) :
"null");
2378 $sql .=
", fk_user_expense_validator = ".($this->fk_user_expense_validator > 0 ? ((int) $this->fk_user_expense_validator) :
"null");
2379 $sql .=
", fk_user_holiday_validator = ".($this->fk_user_holiday_validator > 0 ? ((int) $this->fk_user_holiday_validator) :
"null");
2380 if (isset($this->thm) || $this->thm !=
'') {
2381 $sql .=
", thm= ".($this->thm !=
'' ?
"'".$this->db->escape($this->thm).
"'" :
"null");
2383 if (isset($this->tjm) || $this->tjm !=
'') {
2384 $sql .=
", tjm= ".($this->tjm !=
'' ?
"'".$this->db->escape($this->tjm).
"'" :
"null");
2386 if (isset($this->salary) || $this->salary !=
'') {
2387 $sql .=
", salary= ".($this->salary !=
'' ?
"'".$this->db->escape($this->salary).
"'" :
"null");
2389 if (isset($this->salaryextra) || $this->salaryextra !=
'') {
2390 $sql .=
", salaryextra= ".($this->salaryextra !=
'' ?
"'".$this->db->escape($this->salaryextra).
"'" :
"null");
2392 $sql .=
", weeklyhours= ".($this->weeklyhours !=
'' ?
"'".$this->db->escape($this->weeklyhours).
"'" :
"null");
2393 if (!empty($user->admin) && empty($user->entity) && $user->id != $this->id) {
2394 $sql .=
", entity = ".((int) $this->entity);
2397 $sql .=
", default_range = ".($this->default_range > 0 ? ((int) $this->default_range) :
'null');
2398 $sql .=
", default_c_exp_tax_cat = ".($this->default_c_exp_tax_cat > 0 ? ((int) $this->default_c_exp_tax_cat) :
'null');
2399 $sql .=
", fk_warehouse = ".($this->fk_warehouse > 0 ? ((int) $this->fk_warehouse) :
"null");
2400 $sql .=
", fk_establishment = ".($this->fk_establishment > 0 ? ((int) $this->fk_establishment) :
"null");
2401 $sql .=
", lang = ".($this->lang ?
"'".$this->db->escape($this->lang).
"'" :
"null");
2402 $sql .=
", force_pass_change = ".($this->force_pass_change ? ((int) $this->force_pass_change) :
"0");
2403 $sql .=
" WHERE rowid = ".((int) $this->
id);
2405 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
2406 $resql = $this->db->query($sql);
2408 $nbrowsaffected += $this->db->affected_rows($resql);
2411 if (!empty($this->pass)) {
2412 if ($this->pass != $this->pass_indatabase && !
dol_verifyHash($this->pass, $this->pass_indatabase_crypted)) {
2414 $result = $this->
setPassword($user, $this->pass, 0, $notrigger, $nosyncmemberpass, 0, 1);
2415 if (is_int($result) && $result < 0) {
2422 if ($this->fk_member > 0) {
2423 dol_syslog(get_class($this).
"::update remove link with member. We will recreate it later", LOG_DEBUG);
2424 $sql =
"UPDATE ".$this->db->prefix().
"user SET fk_member = NULL where fk_member = ".((int) $this->fk_member);
2425 $resql = $this->db->query($sql);
2427 $this->
error = $this->db->error();
2428 $this->db->rollback();
2433 dol_syslog(get_class($this).
"::update set link with member", LOG_DEBUG);
2434 $sql =
"UPDATE ".$this->db->prefix().
"user SET fk_member =".($this->fk_member > 0 ? ((int) $this->fk_member) :
'null').
" where rowid = ".((
int) $this->id);
2435 $resql = $this->db->query($sql);
2437 $this->
error = $this->db->error();
2438 $this->db->rollback();
2442 if ($nbrowsaffected) {
2443 if ($this->fk_member > 0 && !$nosyncmember) {
2444 dol_syslog(get_class($this).
"::update user is linked with a member. We try to update member too.", LOG_DEBUG);
2446 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
2451 $result = $adh->fetch($this->fk_member);
2454 $adh->civility_code = $this->civility_code;
2455 $adh->firstname = $this->firstname;
2456 $adh->lastname = $this->lastname;
2457 $adh->login = $this->login;
2458 $adh->gender = $this->gender;
2459 $adh->birth = $this->birth;
2461 $adh->pass = $this->pass;
2463 $adh->address = $this->address;
2464 $adh->town = $this->town;
2465 $adh->zip = $this->zip;
2466 $adh->state_id = $this->state_id;
2467 $adh->country_id = $this->country_id;
2469 $adh->email = $this->email;
2471 $adh->socialnetworks = $this->socialnetworks;
2473 $adh->phone = $this->office_phone;
2474 $adh->phone_mobile = $this->user_mobile;
2476 $adh->default_lang = $this->lang;
2478 $adh->user_id = $this->id;
2479 $adh->user_login = $this->login;
2481 $result = $adh->update($user, 0, 1, 0);
2483 $this->
error = $adh->error;
2484 $this->errors = $adh->errors;
2485 dol_syslog(get_class($this).
"::update error after calling adh->update to sync it with user: ".$this->
error, LOG_ERR);
2488 } elseif ($result < 0) {
2489 $this->
error = $adh->error;
2490 $this->errors = $adh->errors;
2495 if ($this->contact_id > 0 && !$nosynccontact) {
2496 dol_syslog(get_class($this).
"::update user is linked with a contact. We try to update contact too.", LOG_DEBUG);
2498 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
2501 $tmpobj =
new Contact($this->db);
2502 $result = $tmpobj->fetch($this->contact_id);
2505 $tmpobj->civility_code = $this->civility_code;
2506 $tmpobj->firstname = $this->firstname;
2507 $tmpobj->lastname = $this->lastname;
2508 $tmpobj->login = $this->login;
2509 $tmpobj->gender = $this->gender;
2510 $tmpobj->birth = $this->birth;
2514 $tmpobj->email = $this->email;
2516 $tmpobj->socialnetworks = $this->socialnetworks;
2518 $tmpobj->phone_pro = $this->office_phone;
2519 $tmpobj->phone_mobile = $this->user_mobile;
2520 $tmpobj->fax = $this->office_fax;
2522 $tmpobj->default_lang = $this->lang;
2524 $tmpobj->address = $this->address;
2525 $tmpobj->town = $this->town;
2526 $tmpobj->zip = $this->zip;
2527 $tmpobj->state_id = $this->state_id;
2528 $tmpobj->country_id = $this->country_id;
2530 $tmpobj->user_id = $this->id;
2531 $tmpobj->user_login = $this->login;
2533 $result = $tmpobj->update($tmpobj->id, $user, 0,
'update', 1);
2535 $this->
error = $tmpobj->error;
2536 $this->errors = $tmpobj->errors;
2537 dol_syslog(get_class($this).
"::update error after calling adh->update to sync it with user: ".$this->
error, LOG_ERR);
2541 $this->
error = $tmpobj->error;
2542 $this->errors = $tmpobj->errors;
2558 if (!$error && !$notrigger) {
2560 $result = $this->call_trigger(
'USER_MODIFY', $user);
2568 $this->db->commit();
2569 return $nbrowsaffected;
2572 $this->db->rollback();
2576 $this->
error = $this->db->lasterror();
2577 $this->db->rollback();
2596 $sql =
"UPDATE ".$this->db->prefix().
"user SET";
2597 $sql .=
" datepreviouslogin = datelastlogin,";
2598 $sql .=
" ippreviouslogin = iplastlogin,";
2599 $sql .=
" datelastlogin = '".$this->db->idate($now).
"',";
2600 $sql .=
" iplastlogin = '".$this->db->escape($userremoteip).
"',";
2601 $sql .=
" tms = tms";
2602 $sql .=
" WHERE rowid = ".((int) $this->
id);
2604 dol_syslog(get_class($this).
"::update_last_login_date user->id=".$this->
id.
" ".$sql, LOG_DEBUG);
2605 $resql = $this->db->query($sql);
2607 $this->datepreviouslogin = $this->datelastlogin;
2608 $this->datelastlogin = $now;
2609 $this->ippreviouslogin = $this->iplastlogin;
2610 $this->iplastlogin = $userremoteip;
2613 $this->
error = $this->db->lasterror().
' sql='.$sql;
2631 public function setPassword($user, $password =
'', $changelater = 0, $notrigger = 0, $nosyncmember = 0, $passwordalreadycrypted = 0, $flagdelsessionsbefore = 1)
2633 global $conf, $langs;
2634 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
2638 dol_syslog(get_class($this).
"::setPassword user=".$user->id.
" password=".preg_replace(
'/./i',
'*', $password).
" changelater=".$changelater.
" notrigger=".$notrigger.
" nosyncmember=".$nosyncmember, LOG_DEBUG);
2643 $passwordalreadycrypted = 0;
2647 if (!empty($passwordalreadycrypted)) {
2648 $password_crypted = $password;
2652 $modGeneratePassClass =
'modGeneratePass'.ucfirst(
getDolGlobalString(
'USER_PASSWORD_GENERATED'));
2654 include_once DOL_DOCUMENT_ROOT.
'/core/modules/security/generate/'.$modGeneratePassClass.
'.class.php';
2655 if (class_exists($modGeneratePassClass)) {
2656 $modGeneratePass =
new $modGeneratePassClass($this->db,
$conf, $langs, $user);
2657 '@phan-var-force ModeleGenPassword $modGeneratePass';
2660 $modGeneratePass->WithoutAmbi = 0;
2663 $testpassword = $modGeneratePass->validatePassword($password);
2664 if (!$testpassword) {
2665 $this->
error = $modGeneratePass->error;
2677 if (!$changelater) {
2678 if (!is_object($this->oldcopy)) {
2679 $this->oldcopy = clone $this;
2686 $sql =
"UPDATE ".$this->db->prefix().
"user";
2687 $sql .=
" SET pass_crypted = '".$this->db->escape($password_crypted).
"',";
2688 $sql .=
" datelastpassvalidation = '".$this->db->idate(
dol_now()).
"',";
2689 $sql .=
" pass_temp = null,";
2690 $sql .=
" force_pass_change = 0";
2691 if (!empty($flagdelsessionsbefore)) {
2692 $sql .=
", flagdelsessionsbefore = '".$this->db->idate($now - 5,
'gmt').
"'";
2695 $sql .=
", pass = null";
2697 $sql .=
", pass = '".$this->db->escape($password).
"'";
2699 $sql .=
" WHERE rowid = ".((int) $this->
id);
2701 dol_syslog(get_class($this).
"::setPassword", LOG_DEBUG);
2703 $result = $this->db->query($sql);
2705 if ($this->db->affected_rows($result)) {
2706 $this->pass = $password;
2707 $this->pass_indatabase = $password;
2708 $this->pass_indatabase_crypted = (
string) $password_crypted;
2709 $this->force_pass_change = 0;
2711 if ($this->fk_member && !$nosyncmember) {
2712 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
2717 $result = $adh->fetch($this->fk_member);
2720 $result = $adh->setPassword($user, $this->pass, (!
getDolGlobalString(
'DATABASE_PWD_ENCRYPTED') ? 0 : 1), 1);
2721 if (is_int($result) && $result < 0) {
2722 $this->
error = $adh->error;
2727 $this->
error = $adh->error;
2732 dol_syslog(get_class($this).
"::setPassword notrigger=".$notrigger.
" error=".$error, LOG_DEBUG);
2735 $user->context[
'audit'] =
'login='.$user->login;
2736 if (!empty($flagdelsessionsbefore)) {
2737 $user->context[
'audit'] .=
" - flagdelsessionsbefore set to '".$this->db->idate($now - 5,
'gmt').
"'";
2740 if (!$error && !$notrigger) {
2742 $result = $this->call_trigger(
'USER_NEW_PASSWORD', $user);
2745 $this->db->rollback();
2751 $this->db->commit();
2754 $this->db->rollback();
2758 $this->db->rollback();
2765 $sql =
"UPDATE ".$this->db->prefix().
"user";
2766 $sql .=
" SET pass_temp = '".$this->db->escape($password).
"'";
2767 $sql .=
" WHERE rowid = ".((int) $this->
id);
2769 dol_syslog(get_class($this).
"::setPassword", LOG_DEBUG);
2770 $result = $this->db->query($sql);
2792 global $conf, $langs;
2795 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
2807 $outputlangs = $langs;
2811 $outputlangs->loadLangs(array(
"main",
"errors",
"users",
"other"));
2813 $appli =
getDolGlobalString(
'MAIN_APPLICATION_TITLE', constant(
'DOL_APPLICATION_TITLE'));
2815 $subject =
'['.$appli.
'] '.$outputlangs->transnoentitiesnoconv(
"SubjectNewPassword", $appli);
2818 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
2819 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2821 if (!$changelater) {
2822 $url = $urlwithroot.
'/';
2827 dol_syslog(get_class($this).
"::send_password changelater is off, url=".$url);
2829 $mesg .= $outputlangs->transnoentitiesnoconv(
"RequestToResetPasswordReceived").
"\n";
2830 $mesg .= $outputlangs->transnoentitiesnoconv(
"NewKeyIs").
" :\n\n";
2831 $mesg .= $outputlangs->transnoentitiesnoconv(
"Login").
" = ".$this->login.
"\n";
2832 $mesg .= $outputlangs->transnoentitiesnoconv(
"Password").
" = ".$password.
"\n\n";
2835 $mesg .= $outputlangs->transnoentitiesnoconv(
"ClickHereToGoTo", $appli).
': '.$url.
"\n\n";
2837 $mesg .= $user->getFullName($outputlangs);
2840 $url = $urlwithroot.
'/user/passwordforgotten.php?action=validatenewpassword';
2841 $url .=
'&username='.urlencode($this->login).
"&passworduidhash=".urlencode(
dol_hash($password.
'-'.$this->id.
'-'.
$conf->file->instance_unique_id));
2843 $url .=
'&entity='.(!empty($this->entity) ? $this->entity : 1);
2846 dol_syslog(get_class($this).
"::send_password changelater is on, url=".$url);
2850 $mesg .= $outputlangs->transnoentitiesnoconv(
"RequestToResetPasswordReceived").
"<br>\n";
2851 $mesg .= $outputlangs->transnoentitiesnoconv(
"NewKeyWillBe").
" :<br>\n<br>\n";
2852 $mesg .=
'<strong>'.$outputlangs->transnoentitiesnoconv(
"Login").
"</strong> = ".$this->login.
"<br>\n";
2853 $mesg .=
'<strong>'.$outputlangs->transnoentitiesnoconv(
"Password").
"</strong> = ".$password.
"<br>\n<br>\n";
2855 $mesg .= $outputlangs->transnoentitiesnoconv(
"YouMustClickToChange").
" :<br>\n";
2856 $mesg .=
'<a href="'.$url.
'" rel="noopener">'.$outputlangs->transnoentitiesnoconv(
"ConfirmPasswordChange").
'</a>'.
"<br>\n<br>\n";
2857 $mesg .= $outputlangs->transnoentitiesnoconv(
"ForgetIfNothing").
"<br>\n<br>\n";
2860 $trackid =
'use'.$this->id;
2861 $sendcontext =
'passwordreset';
2882 if ($mailfile->sendfile()) {
2885 $langs->trans(
"errors");
2886 $this->
error = $langs->trans(
"ErrorFailedToSendPassword").
' '.$mailfile->error;
2898 return $this->error;
2911 $sql =
"SELECT url, login, pass, poste ";
2912 $sql .=
" FROM ".$this->db->prefix().
"user_clicktodial as u";
2913 $sql .=
" WHERE u.fk_user = ".((int) $this->
id);
2915 $resql = $this->db->query($sql);
2917 if ($this->db->num_rows($resql)) {
2918 $obj = $this->db->fetch_object($resql);
2920 $this->clicktodial_url = $obj->url;
2921 $this->clicktodial_login = $obj->login;
2922 $this->clicktodial_password = $obj->pass;
2923 $this->clicktodial_poste = $obj->poste;
2926 $this->clicktodial_loaded = 1;
2928 $this->db->free($resql);
2931 $this->
error = $this->db->error();
2947 $sql =
"DELETE FROM ".$this->db->prefix().
"user_clicktodial";
2948 $sql .=
" WHERE fk_user = ".((int) $this->
id);
2950 dol_syslog(get_class($this).
'::update_clicktodial', LOG_DEBUG);
2952 $result = $this->db->query($sql);
2954 $sql =
"INSERT INTO ".$this->db->prefix().
"user_clicktodial";
2955 $sql .=
" (fk_user,url,login,pass,poste)";
2956 $sql .=
" VALUES (".((int) $this->
id);
2957 $sql .=
", '".$this->db->escape($this->clicktodial_url).
"'";
2958 $sql .=
", '".$this->db->escape($this->clicktodial_login).
"'";
2959 $sql .=
", '".$this->db->escape($this->clicktodial_password).
"'";
2960 $sql .=
", '".$this->db->escape($this->clicktodial_poste).
"')";
2962 dol_syslog(get_class($this).
'::update_clicktodial', LOG_DEBUG);
2964 $result = $this->db->query($sql);
2966 $this->db->commit();
2969 $this->db->rollback();
2970 $this->
error = $this->db->lasterror();
2988 global $langs, $user;
2994 $sql =
"DELETE FROM ".$this->db->prefix().
"usergroup_user";
2995 $sql .=
" WHERE fk_user = ".((int) $this->
id);
2996 $sql .=
" AND fk_usergroup = ".((int) $group);
2997 $sql .=
" AND entity = ".((int) $entity);
2999 $result = $this->db->query($sql);
3001 $sql =
"INSERT INTO ".$this->db->prefix().
"usergroup_user (entity, fk_user, fk_usergroup)";
3002 $sql .=
" VALUES (".((int) $entity).
",".((int) $this->
id).
",".((int) $group).
")";
3004 $result = $this->db->query($sql);
3006 if (!$error && !$notrigger) {
3007 $this->context = array(
'audit' => $langs->trans(
"UserSetInGroup"),
'newgroupid' => $group);
3010 $result = $this->call_trigger(
'USER_MODIFY', $user);
3018 $this->db->commit();
3022 $this->db->rollback();
3026 $this->
error = $this->db->lasterror();
3027 $this->db->rollback();
3044 global $langs, $user;
3050 $sql =
"DELETE FROM ".$this->db->prefix().
"usergroup_user";
3051 $sql .=
" WHERE fk_user = ".((int) $this->
id);
3052 $sql .=
" AND fk_usergroup = ".((int) $group);
3053 if (empty($entity)) {
3054 $sql .=
" AND entity IN (0, 1)";
3056 $sql .=
" AND entity = ".((int) $entity);
3059 $result = $this->db->query($sql);
3061 if (!$error && !$notrigger) {
3062 $this->context = array(
'audit' => $langs->trans(
"UserRemovedFromGroup"),
'oldgroupid' => $group);
3065 $result = $this->call_trigger(
'USER_MODIFY', $user);
3073 $this->db->commit();
3076 dol_syslog(get_class($this).
"::RemoveFromGroup ".$this->
error, LOG_ERR);
3077 $this->db->rollback();
3081 $this->
error = $this->db->lasterror();
3082 $this->db->rollback();
3096 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
3103 if ($this->datestartvalidity && $this->datestartvalidity >
dol_get_last_hour($now)) {
3126 public function getPhotoUrl($width, $height, $cssclass =
'', $imagesize =
'')
3128 $result =
'<a href="'.DOL_URL_ROOT.
'/user/card.php?id='.$this->
id.
'">';
3129 $result .=
Form::showphoto(
'userphoto', $this, $width, $height, 0, $cssclass, $imagesize);
3143 global $conf, $langs, $menumanager;
3144 global $dolibarr_main_demo;
3146 $infologin = $params[
'infologin'] ?? 0;
3147 $option = $params[
'option'] ??
'';
3150 if (!empty($this->photo)) {
3151 $photo =
'<div class="photointooltip floatright">';
3152 $photo .=
Form::showphoto(
'userphoto', $this, 0, 60, 0,
'photoref photowithmargin photologintooltip',
'small', 0, 1);
3154 $data[
'photo'] = $photo;
3159 $data[
'opendiv'] =
'<div class="centpercent divtooltip">';
3160 $data[
'picto'] =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"User").
'</u> '.$this->
getLibStatut(4);
3162 if (!empty($this->login)) {
3165 if (!empty($this->job)) {
3169 if (!empty($this->office_phone) || !empty($this->office_fax) || !empty($this->fax)) {
3170 $phonelist = array();
3171 if ($this->office_phone) {
3172 $phonelist[] =
dol_print_phone($this->office_phone, $this->country_code, $this->
id, 0,
'',
' ',
'phone');
3174 if ($this->office_fax) {
3175 $phonelist[] =
dol_print_phone($this->office_fax, $this->country_code, $this->
id, 0,
'',
' ',
'fax');
3177 if ($this->user_mobile) {
3178 $phonelist[] =
dol_print_phone($this->user_mobile, $this->country_code, $this->
id, 0,
'',
' ',
'mobile');
3180 $data[
'phones'] =
'<br><b>'.$langs->trans(
'Phone').
':</b> '.implode(
' ', $phonelist);
3182 if (!empty($this->admin)) {
3183 $data[
'administrator'] =
'<br><b>'.$langs->trans(
"Administrator").
'</b>: '.
yn($this->admin);
3185 if (!empty($this->accountancy_code) || $option ==
'accountancy') {
3186 $langs->load(
"companies");
3187 $data[
'accountancycode'] =
'<br><b>'.$langs->trans(
"AccountancyCode").
'</b>: '.$this->accountancy_code;
3190 if (!empty($this->socid)) {
3191 $thirdpartystatic =
new Societe($this->db);
3192 $thirdpartystatic->fetch($this->socid);
3194 if (empty($params[
'hidethirdpartylogo'])) {
3195 $companyimg =
' '.$thirdpartystatic->getNomUrl(2,
'nolink', 0, 1);
3197 $company =
' ('.$langs->trans(
"Company").
': '.($companyimg ? $companyimg :
img_picto(
'',
'company')).
' '.
dol_string_nohtmltag($thirdpartystatic->name).
')';
3199 $type = ($this->socid ? $langs->trans(
"ExternalUser").$company : $langs->trans(
"InternalUser"));
3200 $data[
'type'] =
'<br><b>'.$langs->trans(
"Type").
':</b> '.$type;
3201 $data[
'closediv'] =
'</div>';
3203 if ($infologin > 0) {
3204 $data[
'newlinelogin'] =
'<br>';
3205 $data[
'session'] =
'<br><u>'.$langs->trans(
"Session").
'</u>';
3208 $data[
'multicompany'] =
'<br><b>'.$langs->trans(
"ConnectedOnMultiCompany").
':</b> '.
$conf->entity.
' (User entity '.$this->entity.
')';
3210 $data[
'authentication'] =
'<br><b>'.$langs->trans(
"AuthenticationMode").
':</b> '.
dol_string_nohtmltag($_SESSION[
"dol_authmode"].(empty($dolibarr_main_demo) ?
'' :
' (demo)'));
3211 $data[
'connectedsince'] =
'<br><b>'.$langs->trans(
"ConnectedSince").
':</b> '.
dol_print_date($this->datelastlogin,
"dayhour",
'tzuser');
3212 $data[
'previousconnexion'] =
'<br><b>'.$langs->trans(
"PreviousConnexion").
':</b> '.
dol_print_date($this->datepreviouslogin,
"dayhour",
'tzuser');
3215 $data[
'currentmenumanager'] =
'<br><b>'.$langs->trans(
"CurrentMenuManager").
':</b> '.
dol_string_nohtmltag($menumanager->name);
3217 $data[
'currentuserlang'] =
'<br><b>'.$langs->trans(
"CurrentUserLanguage").
':</b> '.
dol_string_nohtmltag(($s ? $s.
' ' :
'').$langs->getDefaultLang());
3218 $data[
'browser'] =
'<br><b>'.$langs->trans(
"Browser").
':</b> '.
dol_string_nohtmltag(
$conf->browser->name.($conf->browser->version ?
' '.$conf->browser->version :
'').
' ('.$_SERVER[
'HTTP_USER_AGENT'].
')');
3220 $data[
'screen'] =
'<br><b>'.$langs->trans(
"Screen").
':</b> '.
dol_string_nohtmltag($_SESSION[
'dol_screenwidth'].
' x '.$_SESSION[
'dol_screenheight']);
3221 if (
$conf->browser->layout ==
'phone') {
3222 $data[
'phone'] =
'<br><b>'.$langs->trans(
"Phone").
':</b> '.$langs->trans(
"Yes");
3224 if (!empty($_SESSION[
"disablemodules"])) {
3225 $data[
'disabledmodules'] =
'<br><b>'.$langs->trans(
"DisabledModules").
':</b> <br>'.
dol_string_nohtmltag(implode(
', ', explode(
',', $_SESSION[
"disablemodules"])));
3247 public function getNomUrl($withpictoimg = 0, $option =
'', $infologin = 0, $notooltip = 0, $maxlen = 24, $hidethirdpartylogo = 0, $mode =
'', $morecss =
'', $save_lastsearch_value = -1)
3249 global $langs, $hookmanager, $user;
3251 if (!$user->hasRight(
'user',
'user',
'read') && $user->id != $this->id) {
3262 'objecttype' => $this->element,
3263 'infologin' => $infologin,
3264 'option' => $option,
3265 'hidethirdpartylogo' => $hidethirdpartylogo,
3267 $classfortooltip =
'classfortooltip';
3270 $classfortooltip =
'classforajaxtooltip';
3271 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
3278 if (!empty($this->socid)) {
3279 $thirdpartystatic =
new Societe($this->db);
3280 $thirdpartystatic->fetch($this->socid);
3281 if (empty($hidethirdpartylogo)) {
3282 $companylink =
' '.$thirdpartystatic->getNomUrl(2,
'nolink', 0, 1);
3286 if ($infologin < 0) {
3290 $baseurl = DOL_URL_ROOT .
'/user/card.php';
3291 if ($option ==
'leave') {
3292 $baseurl = DOL_URL_ROOT .
'/holiday/list.php';
3294 $query = [
'id' => $this->id];
3295 if ($option !=
'nolink') {
3297 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
3298 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
3299 $add_save_lastsearch_values = 1;
3301 if ($add_save_lastsearch_values) {
3302 $query = array_merge($query, [
'save_lastsearch_values' => 1]);
3307 $linkstart =
'<a href="'.$url.
'"';
3309 if (empty($notooltip)) {
3311 $langs->load(
"users");
3312 $label = $langs->trans(
"ShowUser");
3313 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
3315 $linkclose .= ($label ?
' title="'.dolPrintHTMLForAttribute($label).
'"' :
' title="tocomplete"');
3316 $linkclose .= $dataparams .
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
3318 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
3321 $linkstart .= $linkclose.
'>';
3325 $result .= (($option ==
'nolink') ?
'' : $linkstart);
3326 if ($withpictoimg) {
3327 $paddafterimage =
'';
3328 if (abs((
int) $withpictoimg) == 1 || abs((
int) $withpictoimg) == 4) {
3329 $paddafterimage =
'style="margin-'.($langs->trans(
"DIRECTION") ==
'rtl' ?
'left' :
'right').
': 3px;"';
3332 if ($withpictoimg > 0) {
3333 $picto =
'<!-- picto user --><span class="nopadding userimg'.($morecss ?
' '.$morecss :
'').
'"><div class="valignmiddle userphoto inline-block center marginrightonlyshort"'.($paddafterimage ?
' '.$paddafterimage :
'').
'>'.
img_object(
'',
'user',
'class=""', 0, 0, $notooltip ? 0 : 1).
'</div></span>';
3336 $picto =
'<!-- picto photo user --><span class="nopadding userimg'.($morecss ?
' '.$morecss :
'').
'"'.($paddafterimage ?
' '.$paddafterimage :
'').
'>';
3337 $picto .=
Form::showphoto(
'userphoto', $this, 0, 0, 0,
'userphoto'.(($withpictoimg == -3 || $withpictoimg == -4) ?
'small' :
''),
'mini', 0, 1);
3338 $picto .=
'</span>';
3343 if ($withpictoimg == -4 || ($withpictoimg > -2 && $withpictoimg != 2)) {
3345 $result .=
'<span class="nopadding usertext'.((!isset($this->
status) || $this->status) ?
'' :
' strikefordisabled').($morecss ?
' '.$morecss :
'').
'">';
3347 if ($mode ==
'login') {
3353 $result .=
'</span>';
3356 $result .= (($option ==
'nolink') ?
'' : $linkend);
3359 $result .= $companylink;
3362 $hookmanager->initHooks(array(
'userdao'));
3363 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
3364 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
3366 $result = $hookmanager->resPrint;
3368 $result .= $hookmanager->resPrint;
3383 public function getLoginUrl($withpictoimg = 0, $option =
'', $notooltip = 0, $morecss =
'')
3385 global $langs, $user;
3389 $linkstart =
'<a href="'.DOL_URL_ROOT.
'/user/card.php?id='.$this->
id.
'">';
3393 if ((!$user->hasRight(
'user',
'user',
'lire') && $this->id != $user->id)) {
3397 if ($option ==
'xxx') {
3398 $linkstart =
'<a href="'.DOL_URL_ROOT.
'/user/card.php?id='.$this->
id.
'">';
3402 if ($option ==
'nolink') {
3407 $result .= $linkstart;
3408 if ($withpictoimg) {
3409 $paddafterimage =
'';
3410 if (abs($withpictoimg) == 1) {
3411 $paddafterimage =
'style="margin-'.($langs->trans(
"DIRECTION") ==
'rtl' ?
'left' :
'right').
': 3px;"';
3414 if ($withpictoimg > 0) {
3415 $picto =
'<!-- picto user --><span class="nopadding userimg'.($morecss ?
' '.$morecss :
'').
'">'.
img_object(
'',
'user', $paddafterimage.
' '.($notooltip ?
'' :
'class="paddingright classfortooltip"'), 0, 0, $notooltip ? 0 : 1).
'</span>';
3418 $picto =
'<!-- picto photo user --><span class="nopadding userimg'.($morecss ?
' '.$morecss :
'').
'"'.($paddafterimage ?
' '.$paddafterimage :
'').
'>'.
Form::showphoto(
'userphoto', $this, 0, 0, 0,
'userphoto'.($withpictoimg == -3 ?
'small' :
''),
'mini', 0, 1).
'</span>';
3422 $result .= $this->login;
3423 $result .= $linkend;
3436 return $this->
LibStatut(isset($this->statut) ? (
int) $this->statut : (int) $this->
status, $mode);
3452 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
3455 $this->labelStatus[self::STATUS_ENABLED] = $langs->transnoentitiesnoconv(
'Enabled');
3456 $this->labelStatus[self::STATUS_DISABLED] = $langs->transnoentitiesnoconv(
'Disabled');
3457 $this->labelStatusShort[self::STATUS_ENABLED] = $langs->transnoentitiesnoconv(
'Enabled');
3458 $this->labelStatusShort[self::STATUS_DISABLED] = $langs->transnoentitiesnoconv(
'Disabled');
3461 $statusType =
'status5';
3462 if ($status == self::STATUS_ENABLED) {
3463 $statusType =
'status4';
3466 $label = $this->labelStatus[$status];
3467 $labelshort = $this->labelStatusShort[$status];
3470 if (!empty($this->datestartvalidity) && $now < $this->datestartvalidity) {
3471 $statusType =
'status3';
3472 $label .=
' ('.$langs->trans(
"UserNotYetValid").
')';
3474 if (!empty($this->dateendvalidity) && $now > ($this->dateendvalidity + 24 * 3600 - 1)) {
3475 $statusType =
'status2';
3476 $label .=
' ('.$langs->trans(
"UserExpired").
')';
3479 return dolGetStatus($label, $labelshort,
'', $statusType, $mode);
3494 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
3496 $return =
'<div class="box-flex-item box-flex-grow-zero">';
3497 $return .=
'<div class="info-box info-box-sm">';
3498 $return .=
'<span class="info-box-icon bg-infobox-action">';
3501 if (!empty($this->photo)) {
3503 $label .=
Form::showphoto(
'userphoto', $this, 0, 60, 0,
'photokanban photoref photowithmargin photologintooltip',
'small', 0, 1);
3512 $return .=
'</span>';
3513 $return .=
'<div class="info-box-content">';
3514 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl(0,
'', 0, 0, 24, 0,
'',
'valignmiddle') : $this->ref);
3515 if (
isModEnabled(
'multicompany') && $this->admin && !$this->entity) {
3516 $return .=
img_picto($langs->trans(
"SuperAdministratorDesc"),
'superadmin',
'class="valignmiddle paddingright paddingleft"');
3517 } elseif ($this->admin) {
3518 $return .=
img_picto($langs->trans(
"AdministratorDesc"),
'admin',
'class="valignmiddle paddingright paddingleft"');
3520 $return .=
'</span>';
3521 if ($selected >= 0) {
3522 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
3524 if (property_exists($this,
'label')) {
3525 $return .=
'<br><span class="info-box-label opacitymedium">'.$this->label.
'</span>';
3528 $return .=
'<br><span class="info-box-label opacitymedium small">'.img_picto(
'',
'email').
' '.$this->
email.
'</span>';
3530 if (method_exists($this,
'getLibStatut')) {
3531 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
3533 $return .=
'</div>';
3534 $return .=
'</div>';
3535 $return .=
'</div>';
3559 } elseif ($mode == 1) {
3561 } elseif ($mode == 2) {
3577 global $conf, $langs;
3583 $keymodified =
false;
3592 'LDAP_FIELD_FULLNAME' =>
'fullname',
3593 'LDAP_FIELD_NAME' =>
'lastname',
3594 'LDAP_FIELD_FIRSTNAME' =>
'firstname',
3595 'LDAP_FIELD_LOGIN' =>
'login',
3596 'LDAP_FIELD_LOGIN_SAMBA' =>
'login',
3597 'LDAP_FIELD_PHONE' =>
'office_phone',
3598 'LDAP_FIELD_MOBILE' =>
'user_mobile',
3599 'LDAP_FIELD_FAX' =>
'office_fax',
3600 'LDAP_FIELD_MAIL' =>
'email',
3601 'LDAP_FIELD_SID' =>
'ldap_sid',
3605 foreach ($ldapkey as $constname => $varname) {
3611 if (is_object($this->oldcopy) && !$this->oldcopy->isEmpty() && $this->$varname != $this->oldcopy->$varname) {
3612 $keymodified =
true;
3617 foreach ($socialnetworks as $key => $value) {
3618 if (!empty($this->socialnetworks[$value[
'label']]) &&
getDolGlobalString(
'LDAP_FIELD_'.strtoupper($value[
'label']))) {
3619 $info[
getDolGlobalString(
'LDAP_FIELD_'.strtoupper($value[
'label']))] = $this->socialnetworks[$value[
'label']];
3635 $soc =
new Societe($this->db);
3636 $soc->fetch($this->socid);
3639 if ($soc->client == 1) {
3640 $info[
"businessCategory"] =
"Customers";
3642 if ($soc->client == 2) {
3643 $info[
"businessCategory"] =
"Prospects";
3645 if ($soc->fournisseur == 1) {
3646 $info[
"businessCategory"] =
"Suppliers";
3651 if (!empty($this->pass)) {
3664 if ($this->pass_indatabase_crypted &&
getDolGlobalString(
'LDAP_FIELD_PASSWORD_CRYPTED')) {
3668 } elseif (!empty($this->pass_indatabase)) {
3680 $info[
"objectclass"][4] =
"phpgwContact";
3682 $info[
'uidnumber'] = $this->id;
3684 $info[
'phpgwTz'] = 0;
3685 $info[
'phpgwMailType'] =
'INTERNET';
3686 $info[
'phpgwMailHomeType'] =
'INTERNET';
3688 $info[
"phpgwContactTypeId"] =
'n';
3689 $info[
"phpgwContactCatId"] = 0;
3690 $info[
"phpgwContactAccess"] =
"public";
3692 $info[
"phpgwContactOwner"] = 1;
3695 $info[
"rfc822Mailbox"] = $this->email;
3697 if ($this->user_mobile) {
3698 $info[
"phpgwCellTelephoneNumber"] = $this->user_mobile;
3707 $groupslist = $usergroup->listGroupsForUser($this->
id);
3709 if (!empty($groupslist)) {
3710 foreach ($groupslist as $groupforuser) {
3739 $this->
ref =
'SPECIMEN';
3740 $this->specimen = 1;
3741 $this->user_creation_id = $user->id;
3743 $this->lastname =
'DOLIBARR';
3744 $this->firstname =
'SPECIMEN';
3745 $this->gender =
'man';
3746 $this->note_public =
'This is a note public';
3747 $this->note_private =
'This is a note private';
3748 $this->
email =
'email@specimen.com';
3749 $this->personal_email =
'personalemail@specimen.com';
3750 $this->socialnetworks = array(
3751 'skype' =>
'skypepseudo',
3752 'twitter' =>
'twitterpseudo',
3753 'facebook' =>
'facebookpseudo',
3754 'linkedin' =>
'linkedinpseudo',
3756 $this->office_phone =
'0999999999';
3757 $this->office_fax =
'0999999998';
3758 $this->user_mobile =
'0999999997';
3759 $this->personal_mobile =
'0999999996';
3761 $this->login =
'dolibspec';
3762 $this->pass =
'dolibSpec+@123';
3765 $this->datec = $now;
3766 $this->datem = $now;
3768 $this->datelastlogin = $now;
3769 $this->iplastlogin =
'127.0.0.1';
3770 $this->datepreviouslogin = $now;
3771 $this->ippreviouslogin =
'127.0.0.1';
3787 $sql =
"SELECT u.rowid, u.login as ref, u.datec, fk_user_creat as user_creation_id, fk_user_modif as user_modification_id,";
3788 $sql .=
" GREATEST(u.tms, uef.tms) as date_modification, u.entity";
3789 $sql .=
" FROM ".$this->db->prefix().
"user as u";
3790 $sql .=
" LEFT JOIN ".$this->db->prefix().
"user_extrafields as uef ON uef.fk_object = u.rowid";
3791 $sql .=
" WHERE u.rowid = ".((int) $id);
3793 $result = $this->db->query($sql);
3795 if ($this->db->num_rows($result)) {
3796 $obj = $this->db->fetch_object($result);
3798 $this->
id = $obj->rowid;
3800 $this->user_creation_id = $obj->user_creation_id;
3801 $this->user_modification_id = $obj->user_modification_id;
3803 $this->
ref = (!$obj->ref) ? $obj->rowid : $obj->ref;
3804 $this->date_creation = $this->db->jdate($obj->datec);
3805 $this->date_modification = $this->db->jdate($obj->date_modification);
3806 $this->entity = $obj->entity;
3809 $this->db->free($result);
3823 $sql =
"SELECT count(mc.email) as nb";
3824 $sql .=
" FROM ".$this->db->prefix().
"mailing_cibles as mc";
3825 $sql .=
" WHERE mc.email = '".$this->db->escape($this->
email).
"'";
3826 $sql .=
" AND mc.statut NOT IN (-1,0)";
3828 $resql = $this->db->query($sql);
3830 $obj = $this->db->fetch_object($resql);
3831 $nb = (int) $obj->nb;
3833 $this->db->free($resql);
3836 $this->
error = $this->db->error();
3851 $sql =
"SELECT count(rowid) as nb";
3852 $sql .=
" FROM ".$this->db->prefix().
"user";
3853 if ($option ==
'superadmin') {
3854 $sql .=
" WHERE entity = 0";
3856 $sql .=
" WHERE entity IN (".getEntity(
'user', 0).
")";
3857 if ($limitTo ==
'active') {
3858 $sql .=
" AND statut = 1";
3862 $sql .=
" AND admin = ".(int) $admin;
3865 $resql = $this->db->query($sql);
3867 $obj = $this->db->fetch_object($resql);
3868 $nb = (int) $obj->nb;
3870 $this->db->free($resql);
3873 $this->
error = $this->db->lasterror();
3894 $this->firstname = $ldapuser->$tmpvar;
3896 $this->lastname = $ldapuser->$tmpvar;
3898 $this->login = $ldapuser->$tmpvar;
3900 $this->pass = $ldapuser->$tmpvar;
3902 $this->pass_indatabase_crypted = $ldapuser->$tmpvar;
3905 $this->office_phone = $ldapuser->$tmpvar;
3907 $this->user_mobile = $ldapuser->$tmpvar;
3909 $this->office_fax = $ldapuser->$tmpvar;
3911 $this->
email = $ldapuser->$tmpvar;
3912 foreach ($socialnetworks as $key => $value) {
3914 $this->socialnetworks[$value[
'label']] = $ldapuser->$tmpvar;
3917 $this->ldap_sid = $ldapuser->$tmpvar;
3920 $this->job = $ldapuser->$tmpvar;
3922 $this->note_public = $ldapuser->$tmpvar;
3924 $result = $this->
update($user);
3926 dol_syslog(get_class($this).
"::update_ldap2dolibarr result=".$result, LOG_DEBUG);
3942 $sql =
"SELECT rowid FROM ".$this->db->prefix().
"user";
3943 $sql .=
" WHERE fk_user = ".((int) $this->
id);
3945 dol_syslog(get_class($this).
"::get_children", LOG_DEBUG);
3946 $res = $this->db->query($sql);
3949 while ($rec = $this->db->fetch_array($res)) {
3950 $user =
new User($this->db);
3951 $user->fetch($rec[
'rowid']);
3969 $this->parentof = array();
3972 $sql =
"SELECT fk_user as id_parent, rowid as id_son";
3973 $sql .=
" FROM ".$this->db->prefix().
"user";
3974 $sql .=
" WHERE fk_user <> 0";
3975 $sql .=
" AND entity IN (".getEntity(
'user').
")";
3977 dol_syslog(get_class($this).
"::loadParentOf", LOG_DEBUG);
3978 $resql = $this->db->query($sql);
3980 while ($obj = $this->db->fetch_object($resql)) {
3981 $this->parentof[$obj->id_son] = $obj->id_parent;
4007 global $hookmanager;
4010 $hookmanager->initHooks(array(
'userdao'));
4012 $this->users = array();
4018 $sql =
"SELECT DISTINCT u.rowid, u.firstname, u.lastname, u.fk_user, u.fk_soc, u.login, u.email, u.gender, u.admin, u.statut, u.photo, u.entity";
4019 $sql .=
" FROM ".$this->db->prefix().
"user as u";
4021 $parameters = array();
4022 $reshook = $hookmanager->executeHooks(
'printUserListWhere', $parameters);
4024 $sql .= $hookmanager->resPrint;
4026 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
4032 dol_syslog(get_class($this).
"::get_full_tree get user list", LOG_DEBUG);
4033 $resql = $this->db->query($sql);
4036 while ($obj = $this->db->fetch_object($resql)) {
4037 $this->users[(int) $obj->rowid]
4039 'rowid' => (
int) $obj->rowid,
4040 'id' => (int) $obj->rowid,
4041 'fk_user' => (
int) $obj->fk_user,
4042 'fk_soc' => (int) $obj->fk_soc,
4043 'firstname' => (
string) $obj->firstname,
4044 'lastname' => (
string) $obj->lastname,
4045 'login' => (
string) $obj->login,
4046 'statut' => (int) $obj->statut,
4047 'entity' => (
int) $obj->entity,
4048 'email' => (
string) $obj->email,
4049 'gender' => (
string) $obj->gender,
4050 'admin' => (int) $obj->admin,
4051 'photo' => (
string) $obj->photo,
4065 dol_syslog(get_class($this).
"::get_full_tree call to build_path_from_id_user", LOG_DEBUG);
4066 foreach ($this->users as $key => $val) {
4069 $this->
error =
'ErrorLoopInHierarchy';
4075 if ($deleteafterid) {
4077 $keyfilter1 =
'^'.$deleteafterid.
'$';
4078 $keyfilter2 =
'_'.$deleteafterid.
'$';
4079 $keyfilter3 =
'^'.$deleteafterid.
'_';
4080 $keyfilter4 =
'_'.$deleteafterid.
'_';
4081 foreach (array_keys($this->users) as $key) {
4082 $fullpath = (
string) $this->users[$key][
'fullpath'];
4083 if (preg_match(
'/'.$keyfilter1.
'/', $fullpath) || preg_match(
'/'.$keyfilter2.
'/', $fullpath)
4084 || preg_match(
'/'.$keyfilter3.
'/', $fullpath) || preg_match(
'/'.$keyfilter4.
'/', $fullpath)) {
4085 unset($this->users[$key]);
4090 dol_syslog(get_class($this).
"::get_full_tree dol_sort_array", LOG_DEBUG);
4091 $this->users =
dol_sort_array($this->users,
'fullname',
'asc', 1, 0, 1);
4093 return $this->users;
4106 $childids = array();
4108 if (isset($this->cache_childids[$this->
id])) {
4109 $childids = $this->cache_childids[$this->id];
4114 $idtoscan = $this->id;
4116 dol_syslog(
"Build childid for id = ".$idtoscan);
4117 foreach ($this->users as $id => $val) {
4118 if (preg_match(
'/_'.$idtoscan.
'_/', $val[
'fullpath'])) {
4119 $childids[$val[
'id']] = $val[
'id'];
4123 $this->cache_childids[$this->id] = $childids;
4125 if ($addcurrentuser) {
4126 $childids[$this->id] = $this->id;
4146 if (!empty($this->users[$id_user][
'fullpath'])) {
4148 dol_syslog(get_class($this).
"::build_path_from_id_user fullpath and fullname already defined", LOG_WARNING);
4153 $this->users[$id_user][
'fullpath'] =
'_'.$id_user;
4154 $this->users[$id_user][
'fullname'] = $this->users[$id_user][
'lastname'];
4156 $cursor_user = $id_user;
4158 $useridfound = array($id_user);
4159 while (!empty($this->parentof[$cursor_user]) && !empty($this->users[$this->parentof[$cursor_user]])) {
4160 if (in_array($this->parentof[$cursor_user], $useridfound)) {
4161 dol_syslog(
"The hierarchy of user has a recursive loop", LOG_WARNING);
4164 $useridfound[] = $this->parentof[$cursor_user];
4165 $this->users[$id_user][
'fullpath'] =
'_'.$this->parentof[$cursor_user].$this->users[$id_user][
'fullpath'];
4166 $this->users[$id_user][
'fullname'] = $this->users[$this->parentof[$cursor_user]][
'lastname'].
' >> '.$this->users[$id_user][
'fullname'];
4168 $cursor_user = $this->parentof[$cursor_user];
4172 $this->users[$id_user][
'level'] =
dol_strlen(preg_replace(
'/[^_]/i',
'', $this->users[$id_user][
'fullpath']));
4202 $this->nb = array();
4204 $sql =
"SELECT COUNT(DISTINCT u.rowid) as nb";
4205 $sql .=
" FROM ".$this->db->prefix().
"user as u";
4207 $sql .=
", ".$this->db->prefix().
"usergroup_user as ug";
4208 $sql .=
" WHERE ug.entity IN (".getEntity(
'usergroup').
")";
4209 $sql .=
" AND ug.fk_user = u.rowid";
4211 $sql .=
" WHERE u.entity IN (".getEntity(
'user').
")";
4213 $sql .=
" AND u.statut > 0";
4216 $resql = $this->db->query($sql);
4218 while ($obj = $this->db->fetch_object($resql)) {
4219 $this->nb[
"users"] = $obj->nb;
4221 $this->db->free($resql);
4225 $this->
error = $this->db->error();
4241 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
4245 $langs->load(
"user");
4252 $modele =
'bluesky';
4256 $modelpath =
"core/modules/user/doc/";
4258 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
4272 $user_property =
'';
4274 if (empty($rowid)) {
4278 $sql =
"SELECT rowid, email, user_mobile, civility, lastname, firstname";
4279 $sql .=
" FROM ".$this->db->prefix().
"user";
4280 $sql .=
" WHERE rowid = ".((int) $rowid);
4282 $resql = $this->db->query($sql);
4284 $nump = $this->db->num_rows($resql);
4287 $obj = $this->db->fetch_object($resql);
4289 if ($mode ==
'email') {
4290 $user_property =
dolGetFirstLastname($obj->firstname, $obj->lastname).
" <".$obj->email.
">";
4291 } elseif ($mode ==
'mobile') {
4292 $user_property = $obj->user_mobile;
4293 } elseif ($mode ==
'name') {
4297 return $user_property;
4317 $instanceuniqueid = empty(
$conf->file->instance_unique_id) ?
'' :
$conf->file->instance_unique_id;
4318 $encodedsecurekey =
dol_hash($instanceuniqueid.
'uservirtualcard'.$this->id.
'-'.$this->login,
'md5');
4320 $entity_qr =
'&entity='.((int)
$conf->entity);
4325 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
4326 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
4329 if ($typeofurl ==
'internal') {
4330 $urlwithroot = DOL_URL_ROOT;
4333 return $urlwithroot.
'/public/users/view.php?id='.$this->
id.
'&securekey='.$encodedsecurekey.$entity_qr.($mode ?
'&mode='.urlencode($mode) :
'');
4349 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND', $entityfilter =
false)
4351 global $conf, $user;
4353 $sql =
"SELECT t.rowid";
4354 $sql .=
' FROM '.$this->db->prefix().$this->table_element.
' as t ';
4356 if ($entityfilter) {
4358 if (!empty($user->admin) && empty($user->entity) &&
$conf->entity == 1) {
4359 $sql .=
" WHERE t.entity IS NOT NULL";
4361 $sql .=
" WHERE t.entity = 0 OR EXISTS (";
4362 $sql .=
" SELECT ug.rowid FROM " . $this->db->prefix() .
"usergroup_user as ug";
4363 $sql .=
" WHERE ug.fk_user = t.rowid AND ug.entity IN (" .
getEntity(
'usergroup') .
"))";
4366 $sql .=
" WHERE t.entity IN (".getEntity(
'user').
")";
4369 $sql .=
" WHERE 1 = 1";
4375 if ($errormessage) {
4376 $this->errors[] = $errormessage;
4377 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
4381 $sql .= $this->db->order($sortfield, $sortorder);
4383 $sql .= $this->db->plimit($limit + 1, $offset);
4388 $resql = $this->db->query($sql);
4390 $this->users = array();
4391 $num = $this->db->num_rows($resql);
4393 while ($obj = $this->db->fetch_object($resql)) {
4394 $line =
new self($this->db);
4395 $result = $line->fetch($obj->rowid);
4396 if ($result > 0 && !empty($line->id)) {
4397 $this->users[$obj->rowid] = clone $line;
4400 $this->db->free($resql);
4404 $this->errors[] = $this->db->lasterror();
4416 private $findUserIdByEmailCache;
4430 if (isset($this->findUserIdByEmailCache[$email])) {
4431 return $this->findUserIdByEmailCache[$email];
4434 $this->findUserIdByEmailCache[$email] = -1;
4436 $sql =
'SELECT rowid';
4437 $sql .=
' FROM '.$this->db->prefix().
'user';
4438 if (
getDolGlobalString(
'AGENDA_DISABLE_EXACT_USER_EMAIL_COMPARE_FOR_EXTERNAL_CALENDAR')) {
4439 $sql .=
" WHERE email LIKE '%".$this->db->escape($this->db->escapeforlike($email)).
"%'";
4441 $sql .=
" WHERE email = '".$this->db->escape($email).
"'";
4445 $resql = $this->db->query($sql);
4450 $obj = $this->db->fetch_object($resql);
4455 $this->findUserIdByEmailCache[$email] = (int) $obj->rowid;
4457 return $this->findUserIdByEmailCache[$email];
4468 if (empty($fromId) || empty($toId)) {
4475 $sqlDelete =
"DELETE FROM ".$this->db->prefix().
"user_rights";
4476 $sqlDelete .=
" WHERE fk_user = ".((int) $toId);
4478 dol_syslog(get_class($this).
"::clone_rights (delete default permissions)", LOG_DEBUG);
4480 if (!$this->db->query($sqlDelete)) {
4481 $this->db->rollback();
4486 $sql =
"INSERT INTO ".$this->db->prefix().
"user_rights (entity, fk_user, fk_id)";
4487 $sql .=
" SELECT entity, ".((int) $toId).
", fk_id";
4488 $sql .=
" FROM ".$this->db->prefix().
"user_rights src";
4489 $sql .=
" WHERE fk_user = ".((int) $fromId);
4490 $sql .=
" AND NOT EXISTS (";
4491 $sql .=
" SELECT 1";
4492 $sql .=
" FROM ".$this->db->prefix().
"user_rights dest";
4493 $sql .=
" WHERE dest.entity = src.entity";
4494 $sql .=
" AND dest.fk_user = ".((int) $toId);
4495 $sql .=
" AND dest.fk_id = src.fk_id";
4498 dol_syslog(get_class($this).
"::clone_rights", LOG_DEBUG);
4501 if (!$this->db->query($sql)) {
4502 $this->db->rollback();
4506 $this->db->commit();
4523 $type = $this->table_element;
4526 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
4527 $categorystatic =
new Categorie($this->db);
4529 $sql =
"INSERT INTO ".$this->db->prefix().
"categorie_".(empty($categorystatic->MAP_CAT_TABLE[$type]) ? $type : $categorystatic->MAP_CAT_TABLE[$type]).
" (fk_categorie, fk_user)";
4530 $sql .=
" SELECT fk_categorie, ".((int) $toId).
" FROM ".$this->db->prefix().
"categorie_".(empty($categorystatic->MAP_CAT_TABLE[$type]) ? $type : $categorystatic->MAP_CAT_TABLE[$type]);
4531 $sql .=
" WHERE fk_user = ".((int) $fromId);
4533 if (!$this->db->query($sql)) {
4534 $this->
error = $this->db->lasterror();
4535 $this->db->rollback();
4539 $this->db->commit();
global $dolibarr_main_url_root
Class to manage members of a foundation.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to manage categories.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
deleteExtraFields()
Delete all extra fields values for the current object.
static commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
Class to manage Dolibarr database access.
Class to manage warehouses.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
Class to manage user groups.
Class to manage Dolibarr users.
fetch($id=0, $login='', $sid='', $loadpersonalconf=0, $entity=-1, $email='', $fk_socpeople=0, $use_email_oauth2=0)
Load a user from database with its id or ref (login).
SetInGroup($group, $entity, $notrigger=0)
Add user into a group.
LibStatut($status, $mode=0)
Return the label of a status of user (active, inactive)
loadRights($moduletag='', $forcereload=0)
Load permissions granted to a user->id into object user->rights.
get_children()
Return and array with all instantiated first level children users of current user.
static replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
loadStateBoard()
Load metrics this->nb for dashboard.
hasRight($module, $permlevel1, $permlevel2='')
Return if a user has a permission.
info($id)
Load info of user object.
create_from_contact($contact, $login='', $password='')
Create a user from a contact object.
setstatus($status)
Change status of a user.
get_full_tree($deleteafterid=0, $filter='')
Build the hierarchy/tree of users into an array.
_load_ldap_info()
Initialize the info array (array of LDAP values) that will be used to call LDAP functions.
delrights($rid, $allmodule='', $allperms='', $entity=0, $notrigger=0)
Remove a right to the user.
update_last_login_date()
Update the user's last login date in the database.
__construct($db)
Constructor of the class.
RemoveFromGroup($group, $entity, $notrigger=0)
Remove a user from a group.
isNotIntoValidityDateRange()
Return a link with photo Use this->id,this->photo.
getNbOfUsers($limitTo, $option='', $admin=-1)
Return number of existing users.
set_default_rights()
Assign rights by default.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, $filter='', $filtermode='AND', $entityfilter=false)
Load all objects into $this->users.
getOnlineVirtualCardUrl($mode='', $typeofurl='external')
Return string with full Url to virtual card.
update($user, $notrigger=0, $nosyncmember=0, $nosyncmemberpass=0, $nosynccontact=0)
Update a user into database (and also password if this->pass is defined)
getLoginUrl($withpictoimg=0, $option='', $notooltip=0, $morecss='')
Return clickable link of login (optionally with picto)
setCategories($categories)
Sets object to supplied categories.
loadParentOf()
Load this->parentof that is array(id_son=>id_parent, ...)
setForcePasswordChange($user, $value)
Set force password change flag.
fetch_clicktodial()
Read clicktodial information for user.
build_path_from_id_user($id_user, $protection=0)
For user id_user and its children available in this->users, define property fullpath and fullname.
error()
Returns the last functional error when manipulating the object.
cloneCategories($fromId, $toId, $type='user')
Copy related categories to another object.
getAllChildIds($addcurrentuser=0)
Return list of all child user ids in hierarchy (all sublevels).
initAsSpecimen()
Initialise an instance with random values.
setPassword($user, $password='', $changelater=0, $notrigger=0, $nosyncmember=0, $passwordalreadycrypted=0, $flagdelsessionsbefore=1)
Change password of a user.
getNomUrl($withpictoimg=0, $option='', $infologin=0, $notooltip=0, $maxlen=24, $hidethirdpartylogo=0, $mode='', $morecss='', $save_lastsearch_value=-1)
Return a HTML link to the user card (with optionally the picto) Use this->id,this->lastname,...
clearrights()
Clear all permissions array of user.
update_clicktodial()
Update clicktodial info.
cloneRights($fromId, $toId)
Clone permissions of user.
isExternalUser()
Return if a user is an external user It replaces old syntax: if ($user->socid)
getLibStatut($mode=0)
Return the label of the status of user (active, inactive)
create_from_member($member, $login='')
Create a user into database from a member object.
_load_ldap_dn($info, $mode=0)
Returns the complete DN (Distinguished Name) string in the LDAP directory for the object.
loadDefaultValues()
Load default values from database table into property ->default_values.
getPhotoUrl($width, $height, $cssclass='', $imagesize='')
Return a link with photo Use this->id,this->photo.
isAdmin()
Return if a user is an admin user It replaces old syntax: if ($user->admin)
update_ldap2dolibarr(&$ldapuser)
Update user using data from the LDAP.
getrights($moduletag='', $forcereload=0)
Load permissions granted to a user->id into object user->rights TODO Remove this method.
user_get_property($rowid, $mode)
Return property of user from its id.
send_password($user, $password='', $changelater=0)
Send a new password (or instructions to reset it) by email.
getKanbanView($option='', $arraydata=null)
Return clickable link of object (optionally with picto)
getNbOfEMailings()
Return number of mass Emailing received by this contacts with its email.
addrights($rid, $allmodule='', $allperms='', $entity=0, $notrigger=0)
Add a right to the user.
create($user, $notrigger=0)
Create a user into database.
loadPersonalConf($entity=-1)
Load const values from database table user_param and set it into user->conf->XXX.
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
findUserIdByEmail($email)
Find a user by the given e-mail and return it's user id when found.
getTooltipContentArray($params)
getTooltipContentArray
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
getFullName($langs, $option=0, $nameorder=-1, $maxlen=0)
Return full name (civility+' '+name+' '+lastname)
setUpperOrLowerCase()
Set to upper or ucwords/lower if needed.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
dol_get_first_hour($date, $gm='tzserver')
Return GMT time for first hour of a given GMT date (it removes hours, min and second part)
dol_get_last_hour($date, $gm='tzserver')
Return GMT time for last hour of a given GMT date (it replaces hours, min and second part to 23:59:59...
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
dol_buildlogin($lastname, $firstname)
Build a login from lastname, firstname.
dol_now($mode='gmt')
Return date for now.
getDolGlobalLoginBadCharUnauthorized()
Return the list of unauthorized characters in user logins.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
dol_print_phone($phone, $countrycode='', $contactid=0, $socid=0, $addlink='', $separ=" ", $withpicto='', $titlealt='', $adddivfloat=0, $morecss='paddingright')
Format phone numbers according to country.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0, $forbiddenfields=array())
forgeSQLFromUniversalSearchCriteria
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
getArrayOfSocialNetworks()
Get array of social network dictionary.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getUserRemoteIP($trusted=0)
Return the real IP of remote user.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
div refaddress div address
conf($dolibarr_main_document_root, $realpathconf=null)
Load conf file (file must exists)
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
dolGetLdapPasswordHash($password, $type='md5')
Returns a specific ldap hash of a password.
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.
dolDecrypt($chain, $key='', $patterntotest='')
Decode a string with a symmetric encryption.
dol_verifyHash($chain, $hash, $type='0')
Compute a hash and compare it to the given one For backward compatibility reasons,...
dolEncrypt($chain, $key='', $ciphering='', $forceseed='', $obfuscationmode='dolcrypt')
Encode a string with a symmetric encryption.