49 $this->module_position =
'05';
51 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
52 $this->
description =
"Management of users and groups of users (mandatory)";
55 $this->version =
'dolibarr';
57 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
58 $this->picto =
'group';
61 $this->dirs = array(
"/users/temp");
64 $this->config_page_url = array(
"user.php");
67 $this->hidden =
false;
68 $this->depends = array();
69 $this->requiredby = array();
70 $this->conflictwith = array();
71 $this->phpmin = array(7, 0);
72 $this->langfiles = array(
"main",
"users",
"companies",
"members",
"salaries",
"hrm");
73 $this->always_enabled =
true;
76 $this->
const = array();
80 0=>array(
'file'=>
'box_lastlogin.php',
'enabledbydefaulton'=>
'Home'),
81 1=>array(
'file'=>
'box_birthdays.php',
'enabledbydefaulton'=>
'Home'),
82 2=>array(
'file'=>
'box_dolibarr_state_board.php',
'enabledbydefaulton'=>
'Home')
86 $this->rights = array();
87 $this->rights_class =
'user';
88 $this->rights_admin_allowed = 1;
92 $this->rights[$r][0] = 251;
93 $this->rights[$r][1] =
'Read information of other users, groups and permissions';
94 $this->rights[$r][2] =
'r';
95 $this->rights[$r][3] = 0;
96 $this->rights[$r][4] =
'user';
97 $this->rights[$r][5] =
'lire';
100 $this->rights[$r][0] = 252;
101 $this->rights[$r][1] =
'Read permissions of other users';
102 $this->rights[$r][2] =
'r';
103 $this->rights[$r][3] = 0;
104 $this->rights[$r][4] =
'user_advance';
105 $this->rights[$r][5] =
'readperms';
108 $this->rights[$r][0] = 253;
109 $this->rights[$r][1] =
'Create/modify internal and external users, groups and permissions';
110 $this->rights[$r][2] =
'w';
111 $this->rights[$r][3] = 0;
112 $this->rights[$r][4] =
'user';
113 $this->rights[$r][5] =
'creer';
116 $this->rights[$r][0] = 254;
117 $this->rights[$r][1] =
'Create/modify external users only';
118 $this->rights[$r][2] =
'w';
119 $this->rights[$r][3] = 0;
120 $this->rights[$r][4] =
'user_advance';
121 $this->rights[$r][5] =
'write';
124 $this->rights[$r][0] = 255;
125 $this->rights[$r][1] =
'Modify the password of other users';
126 $this->rights[$r][2] =
'w';
127 $this->rights[$r][3] = 0;
128 $this->rights[$r][4] =
'user';
129 $this->rights[$r][5] =
'password';
132 $this->rights[$r][0] = 256;
133 $this->rights[$r][1] =
'Delete or disable other users';
134 $this->rights[$r][2] =
'd';
135 $this->rights[$r][3] = 0;
136 $this->rights[$r][4] =
'user';
137 $this->rights[$r][5] =
'supprimer';
140 $this->rights[$r][0] = 341;
141 $this->rights[$r][1] =
'Read its own permissions';
142 $this->rights[$r][2] =
'r';
143 $this->rights[$r][3] = 0;
144 $this->rights[$r][4] =
'self_advance';
145 $this->rights[$r][5] =
'readperms';
148 $this->rights[$r][0] = 342;
149 $this->rights[$r][1] =
'Create/modify of its own user';
150 $this->rights[$r][2] =
'w';
151 $this->rights[$r][3] = 0;
152 $this->rights[$r][4] =
'self';
153 $this->rights[$r][5] =
'creer';
156 $this->rights[$r][0] = 343;
157 $this->rights[$r][1] =
'Modify its own password';
158 $this->rights[$r][2] =
'w';
159 $this->rights[$r][3] = 0;
160 $this->rights[$r][4] =
'self';
161 $this->rights[$r][5] =
'password';
164 $this->rights[$r][0] = 344;
165 $this->rights[$r][1] =
'Modify its own permissions';
166 $this->rights[$r][2] =
'w';
167 $this->rights[$r][3] = 0;
168 $this->rights[$r][4] =
'self_advance';
169 $this->rights[$r][5] =
'writeperms';
172 $this->rights[$r][0] = 351;
173 $this->rights[$r][1] =
'Read groups';
174 $this->rights[$r][2] =
'r';
175 $this->rights[$r][3] = 0;
176 $this->rights[$r][4] =
'group_advance';
177 $this->rights[$r][5] =
'read';
180 $this->rights[$r][0] = 352;
181 $this->rights[$r][1] =
'Read permissions of groups';
182 $this->rights[$r][2] =
'r';
183 $this->rights[$r][3] = 0;
184 $this->rights[$r][4] =
'group_advance';
185 $this->rights[$r][5] =
'readperms';
188 $this->rights[$r][0] = 353;
189 $this->rights[$r][1] =
'Create/modify groups and permissions';
190 $this->rights[$r][2] =
'w';
191 $this->rights[$r][3] = 0;
192 $this->rights[$r][4] =
'group_advance';
193 $this->rights[$r][5] =
'write';
196 $this->rights[$r][0] = 354;
197 $this->rights[$r][1] =
'Delete groups';
198 $this->rights[$r][2] =
'd';
199 $this->rights[$r][3] = 0;
200 $this->rights[$r][4] =
'group_advance';
201 $this->rights[$r][5] =
'delete';
204 $this->rights[$r][0] = 358;
205 $this->rights[$r][1] =
'Export all users';
206 $this->rights[$r][2] =
'r';
207 $this->rights[$r][3] = 0;
208 $this->rights[$r][4] =
'user';
209 $this->rights[$r][5] =
'export';
220 $this->export_code[$r] = $this->rights_class.
'_'.$r;
221 $this->export_label[$r] =
'List of users and attributes';
222 $this->export_permission[$r] = array(array(
"user",
"user",
"export"));
223 $this->export_fields_array[$r] = array(
224 'u.rowid'=>
"Id",
'u.login'=>
"Login",
'u.lastname'=>
"Lastname",
'u.firstname'=>
"Firstname",
'u.employee'=>
"Employee",
'u.job'=>
"PostOrFunction",
'u.gender'=>
"Gender",
225 'u.accountancy_code'=>
"UserAccountancyCode",
226 'u.address'=>
"Address",
'u.zip'=>
"Zip",
'u.town'=>
"Town",
227 'u.office_phone'=>
'Phone',
'u.user_mobile'=>
"Mobile",
'u.office_fax'=>
'Fax',
228 'u.email'=>
"Email",
'u.note_public'=>
"NotePublic",
'u.note_private'=>
"NotePrivate",
'u.signature'=>
'Signature',
229 'u.fk_user'=>
'HierarchicalResponsible',
'u.thm'=>
'THM',
'u.tjm'=>
'TJM',
'u.weeklyhours'=>
'WeeklyHours',
230 'u.dateemployment'=>
'DateEmploymentStart',
'u.dateemploymentend'=>
'DateEmploymentEnd',
'u.salary'=>
'Salary',
'u.color'=>
'Color',
'u.api_key'=>
'ApiKey',
231 'u.birth'=>
'DateOfBirth',
232 'u.datec'=>
"DateCreation",
'u.tms'=>
"DateLastModification",
233 'u.admin'=>
"Administrator",
'u.statut'=>
'Status',
'u.datelastlogin'=>
'LastConnexion',
'u.datepreviouslogin'=>
'PreviousConnexion',
234 'u.fk_socpeople'=>
"IdContact",
'u.fk_soc'=>
"IdCompany",
235 'u.fk_member'=>
"MemberId",
236 "a.firstname"=>
"MemberFirstname",
237 "a.lastname"=>
"MemberLastname",
240 $this->export_TypeFields_array[$r] = array(
241 'u.rowid'=>
'Numeric',
'u.login'=>
"Text",
'u.lastname'=>
"Text",
'u.firstname'=>
"Text",
'u.employee'=>
'Boolean',
'u.job'=>
'Text',
242 'u.accountancy_code'=>
'Text',
243 'u.address'=>
"Text",
'u.zip'=>
"Text",
'u.town'=>
"Text",
244 'u.office_phone'=>
'Text',
'u.user_mobile'=>
'Text',
'u.office_fax'=>
'Text',
245 'u.email'=>
'Text',
'u.datec'=>
"Date",
'u.tms'=>
"Date",
'u.admin'=>
"Boolean",
'u.statut'=>
'Status',
'u.note_public'=>
"Text",
'u.note_private'=>
"Text",
'u.signature'=>
"Text",
'u.datelastlogin'=>
'Date',
246 'u.fk_user'=>
"FormSelect:select_dolusers",
248 'u.datepreviouslogin'=>
'Date',
249 'u.fk_socpeople'=>
'FormSelect:selectcontacts',
250 'u.fk_soc'=>
"FormSelect:select_company",
251 'u.tjm'=>
"Numeric",
'u.thm'=>
"Numeric",
'u.fk_member'=>
"Numeric",
252 'u.weeklyhours'=>
"Numeric",
253 'u.dateemployment'=>
"Date",
'u.dateemploymentend'=>
"Date",
'u.salary'=>
"Numeric",
254 'u.color'=>
'Text',
'u.api_key'=>
'Text',
255 'a.firstname'=>
'Text',
256 'a.lastname'=>
'Text',
259 $this->export_entities_array[$r] = array(
260 'u.rowid'=>
"user",
'u.login'=>
"user",
'u.lastname'=>
"user",
'u.firstname'=>
"user",
'u.employee'=>
'user',
'u.job'=>
'user',
'u.gender'=>
'user',
261 'u.accountancy_code'=>
'user',
262 'u.address'=>
"user",
'u.zip'=>
"user",
'u.town'=>
"user",
263 'u.office_phone'=>
'user',
'u.user_mobile'=>
'user',
'u.office_fax'=>
'user',
264 'u.email'=>
'user',
'u.note_public'=>
"user",
'u.note_private'=>
"user",
'u.signature'=>
'user',
265 'u.fk_user'=>
'user',
'u.thm'=>
'user',
'u.tjm'=>
'user',
'u.weeklyhours'=>
'user',
266 'u.dateemployment'=>
'user',
'u.dateemploymentend'=>
'user',
'u.salary'=>
'user',
'u.color'=>
'user',
'u.api_key'=>
'user',
268 'u.datec'=>
"user",
'u.tms'=>
"user",
269 'u.admin'=>
"user",
'u.statut'=>
'user',
'u.datelastlogin'=>
'user',
'u.datepreviouslogin'=>
'user',
270 'u.fk_socpeople'=>
"contact",
'u.fk_soc'=>
"company",
'u.fk_member'=>
"member",
271 'a.firstname'=>
"member",
'a.lastname'=>
"member",
274 $keyforselect =
'user';
275 $keyforelement =
'user';
276 $keyforaliasextra =
'extra';
277 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
278 if (!isModEnabled(
'adherent')) {
279 unset($this->export_fields_array[$r][
'u.fk_member']);
280 unset($this->export_entities_array[$r][
'u.fk_member']);
282 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
283 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'user as u';
284 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user_extrafields as extra ON u.rowid = extra.fk_object';
285 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'usergroup_user as ug ON u.rowid = ug.fk_user';
286 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'usergroup as g ON ug.fk_usergroup = g.rowid';
287 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'adherent as a ON u.fk_member = a.rowid';
288 $this->export_sql_end[$r] .=
' WHERE u.entity IN ('.getEntity(
'user').
')';
295 $this->import_code[$r] = $this->rights_class.
'_'.$r;
296 $this->import_label[$r] =
'ImportDataset_user_1';
297 $this->import_icon[$r] =
'user';
298 $this->import_entities_array[$r] = array();
299 $this->import_tables_array[$r] = array(
'u'=>MAIN_DB_PREFIX.
'user',
'extra'=>MAIN_DB_PREFIX.
'user_extrafields');
300 $this->import_fields_array[$r] = array(
301 'u.login'=>
"Login*",
'u.lastname'=>
"Name*",
'u.firstname'=>
"Firstname",
'u.employee'=>
"Employee*",
'u.job'=>
"PostOrFunction",
'u.gender'=>
"Gender",
302 'u.accountancy_code'=>
"UserAccountancyCode",
303 'u.pass_crypted'=>
"Password",
'u.admin'=>
"Administrator",
'u.fk_soc'=>
"Company*",
'u.address'=>
"Address",
'u.zip'=>
"Zip",
'u.town'=>
"Town",
304 'u.fk_state'=>
"StateId",
'u.fk_country'=>
"CountryCode",
305 'u.office_phone'=>
"Phone",
'u.user_mobile'=>
"Mobile",
'u.office_fax'=>
"Fax",
306 'u.email'=>
"Email",
'u.note_public'=>
"NotePublic",
'u.note_private'=>
"NotePrivate",
'u.signature'=>
'Signature',
307 'u.fk_user'=>
'HierarchicalResponsible',
'u.thm'=>
'THM',
'u.tjm'=>
'TJM',
'u.weeklyhours'=>
'WeeklyHours',
308 'u.dateemployment'=>
'DateEmploymentStart',
'u.dateemploymentend'=>
'DateEmploymentEnd',
'u.salary'=>
'Salary',
'u.color'=>
'Color',
'u.api_key'=>
'ApiKey',
309 'u.birth'=>
'DateOfBirth',
310 'u.datec'=>
"DateCreation",
314 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'user' AND entity IN (0,".$conf->entity.
")";
315 $resql = $this->db->query($sql);
317 while ($obj = $this->db->fetch_object($resql)) {
318 $fieldname =
'extra.'.$obj->name;
319 $fieldlabel = ucfirst($obj->label);
320 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
324 $this->import_fieldshidden_array[$r] = array(
'u.fk_user_creat'=>
'user->id',
'extra.fk_object'=>
'lastrowid-'.MAIN_DB_PREFIX.
'user');
325 $this->import_convertvalue_array[$r] = array(
326 'u.fk_state'=>array(
'rule'=>
'fetchidfromcodeid',
'classfile'=>
'/core/class/cstate.class.php',
'class'=>
'Cstate',
'method'=>
'fetch',
'dict'=>
'DictionaryState'),
327 'u.fk_country'=>array(
'rule'=>
'fetchidfromcodeid',
'classfile'=>
'/core/class/ccountry.class.php',
'class'=>
'Ccountry',
'method'=>
'fetch',
'dict'=>
'DictionaryCountry'),
328 'u.salary'=>array(
'rule'=>
'numeric')
331 $this->import_regex_array[$r] = array(
332 'u.employee'=>
'^[0|1]',
333 'u.datec'=>
'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$',
334 'u.dateemployment'=>
'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
335 'u.birth'=>
'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'
337 $this->import_examplevalues_array[$r] = array(
338 'u.lastname'=>
"Doe",
'u.firstname'=>
'John',
'u.login'=>
'jdoe',
'u.employee'=>
'0 or 1',
'u.job'=>
'CTO',
'u.gender'=>
'man or woman',
339 'u.pass_crypted'=>
'Encrypted password',
340 'u.fk_soc'=>
'0 (internal user) or company name (external user)',
'u.address'=>
"61 jump street",
341 'u.zip'=>
"123456",
'u.town'=>
"Big town",
'u.fk_country'=>
'US, FR, DE...',
'u.office_phone'=>
"0101010101",
'u.office_fax'=>
"0101010102",
342 'u.email'=>
"test@mycompany.com",
'u.salary'=>
"10000",
'u.note_public'=>
"This is an example of public note for record",
'u.note_private'=>
"This is an example of private note for record",
'u.datec'=>
"2015-01-01 or 2015-01-01 12:30:00",
343 'u.statut'=>
"0 (closed) or 1 (active)",
345 $this->import_updatekeys_array[$r] = array(
'u.lastname'=>
'Lastname',
'u.firstname'=>
'Firstname',
'u.login'=>
'Login');