23use Luracast\Restler\RestException;
25require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
26require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
43 public static $FIELDS = array(
60 $this->useraccount =
new User($this->db);
85 public function index($sortfield =
"t.rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $user_ids =
'0', $category = 0, $sqlfilters =
'', $properties =
'')
87 if (!DolibarrApiAccess::$user->hasRight(
'user',
'user',
'lire') && empty(DolibarrApiAccess::$user->admin)) {
88 throw new RestException(403,
"You are not allowed to read list of users");
96 $sql =
"SELECT t.rowid";
97 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user AS t LEFT JOIN ".MAIN_DB_PREFIX.
"user_extrafields AS ef ON (ef.fk_object = t.rowid)";
99 $sql .=
", ".$this->db->prefix().
"categorie_user as c";
101 $sql .=
' WHERE t.entity IN ('.getEntity(
'user').
')';
103 $sql .=
" AND t.rowid IN (".$this->db->sanitize($user_ids).
")";
108 $sql .=
" AND c.fk_categorie = ".((int) $category);
109 $sql .=
" AND c.fk_user = t.rowid";
117 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
121 $sql .= $this->db->order($sortfield, $sortorder);
126 $offset = $limit * $page;
128 $sql .= $this->db->plimit($limit + 1, $offset);
131 $result = $this->db->query($sql);
135 $num = $this->db->num_rows($result);
136 $min = min($num, ($limit <= 0 ? $num : $limit));
138 $obj = $this->db->fetch_object($result);
139 $user_static =
new User($this->db);
140 if ($user_static->fetch($obj->rowid)) {
146 throw new RestException(503,
'Error when retrieve User list : '.$this->db->lasterror());
167 public function get(
$id, $includepermissions = 0)
170 throw new RestException(400,
'No user with id=0 can exist');
173 if (!DolibarrApiAccess::$user->hasRight(
'user',
'user',
'lire') && empty(DolibarrApiAccess::$user->admin) &&
$id != 0 && DolibarrApiAccess::$user->
id !=
$id) {
174 throw new RestException(403,
'Not allowed');
178 $result = $this->useraccount->initAsSpecimen();
180 $result = $this->useraccount->fetch(
$id);
183 throw new RestException(404,
'User not found');
187 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
190 if ($includepermissions) {
191 $this->useraccount->loadRights();
217 throw new RestException(400,
'Bad parameters');
220 if (!DolibarrApiAccess::$user->hasRight(
'user',
'user',
'lire') && empty(DolibarrApiAccess::$user->admin) && DolibarrApiAccess::$user->login != $login) {
221 throw new RestException(403,
'Not allowed');
224 $result = $this->useraccount->fetch(0, $login);
226 throw new RestException(404,
'User not found');
230 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
233 if ($includepermissions) {
234 $this->useraccount->loadRights();
260 throw new RestException(400,
'Bad parameters');
263 if (!DolibarrApiAccess::$user->hasRight(
'user',
'user',
'lire') && empty(DolibarrApiAccess::$user->admin) && DolibarrApiAccess::$user->
email != $email) {
264 throw new RestException(403,
'Not allowed');
267 $result = $this->useraccount->fetch(0,
'',
'', 0, -1, $email);
269 throw new RestException(404,
'User not found');
273 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
276 if ($includepermissions) {
277 $this->useraccount->loadRights();
298 public function getInfo($includepermissions = 0)
300 if (!DolibarrApiAccess::$user->hasRight(
'user',
'self',
'creer') && !DolibarrApiAccess::$user->hasRight(
'user',
'user',
'lire') && empty(DolibarrApiAccess::$user->admin)) {
301 throw new RestException(403,
'Not allowed');
304 $apiUser = DolibarrApiAccess::$user;
306 $result = $this->useraccount->fetch($apiUser->id);
308 throw new RestException(404,
'User not found');
312 throw new RestException(403,
'Access not allowed to current logged user');
315 if ($includepermissions) {
316 $this->useraccount->loadRights();
320 $userGroupList = $usergroup->listGroupsForUser($apiUser->id,
false);
321 if (!is_array($userGroupList)) {
322 throw new RestException(404,
'User group not found');
342 public function post($request_data =
null)
345 if (!DolibarrApiAccess::$user->hasRight(
'user',
'user',
'creer') && empty(DolibarrApiAccess::$user->admin)) {
346 throw new RestException(403,
"User creation not allowed for login ".DolibarrApiAccess::$user->login);
350 if (!isset($request_data[
"login"]))
351 throw new RestException(500,
"login field missing");
358 foreach ($request_data as $field => $value) {
359 if (in_array($field, array(
'pass_crypted',
'pass_indatabase',
'pass_indatabase_crypted',
'pass_temp',
'api_key'))) {
361 throw new RestException(405,
'The property '.$field.
" can't be set/modified using the APIs");
370 if ($field ===
'caller') {
372 $this->useraccount->context[
'caller'] =
sanitizeVal($request_data[
'caller'],
'aZ09');
376 if (DolibarrApiAccess::$user->admin) {
377 if ($field ==
'admin' && $value != $this->useraccount->admin && empty($value)) {
378 throw new RestException(403,
'Reseting the admin status of a user is not possible using the API');
381 if ($field ==
'admin' && $value != $this->useraccount->admin) {
382 throw new RestException(403,
'Only an admin user can modify the admin status of another user');
386 $this->useraccount->$field = $this->
_checkValForAPI($field, $value, $this->useraccount);
389 if ($this->useraccount->create(DolibarrApiAccess::$user) < 0) {
390 throw new RestException(500,
'Error creating', array_merge(array($this->useraccount->error), $this->useraccount->errors));
392 return $this->useraccount->id;
411 public function put(
$id, $request_data =
null)
414 if (!DolibarrApiAccess::$user->hasRight(
'user',
'user',
'creer') && empty(DolibarrApiAccess::$user->admin)) {
415 throw new RestException(403,
"User update not allowed");
418 $result = $this->useraccount->fetch(
$id);
420 throw new RestException(404,
'Account not found');
424 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
427 foreach ($request_data as $field => $value) {
428 if (in_array($field, array(
'pass_crypted',
'pass_indatabase',
'pass_indatabase_crypted',
'pass_temp',
'api_key'))) {
430 throw new RestException(405,
'The property '.$field.
" can't be set/modified using the APIs");
432 if ($field ==
'id') {
435 if ($field ==
'pass') {
436 if ($this->useraccount->id != DolibarrApiAccess::$user->id && !DolibarrApiAccess::$user->hasRight(
'user',
'user',
'password')) {
437 throw new RestException(403,
'You are not allowed to modify password of other users');
439 if ($this->useraccount->id == DolibarrApiAccess::$user->id && !DolibarrApiAccess::$user->hasRight(
'user',
'self',
'password')) {
440 throw new RestException(403,
'You are not allowed to modify your own password');
443 if ($field ===
'caller') {
445 $this->useraccount->context[
'caller'] =
sanitizeVal($request_data[
'caller'],
'aZ09');
448 if ($field ==
'array_options' && is_array($value)) {
449 foreach ($value as $index => $val) {
450 $this->useraccount->array_options[$index] = $this->
_checkValForAPI($field, $val, $this->useraccount);
455 if (DolibarrApiAccess::$user->admin) {
456 if ($field ==
'admin' && $value != $this->useraccount->admin && empty($value)) {
457 throw new RestException(403,
'Reseting the admin status of a user is not possible using the API');
460 if ($field ==
'admin' && $value != $this->useraccount->admin) {
461 throw new RestException(403,
'Only an admin user can modify the admin status of another user');
464 if ($field ==
'entity' && $value != $this->useraccount->entity) {
465 throw new RestException(403,
'Changing entity of a user using the APIs is not possible');
470 if ($field ==
'statut' || $field ==
'status') {
471 $result = $this->useraccount->setstatus($value);
473 throw new RestException(500,
'Error when updating status of user: '.$this->useraccount->error);
476 $this->useraccount->$field = $this->
_checkValForAPI($field, $value, $this->useraccount);
482 if ($this->useraccount->update(DolibarrApiAccess::$user) >= 0) {
483 return $this->
get(
$id);
485 throw new RestException(500, $this->useraccount->error);
508 throw new RestException(403,
"Error: login and password reset APIs are disabled. You can get access token from the backoffice to get access permission but permission and password manipulation from APIs are forbidden.");
513 throw new RestException(403,
"Error: password reset APIs are disabled by default. To allow this, the option API_ALLOW_PASSWORD_RESET must be set.");
516 if (!DolibarrApiAccess::$user->hasRight(
'user',
'user',
'creer') && empty(DolibarrApiAccess::$user->admin)) {
517 throw new RestException(403,
"setPassword on user not allowed for login ".DolibarrApiAccess::$user->login);
520 $result = $this->useraccount->fetch(
$id);
522 throw new RestException(404,
'User not found, no password changed');
526 throw new RestException(403,
'Access on this object not allowed for login '.DolibarrApiAccess::$user->login);
529 $newpassword = $this->useraccount->setPassword($this->useraccount,
'');
530 if (is_int($newpassword) && $newpassword < 0) {
531 throw new RestException(500,
'ErrorFailedToSetNewPassword'.$this->useraccount->error);
534 if ($send_password) {
535 if ($this->useraccount->send_password($this->useraccount, $newpassword) > 0) {
538 throw new RestException(500,
'ErrorFailedSendingNewPassword - '.$this->useraccount->error);
565 throw new RestException(400,
'No user with id=0 can exist');
568 if (!DolibarrApiAccess::$user->hasRight(
'user',
'user',
'lire') && empty(DolibarrApiAccess::$user->admin)) {
569 throw new RestException(403);
572 $user =
new User($this->db);
573 $result = $user->fetch(
$id);
575 throw new RestException(404,
'user not found');
579 $groups = $usergroup->listGroupsForUser(
$id,
false);
581 foreach ($groups as $group) {
608 if (!DolibarrApiAccess::$user->hasRight(
'user',
'user',
'creer') && empty(DolibarrApiAccess::$user->admin)) {
609 throw new RestException(403,
'setGroup on users not allowed for login '.DolibarrApiAccess::$user->login);
612 $result = $this->useraccount->fetch(
$id);
614 throw new RestException(404,
'User not found');
618 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
621 if (
isModEnabled(
'multicompany') &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') && !empty(DolibarrApiAccess::$user->admin) && empty(DolibarrApiAccess::$user->entity)) {
622 $entity = (!empty($entity) ? (int) $entity : $conf->entity);
626 $entity = (((int) DolibarrApiAccess::$user->entity) > 0 ? (int) DolibarrApiAccess::$user->entity : $conf->entity);
629 $result = $this->useraccount->SetInGroup($group, $entity);
630 if (!($result > 0)) {
631 throw new RestException(500, $this->useraccount->error);
653 if (!DolibarrApiAccess::$user->hasRight(
'user',
'group_advance',
'write') && empty(DolibarrApiAccess::$user->admin)) {
654 throw new RestException(403,
"Usergroup creation not allowed for login ".DolibarrApiAccess::$user->login);
657 foreach ($request_data as $field => $value) {
658 if ($field ===
'caller') {
660 $usergroup->context[
'caller'] =
sanitizeVal($request_data[
'caller'],
'aZ09');
663 if ($field ==
'id') {
664 throw new RestException(400,
'Creating with id field is forbidden');
667 $usergroup->$field = $this->
_checkValForAPI($field, $value, $usergroup);
670 if ($usergroup->create(1) < 0) {
671 throw new RestException(500,
'Error creating', array_merge(array($usergroup->error), $usergroup->errors));
673 return $usergroup->id;
696 if (!DolibarrApiAccess::$user->hasRight(
'user',
'group_advance',
'write') && empty(DolibarrApiAccess::$user->admin)) {
697 throw new RestException(403,
"Usergroup update not allowed");
702 $result = $usergroup->fetch($group);
704 throw new RestException(404,
'Usergroup not found');
707 foreach ($request_data as $field => $value) {
708 if ($field ==
'id') {
709 throw new RestException(400,
'Updating with id field is forbidden');
711 if ($field ===
'caller') {
713 $usergroup->context[
'caller'] =
sanitizeVal($request_data[
'caller'],
'aZ09');
717 if ($field ==
'entity' && $value != $usergroup->entity) {
718 throw new RestException(403,
'Changing entity of a user using the APIs is not possible');
721 $usergroup->$field = $this->
_checkValForAPI($field, $value, $usergroup);
726 if ($usergroup->update() >= 0) {
729 throw new RestException(500, $usergroup->error);
750 if (!DolibarrApiAccess::$user->admin) {
751 throw new RestException(403,
'Only admin can remove users from groups');
754 $sql =
"DELETE FROM " . MAIN_DB_PREFIX .
"usergroup_user";
755 $sql .=
" WHERE fk_user = " . ((int)
$id);
756 $sql .=
" AND fk_usergroup = " . ((int) $group);
758 $resql = $this->db->query($sql);
761 throw new RestException(503,
'DB error: ' . $this->db->lasterror());
766 'message' =>
"User $id removed from group $group"
794 public function listGroups($sortfield =
"t.rowid", $sortorder =
'ASC', $limit = 100, $page = 0, $group_ids =
'0', $sqlfilters =
'', $properties =
'')
798 if ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !DolibarrApiAccess::$user->hasRight(
'user',
'user',
'lire') && empty(DolibarrApiAccess::$user->admin)) ||
799 getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !DolibarrApiAccess::$user->hasRight(
'user',
'group_advance',
'read') && empty(DolibarrApiAccess::$user->admin)) {
800 throw new RestException(403,
"You are not allowed to read groups");
806 $sql =
"SELECT t.rowid";
807 $sql .=
" FROM ".MAIN_DB_PREFIX.
"usergroup AS t LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_extrafields AS ef ON (ef.fk_object = t.rowid)";
808 $sql .=
' WHERE t.entity IN ('.getEntity(
'user').
')';
810 $sql .=
" AND t.rowid IN (".$this->db->sanitize($group_ids).
")";
817 throw new RestException(400,
'Error when validating parameter sqlfilters -> '.$errormessage);
821 $sql .= $this->db->order($sortfield, $sortorder);
826 $offset = $limit * $page;
828 $sql .= $this->db->plimit($limit + 1, $offset);
831 $result = $this->db->query($sql);
835 $num = $this->db->num_rows($result);
836 $min = min($num, ($limit <= 0 ? $num : $limit));
838 $obj = $this->db->fetch_object($result);
839 $group_static =
new UserGroup($this->db);
840 if ($group_static->fetch($obj->rowid)) {
846 throw new RestException(503,
'Error when retrieve Group list : '.$this->db->lasterror());
872 throw new RestException(400,
'No usergroup with id=0 can exist');
875 if ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !DolibarrApiAccess::$user->hasRight(
'user',
'user',
'lire') && empty(DolibarrApiAccess::$user->admin)) ||
876 getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !DolibarrApiAccess::$user->hasRight(
'user',
'group_advance',
'read') && empty(DolibarrApiAccess::$user->admin)) {
877 throw new RestException(403,
"You are not allowed to read groups");
880 $group_static =
new UserGroup($this->db);
881 $result = $group_static->fetch($group,
'', (
bool) $load_members);
884 throw new RestException(404,
'Usergroup not found');
887 if ($load_members > 0 && is_array($group_static->members) && count($group_static->members) > 0) {
888 foreach ($group_static->members as &$member) {
909 public function delete(
$id)
911 if (!DolibarrApiAccess::$user->hasRight(
'user',
'user',
'supprimer') && empty(DolibarrApiAccess::$user->admin)) {
912 throw new RestException(403,
'Not allowed');
914 $result = $this->useraccount->fetch(
$id);
916 throw new RestException(404,
'User not found');
920 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
922 $this->useraccount->oldcopy = clone $this->useraccount;
924 if (!$this->useraccount->delete(DolibarrApiAccess::$user)) {
925 throw new RestException(500);
931 'message' =>
'User deleted'
953 if (!DolibarrApiAccess::$user->hasRight(
'user',
'group_advance',
'delete') && empty(DolibarrApiAccess::$user->admin)) {
954 throw new RestException(403,
'Not allowed');
959 $result = $usergroup->fetch($group);
961 throw new RestException(404,
'Usergroup not found');
964 if (!$usergroup->delete(DolibarrApiAccess::$user)) {
965 throw new RestException(500);
971 'message' =>
'Usergroup deleted'
996 throw new RestException(400,
'No user with id=0 can exist');
998 if (!DolibarrApiAccess::$user->hasRight(
'user',
'user',
'lire') && empty(DolibarrApiAccess::$user->admin)) {
999 throw new RestException(403);
1002 throw new RestException(403,
'Access not allowed for login '.DolibarrApiAccess::$user->login);
1009 $sql =
"SELECT rowid as id, fk_action as event, fk_user, type, datec, tms";
1010 $sql .=
" FROM ".MAIN_DB_PREFIX.
"notify_def";
1011 $sql .=
" WHERE fk_user = ".((int)
$id);
1013 $result = $this->db->query($sql);
1014 if ($this->db->num_rows($result) == 0) {
1015 throw new RestException(404,
'Notification not found');
1020 $notifications = array();
1023 $num = $this->db->num_rows($result);
1027 $obj = $this->db->fetch_object($result);
1028 $notifications[] = $obj;
1032 throw new RestException(404,
'No notifications found');
1035 $fields = array(
'id',
'fk_user',
'event',
'datec',
'tms',
'type');
1037 $returnNotifications = array();
1039 foreach ($notifications as $notification) {
1041 foreach ($notification as $key => $value) {
1042 if (in_array($key, $fields)) {
1046 $returnNotifications[] =
$object;
1050 return $returnNotifications;
1071 if (!DolibarrApiAccess::$user->hasRight(
'user',
'user',
'creer')) {
1072 throw new RestException(403,
"User has no right to update users");
1074 if ($this->useraccount->fetch(
$id) <= 0) {
1075 throw new RestException(404,
'Error creating User Notification, User doesn\'t exists');
1077 $notification =
new Notify($this->db);
1079 $notification->fk_user =
$id;
1081 foreach ($request_data as $field => $value) {
1082 $notification->$field = $value;
1085 $event = $notification->event;
1087 throw new RestException(500,
'Error creating User Notification, request_data missing event');
1089 $fk_user = $notification->fk_user;
1091 $exists_sql =
"SELECT rowid, fk_action as event, fk_user, type, datec, tms as datem";
1092 $exists_sql .=
" FROM ".MAIN_DB_PREFIX.
"notify_def";
1093 $exists_sql .=
" WHERE fk_action = '".$this->db->escape((
string) $event).
"'";
1094 $exists_sql .=
" AND fk_user = '".$this->db->escape((
string) $fk_user).
"'";
1096 $exists_result = $this->db->query($exists_sql);
1097 if ($this->db->num_rows($exists_result) > 0) {
1098 throw new RestException(403,
'Notification already exists');
1101 if ($notification->create(DolibarrApiAccess::$user) < 0) {
1102 throw new RestException(500,
'Error creating User Notification');
1105 if ($notification->update(DolibarrApiAccess::$user) < 0) {
1106 throw new RestException(500,
'Error updating values');
1132 if (!DolibarrApiAccess::$user->hasRight(
'user',
'user',
'creer')) {
1133 throw new RestException(403,
"User has no right to update users");
1135 if ($this->useraccount->fetch(
$id) <= 0) {
1136 throw new RestException(404,
'Error creating User Notification, User doesn\'t exists');
1138 $notification =
new Notify($this->db);
1139 $notification->fk_user =
$id;
1141 $sql =
"SELECT t.rowid as id FROM ".MAIN_DB_PREFIX.
"c_action_trigger as t";
1142 $sql .=
" WHERE t.code = '".$this->db->escape($code).
"'";
1144 $result = $this->db->query($sql);
1145 if ($this->db->num_rows($result) == 0) {
1146 throw new RestException(404,
'Action Trigger code not found');
1149 $notification->event = $this->db->fetch_row($result)[0];
1150 foreach ($request_data as $field => $value) {
1151 if ($field ===
'event') {
1152 throw new RestException(500,
'Error creating User Notification, request_data contains event key');
1154 if ($field ===
'fk_action') {
1155 throw new RestException(500,
'Error creating User Notification, request_data contains fk_action key');
1157 $notification->$field = $value;
1160 $event = $notification->event;
1161 $fk_user = $notification->fk_user;
1163 $exists_sql =
"SELECT rowid, fk_action as event, fk_user, type, datec, tms as datem";
1164 $exists_sql .=
" FROM ".MAIN_DB_PREFIX.
"notify_def";
1165 $exists_sql .=
" WHERE fk_action = '".$this->db->escape((
string) $event).
"'";
1166 $exists_sql .=
" AND fk_user = '".$this->db->escape((
string) $fk_user).
"'";
1168 $exists_result = $this->db->query($exists_sql);
1169 if ($this->db->num_rows($exists_result) > 0) {
1170 throw new RestException(403,
'Notification already exists');
1173 if ($notification->create(DolibarrApiAccess::$user) < 0) {
1174 throw new RestException(500,
'Error creating User Notification, are request_data well formed?');
1177 if ($notification->update(DolibarrApiAccess::$user) < 0) {
1178 throw new RestException(500,
'Error updating values');
1200 if (!DolibarrApiAccess::$user->hasRight(
'user',
'user',
'creer')) {
1201 throw new RestException(403,
"User has no right to update users");
1204 $notification =
new Notify($this->db);
1206 $notification->fetch($notification_id);
1208 $fk_user = (int) $notification->fk_user;
1210 if ($fk_user ==
$id) {
1211 return $notification->delete(DolibarrApiAccess::$user);
1213 throw new RestException(403,
"Not allowed due to bad consistency of input data");
1236 if (!DolibarrApiAccess::$user->hasRight(
'user',
'user',
'creer')) {
1237 throw new RestException(403,
"User has no right to update users");
1239 if ($this->useraccount->fetch(
$id) <= 0) {
1240 throw new RestException(404,
'Error creating Notification, User doesn\'t exists');
1242 $notification =
new Notify($this->db);
1245 $notification->fetch($notification_id,
$id);
1247 if ($notification->fk_user !=
$id) {
1248 throw new RestException(403,
"Not allowed due to bad consistency of input data");
1251 foreach ($request_data as $field => $value) {
1252 $notification->$field = $value;
1255 if ($notification->update(DolibarrApiAccess::$user) < 0) {
1256 throw new RestException(500,
'Error updating values');
1277 unset(
$object->default_values);
1278 unset(
$object->lastsearch_values);
1279 unset(
$object->lastsearch_values_tmp);
1283 unset(
$object->total_localtax1);
1284 unset(
$object->total_localtax2);
1287 unset(
$object->label_incoterms);
1288 unset(
$object->location_incoterms);
1290 unset(
$object->fk_delivery_address);
1292 unset(
$object->all_permissions_are_loaded);
1293 unset(
$object->shipping_method_id);
1297 unset(
$object->clicktodial_loaded);
1301 unset(
$object->pass_indatabase);
1302 unset(
$object->pass_indatabase_crypted);
1305 unset(
$object->clicktodial_password);
1311 $canreadsalary = ((
isModEnabled(
'salaries') && DolibarrApiAccess::$user->hasRight(
'salaries',
'read')) || !
isModEnabled(
'salaries'));
1313 if (!$canreadsalary) {
1335 unset(
$object->actiontypecode);
1336 unset(
$object->all_permissions_are_loaded);
1337 unset(
$object->barcode_type_coder);
1340 unset(
$object->civility_code);
1342 unset(
$object->clicktodial_loaded);
1343 unset(
$object->cond_reglement_id);
1344 unset(
$object->cond_reglement_supplier_id);
1346 unset(
$object->contacts_ids_internal);
1351 unset(
$object->date_creation);
1352 unset(
$object->date_modification);
1353 unset(
$object->date_validation);
1354 unset(
$object->default_values);
1355 unset(
$object->demand_reason_id);
1356 unset(
$object->deposit_percent);
1360 unset(
$object->fk_delivery_address);
1362 unset(
$object->fk_multicurrency);
1364 unset(
$object->fk_user_creat);
1365 unset(
$object->fk_user_modif);
1368 unset(
$object->last_main_doc);
1370 unset(
$object->lastsearch_values_tmp);
1371 unset(
$object->lastsearch_values);
1373 unset(
$object->libelle_incoterms);
1375 unset(
$object->linkedObjectsIds);
1376 unset(
$object->location_incoterms);
1378 unset(
$object->mode_reglement_id);
1380 unset(
$object->multicurrency_code);
1381 unset(
$object->multicurrency_total_ht);
1382 unset(
$object->multicurrency_total_localtax1);
1383 unset(
$object->multicurrency_total_localtax2);
1384 unset(
$object->multicurrency_total_ttc);
1385 unset(
$object->multicurrency_total_tva);
1386 unset(
$object->multicurrency_tx);
1396 unset(
$object->retained_warranty_fk_cond_reglement);
1399 unset(
$object->shipping_method_id);
1400 unset(
$object->shipping_method);
1406 unset(
$object->total_localtax1);
1407 unset(
$object->total_localtax2);
1410 unset(
$object->totalpaid_multicurrency);
1412 unset(
$object->transport_mode_id);
1413 unset(
$object->TRIGGER_PREFIX);
1414 unset(
$object->user_closing_id);
1415 unset(
$object->user_creation_id);
1416 unset(
$object->user_modification_id);
1417 unset(
$object->user_validation_id);
1419 unset(
$object->usergroup_entity);
1433 $cleanObjectList = array();
1435 foreach ($objectList as
$object) {
1436 $cleanObject = parent::_cleanObjectDatas(
$object);
1438 unset($cleanObject->default_values);
1439 unset($cleanObject->lastsearch_values);
1440 unset($cleanObject->lastsearch_values_tmp);
1442 unset($cleanObject->total_ht);
1443 unset($cleanObject->total_tva);
1444 unset($cleanObject->total_localtax1);
1445 unset($cleanObject->total_localtax2);
1446 unset($cleanObject->total_ttc);
1448 unset($cleanObject->libelle_incoterms);
1449 unset($cleanObject->location_incoterms);
1451 unset($cleanObject->fk_delivery_address);
1452 unset($cleanObject->fk_incoterms);
1453 unset($cleanObject->all_permissions_are_loaded);
1454 unset($cleanObject->shipping_method_id);
1455 unset($cleanObject->nb_rights);
1456 unset($cleanObject->search_sid);
1457 unset($cleanObject->ldap_sid);
1458 unset($cleanObject->clicktodial_loaded);
1460 unset($cleanObject->datec);
1461 unset($cleanObject->tms);
1462 unset($cleanObject->members);
1463 unset($cleanObject->note);
1464 unset($cleanObject->note_private);
1466 $cleanObjectList[] = $cleanObject;
1469 return $cleanObjectList;
1482 foreach (Users::$FIELDS as $field) {
1483 if (!isset($data[$field])) {
1484 throw new RestException(400,
"$field field missing");
1486 $account[$field] = $data[$field];
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
_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.
Class to manage the table of subscription to notifications.
Class to manage user groups.
Class to manage Dolibarr users.
put($id, $request_data=null)
Update a user.
listGroups($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $group_ids='0', $sqlfilters='', $properties='')
List groups of the current user (so user of API token)
index($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $user_ids='0', $category=0, $sqlfilters='', $properties='')
List users.
deleteGroups($group)
Delete a usergroup.
_cleanObjectDatas($object)
Clean sensible object datas @phpstan-template T.
getInfo($includepermissions=0)
Get more properties of the current user (so user of API token).
_cleanUserGroupListDatas($objectList)
Clean sensible user group list datas.
updateUserNotification($id, $notification_id, $request_data=null)
Update a notification for a user.
setGroup($id, $group, $entity=1)
Add a user to a group.
setPassword($id, $send_password=false)
Update a user password.
postGroups($request_data=null)
Create user group.
deleteUserNotification($id, $notification_id)
Delete a notification attached to a user.
infoGroups($group, $load_members=0)
Get properties of a user group.
_validate($data)
Validate fields before create or update object.
getByEmail($email, $includepermissions=0)
Get a user by email.
getGroups($id)
List the groups of a user.
putGroups($group, $request_data=null)
Update user group.
createUserNotificationByCode($id, $code, $request_data=null)
Create a notification for a user using action trigger code.
post($request_data=null)
Create a user.
createUserNotification($id, $request_data=null)
Create a notification for a user.
getByLogin($login, $includepermissions=0)
Get a user by login.
removeUserFromGroup($id, $group)
Remove user from group (only admin)
getUserNotification($id)
Get notifications for a user.
__construct()
Constructor.
_cleanUserGroup($object)
Clean sensible usergroup object datas.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
sanitizeVal($out='', $check='alphanohtml', $filter=null, $options=null)
Return a sanitized or empty value after checking value against a rule.
isModEnabled($module)
Is Dolibarr module enabled.