mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 07:04:57 +00:00
simplified removeDocumentCategory
This commit is contained in:
parent
cab5f5bb2e
commit
1ac232476a
|
@ -1562,24 +1562,20 @@ class RestapiController { /* {{{ */
|
|||
}
|
||||
|
||||
$document = $dms->getDocument($args['id']);
|
||||
if(!$document)
|
||||
return $response->withJson(array('success'=>false, 'message'=>'No such document', 'data'=>''), 404);
|
||||
$category = $dms->getDocumentCategory($args['catid']);
|
||||
if(!$category)
|
||||
return $response->withJson(array('success'=>false, 'message'=>'No such category', 'data'=>''), 404);
|
||||
|
||||
if($document && $category) {
|
||||
if ($document->getAccessMode($userobj, 'removeDocumentCategory') >= M_READWRITE) {
|
||||
$ret = $document->removeCategories(array($category));
|
||||
if ($ret)
|
||||
return $response->withJson(array('success'=>true, 'message'=>'Deleted category successfully.', 'data'=>''), 200);
|
||||
else
|
||||
return $response->withJson(array('success'=>true, 'message'=>'', 'data'=>''), 200);
|
||||
} else {
|
||||
return $response->withJson(array('success'=>false, 'message'=>'No access', 'data'=>''), 403);
|
||||
}
|
||||
if ($document->getAccessMode($userobj, 'removeDocumentCategory') >= M_READWRITE) {
|
||||
$ret = $document->removeCategories(array($category));
|
||||
if ($ret)
|
||||
return $response->withJson(array('success'=>true, 'message'=>'Deleted category successfully.', 'data'=>''), 200);
|
||||
else
|
||||
return $response->withJson(array('success'=>true, 'message'=>'', 'data'=>''), 200);
|
||||
} else {
|
||||
if(!$document)
|
||||
return $response->withJson(array('success'=>false, 'message'=>'No such document', 'data'=>''), 404);
|
||||
if(!$category)
|
||||
return $response->withJson(array('success'=>false, 'message'=>'No such category', 'data'=>''), 404);
|
||||
return $response->withJson(array('success'=>false, 'message'=>'', 'data'=>''), 500);
|
||||
return $response->withJson(array('success'=>false, 'message'=>'No access', 'data'=>''), 403);
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user