Skip to content
Permalink
Browse files

FIX 'statut' is ignored when updating a user with the REST API.

  • Loading branch information...
Xebax committed Jan 27, 2019
1 parent b868397 commit 94d3f038eb6dbe5794d56a904cf85c8794f6ee79
Showing with 14 additions and 3 deletions.
  1. +14 −3 htdocs/user/class/api_users.class.php
@@ -212,11 +212,22 @@ function put($id, $request_data = NULL) {
foreach ($request_data as $field => $value)
{
if ($field == 'id') continue;
$this->useraccount->$field = $value;
if ($field == 'id') continue;
// The status must be updated using setstatus() because it
// is not handled by the update() method.
if ($field == 'statut') {
$result = $this->useraccount->setstatus($value);
if ($result < 0) {
throw new RestException(500, 'Error when updating status of user: '.$this->useraccount->error);
}
} else {
$this->useraccount->$field = $value;
}
}
if ($this->useraccount->update(DolibarrApiAccess::$user) > 0)
// If there is no error, update() returns the number of affected
// rows so if the update is a no op, the return value is zezo.
if ($this->useraccount->update(DolibarrApiAccess::$user) >= 0)
{
return $this->get($id);
}

0 comments on commit 94d3f03

Please sign in to comment.
You can’t perform that action at this time.