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