public function updateUser($id, $input)
{
$validator = $this->Validator->make($input, $this->updateRules($id, $input), $this->messages);
if ($validator->passes()) {
$user = $this->DvsUser->findOrFail($id);
$user->activated = array_get($input, 'activated', false);
$user->name = array_get($input, 'name', null);
$user->email = array_get($input, 'email');
$user->username = array_get($input, 'username', null);
if (array_get($input, 'password', null)) {
$user->password = $this->Hash->make(array_get($input, 'password'));
}
$user->save();
$user->groups()->sync(array_get($input, 'group_id', []));
return $user;
}
$this->errors = $validator->errors()->all();
$this->message = "There were validation errors.";
return false;
}