diff --git a/restapi/index.php b/restapi/index.php index 178bcfa2d..75f027863 100644 --- a/restapi/index.php +++ b/restapi/index.php @@ -2264,7 +2264,8 @@ final class SeedDMS_RestapiController { /* {{{ */ return $this->renderer->json($response, array('success'=>false, 'message'=>'', 'data'=>'Could not change quota.'))->withStatus(404); } - return $this->renderer->json($response, array('success'=>true, 'message'=>'', 'data'=>''))->withStatus(200); + $data = $this->__getUserData($account); + return $this->renderer->json($response, array('success'=>true, 'message'=>'', 'data'=>$data))->withStatus(200); } /* }}} */ function changeUserHomefolder($request, $response, $args) { /* {{{ */ @@ -2289,23 +2290,28 @@ final class SeedDMS_RestapiController { /* {{{ */ return; } - if(!ctype_digit($args['folderid']) || $args['folderid'] == 0) { + if(!ctype_digit($args['folderid'])) { return $this->renderer->json($response, array('success'=>false, 'message'=>'No homefolder given', 'data'=>''))->withStatus(400); return; } - $newHomefolder = $dms->getFolder($args['folderid']); - if (!$newHomefolder) { - return $this->renderer->json($response, array('success'=>false, 'message'=>'', 'data'=>'Folder not found.'))->withStatus(404); - return; - } + if($args['folderid'] == 0) { + $operation = $account->setHomeFolder(0); + } else { + $newHomefolder = $dms->getFolder($args['folderid']); + if (!$newHomefolder) { + return $this->renderer->json($response, array('success'=>false, 'message'=>'', 'data'=>'Folder not found.'))->withStatus(404); + return; + } - $operation = $account->setHomeFolder($newHomefolder->getId()); + $operation = $account->setHomeFolder($newHomefolder->getId()); + } if (!$operation){ return $this->renderer->json($response, array('success'=>false, 'message'=>'', 'data'=>'Could not change homefolder.'))->withStatus(404); } - return $this->renderer->json($response, array('success'=>true, 'message'=>'', 'data'=>''))->withStatus(200); + $data = $this->__getUserData($account); + return $this->renderer->json($response, array('success'=>true, 'message'=>'', 'data'=>$data))->withStatus(200); } /* }}} */ function getUserById($request, $response, $args) { /* {{{ */