mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-28 04:27:32 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
faaf6d2fbb
|
@ -169,6 +169,7 @@ class RestapiController { /* {{{ */
|
|||
'login'=>$u->getLogin(),
|
||||
'email'=>$u->getEmail(),
|
||||
'language' => $u->getLanguage(),
|
||||
'quota' => $u->getQuota(),
|
||||
'theme' => $u->getTheme(),
|
||||
'role' => $this->__getRoleData($u->getRole()), //array('id'=>(int)$u->getRole()->getId(), 'name'=>$u->getRole()->getName()),
|
||||
'hidden'=>$u->isHidden() ? true : false,
|
||||
|
@ -2208,6 +2209,92 @@ class RestapiController { /* {{{ */
|
|||
return $response->withJson(array('success'=>true, 'message'=>'', 'data'=>''), 200);
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Updates the quota of an existing account
|
||||
*
|
||||
* @param <type> $id The user name or numerical identifier
|
||||
*/
|
||||
function changeUserQuota($request, $response, $args) { /* {{{ */
|
||||
$dms = $this->container->dms;
|
||||
$userobj = $this->container->userobj;
|
||||
|
||||
$check = $this->checkIfAdmin($request, $response);
|
||||
if($check !== true)
|
||||
return $check;
|
||||
|
||||
$params = $request->getParsedBody();
|
||||
if ($params['quota'] == null) {
|
||||
return $response->withJson(array('success'=>false, 'message'=>'You must supply a new quota', 'data'=>''), 400);
|
||||
}
|
||||
|
||||
$newQuota = $params['quota'];
|
||||
|
||||
if(ctype_digit($args['id']))
|
||||
$account = $dms->getUser($args['id']);
|
||||
else {
|
||||
$account = $dms->getUserByLogin($args['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* User not found
|
||||
*/
|
||||
if (!$account) {
|
||||
return $response->withJson(array('success'=>false, 'message'=>'', 'data'=>'User not found.'), 404);
|
||||
return;
|
||||
}
|
||||
|
||||
$operation = $account->setQuota($newQuota);
|
||||
|
||||
if (!$operation){
|
||||
return $response->withJson(array('success'=>false, 'message'=>'', 'data'=>'Could not change quota.'), 404);
|
||||
}
|
||||
|
||||
return $response->withJson(array('success'=>true, 'message'=>'', 'data'=>''), 200);
|
||||
} /* }}} */
|
||||
|
||||
function changeUserHomefolder($request, $response, $args) { /* {{{ */
|
||||
$dms = $this->container->dms;
|
||||
$userobj = $this->container->userobj;
|
||||
|
||||
$check = $this->checkIfAdmin($request, $response);
|
||||
if($check !== true)
|
||||
return $check;
|
||||
|
||||
$params = $request->getParsedBody();
|
||||
if ($params['homefolder'] == null) {
|
||||
return $response->withJson(array('success'=>false, 'message'=>'You must supply a new home folder', 'data'=>''), 400);
|
||||
}
|
||||
|
||||
$newHomefolderId = (int) $params['homefolder'];
|
||||
$newHomefolder = $dms->getFolder($newHomefolderId);
|
||||
if (!$newHomefolder) {
|
||||
return $response->withJson(array('success'=>false, 'message'=>'', 'data'=>'Folder not found.'), 404);
|
||||
return;
|
||||
}
|
||||
|
||||
if(ctype_digit($args['id']))
|
||||
$account = $dms->getUser($args['id']);
|
||||
else {
|
||||
$account = $dms->getUserByLogin($args['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* User not found
|
||||
*/
|
||||
if (!$account) {
|
||||
return $response->withJson(array('success'=>false, 'message'=>'', 'data'=>'User not found.'), 404);
|
||||
return;
|
||||
}
|
||||
|
||||
$operation = $account->setHomeFolder($newHomefolder->getId());
|
||||
|
||||
if (!$operation){
|
||||
return $response->withJson(array('success'=>false, 'message'=>'', 'data'=>'Could not change homefolder.'), 404);
|
||||
}
|
||||
|
||||
return $response->withJson(array('success'=>true, 'message'=>'', 'data'=>''), 200);
|
||||
} /* }}} */
|
||||
|
||||
function getUserById($request, $response, $args) { /* {{{ */
|
||||
$dms = $this->container->dms;
|
||||
$userobj = $this->container->userobj;
|
||||
|
@ -2531,6 +2618,46 @@ class RestapiController { /* {{{ */
|
|||
}
|
||||
} /* }}} */
|
||||
|
||||
function setFolderOwner($request, $response, $args) { /* {{{ */
|
||||
$dms = $this->container->dms;
|
||||
$userobj = $this->container->userobj;
|
||||
|
||||
if(!$userobj) {
|
||||
return $response->withJson(array('success'=>false, 'message'=>'Not logged in', 'data'=>''), 403);
|
||||
}
|
||||
if(!$userobj->isAdmin()) {
|
||||
return $response->withJson(array('success'=>false, 'message'=>'No access on folder', 'data'=>''), 403);
|
||||
}
|
||||
|
||||
if(!ctype_digit($args['id']) || $args['id'] == 0) {
|
||||
return $response->withJson(array('success'=>false, 'message'=>'No folder given', 'data'=>''), 400);
|
||||
return;
|
||||
}
|
||||
if(!ctype_digit($args['userid']) || $args['userid'] == 0) {
|
||||
return $response->withJson(array('success'=>false, 'message'=>'No user given', 'data'=>''), 400);
|
||||
return;
|
||||
}
|
||||
$owner = $dms->getUser($args['userid']);
|
||||
$folder = $dms->getFolder($args['id']);
|
||||
if($folder && $owner) {
|
||||
if($folder->getAccessMode($userobj, 'setDocumentOwner') > M_READ) {
|
||||
if ($folder->setOwner($owner)){
|
||||
return $response->withJson(array('success'=>true, 'message'=>'', 'data'=>''), 201);
|
||||
} else {
|
||||
return $response->withJson(array('success'=>false, 'message'=>'Could not set owner of folder', 'data'=>''), 500);
|
||||
}
|
||||
} else {
|
||||
return $response->withJson(array('success'=>false, 'message'=>'No access on folder', 'data'=>''), 403);
|
||||
}
|
||||
} else {
|
||||
if(!$doc)
|
||||
return $response->withJson(array('success'=>false, 'message'=>'No such folder', 'data'=>''), 404);
|
||||
if(!$owner)
|
||||
return $response->withJson(array('success'=>false, 'message'=>'No such user', 'data'=>''), 404);
|
||||
return $response->withJson(array('success'=>false, 'message'=>'Could not find user or folder', 'data'=>''), 500);
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
function addUserAccessToFolder($request, $response, $args) { /* {{{ */
|
||||
return $this->changeFolderAccess($request, $response, $args, 'add', 'user');
|
||||
} /* }}} */
|
||||
|
@ -3072,6 +3199,8 @@ $app->get('/roles', \RestapiController::class.':getRoles');
|
|||
$app->post('/roles', \RestapiController::class.':createRole');
|
||||
$app->get('/roles/{id}', \RestapiController::class.':getRole');
|
||||
$app->delete('/roles/{id}', \RestapiController::class.':deleteRole');
|
||||
$app->put('/users/{id}/quota', \RestapiController::class.':changeUserQuota');
|
||||
$app->put('/users/{id}/homefolder', \RestapiController::class.':changeUserHomefolder');
|
||||
$app->post('/groups', \RestapiController::class.':createGroup');
|
||||
$app->get('/groups', \RestapiController::class.':getGroups');
|
||||
$app->delete('/groups/{id}', \RestapiController::class.':deleteGroup');
|
||||
|
@ -3079,6 +3208,7 @@ $app->get('/groups/{id}', \RestapiController::class.':getGroup');
|
|||
$app->put('/groups/{id}/addUser', \RestapiController::class.':addUserToGroup');
|
||||
$app->put('/groups/{id}/removeUser', \RestapiController::class.':removeUserFromGroup');
|
||||
$app->put('/folder/{id}/setInherit', \RestapiController::class.':setFolderInheritsAccess');
|
||||
$app->put('/folder/{id}/owner/{userid}', \RestapiController::class.':setFolderOwner');
|
||||
$app->put('/folder/{id}/access/group/add', \RestapiController::class.':addGroupAccessToFolder'); //
|
||||
$app->put('/folder/{id}/access/user/add', \RestapiController::class.':addUserAccessToFolder'); //
|
||||
$app->put('/folder/{id}/access/group/remove', \RestapiController::class.':removeGroupAccessFromFolder');
|
||||
|
|
Loading…
Reference in New Issue
Block a user