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][self::KEY_ID] = 251;
93 $this->rights[$r][self::KEY_LABEL] =
'Read information of other users, groups and permissions';
94 $this->rights[$r][self::KEY_DEFAULT] = 0;
95 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'user';
96 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'lire';
99 $this->rights[$r][self::KEY_ID] = 252;
100 $this->rights[$r][self::KEY_LABEL] =
'Read permissions of other users';
101 $this->rights[$r][self::KEY_DEFAULT] = 0;
102 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'user_advance';
103 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'readperms';
106 $this->rights[$r][self::KEY_ID] = 253;
107 $this->rights[$r][self::KEY_LABEL] =
'Create/modify internal and external users, groups and permissions';
108 $this->rights[$r][self::KEY_DEFAULT] = 0;
109 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'user';
110 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'creer';
113 $this->rights[$r][self::KEY_ID] = 254;
114 $this->rights[$r][self::KEY_LABEL] =
'Create/modify external users only';
115 $this->rights[$r][self::KEY_DEFAULT] = 0;
116 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'user_advance';
117 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'write';
120 $this->rights[$r][self::KEY_ID] = 255;
121 $this->rights[$r][self::KEY_LABEL] =
'Modify the password of other users';
122 $this->rights[$r][self::KEY_DEFAULT] = 0;
123 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'user';
124 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'password';
127 $this->rights[$r][self::KEY_ID] = 256;
128 $this->rights[$r][self::KEY_LABEL] =
'Delete or disable other users';
129 $this->rights[$r][self::KEY_DEFAULT] = 0;
130 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'user';
131 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'supprimer';
134 $this->rights[$r][self::KEY_ID] = 341;
135 $this->rights[$r][self::KEY_LABEL] =
'Read its own permissions';
136 $this->rights[$r][self::KEY_DEFAULT] = 0;
137 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'self_advance';
138 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'readperms';
141 $this->rights[$r][self::KEY_ID] = 342;
142 $this->rights[$r][self::KEY_LABEL] =
'Create/modify of its own user';
143 $this->rights[$r][self::KEY_DEFAULT] = 0;
144 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'self';
145 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'creer';
148 $this->rights[$r][self::KEY_ID] = 343;
149 $this->rights[$r][self::KEY_LABEL] =
'Modify its own password';
150 $this->rights[$r][self::KEY_DEFAULT] = 0;
151 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'self';
152 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'password';
155 $this->rights[$r][self::KEY_ID] = 344;
156 $this->rights[$r][self::KEY_LABEL] =
'Modify its own permissions';
157 $this->rights[$r][self::KEY_DEFAULT] = 0;
158 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'self_advance';
159 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'writeperms';
162 $this->rights[$r][self::KEY_ID] = 351;
163 $this->rights[$r][self::KEY_LABEL] =
'Read groups';
164 $this->rights[$r][self::KEY_DEFAULT] = 0;
165 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'group_advance';
166 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'read';
169 $this->rights[$r][self::KEY_ID] = 352;
170 $this->rights[$r][self::KEY_LABEL] =
'Read permissions of groups';
171 $this->rights[$r][self::KEY_DEFAULT] = 0;
172 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'group_advance';
173 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'readperms';
176 $this->rights[$r][self::KEY_ID] = 353;
177 $this->rights[$r][self::KEY_LABEL] =
'Create/modify groups and permissions';
178 $this->rights[$r][self::KEY_DEFAULT] = 0;
179 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'group_advance';
180 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'write';
183 $this->rights[$r][self::KEY_ID] = 354;
184 $this->rights[$r][self::KEY_LABEL] =
'Delete groups';
185 $this->rights[$r][self::KEY_DEFAULT] = 0;
186 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'group_advance';
187 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'delete';
190 $this->rights[$r][self::KEY_ID] = 358;
191 $this->rights[$r][self::KEY_LABEL] =
'Export all users';
192 $this->rights[$r][self::KEY_DEFAULT] = 0;
193 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'user';
194 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'export';
205 $this->export_code[$r] = $this->rights_class.
'_'.$r;
206 $this->export_label[$r] =
'List of users and attributes';
207 $this->export_permission[$r] = array(array(
"user",
"user",
"export"));
208 $this->export_fields_array[$r] = array(
209 'u.rowid'=>
"Id",
'u.login'=>
"Login",
'u.lastname'=>
"Lastname",
'u.firstname'=>
"Firstname",
'u.employee'=>
"Employee",
'u.job'=>
"PostOrFunction",
'u.gender'=>
"Gender",
210 'u.accountancy_code'=>
"UserAccountancyCode",
211 'u.address'=>
"Address",
'u.zip'=>
"Zip",
'u.town'=>
"Town",
212 'u.office_phone'=>
'Phone',
'u.user_mobile'=>
"Mobile",
'u.office_fax'=>
'Fax',
213 'u.email'=>
"Email",
'u.note_public'=>
"NotePublic",
'u.note_private'=>
"NotePrivate",
'u.signature'=>
'Signature',
214 'u.fk_user'=>
'HierarchicalResponsible',
'u.thm'=>
'THM',
'u.tjm'=>
'TJM',
'u.weeklyhours'=>
'WeeklyHours',
215 'u.dateemployment'=>
'DateEmploymentStart',
'u.dateemploymentend'=>
'DateEmploymentEnd',
'u.salary'=>
'Salary',
'u.color'=>
'Color',
'u.api_key'=>
'ApiKey',
216 'u.birth'=>
'DateOfBirth',
217 'u.datec'=>
"DateCreation",
'u.tms'=>
"DateLastModification",
218 'u.admin'=>
"Administrator",
'u.statut'=>
'Status',
'u.datelastlogin'=>
'LastConnexion',
'u.datepreviouslogin'=>
'PreviousConnexion',
219 'u.fk_socpeople'=>
"IdContact",
'u.fk_soc'=>
"IdCompany",
220 'u.fk_member'=>
"MemberId",
221 "a.firstname"=>
"MemberFirstname",
222 "a.lastname"=>
"MemberLastname",
225 $this->export_TypeFields_array[$r] = array(
226 'u.rowid'=>
'Numeric',
'u.login'=>
"Text",
'u.lastname'=>
"Text",
'u.firstname'=>
"Text",
'u.employee'=>
'Boolean',
'u.job'=>
'Text',
227 'u.accountancy_code'=>
'Text',
228 'u.address'=>
"Text",
'u.zip'=>
"Text",
'u.town'=>
"Text",
229 'u.office_phone'=>
'Text',
'u.user_mobile'=>
'Text',
'u.office_fax'=>
'Text',
230 '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',
231 'u.fk_user'=>
"FormSelect:select_dolusers",
233 'u.datepreviouslogin'=>
'Date',
234 'u.fk_socpeople'=>
'FormSelect:selectcontacts',
235 'u.fk_soc'=>
"FormSelect:select_company",
236 'u.tjm'=>
"Numeric",
'u.thm'=>
"Numeric",
'u.fk_member'=>
"Numeric",
237 'u.weeklyhours'=>
"Numeric",
238 'u.dateemployment'=>
"Date",
'u.dateemploymentend'=>
"Date",
'u.salary'=>
"Numeric",
239 'u.color'=>
'Text',
'u.api_key'=>
'Text',
240 'a.firstname'=>
'Text',
241 'a.lastname'=>
'Text',
244 $this->export_entities_array[$r] = array(
245 'u.rowid'=>
"user",
'u.login'=>
"user",
'u.lastname'=>
"user",
'u.firstname'=>
"user",
'u.employee'=>
'user',
'u.job'=>
'user',
'u.gender'=>
'user',
246 'u.accountancy_code'=>
'user',
247 'u.address'=>
"user",
'u.zip'=>
"user",
'u.town'=>
"user",
248 'u.office_phone'=>
'user',
'u.user_mobile'=>
'user',
'u.office_fax'=>
'user',
249 'u.email'=>
'user',
'u.note_public'=>
"user",
'u.note_private'=>
"user",
'u.signature'=>
'user',
250 'u.fk_user'=>
'user',
'u.thm'=>
'user',
'u.tjm'=>
'user',
'u.weeklyhours'=>
'user',
251 'u.dateemployment'=>
'user',
'u.dateemploymentend'=>
'user',
'u.salary'=>
'user',
'u.color'=>
'user',
'u.api_key'=>
'user',
253 'u.datec'=>
"user",
'u.tms'=>
"user",
254 'u.admin'=>
"user",
'u.statut'=>
'user',
'u.datelastlogin'=>
'user',
'u.datepreviouslogin'=>
'user',
255 'u.fk_socpeople'=>
"contact",
'u.fk_soc'=>
"company",
'u.fk_member'=>
"member",
256 'a.firstname'=>
"member",
'a.lastname'=>
"member",
259 $keyforselect =
'user';
260 $keyforelement =
'user';
261 $keyforaliasextra =
'extra';
262 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
263 if (!isModEnabled(
'member')) {
264 unset($this->export_fields_array[$r][
'u.fk_member']);
265 unset($this->export_entities_array[$r][
'u.fk_member']);
267 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
268 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'user as u';
269 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user_extrafields as extra ON u.rowid = extra.fk_object';
270 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'usergroup_user as ug ON u.rowid = ug.fk_user';
271 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'usergroup as g ON ug.fk_usergroup = g.rowid';
272 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'adherent as a ON u.fk_member = a.rowid';
273 $this->export_sql_end[$r] .=
' WHERE u.entity IN ('.getEntity(
'user').
')';
277 $this->export_code[$r] = $this->rights_class.
'_'.$r;
278 $this->export_label[$r] =
'List of security events';
279 $this->export_permission[$r] = array(array(
"user"));
280 $this->export_fields_array[$r] = array(
281 'e.rowid'=>
"Id",
'e.type'=>
"Type",
282 'e.dateevent'=>
"Date",
283 'e.description'=>
'Description',
284 'e.ip'=>
'IPAddress',
'e.user_agent'=>
'UserAgent',
285 'e.authentication_method' =>
'AuthenticationMode',
286 'e.fk_user'=>
"UserID",
'u.login'=>
"Login",
288 $this->export_TypeFields_array[$r] = array(
289 'e.rowid'=>
'Numeric',
'e.type'=>
"Text",
290 'e.dateevent'=>
"Date",
291 'e.description'=>
'Text',
292 'e.ip'=>
'Text',
'e.user_agent'=>
'Text',
293 'e.authentication_method' =>
'Text',
294 'e.fk_user'=>
"Numeric",
'u.login'=>
"Text",
296 $this->export_entities_array[$r] = array(
297 'e.rowid'=>
'securityevent',
'e.type'=>
"securityevent",
298 'e.dateevent'=>
"securityevent",
299 'e.description'=>
'securityevent',
300 'e.ip'=>
'securityevent',
'e.user_agent'=>
'securityevent',
301 'e.authentication_method' =>
'securityevent',
302 'e.fk_user'=>
"user",
'u.login'=>
"user",
304 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
305 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'events as e';
306 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as u ON e.fk_user = u.rowid';
307 $this->export_sql_end[$r] .=
' WHERE e.entity IN ('.getEntity(
'event').
')';
315 $this->import_code[$r] = $this->rights_class.
'_'.$r;
316 $this->import_label[$r] =
'ImportDataset_user_1';
317 $this->import_icon[$r] =
'user';
318 $this->import_entities_array[$r] = array();
319 $this->import_tables_array[$r] = array(
'u'=>MAIN_DB_PREFIX.
'user',
'extra'=>MAIN_DB_PREFIX.
'user_extrafields');
320 $this->import_fields_array[$r] = array(
321 'u.login'=>
"Login*",
'u.lastname'=>
"Name*",
'u.firstname'=>
"Firstname",
'u.employee'=>
"Employee*",
'u.job'=>
"PostOrFunction",
'u.gender'=>
"Gender",
322 'u.accountancy_code'=>
"UserAccountancyCode",
323 'u.pass_crypted'=>
"Password",
'u.admin'=>
"Administrator",
'u.fk_soc'=>
"Company*",
'u.address'=>
"Address",
'u.zip'=>
"Zip",
'u.town'=>
"Town",
324 'u.fk_state'=>
"StateId",
'u.fk_country'=>
"CountryCode",
325 'u.office_phone'=>
"Phone",
'u.user_mobile'=>
"Mobile",
'u.office_fax'=>
"Fax",
326 'u.email'=>
"Email",
'u.note_public'=>
"NotePublic",
'u.note_private'=>
"NotePrivate",
'u.signature'=>
'Signature',
327 'u.fk_user'=>
'HierarchicalResponsible',
'u.thm'=>
'THM',
'u.tjm'=>
'TJM',
'u.weeklyhours'=>
'WeeklyHours',
328 'u.dateemployment'=>
'DateEmploymentStart',
'u.dateemploymentend'=>
'DateEmploymentEnd',
'u.salary'=>
'Salary',
'u.color'=>
'Color',
'u.api_key'=>
'ApiKey',
329 'u.birth'=>
'DateOfBirth',
330 'u.datec'=>
"DateCreation",
334 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'user' AND entity IN (0,".$conf->entity.
")";
335 $resql = $this->db->query($sql);
337 while ($obj = $this->db->fetch_object($resql)) {
338 $fieldname =
'extra.'.$obj->name;
339 $fieldlabel = ucfirst($obj->label);
340 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
344 $this->import_fieldshidden_array[$r] = array(
'u.fk_user_creat'=>
'user->id',
'extra.fk_object'=>
'lastrowid-'.MAIN_DB_PREFIX.
'user');
345 $this->import_convertvalue_array[$r] = array(
346 'u.fk_state'=>array(
'rule'=>
'fetchidfromcodeid',
'classfile'=>
'/core/class/cstate.class.php',
'class'=>
'Cstate',
'method'=>
'fetch',
'dict'=>
'DictionaryState'),
347 'u.fk_country'=>array(
'rule'=>
'fetchidfromcodeid',
'classfile'=>
'/core/class/ccountry.class.php',
'class'=>
'Ccountry',
'method'=>
'fetch',
'dict'=>
'DictionaryCountry'),
348 'u.salary'=>array(
'rule'=>
'numeric')
351 $this->import_regex_array[$r] = array(
352 'u.employee'=>
'^[0|1]',
353 '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])?$',
354 'u.dateemployment'=>
'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
355 'u.birth'=>
'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'
357 $this->import_examplevalues_array[$r] = array(
358 'u.lastname'=>
"Doe",
'u.firstname'=>
'John',
'u.login'=>
'jdoe',
'u.employee'=>
'0 or 1',
'u.job'=>
'CTO',
'u.gender'=>
'man or woman',
359 'u.pass_crypted'=>
'Encrypted password',
360 'u.fk_soc'=>
'0 (internal user) or company name (external user)',
'u.address'=>
"61 jump street",
361 'u.zip'=>
"123456",
'u.town'=>
"Big town",
'u.fk_country'=>
'US, FR, DE...',
'u.office_phone'=>
"0101010101",
'u.office_fax'=>
"0101010102",
362 '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",
363 'u.statut'=>
"0 (closed) or 1 (active)",
365 $this->import_updatekeys_array[$r] = array(
'u.lastname'=>
'Lastname',
'u.firstname'=>
'Firstname',
'u.login'=>
'Login');