mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 15:14:58 +00:00
add new method addDocumentCategory
This commit is contained in:
parent
d867e5d0b8
commit
fd9bc77fef
|
@ -1322,6 +1322,39 @@ class RestapiController { /* {{{ */
|
|||
}
|
||||
} /* }}} */
|
||||
|
||||
function addDocumentCategory($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(!ctype_digit($args['id']) || $args['id'] == 0) {
|
||||
return $response->withJson(array('success'=>false, 'message'=>'No document given', 'data'=>''), 400);
|
||||
return;
|
||||
}
|
||||
if(!ctype_digit($args['catid']) || $args['catid'] == 0) {
|
||||
return $response->withJson(array('success'=>false, 'message'=>'No category given', 'data'=>''), 400);
|
||||
return;
|
||||
}
|
||||
$cat = $dms->getDocumentCategory($args['catid']);
|
||||
$doc = $dms->getDocument($args['id']);
|
||||
if($doc && $cat) {
|
||||
if($doc->getAccessMode($userobj, 'addDocumentCategory') >= M_READ) {
|
||||
if ($doc->addCategories([$cat])){
|
||||
return $response->withJson(array('success'=>true, 'message'=>'', 'data'=>''), 201);
|
||||
} else {
|
||||
return $response->withJson(array('success'=>false, 'message'=>'Could not add document category', 'data'=>''), 500);
|
||||
}
|
||||
} else {
|
||||
return $response->withJson(array('success'=>false, 'message'=>'No access on document', 'data'=>''), 403);
|
||||
}
|
||||
} else {
|
||||
return $response->withJson(array('success'=>false, 'message'=>'Could not find category or document', 'data'=>''), 500);
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
function removeDocumentCategory($request, $response, $args) { /* {{{ */
|
||||
$dms = $this->container->dms;
|
||||
$userobj = $this->container->userobj;
|
||||
|
@ -2355,6 +2388,7 @@ $app->get('/document/{id}/attributes', \RestapiController::class.':getDocumentAt
|
|||
$app->get('/document/{id}/preview/{version}/{width}', \RestapiController::class.':getDocumentPreview');
|
||||
$app->delete('/document/{id}/categories', \RestapiController::class.':removeDocumentCategories');
|
||||
$app->delete('/document/{id}/category/{catid}', \RestapiController::class.':removeDocumentCategory');
|
||||
$app->post('/document/{id}/category/{catid}', \RestapiController::class.':addDocumentCategory');
|
||||
$app->put('/account/fullname', \RestapiController::class.':setFullName');
|
||||
$app->put('/account/email', \RestapiController::class.':setEmail');
|
||||
$app->get('/account/documents/locked', \RestapiController::class.':getLockedDocuments');
|
||||
|
|
Loading…
Reference in New Issue
Block a user