51 $this->module_position =
'05';
53 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
54 $this->
description =
"Management of users and groups of users (mandatory)";
57 $this->version =
'dolibarr';
59 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
60 $this->picto =
'group';
63 $this->dirs = array(
"/users/temp");
66 $this->config_page_url = array(
"user.php");
69 $this->hidden =
false;
70 $this->depends = array();
71 $this->requiredby = array();
72 $this->conflictwith = array();
73 $this->langfiles = array(
"main",
"users",
"companies",
"members",
"salaries",
"hrm");
74 $this->always_enabled =
true;
78 $this->
const = array();
82 [
'file' =>
'box_lastlogin.php',
'enabledbydefaulton' =>
'Home'],
83 [
'file' =>
'box_birthdays.php',
'enabledbydefaulton' =>
'Home'],
84 [
'file' =>
'box_dolibarr_state_board.php',
'enabledbydefaulton' =>
'Home'],
88 $this->rights = array();
89 $this->rights_class =
'user';
90 $this->rights_admin_allowed = 1;
94 $this->rights[$r][self::KEY_ID] = 251;
95 $this->rights[$r][self::KEY_LABEL] =
'Read information of other users, groups and permissions';
96 $this->rights[$r][self::KEY_DEFAULT] = 0;
97 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'user';
98 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'lire';
101 $this->rights[$r][self::KEY_ID] = 252;
102 $this->rights[$r][self::KEY_LABEL] =
'Read permissions of other users';
103 $this->rights[$r][self::KEY_DEFAULT] = 0;
104 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'user_advance';
105 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'readperms';
108 $this->rights[$r][self::KEY_ID] = 253;
109 $this->rights[$r][self::KEY_LABEL] =
'Create/modify internal and external users, groups and permissions';
110 $this->rights[$r][self::KEY_DEFAULT] = 0;
111 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'user';
112 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'creer';
115 $this->rights[$r][self::KEY_ID] = 254;
116 $this->rights[$r][self::KEY_LABEL] =
'Create/modify external users only';
117 $this->rights[$r][self::KEY_DEFAULT] = 0;
118 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'user_advance';
119 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'write';
122 $this->rights[$r][self::KEY_ID] = 255;
123 $this->rights[$r][self::KEY_LABEL] =
'Modify the password of other users';
124 $this->rights[$r][self::KEY_DEFAULT] = 0;
125 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'user';
126 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'password';
129 $this->rights[$r][self::KEY_ID] = 256;
130 $this->rights[$r][self::KEY_LABEL] =
'Delete or disable other users';
131 $this->rights[$r][self::KEY_DEFAULT] = 0;
132 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'user';
133 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'supprimer';
136 $this->rights[$r][self::KEY_ID] = 341;
137 $this->rights[$r][self::KEY_LABEL] =
'Read its own permissions';
138 $this->rights[$r][self::KEY_DEFAULT] = 0;
139 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'self_advance';
140 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'readperms';
143 $this->rights[$r][self::KEY_ID] = 342;
144 $this->rights[$r][self::KEY_LABEL] =
'Create/modify of its own user';
145 $this->rights[$r][self::KEY_DEFAULT] = 0;
146 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'self';
147 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'creer';
150 $this->rights[$r][self::KEY_ID] = 343;
151 $this->rights[$r][self::KEY_LABEL] =
'Modify its own password';
152 $this->rights[$r][self::KEY_DEFAULT] = 0;
153 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'self';
154 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'password';
157 $this->rights[$r][self::KEY_ID] = 344;
158 $this->rights[$r][self::KEY_LABEL] =
'Modify its own permissions';
159 $this->rights[$r][self::KEY_DEFAULT] = 0;
160 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'self_advance';
161 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'writeperms';
164 $this->rights[$r][self::KEY_ID] = 351;
165 $this->rights[$r][self::KEY_LABEL] =
'Read groups';
166 $this->rights[$r][self::KEY_DEFAULT] = 0;
167 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'group_advance';
168 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'read';
171 $this->rights[$r][self::KEY_ID] = 352;
172 $this->rights[$r][self::KEY_LABEL] =
'Read permissions of groups';
173 $this->rights[$r][self::KEY_DEFAULT] = 0;
174 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'group_advance';
175 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'readperms';
178 $this->rights[$r][self::KEY_ID] = 353;
179 $this->rights[$r][self::KEY_LABEL] =
'Create/modify groups and permissions';
180 $this->rights[$r][self::KEY_DEFAULT] = 0;
181 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'group_advance';
182 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'write';
185 $this->rights[$r][self::KEY_ID] = 354;
186 $this->rights[$r][self::KEY_LABEL] =
'Delete groups';
187 $this->rights[$r][self::KEY_DEFAULT] = 0;
188 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'group_advance';
189 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'delete';
192 $this->rights[$r][self::KEY_ID] = 358;
193 $this->rights[$r][self::KEY_LABEL] =
'Export all users';
194 $this->rights[$r][self::KEY_DEFAULT] = 0;
195 $this->rights[$r][self::KEY_FIRST_LEVEL] =
'user';
196 $this->rights[$r][self::KEY_SECOND_LEVEL] =
'export';
207 $this->export_code[$r] = $this->rights_class.
'_'.$r;
208 $this->export_label[$r] =
'List of users and attributes';
209 $this->export_permission[$r] = array(array(
"user",
"user",
"export"));
210 $this->export_fields_array[$r] = array(
211 'u.rowid' =>
"Id",
'u.login' =>
"Login",
'u.lastname' =>
"Lastname",
'u.firstname' =>
"Firstname",
'u.employee' =>
"Employee",
'u.job' =>
"PostOrFunction",
'u.gender' =>
"Gender",
212 'u.accountancy_code' =>
"UserAccountancyCode",
213 'u.address' =>
"Address",
'u.zip' =>
"Zip",
'u.town' =>
"Town",
214 'u.office_phone' =>
'Phone',
'u.user_mobile' =>
"Mobile",
'u.office_fax' =>
'Fax',
215 'u.email' =>
"Email",
'u.note_public' =>
"NotePublic",
'u.note_private' =>
"NotePrivate",
'u.signature' =>
'Signature',
216 'u.fk_user' =>
'HierarchicalResponsible',
'u.thm' =>
'THM',
'u.tjm' =>
'TJM',
'u.weeklyhours' =>
'WeeklyHours',
217 'u.dateemployment' =>
'DateEmploymentStart',
'u.dateemploymentend' =>
'DateEmploymentEnd',
'u.salary' =>
'Salary',
'u.color' =>
'Color',
'u.api_key' =>
'ApiKey',
218 'u.birth' =>
'DateOfBirth',
219 'u.datec' =>
"DateCreation",
'u.tms' =>
"DateLastModification",
220 'u.admin' =>
"Administrator",
'u.statut' =>
'Status',
'u.datelastlogin' =>
'LastConnexion',
'u.datepreviouslogin' =>
'PreviousConnexion',
221 'u.fk_socpeople' =>
"IdContact",
'u.fk_soc' =>
"IdCompany",
222 'u.fk_member' =>
"MemberId",
223 "a.firstname" =>
"MemberFirstname",
224 "a.lastname" =>
"MemberLastname",
227 $this->export_TypeFields_array[$r] = array(
228 'u.rowid' =>
'Numeric',
'u.login' =>
"Text",
'u.lastname' =>
"Text",
'u.firstname' =>
"Text",
'u.employee' =>
'Boolean',
'u.job' =>
'Text',
229 'u.accountancy_code' =>
'Text',
230 'u.address' =>
"Text",
'u.zip' =>
"Text",
'u.town' =>
"Text",
231 'u.office_phone' =>
'Text',
'u.user_mobile' =>
'Text',
'u.office_fax' =>
'Text',
232 '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',
233 'u.fk_user' =>
"FormSelect:select_dolusers",
235 'u.datepreviouslogin' =>
'Date',
236 'u.fk_socpeople' =>
'FormSelect:selectcontacts',
237 'u.fk_soc' =>
"FormSelect:select_company",
238 'u.tjm' =>
"Numeric",
'u.thm' =>
"Numeric",
'u.fk_member' =>
"Numeric",
239 'u.weeklyhours' =>
"Numeric",
240 'u.dateemployment' =>
"Date",
'u.dateemploymentend' =>
"Date",
'u.salary' =>
"Numeric",
241 'u.color' =>
'Text',
'u.api_key' =>
'Text',
242 'a.firstname' =>
'Text',
243 'a.lastname' =>
'Text',
246 $this->export_entities_array[$r] = array(
247 'u.rowid' =>
"user",
'u.login' =>
"user",
'u.lastname' =>
"user",
'u.firstname' =>
"user",
'u.employee' =>
'user',
'u.job' =>
'user',
'u.gender' =>
'user',
248 'u.accountancy_code' =>
'user',
249 'u.address' =>
"user",
'u.zip' =>
"user",
'u.town' =>
"user",
250 'u.office_phone' =>
'user',
'u.user_mobile' =>
'user',
'u.office_fax' =>
'user',
251 'u.email' =>
'user',
'u.note_public' =>
"user",
'u.note_private' =>
"user",
'u.signature' =>
'user',
252 'u.fk_user' =>
'user',
'u.thm' =>
'user',
'u.tjm' =>
'user',
'u.weeklyhours' =>
'user',
253 'u.dateemployment' =>
'user',
'u.dateemploymentend' =>
'user',
'u.salary' =>
'user',
'u.color' =>
'user',
'u.api_key' =>
'user',
255 'u.datec' =>
"user",
'u.tms' =>
"user",
256 'u.admin' =>
"user",
'u.statut' =>
'user',
'u.datelastlogin' =>
'user',
'u.datepreviouslogin' =>
'user',
257 'u.fk_socpeople' =>
"contact",
'u.fk_soc' =>
"company",
'u.fk_member' =>
"member",
258 'a.firstname' =>
"member",
'a.lastname' =>
"member",
261 $keyforselect =
'user';
262 $keyforelement =
'user';
263 $keyforaliasextra =
'extra';
264 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
266 unset($this->export_fields_array[$r][
'u.fk_member']);
267 unset($this->export_entities_array[$r][
'u.fk_member']);
269 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
270 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'user as u';
271 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user_extrafields as extra ON u.rowid = extra.fk_object';
272 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'usergroup_user as ug ON u.rowid = ug.fk_user';
273 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'usergroup as g ON ug.fk_usergroup = g.rowid';
274 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'adherent as a ON u.fk_member = a.rowid';
275 $this->export_sql_end[$r] .=
' WHERE u.entity IN ('.getEntity(
'user').
')';
279 $this->export_code[$r] = $this->rights_class.
'_'.$r;
280 $this->export_label[$r] =
'List of security events';
281 $this->export_permission[$r] = array(array(
"user"));
282 $this->export_fields_array[$r] = array(
283 'e.rowid' =>
"Id",
'e.type' =>
"Type",
284 'e.dateevent' =>
"Date",
285 'e.description' =>
'Description',
286 'e.ip' =>
'IPAddress',
'e.user_agent' =>
'UserAgent',
287 'e.authentication_method' =>
'AuthenticationMode',
288 'e.fk_user' =>
"UserID",
'u.login' =>
"Login",
290 $this->export_TypeFields_array[$r] = array(
291 'e.rowid' =>
'Numeric',
'e.type' =>
"Text",
292 'e.dateevent' =>
"Date",
293 'e.description' =>
'Text',
294 'e.ip' =>
'Text',
'e.user_agent' =>
'Text',
295 'e.authentication_method' =>
'Text',
296 'e.fk_user' =>
"Numeric",
'u.login' =>
"Text",
298 $this->export_entities_array[$r] = array(
299 'e.rowid' =>
'securityevent',
'e.type' =>
"securityevent",
300 'e.dateevent' =>
"securityevent",
301 'e.description' =>
'securityevent',
302 'e.ip' =>
'securityevent',
'e.user_agent' =>
'securityevent',
303 'e.authentication_method' =>
'securityevent',
304 'e.fk_user' =>
"user",
'u.login' =>
"user",
306 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
307 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'events as e';
308 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as u ON e.fk_user = u.rowid';
309 $this->export_sql_end[$r] .=
' WHERE e.entity IN ('.getEntity(
'event').
')';
317 $this->import_code[$r] = $this->rights_class.
'_'.$r;
318 $this->import_label[$r] =
'ImportDataset_user_1';
319 $this->import_icon[$r] =
'user';
320 $this->import_entities_array[$r] = array();
321 $this->import_tables_array[$r] = array(
'u' => MAIN_DB_PREFIX.
'user',
'extra' => MAIN_DB_PREFIX.
'user_extrafields');
322 $this->import_fields_array[$r] = array(
323 'u.login' =>
"Login*",
'u.lastname' =>
"Name*",
'u.firstname' =>
"Firstname",
'u.employee' =>
"Employee*",
'u.job' =>
"PostOrFunction",
'u.gender' =>
"Gender",
324 'u.accountancy_code' =>
"UserAccountancyCode",
325 'u.pass_crypted' =>
"Password",
'u.admin' =>
"Administrator",
'u.fk_soc' =>
"Company*",
'u.address' =>
"Address",
'u.zip' =>
"Zip",
'u.town' =>
"Town",
326 'u.fk_state' =>
"StateId",
'u.fk_country' =>
"CountryCode",
327 'u.office_phone' =>
"Phone",
'u.user_mobile' =>
"Mobile",
'u.office_fax' =>
"Fax",
328 'u.email' =>
"Email",
'u.note_public' =>
"NotePublic",
'u.note_private' =>
"NotePrivate",
'u.signature' =>
'Signature',
329 'u.fk_user' =>
'HierarchicalResponsible',
'u.thm' =>
'THM',
'u.tjm' =>
'TJM',
'u.weeklyhours' =>
'WeeklyHours',
330 'u.dateemployment' =>
'DateEmploymentStart',
'u.dateemploymentend' =>
'DateEmploymentEnd',
'u.salary' =>
'Salary',
'u.color' =>
'Color',
'u.api_key' =>
'ApiKey',
331 'u.birth' =>
'DateOfBirth',
332 'u.datec' =>
"DateCreation",
333 'u.statut' =>
'Status'
336 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE type <> 'separate' AND elementtype = 'user' AND entity IN (0,".((int)
$conf->entity).
")";
337 $resql = $this->db->query($sql);
339 while ($obj = $this->db->fetch_object($resql)) {
340 $fieldname =
'extra.'.$obj->name;
341 $fieldlabel = ucfirst($obj->label);
342 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
346 $this->import_fieldshidden_array[$r] = array(
'u.fk_user_creat' =>
'user->id',
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'user');
347 $this->import_convertvalue_array[$r] = array(
348 'u.fk_state' => array(
'rule' =>
'fetchidfromcodeid',
'classfile' =>
'/core/class/cstate.class.php',
'class' =>
'Cstate',
'method' =>
'fetch',
'dict' =>
'DictionaryState'),
349 'u.fk_country' => array(
'rule' =>
'fetchidfromcodeid',
'classfile' =>
'/core/class/ccountry.class.php',
'class' =>
'Ccountry',
'method' =>
'fetch',
'dict' =>
'DictionaryCountry'),
350 'u.salary' => array(
'rule' =>
'numeric')
353 $this->import_regex_array[$r] = array(
354 'u.employee' =>
'^[0|1]',
355 '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])?$',
356 'u.dateemployment' =>
'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
357 'u.birth' =>
'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'
359 $this->import_examplevalues_array[$r] = array(
360 'u.lastname' =>
"Doe",
'u.firstname' =>
'John',
'u.login' =>
'jdoe',
'u.employee' =>
'0 or 1',
'u.job' =>
'CTO',
'u.gender' =>
'man or woman',
361 'u.pass_crypted' =>
'Encrypted password',
362 'u.fk_soc' =>
'0 (internal user) or company name (external user)',
'u.address' =>
"61 jump street",
363 'u.zip' =>
"123456",
'u.town' =>
"Big town",
'u.fk_country' =>
'US, FR, DE...',
'u.office_phone' =>
"0101010101",
'u.office_fax' =>
"0101010102",
364 '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",
365 'u.statut' =>
"0 (closed) or 1 (active)",
367 $this->import_updatekeys_array[$r] = array(
'u.lastname' =>
'Lastname',
'u.firstname' =>
'Firstname',
'u.login' =>
'Login');