dolibarr 19.0.4
api_users.class.php
1<?php
2/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
3 * Copyright (C) 2020 Thibault FOUCART <support@ptibogxiv.net>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19use Luracast\Restler\RestException;
20
21require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
22require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
23
24
31class Users extends DolibarrApi
32{
36 public static $FIELDS = array(
37 'login',
38 );
39
43 public $useraccount;
44
48 public function __construct()
49 {
50 global $db, $conf;
51
52 $this->db = $db;
53 $this->useraccount = new User($this->db);
54 }
55
56
72 public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $category = 0, $sqlfilters = '', $properties = '')
73 {
74 global $conf;
75
76 if (empty(DolibarrApiAccess::$user->rights->user->user->lire) && empty(DolibarrApiAccess::$user->admin)) {
77 throw new RestException(401, "You are not allowed to read list of users");
78 }
79
80 $obj_ret = array();
81
82 // case of external user, $societe param is ignored and replaced by user's socid
83 //$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $societe;
84
85 $sql = "SELECT t.rowid";
86 $sql .= " FROM ".MAIN_DB_PREFIX."user AS t LEFT JOIN ".MAIN_DB_PREFIX."user_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
87 if ($category > 0) {
88 $sql .= ", ".$this->db->prefix()."categorie_user as c";
89 }
90 $sql .= ' WHERE t.entity IN ('.getEntity('user').')';
91 if ($user_ids) {
92 $sql .= " AND t.rowid IN (".$this->db->sanitize($user_ids).")";
93 }
94
95 // Select products of given category
96 if ($category > 0) {
97 $sql .= " AND c.fk_categorie = ".((int) $category);
98 $sql .= " AND c.fk_user = t.rowid";
99 }
100
101 // Add sql filters
102 if ($sqlfilters) {
103 $errormessage = '';
104 $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage);
105 if ($errormessage) {
106 throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
107 }
108 }
109
110 $sql .= $this->db->order($sortfield, $sortorder);
111 if ($limit) {
112 if ($page < 0) {
113 $page = 0;
114 }
115 $offset = $limit * $page;
116
117 $sql .= $this->db->plimit($limit + 1, $offset);
118 }
119
120 $result = $this->db->query($sql);
121
122 if ($result) {
123 $i = 0;
124 $num = $this->db->num_rows($result);
125 $min = min($num, ($limit <= 0 ? $num : $limit));
126 while ($i < $min) {
127 $obj = $this->db->fetch_object($result);
128 $user_static = new User($this->db);
129 if ($user_static->fetch($obj->rowid)) {
130 $obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($user_static), $properties);
131 }
132 $i++;
133 }
134 } else {
135 throw new RestException(503, 'Error when retrieve User list : '.$this->db->lasterror());
136 }
137
138 return $obj_ret;
139 }
140
151 public function get($id, $includepermissions = 0)
152 {
153 if (empty(DolibarrApiAccess::$user->rights->user->user->lire) && empty(DolibarrApiAccess::$user->admin) && $id != 0 && DolibarrApiAccess::$user->id != $id) {
154 throw new RestException(401, 'Not allowed');
155 }
156
157 if ($id == 0) {
158 $result = $this->useraccount->initAsSpecimen();
159 } else {
160 $result = $this->useraccount->fetch($id);
161 }
162 if (!$result) {
163 throw new RestException(404, 'User not found');
164 }
165
166 if ($id > 0 && !DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) {
167 throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
168 }
169
170 if ($includepermissions) {
171 $this->useraccount->getRights();
172 }
173
174 return $this->_cleanObjectDatas($this->useraccount);
175 }
176
190 public function getByLogin($login, $includepermissions = 0)
191 {
192 if (empty($login)) {
193 throw new RestException(400, 'Bad parameters');
194 }
195
196 if (empty(DolibarrApiAccess::$user->rights->user->user->lire) && empty(DolibarrApiAccess::$user->admin) && DolibarrApiAccess::$user->login != $login) {
197 throw new RestException(401, 'Not allowed');
198 }
199
200 $result = $this->useraccount->fetch('', $login);
201 if (!$result) {
202 throw new RestException(404, 'User not found');
203 }
204
205 if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) {
206 throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
207 }
208
209 if ($includepermissions) {
210 $this->useraccount->getRights();
211 }
212
213 return $this->_cleanObjectDatas($this->useraccount);
214 }
215
229 public function getByEmail($email, $includepermissions = 0)
230 {
231 if (empty($email)) {
232 throw new RestException(400, 'Bad parameters');
233 }
234
235 if (empty(DolibarrApiAccess::$user->rights->user->user->lire) && empty(DolibarrApiAccess::$user->admin) && DolibarrApiAccess::$user->email != $email) {
236 throw new RestException(401, 'Not allowed');
237 }
238
239 $result = $this->useraccount->fetch('', '', '', 0, -1, $email);
240 if (!$result) {
241 throw new RestException(404, 'User not found');
242 }
243
244 if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) {
245 throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
246 }
247
248 if ($includepermissions) {
249 $this->useraccount->getRights();
250 }
251
252 return $this->_cleanObjectDatas($this->useraccount);
253 }
254
266 public function getInfo($includepermissions = 0)
267 {
268 if (empty(DolibarrApiAccess::$user->rights->user->self->creer) && empty(DolibarrApiAccess::$user->rights->user->user->lire) && empty(DolibarrApiAccess::$user->admin)) {
269 throw new RestException(401, 'Not allowed');
270 }
271
272 $apiUser = DolibarrApiAccess::$user;
273
274 $result = $this->useraccount->fetch($apiUser->id);
275 if (!$result) {
276 throw new RestException(404, 'User not found');
277 }
278
279 if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) {
280 throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
281 }
282
283 if ($includepermissions) {
284 $this->useraccount->getRights();
285 }
286
287 $usergroup = new UserGroup($this->db);
288 $userGroupList = $usergroup->listGroupsForUser($apiUser->id, false);
289 if (!is_array($userGroupList)) {
290 throw new RestException(404, 'User group not found');
291 }
292
293 $this->useraccount->user_group_list = $this->_cleanUserGroupListDatas($userGroupList);
294
295 return $this->_cleanObjectDatas($this->useraccount);
296 }
297
306 public function post($request_data = null)
307 {
308 // Check user authorization
309 if (empty(DolibarrApiAccess::$user->rights->user->creer) && empty(DolibarrApiAccess::$user->admin)) {
310 throw new RestException(401, "User creation not allowed for login ".DolibarrApiAccess::$user->login);
311 }
312
313 // check mandatory fields
314 /*if (!isset($request_data["login"]))
315 throw new RestException(400, "login field missing");
316 if (!isset($request_data["password"]))
317 throw new RestException(400, "password field missing");
318 if (!isset($request_data["lastname"]))
319 throw new RestException(400, "lastname field missing");*/
320
321 //assign field values
322 foreach ($request_data as $field => $value) {
323 if (in_array($field, array('pass_crypted', 'pass_indatabase', 'pass_indatabase_crypted', 'pass_temp', 'api_key'))) {
324 // This properties can't be set/modified with API
325 throw new RestException(401, 'The property '.$field." can't be set/modified using the APIs");
326 }
327 if ($field === 'caller') {
328 // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
329 $this->useraccount->context['caller'] = $request_data['caller'];
330 continue;
331 }
332 /*if ($field == 'pass') {
333 if (empty(DolibarrApiAccess::$user->rights->user->user->password)) {
334 throw new RestException(401, 'You are not allowed to modify/set password of other users');
335 continue;
336 }
337 }
338 */
339
340 $this->useraccount->$field = $value;
341 }
342
343 if ($this->useraccount->create(DolibarrApiAccess::$user) < 0) {
344 throw new RestException(500, 'Error creating', array_merge(array($this->useraccount->error), $this->useraccount->errors));
345 }
346 return $this->useraccount->id;
347 }
348
349
361 public function put($id, $request_data = null)
362 {
363 // Check user authorization
364 if (!DolibarrApiAccess::$user->hasRight('user', 'user', 'creer') && empty(DolibarrApiAccess::$user->admin)) {
365 throw new RestException(401, "User update not allowed");
366 }
367
368 $result = $this->useraccount->fetch($id);
369 if (!$result) {
370 throw new RestException(404, 'Account not found');
371 }
372
373 if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) {
374 throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
375 }
376
377 foreach ($request_data as $field => $value) {
378 if (in_array($field, array('pass_crypted', 'pass_indatabase', 'pass_indatabase_crypted', 'pass_temp', 'api_key'))) {
379 // This properties can't be set/modified with API
380 throw new RestException(401, 'The property '.$field." can't be set/modified using the APIs");
381 }
382 if ($field == 'id') {
383 continue;
384 }
385 if ($field == 'pass') {
386 if ($this->useraccount->id != DolibarrApiAccess::$user->id && empty(DolibarrApiAccess::$user->rights->user->user->password)) {
387 throw new RestException(401, 'You are not allowed to modify password of other users');
388 }
389 if ($this->useraccount->id == DolibarrApiAccess::$user->id && empty(DolibarrApiAccess::$user->rights->user->self->password)) {
390 throw new RestException(401, 'You are not allowed to modify your own password');
391 }
392 }
393 if ($field === 'caller') {
394 // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
395 $this->useraccount->context['caller'] = $request_data['caller'];
396 continue;
397 }
398
399 if (DolibarrApiAccess::$user->admin) { // If user for API is admin
400 if ($field == 'admin' && $value != $this->useraccount->admin && empty($value)) {
401 throw new RestException(401, 'Reseting the admin status of a user is not possible using the API');
402 }
403 } else {
404 if ($field == 'admin' && $value != $this->useraccount->admin) {
405 throw new RestException(401, 'Only an admin user can modify the admin status of another user');
406 }
407 }
408 if ($field == 'entity' && $value != $this->useraccount->entity) {
409 throw new RestException(401, 'Changing entity of a user using the APIs is not possible');
410 }
411
412 // The status must be updated using setstatus() because it
413 // is not handled by the update() method.
414 if ($field == 'statut' || $field == 'status') {
415 $result = $this->useraccount->setstatus($value);
416 if ($result < 0) {
417 throw new RestException(500, 'Error when updating status of user: '.$this->useraccount->error);
418 }
419 } else {
420 if ($field == 'array_options' && is_array($value)) {
421 foreach ($value as $index => $val) {
422 $this->useraccount->array_options[$index] = $this->_checkValForAPI($field, $val, $this->useraccount);
423 }
424 continue;
425 }
426 $this->useraccount->$field = $this->_checkValForAPI($field, $value, $this->useraccount);
427 }
428 }
429
430 // If there is no error, update() returns the number of affected
431 // rows so if the update is a no op, the return value is zezo.
432 if ($this->useraccount->update(DolibarrApiAccess::$user) >= 0) {
433 return $this->get($id);
434 } else {
435 throw new RestException(500, $this->useraccount->error);
436 }
437 }
438
439
451 public function getGroups($id)
452 {
453 if (empty(DolibarrApiAccess::$user->rights->user->user->lire) && empty(DolibarrApiAccess::$user->admin)) {
454 throw new RestException(403);
455 }
456
457 $obj_ret = array();
458
459 $user = new User($this->db);
460 $result = $user->fetch($id);
461 if (!$result) {
462 throw new RestException(404, 'user not found');
463 }
464
465 $usergroup = new UserGroup($this->db);
466 $groups = $usergroup->listGroupsForUser($id, false);
467 $obj_ret = array();
468 foreach ($groups as $group) {
469 $obj_ret[] = $this->_cleanObjectDatas($group);
470 }
471 return $obj_ret;
472 }
473
474
489 public function setGroup($id, $group, $entity = 1)
490 {
491 global $conf;
492
493 if (!DolibarrApiAccess::$user->hasRight('user', 'user', 'creer') && empty(DolibarrApiAccess::$user->admin)) {
494 throw new RestException(401);
495 }
496
497 $result = $this->useraccount->fetch($id);
498 if (!$result) {
499 throw new RestException(404, 'User not found');
500 }
501
502 if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) {
503 throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
504 }
505
506 if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE') && !empty(DolibarrApiAccess::$user->admin) && empty(DolibarrApiAccess::$user->entity)) {
507 $entity = (!empty($entity) ? $entity : $conf->entity);
508 } else {
509 // When using API, action is done on entity of logged user because a user of entity X with permission to create user should not be able to
510 // hack the security by giving himself permissions on another entity.
511 $entity = (DolibarrApiAccess::$user->entity > 0 ? DolibarrApiAccess::$user->entity : $conf->entity);
512 }
513
514 $result = $this->useraccount->SetInGroup($group, $entity);
515 if (!($result > 0)) {
516 throw new RestException(500, $this->useraccount->error);
517 }
518
519 return 1;
520 }
521
541 public function listGroups($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $group_ids = 0, $sqlfilters = '', $properties = '')
542 {
543 global $conf;
544
545 $obj_ret = array();
546
547 if ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && empty(DolibarrApiAccess::$user->rights->user->user->lire) && empty(DolibarrApiAccess::$user->admin)) ||
548 getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && empty(DolibarrApiAccess::$user->rights->user->group_advance->read) && empty(DolibarrApiAccess::$user->admin)) {
549 throw new RestException(401, "You are not allowed to read groups");
550 }
551
552 // case of external user, $societe param is ignored and replaced by user's socid
553 //$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $societe;
554
555 $sql = "SELECT t.rowid";
556 $sql .= " FROM ".MAIN_DB_PREFIX."usergroup AS t LEFT JOIN ".MAIN_DB_PREFIX."usergroup_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
557 $sql .= ' WHERE t.entity IN ('.getEntity('user').')';
558 if ($group_ids) {
559 $sql .= " AND t.rowid IN (".$this->db->sanitize($group_ids).")";
560 }
561 // Add sql filters
562 if ($sqlfilters) {
563 $errormessage = '';
564 $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage);
565 if ($errormessage) {
566 throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
567 }
568 }
569
570 $sql .= $this->db->order($sortfield, $sortorder);
571 if ($limit) {
572 if ($page < 0) {
573 $page = 0;
574 }
575 $offset = $limit * $page;
576
577 $sql .= $this->db->plimit($limit + 1, $offset);
578 }
579
580 $result = $this->db->query($sql);
581
582 if ($result) {
583 $i = 0;
584 $num = $this->db->num_rows($result);
585 $min = min($num, ($limit <= 0 ? $num : $limit));
586 while ($i < $min) {
587 $obj = $this->db->fetch_object($result);
588 $group_static = new UserGroup($this->db);
589 if ($group_static->fetch($obj->rowid)) {
590 $obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($group_static), $properties);
591 }
592 $i++;
593 }
594 } else {
595 throw new RestException(503, 'Error when retrieve Group list : '.$this->db->lasterror());
596 }
597
598 return $obj_ret;
599 }
600
615 public function infoGroups($group, $load_members = 0)
616 {
617 global $db, $conf;
618
619 if ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && empty(DolibarrApiAccess::$user->rights->user->user->lire) && empty(DolibarrApiAccess::$user->admin)) ||
620 getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && empty(DolibarrApiAccess::$user->rights->user->group_advance->read) && empty(DolibarrApiAccess::$user->admin)) {
621 throw new RestException(401, "You are not allowed to read groups");
622 }
623
624 $group_static = new UserGroup($this->db);
625 $result = $group_static->fetch($group, '', $load_members);
626
627 if (!$result) {
628 throw new RestException(404, 'Group not found');
629 }
630
631 return $this->_cleanObjectDatas($group_static);
632 }
633
643 public function delete($id)
644 {
645 if (empty(DolibarrApiAccess::$user->rights->user->user->supprimer) && empty(DolibarrApiAccess::$user->admin)) {
646 throw new RestException(401, 'Not allowed');
647 }
648 $result = $this->useraccount->fetch($id);
649 if (!$result) {
650 throw new RestException(404, 'User not found');
651 }
652
653 if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) {
654 throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
655 }
656 $this->useraccount->oldcopy = clone $this->useraccount;
657
658 if (!$this->useraccount->delete(DolibarrApiAccess::$user)) {
659 throw new RestException(500);
660 }
661
662 return array(
663 'success' => array(
664 'code' => 200,
665 'message' => 'Ticket deleted'
666 )
667 );
668 }
669
670 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
677 protected function _cleanObjectDatas($object)
678 {
679 // phpcs:enable
680 global $conf;
681
682 $object = parent::_cleanObjectDatas($object);
683
684 unset($object->default_values);
685 unset($object->lastsearch_values);
686 unset($object->lastsearch_values_tmp);
687
688 unset($object->total_ht);
689 unset($object->total_tva);
690 unset($object->total_localtax1);
691 unset($object->total_localtax2);
692 unset($object->total_ttc);
693
694 unset($object->label_incoterms);
695 unset($object->location_incoterms);
696
697 unset($object->fk_delivery_address);
698 unset($object->fk_incoterms);
699 unset($object->all_permissions_are_loaded);
700 unset($object->shipping_method_id);
701 unset($object->nb_rights);
702 unset($object->search_sid);
703 unset($object->ldap_sid);
704 unset($object->clicktodial_loaded);
705
706 // List of properties never returned by API, whatever are permissions
707 unset($object->pass);
708 unset($object->pass_indatabase);
709 unset($object->pass_indatabase_crypted);
710 unset($object->pass_temp);
711 unset($object->api_key);
712 unset($object->clicktodial_password);
713 unset($object->openid);
714
715 unset($object->lines);
716 unset($object->model_pdf);
717
718 $canreadsalary = ((isModEnabled('salaries') && !empty(DolibarrApiAccess::$user->rights->salaries->read)) || (empty($conf->salaries->enabled)));
719
720 if (!$canreadsalary) {
721 unset($object->salary);
722 unset($object->salaryextra);
723 unset($object->thm);
724 unset($object->tjm);
725 }
726
727 return $object;
728 }
729
736 private function _cleanUserGroupListDatas($objectList)
737 {
738 $cleanObjectList = array();
739
740 foreach ($objectList as $object) {
741 $cleanObject = parent::_cleanObjectDatas($object);
742
743 unset($cleanObject->default_values);
744 unset($cleanObject->lastsearch_values);
745 unset($cleanObject->lastsearch_values_tmp);
746
747 unset($cleanObject->total_ht);
748 unset($cleanObject->total_tva);
749 unset($cleanObject->total_localtax1);
750 unset($cleanObject->total_localtax2);
751 unset($cleanObject->total_ttc);
752
753 unset($cleanObject->libelle_incoterms);
754 unset($cleanObject->location_incoterms);
755
756 unset($cleanObject->fk_delivery_address);
757 unset($cleanObject->fk_incoterms);
758 unset($cleanObject->all_permissions_are_loaded);
759 unset($cleanObject->shipping_method_id);
760 unset($cleanObject->nb_rights);
761 unset($cleanObject->search_sid);
762 unset($cleanObject->ldap_sid);
763 unset($cleanObject->clicktodial_loaded);
764
765 unset($cleanObject->datec);
766 unset($cleanObject->tms);
767 unset($cleanObject->members);
768 unset($cleanObject->note);
769 unset($cleanObject->note_private);
770
771 $cleanObjectList[] = $cleanObject;
772 }
773
774 return $cleanObjectList;
775 }
776
784 private function _validate($data)
785 {
786 $account = array();
787 foreach (Users::$FIELDS as $field) {
788 if (!isset($data[$field])) {
789 throw new RestException(400, "$field field missing");
790 }
791 $account[$field] = $data[$field];
792 }
793 return $account;
794 }
795}
Class for API REST v1.
Definition api.class.php:31
_filterObjectProperties($object, $properties)
Filter properties that will be returned on object.
static _checkAccessToResource($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
Check access by user to a given resource.
_checkValForAPI($field, $value, $object)
Check and convert a string depending on its type/name.
Definition api.class.php:85
Class to manage user groups.
Class to manage Dolibarr users.
put($id, $request_data=null)
Update user account.
_cleanObjectDatas($object)
Clean sensible object datas.
getInfo($includepermissions=0)
Get more properties of a user.
_cleanUserGroupListDatas($objectList)
Clean sensible user group list datas.
setGroup($id, $group, $entity=1)
Add a user into a group.
infoGroups($group, $load_members=0)
Get properties of an group object.
index($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $user_ids=0, $category=0, $sqlfilters='', $properties='')
List Users.
_validate($data)
Validate fields before create or update object.
getByEmail($email, $includepermissions=0)
Get properties of an user object by Email.
getGroups($id)
List the groups of a user.
post($request_data=null)
Create user account.
listGroups($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $group_ids=0, $sqlfilters='', $properties='')
List Groups.
getByLogin($login, $includepermissions=0)
Get properties of an user object by login.
__construct()
Constructor.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.