public function addRoleToUser($user, $role)
	{
		if (is_string($user)) {
			$user = $this->getUser($user);
		} elseif (!property_exists($user, "_id") || !property_exists($user, "roles")) {
			throw new InvalidArgumentException("user parameter should be the login or a user document");
		}
		if (!in_array($role, $user->roles)) {
			$user->roles[] = $role;
			$client = clone($this->client);
			$client->useDatabase($this->usersdb);
			$client->storeDoc($user);
		}
		return true;
	}
public function addRoleToUser($user, $role)
	{
		if (is_string($user)) {
			$user = $this->getUser($user);
		} elseif (!property_exists($user, "_id") || !property_exists($user, "roles")) {
			throw new InvalidArgumentException("user parameter should be the login or a user document");
		}
		if (!in_array($role, $user->roles)) {
			$user->roles[] = $role;
			$client = clone($this->client);
			$client->useDatabase($this->usersdb);
			$client->storeDoc($user);
		}
		return true;
	}
public function addRoleToUser ( $ user , $ role ) { if ( is_string ( $ user ) ) { $ user = $ this -> getUser ( $ user ) ; } elseif ( ! property_exists ( $ user , "_id" ) || ! property_exists ( $ user , "roles" ) ) { throw new InvalidArgumentException ( "user parameter should be the login or a user document" ) ; } if ( ! in_array ( $ role , $ user -> roles ) ) { $ user -> roles [ ] = $ role ; $ client = clone ( $ this -> client ) ; $ client -> useDatabase ( $ this -> usersdb ) ; $ client -> storeDoc ( $ user ) ; } return true ; }
Add a role to a user document

@param string|stdClass $user the user login (as a string) or the user document ( fetched by getUser() method )
@param string $role the role to add in the list of roles the user belongs to
@return boolean true if the user $user now belongs to the role $role
@throws InvalidArgumentException
Add a role to a user document