mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-14 13:42:04 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
895dbf1b29
|
@ -18,6 +18,14 @@ Please note, that when ever a command outputs anything to stderr,
|
||||||
this will considered as a failure of the command. Most command line
|
this will considered as a failure of the command. Most command line
|
||||||
programs have a parameter (.e.g. `-q`) to suppress such an output.
|
programs have a parameter (.e.g. `-q`) to suppress such an output.
|
||||||
|
|
||||||
|
If you run php-fpm you may encounter problems with charsets based on
|
||||||
|
UTF-8. Programms like `catdoc` read LANG from the environment to
|
||||||
|
set the correct encoding of the output. php-fpm often clears the
|
||||||
|
environment and programms like `catdoc` will not longer output any
|
||||||
|
UTF-8 chars. In such a case you may want to set `clear_env=no` in
|
||||||
|
php-fpm's configuration. On Debian this is done in the file
|
||||||
|
`/etc/php/<php version>/fpm/pool.d/www.conf`. Search for `clear_env`.
|
||||||
|
|
||||||
Conversion to text for fulltext search
|
Conversion to text for fulltext search
|
||||||
=======================================
|
=======================================
|
||||||
|
|
||||||
|
|
|
@ -25,24 +25,21 @@ use Psr\Http\Server\MiddlewareInterface;
|
||||||
use DI\ContainerBuilder;
|
use DI\ContainerBuilder;
|
||||||
use Slim\Factory\AppFactory;
|
use Slim\Factory\AppFactory;
|
||||||
|
|
||||||
final class JsonRenderer
|
final class JsonRenderer { /* {{{ */
|
||||||
{
|
|
||||||
public function json(
|
public function json(
|
||||||
ResponseInterface $response,
|
ResponseInterface $response,
|
||||||
array $data = null
|
array $data = null
|
||||||
): ResponseInterface {
|
): ResponseInterface {
|
||||||
$response = $response->withHeader('Content-Type', 'application/json');
|
$response = $response->withHeader('Content-Type', 'application/json');
|
||||||
|
$response->getBody()->write(
|
||||||
$response->getBody()->write(
|
(string)json_encode(
|
||||||
(string)json_encode(
|
$data,
|
||||||
$data,
|
JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR
|
||||||
JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR
|
)
|
||||||
)
|
);
|
||||||
);
|
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
}
|
} /* }}} */
|
||||||
|
|
||||||
final class SeedDMS_RestapiController { /* {{{ */
|
final class SeedDMS_RestapiController { /* {{{ */
|
||||||
protected $container;
|
protected $container;
|
||||||
|
@ -1740,12 +1737,9 @@ final class SeedDMS_RestapiController { /* {{{ */
|
||||||
$dms = $this->container->get('dms');
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->get('userobj');
|
$userobj = $this->container->get('userobj');
|
||||||
|
|
||||||
if(!$userobj) {
|
$check = $this->checkIfAdmin($request, $response);
|
||||||
return $this->renderer->json($response, array('success'=>false, 'message'=>'Not logged in', 'data'=>''))->withStatus(403);
|
if ($check !== true)
|
||||||
}
|
return $check;
|
||||||
if(!$userobj->isAdmin()) {
|
|
||||||
return $this->renderer->json($response, array('success'=>false, 'message'=>'No access on document', 'data'=>''))->withStatus(403);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!ctype_digit($args['id']) || $args['id'] == 0) {
|
if(!ctype_digit($args['id']) || $args['id'] == 0) {
|
||||||
return $this->renderer->json($response, array('success'=>false, 'message'=>'No document given', 'data'=>''))->withStatus(400);
|
return $this->renderer->json($response, array('success'=>false, 'message'=>'No document given', 'data'=>''))->withStatus(400);
|
||||||
|
@ -2116,8 +2110,8 @@ final class SeedDMS_RestapiController { /* {{{ */
|
||||||
|
|
||||||
function checkIfAdmin($request, $response) { /* {{{ */
|
function checkIfAdmin($request, $response) { /* {{{ */
|
||||||
$dms = $this->container->get('dms');
|
$dms = $this->container->get('dms');
|
||||||
if(!$this->container->has('userobj'))
|
// if(!$this->container->has('userobj'))
|
||||||
echo "no user object";
|
// echo "no user object";
|
||||||
|
|
||||||
if(!$this->container->has('userobj') || !($userobj = $this->container->get('userobj'))) {
|
if(!$this->container->has('userobj') || !($userobj = $this->container->get('userobj'))) {
|
||||||
return $this->renderer->json($response, ['success'=>false, 'message'=>'Not logged in', 'data'=>''])->withStatus(403);
|
return $this->renderer->json($response, ['success'=>false, 'message'=>'Not logged in', 'data'=>''])->withStatus(403);
|
||||||
|
@ -2259,7 +2253,7 @@ final class SeedDMS_RestapiController { /* {{{ */
|
||||||
return $check;
|
return $check;
|
||||||
|
|
||||||
$params = $request->getParsedBody();
|
$params = $request->getParsedBody();
|
||||||
if ($params['quota'] == null) {
|
if ($params['quota'] == null || !ctype_digit($params['quota'])) {
|
||||||
return $this->renderer->json($response, array('success'=>false, 'message'=>'You must supply a new quota', 'data'=>''))->withStatus(400);
|
return $this->renderer->json($response, array('success'=>false, 'message'=>'You must supply a new quota', 'data'=>''))->withStatus(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2530,6 +2524,7 @@ final class SeedDMS_RestapiController { /* {{{ */
|
||||||
$check = $this->checkIfAdmin($request, $response);
|
$check = $this->checkIfAdmin($request, $response);
|
||||||
if($check !== true)
|
if($check !== true)
|
||||||
return $check;
|
return $check;
|
||||||
|
|
||||||
if(ctype_digit($args['id']))
|
if(ctype_digit($args['id']))
|
||||||
$group = $dms->getGroup($args['id']);
|
$group = $dms->getGroup($args['id']);
|
||||||
else {
|
else {
|
||||||
|
@ -2552,21 +2547,21 @@ final class SeedDMS_RestapiController { /* {{{ */
|
||||||
$userobj = $this->container->get('userobj');
|
$userobj = $this->container->get('userobj');
|
||||||
|
|
||||||
$check = $this->checkIfAdmin($request, $response);
|
$check = $this->checkIfAdmin($request, $response);
|
||||||
if($check !== true)
|
if ($check !== true)
|
||||||
return $check;
|
return $check;
|
||||||
|
|
||||||
if(ctype_digit($args['id']))
|
if (ctype_digit($args['id']))
|
||||||
$group = $dms->getGroup($args['id']);
|
$group = $dms->getGroup($args['id']);
|
||||||
else {
|
else {
|
||||||
$group = $dms->getGroupByName($args['id']);
|
$group = $dms->getGroupByName($args['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$params = $request->getParsedBody();
|
$params = $request->getParsedBody();
|
||||||
if (empty($params['userid'])) {
|
if (empty($params['userid'])) {
|
||||||
return $this->renderer->json($response, array('success'=>false, 'message'=>'Missing userid', 'data'=>''))->withStatus(400);
|
return $this->renderer->json($response, array('success'=>false, 'message'=>'Missing userid', 'data'=>''))->withStatus(400);
|
||||||
}
|
}
|
||||||
$userId = $params['userid'];
|
$userId = $params['userid'];
|
||||||
if(ctype_digit($userId))
|
if (ctype_digit($userId))
|
||||||
$user = $dms->getUser($userId);
|
$user = $dms->getUser($userId);
|
||||||
else {
|
else {
|
||||||
$user = $dms->getUserByLogin($userId);
|
$user = $dms->getUserByLogin($userId);
|
||||||
|
@ -2578,20 +2573,16 @@ final class SeedDMS_RestapiController { /* {{{ */
|
||||||
|
|
||||||
$operationResult = false;
|
$operationResult = false;
|
||||||
|
|
||||||
if ($operationType == 'add')
|
if ($operationType == 'add') {
|
||||||
{
|
|
||||||
$operationResult = $group->addUser($user);
|
$operationResult = $group->addUser($user);
|
||||||
}
|
}
|
||||||
if ($operationType == 'remove')
|
if ($operationType == 'remove') {
|
||||||
{
|
|
||||||
$operationResult = $group->removeUser($user);
|
$operationResult = $group->removeUser($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($operationResult === false)
|
if ($operationResult === false) {
|
||||||
{
|
|
||||||
$message = 'Could not add user to the group.';
|
$message = 'Could not add user to the group.';
|
||||||
if ($operationType == 'remove')
|
if ($operationType == 'remove') {
|
||||||
{
|
|
||||||
$message = 'Could not remove user from group.';
|
$message = 'Could not remove user from group.';
|
||||||
}
|
}
|
||||||
return $this->renderer->json($response, array('success'=>false, 'message'=>'Something went wrong. ' . $message, 'data'=>''))->withStatus(500);
|
return $this->renderer->json($response, array('success'=>false, 'message'=>'Something went wrong. ' . $message, 'data'=>''))->withStatus(500);
|
||||||
|
@ -2618,8 +2609,9 @@ final class SeedDMS_RestapiController { /* {{{ */
|
||||||
$userobj = $this->container->get('userobj');
|
$userobj = $this->container->get('userobj');
|
||||||
|
|
||||||
$check = $this->checkIfAdmin($request, $response);
|
$check = $this->checkIfAdmin($request, $response);
|
||||||
if($check !== true)
|
if ($check !== true)
|
||||||
return $check;
|
return $check;
|
||||||
|
|
||||||
$params = $request->getParsedBody();
|
$params = $request->getParsedBody();
|
||||||
if (!isset($params['enable']))
|
if (!isset($params['enable']))
|
||||||
{
|
{
|
||||||
|
@ -2656,12 +2648,9 @@ final class SeedDMS_RestapiController { /* {{{ */
|
||||||
$dms = $this->container->get('dms');
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->get('userobj');
|
$userobj = $this->container->get('userobj');
|
||||||
|
|
||||||
if(!$userobj) {
|
$check = $this->checkIfAdmin($request, $response);
|
||||||
return $this->renderer->json($response, array('success'=>false, 'message'=>'Not logged in', 'data'=>''))->withStatus(403);
|
if ($check !== true)
|
||||||
}
|
return $check;
|
||||||
if(!$userobj->isAdmin()) {
|
|
||||||
return $this->renderer->json($response, array('success'=>false, 'message'=>'No access on folder', 'data'=>''))->withStatus(403);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!ctype_digit($args['id']) || $args['id'] == 0) {
|
if(!ctype_digit($args['id']) || $args['id'] == 0) {
|
||||||
return $this->renderer->json($response, array('success'=>false, 'message'=>'No folder given', 'data'=>''))->withStatus(400);
|
return $this->renderer->json($response, array('success'=>false, 'message'=>'No folder given', 'data'=>''))->withStatus(400);
|
||||||
|
@ -2727,51 +2716,40 @@ final class SeedDMS_RestapiController { /* {{{ */
|
||||||
|
|
||||||
$params = $request->getParsedBody();
|
$params = $request->getParsedBody();
|
||||||
$userOrGroupIdInput = $params['id'];
|
$userOrGroupIdInput = $params['id'];
|
||||||
if ($operationType == 'add')
|
if ($operationType == 'add') {
|
||||||
{
|
if ($params['id'] == null) {
|
||||||
if ($params['id'] == null)
|
|
||||||
{
|
|
||||||
return $this->renderer->json($response, array('success'=>false, 'message'=>'Please PUT the user or group Id', 'data'=>''))->withStatus(400);
|
return $this->renderer->json($response, array('success'=>false, 'message'=>'Please PUT the user or group Id', 'data'=>''))->withStatus(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($params['mode'] == null)
|
if ($params['mode'] == null) {
|
||||||
{
|
|
||||||
return $this->renderer->json($response, array('success'=>false, 'message'=>'Please PUT the access mode', 'data'=>''))->withStatus(400);
|
return $this->renderer->json($response, array('success'=>false, 'message'=>'Please PUT the access mode', 'data'=>''))->withStatus(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$modeInput = $params['mode'];
|
$modeInput = $params['mode'];
|
||||||
|
|
||||||
$mode = M_NONE;
|
$mode = M_NONE;
|
||||||
if ($modeInput == 'read')
|
if ($modeInput == 'read') {
|
||||||
{
|
|
||||||
$mode = M_READ;
|
$mode = M_READ;
|
||||||
}
|
}
|
||||||
if ($modeInput == 'readwrite')
|
if ($modeInput == 'readwrite') {
|
||||||
{
|
|
||||||
$mode = M_READWRITE;
|
$mode = M_READWRITE;
|
||||||
}
|
}
|
||||||
if ($modeInput == 'all')
|
if ($modeInput == 'all') {
|
||||||
{
|
|
||||||
$mode = M_ALL;
|
$mode = M_ALL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$userOrGroupId = $userOrGroupIdInput;
|
$userOrGroupId = $userOrGroupIdInput;
|
||||||
if(!ctype_digit($userOrGroupIdInput) && $userOrGroup == 'user')
|
if (!ctype_digit($userOrGroupIdInput) && $userOrGroup == 'user') {
|
||||||
{
|
|
||||||
$userOrGroupObj = $dms->getUserByLogin($userOrGroupIdInput);
|
$userOrGroupObj = $dms->getUserByLogin($userOrGroupIdInput);
|
||||||
}
|
}
|
||||||
if(!ctype_digit($userOrGroupIdInput) && $userOrGroup == 'group')
|
if (!ctype_digit($userOrGroupIdInput) && $userOrGroup == 'group') {
|
||||||
{
|
|
||||||
$userOrGroupObj = $dms->getGroupByName($userOrGroupIdInput);
|
$userOrGroupObj = $dms->getGroupByName($userOrGroupIdInput);
|
||||||
}
|
}
|
||||||
if(ctype_digit($userOrGroupIdInput) && $userOrGroup == 'user')
|
if (ctype_digit($userOrGroupIdInput) && $userOrGroup == 'user') {
|
||||||
{
|
|
||||||
$userOrGroupObj = $dms->getUser($userOrGroupIdInput);
|
$userOrGroupObj = $dms->getUser($userOrGroupIdInput);
|
||||||
}
|
}
|
||||||
if(ctype_digit($userOrGroupIdInput) && $userOrGroup == 'group')
|
if (ctype_digit($userOrGroupIdInput) && $userOrGroup == 'group') {
|
||||||
{
|
|
||||||
$userOrGroupObj = $dms->getGroup($userOrGroupIdInput);
|
$userOrGroupObj = $dms->getGroup($userOrGroupIdInput);
|
||||||
}
|
}
|
||||||
if (!$userOrGroupObj) {
|
if (!$userOrGroupObj) {
|
||||||
|
@ -2781,29 +2759,23 @@ final class SeedDMS_RestapiController { /* {{{ */
|
||||||
|
|
||||||
$operationResult = false;
|
$operationResult = false;
|
||||||
|
|
||||||
if ($operationType == 'add' && $userOrGroup == 'user')
|
if ($operationType == 'add' && $userOrGroup == 'user') {
|
||||||
{
|
|
||||||
$operationResult = $folder->addAccess($mode, $userOrGroupId, true);
|
$operationResult = $folder->addAccess($mode, $userOrGroupId, true);
|
||||||
}
|
}
|
||||||
if ($operationType == 'remove' && $userOrGroup == 'user')
|
if ($operationType == 'remove' && $userOrGroup == 'user') {
|
||||||
{
|
|
||||||
$operationResult = $folder->removeAccess($userOrGroupId, true);
|
$operationResult = $folder->removeAccess($userOrGroupId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($operationType == 'add' && $userOrGroup == 'group')
|
if ($operationType == 'add' && $userOrGroup == 'group') {
|
||||||
{
|
|
||||||
$operationResult = $folder->addAccess($mode, $userOrGroupId, false);
|
$operationResult = $folder->addAccess($mode, $userOrGroupId, false);
|
||||||
}
|
}
|
||||||
if ($operationType == 'remove' && $userOrGroup == 'group')
|
if ($operationType == 'remove' && $userOrGroup == 'group') {
|
||||||
{
|
|
||||||
$operationResult = $folder->removeAccess($userOrGroupId, false);
|
$operationResult = $folder->removeAccess($userOrGroupId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($operationResult === false)
|
if ($operationResult === false) {
|
||||||
{
|
|
||||||
$message = 'Could not add user/group access to this folder.';
|
$message = 'Could not add user/group access to this folder.';
|
||||||
if ($operationType == 'remove')
|
if ($operationType == 'remove') {
|
||||||
{
|
|
||||||
$message = 'Could not remove user/group access from this folder.';
|
$message = 'Could not remove user/group access from this folder.';
|
||||||
}
|
}
|
||||||
return $this->renderer->json($response, array('success'=>false, 'message'=>'Something went wrong. ' . $message, 'data'=>''))->withStatus(500);
|
return $this->renderer->json($response, array('success'=>false, 'message'=>'Something went wrong. ' . $message, 'data'=>''))->withStatus(500);
|
||||||
|
@ -2817,11 +2789,12 @@ final class SeedDMS_RestapiController { /* {{{ */
|
||||||
$dms = $this->container->get('dms');
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->get('userobj');
|
$userobj = $this->container->get('userobj');
|
||||||
|
|
||||||
if(false === ($categories = $dms->getDocumentCategories())) {
|
if (false === ($categories = $dms->getDocumentCategories())) {
|
||||||
return $this->renderer->json($response, array('success'=>false, 'message'=>'Could not get categories', 'data'=>null))->withStatus(500);
|
return $this->renderer->json($response, array('success'=>false, 'message'=>'Could not get categories', 'data'=>null))->withStatus(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
foreach($categories as $category)
|
foreach ($categories as $category)
|
||||||
$data[] = $this->__getCategoryData($category);
|
$data[] = $this->__getCategoryData($category);
|
||||||
|
|
||||||
return $this->renderer->json($response, array('success'=>true, 'message'=>'', 'data'=>$data))->withStatus(200);
|
return $this->renderer->json($response, array('success'=>true, 'message'=>'', 'data'=>$data))->withStatus(200);
|
||||||
|
@ -2831,12 +2804,12 @@ final class SeedDMS_RestapiController { /* {{{ */
|
||||||
$dms = $this->container->get('dms');
|
$dms = $this->container->get('dms');
|
||||||
$userobj = $this->container->get('userobj');
|
$userobj = $this->container->get('userobj');
|
||||||
|
|
||||||
if(!ctype_digit($args['id'])) {
|
if (!ctype_digit($args['id'])) {
|
||||||
return $this->renderer->json($response, array('success'=>false, 'message'=>'Invalid parameter', 'data'=>''))->withStatus(400);
|
return $this->renderer->json($response, array('success'=>false, 'message'=>'Invalid parameter', 'data'=>''))->withStatus(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$category = $dms->getDocumentCategory($args['id']);
|
$category = $dms->getDocumentCategory($args['id']);
|
||||||
if($category) {
|
if ($category) {
|
||||||
return $this->renderer->json($response, array('success'=>true, 'message'=>'', 'data'=>$this->__getCategoryData($category)))->withStatus(200);
|
return $this->renderer->json($response, array('success'=>true, 'message'=>'', 'data'=>$this->__getCategoryData($category)))->withStatus(200);
|
||||||
} else {
|
} else {
|
||||||
return $this->renderer->json($response, array('success'=>false, 'message'=>'No such category', 'data'=>''))->withStatus(404);
|
return $this->renderer->json($response, array('success'=>false, 'message'=>'No such category', 'data'=>''))->withStatus(404);
|
||||||
|
@ -2849,7 +2822,7 @@ final class SeedDMS_RestapiController { /* {{{ */
|
||||||
$logger = $this->container->get('logger');
|
$logger = $this->container->get('logger');
|
||||||
|
|
||||||
$check = $this->checkIfAdmin($request, $response);
|
$check = $this->checkIfAdmin($request, $response);
|
||||||
if($check !== true)
|
if ($check !== true)
|
||||||
return $check;
|
return $check;
|
||||||
|
|
||||||
$params = $request->getParsedBody();
|
$params = $request->getParsedBody();
|
||||||
|
@ -2858,7 +2831,7 @@ final class SeedDMS_RestapiController { /* {{{ */
|
||||||
}
|
}
|
||||||
|
|
||||||
$catobj = $dms->getDocumentCategoryByName($params['name']);
|
$catobj = $dms->getDocumentCategoryByName($params['name']);
|
||||||
if($catobj) {
|
if ($catobj) {
|
||||||
return $this->renderer->json($response, array('success'=>false, 'message'=>'Category already exists', 'data'=>''))->withStatus(409);
|
return $this->renderer->json($response, array('success'=>false, 'message'=>'Category already exists', 'data'=>''))->withStatus(409);
|
||||||
} else {
|
} else {
|
||||||
if($data = $dms->addDocumentCategory($params['name'])) {
|
if($data = $dms->addDocumentCategory($params['name'])) {
|
||||||
|
@ -2875,11 +2848,11 @@ final class SeedDMS_RestapiController { /* {{{ */
|
||||||
$userobj = $this->container->get('userobj');
|
$userobj = $this->container->get('userobj');
|
||||||
|
|
||||||
$check = $this->checkIfAdmin($request, $response);
|
$check = $this->checkIfAdmin($request, $response);
|
||||||
if($check !== true)
|
if ($check !== true)
|
||||||
return $check;
|
return $check;
|
||||||
|
|
||||||
if($category = $dms->getDocumentCategory($args['id'])) {
|
if ($category = $dms->getDocumentCategory($args['id'])) {
|
||||||
if($result = $category->remove()) {
|
if ($result = $category->remove()) {
|
||||||
return $this->renderer->json($response, array('success'=>$result, 'message'=>'', 'data'=>''))->withStatus(200);
|
return $this->renderer->json($response, array('success'=>$result, 'message'=>'', 'data'=>''))->withStatus(200);
|
||||||
} else {
|
} else {
|
||||||
return $this->renderer->json($response, array('success'=>$result, 'message'=>'Could not delete category', 'data'=>''))->withStatus(500);
|
return $this->renderer->json($response, array('success'=>$result, 'message'=>'Could not delete category', 'data'=>''))->withStatus(500);
|
||||||
|
@ -2899,16 +2872,15 @@ final class SeedDMS_RestapiController { /* {{{ */
|
||||||
$userobj = $this->container->get('userobj');
|
$userobj = $this->container->get('userobj');
|
||||||
|
|
||||||
$check = $this->checkIfAdmin($request, $response);
|
$check = $this->checkIfAdmin($request, $response);
|
||||||
if($check !== true)
|
if ($check !== true)
|
||||||
return $check;
|
return $check;
|
||||||
|
|
||||||
if(!ctype_digit($args['id'])) {
|
if (!ctype_digit($args['id'])) {
|
||||||
return $this->renderer->json($response, array('success'=>false, 'message'=>'Invalid parameter', 'data'=>''))->withStatus(400);
|
return $this->renderer->json($response, array('success'=>false, 'message'=>'Invalid parameter', 'data'=>''))->withStatus(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$params = $request->getParsedBody();
|
$params = $request->getParsedBody();
|
||||||
if (empty($params['name']))
|
if (empty($params['name'])) {
|
||||||
{
|
|
||||||
return $this->renderer->json($response, array('success'=>false, 'message'=>'You must supply a new name', 'data'=>''))->withStatus(400);
|
return $this->renderer->json($response, array('success'=>false, 'message'=>'You must supply a new name', 'data'=>''))->withStatus(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2936,7 +2908,7 @@ final class SeedDMS_RestapiController { /* {{{ */
|
||||||
|
|
||||||
$attrdefs = $dms->getAllAttributeDefinitions();
|
$attrdefs = $dms->getAllAttributeDefinitions();
|
||||||
$data = [];
|
$data = [];
|
||||||
foreach($attrdefs as $attrdef)
|
foreach ($attrdefs as $attrdef)
|
||||||
$data[] = $this->__getAttributeDefinitionData($attrdef);
|
$data[] = $this->__getAttributeDefinitionData($attrdef);
|
||||||
|
|
||||||
return $this->renderer->json($response, array('success'=>true, 'message'=>'', 'data'=>$data))->withStatus(200);
|
return $this->renderer->json($response, array('success'=>true, 'message'=>'', 'data'=>$data))->withStatus(200);
|
||||||
|
@ -2952,10 +2924,10 @@ final class SeedDMS_RestapiController { /* {{{ */
|
||||||
$userobj = $this->container->get('userobj');
|
$userobj = $this->container->get('userobj');
|
||||||
|
|
||||||
$check = $this->checkIfAdmin($request, $response);
|
$check = $this->checkIfAdmin($request, $response);
|
||||||
if($check !== true)
|
if ($check !== true)
|
||||||
return $check;
|
return $check;
|
||||||
|
|
||||||
if(!ctype_digit($args['id'])) {
|
if (!ctype_digit($args['id'])) {
|
||||||
return $this->renderer->json($response, array('success'=>false, 'message'=>'Invalid parameter', 'data'=>''))->withStatus(400);
|
return $this->renderer->json($response, array('success'=>false, 'message'=>'Invalid parameter', 'data'=>''))->withStatus(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2988,12 +2960,12 @@ final class SeedDMS_RestapiController { /* {{{ */
|
||||||
$userobj = $this->container->get('userobj');
|
$userobj = $this->container->get('userobj');
|
||||||
|
|
||||||
$check = $this->checkIfAdmin($request, $response);
|
$check = $this->checkIfAdmin($request, $response);
|
||||||
if($check !== true)
|
if ($check !== true)
|
||||||
return $check;
|
return $check;
|
||||||
|
|
||||||
if(ctype_digit($args['id']))
|
if (ctype_digit($args['id'])) {
|
||||||
$folder = $dms->getFolder($args['id']);
|
$folder = $dms->getFolder($args['id']);
|
||||||
else {
|
} else {
|
||||||
$folder = $dms->getFolderByName($args['id']);
|
$folder = $dms->getFolderByName($args['id']);
|
||||||
}
|
}
|
||||||
if (!$folder) {
|
if (!$folder) {
|
||||||
|
@ -3008,11 +2980,11 @@ final class SeedDMS_RestapiController { /* {{{ */
|
||||||
function getStatsTotal($request, $response) { /* {{{ */
|
function getStatsTotal($request, $response) { /* {{{ */
|
||||||
$dms = $this->container->get('dms');
|
$dms = $this->container->get('dms');
|
||||||
$check = $this->checkIfAdmin($request, $response);
|
$check = $this->checkIfAdmin($request, $response);
|
||||||
if($check !== true)
|
if ($check !== true)
|
||||||
return $check;
|
return $check;
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
foreach(array('docstotal', 'folderstotal', 'userstotal') as $type) {
|
foreach (array('docstotal', 'folderstotal', 'userstotal') as $type) {
|
||||||
$total = $dms->getStatisticalData($type);
|
$total = $dms->getStatisticalData($type);
|
||||||
$data[$type] = $total;
|
$data[$type] = $total;
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,6 +403,92 @@ paths:
|
||||||
$ref: "#/definitions/ApiResponse"
|
$ref: "#/definitions/ApiResponse"
|
||||||
security:
|
security:
|
||||||
- api_key: []
|
- api_key: []
|
||||||
|
/users/{id}/quota:
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- "user"
|
||||||
|
summary: "Change quota of user by ID"
|
||||||
|
description: "Change the quota of a single user"
|
||||||
|
operationId: "changeUserQuota"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
consumes:
|
||||||
|
- "application/x-www-form-urlencoded"
|
||||||
|
parameters:
|
||||||
|
- name: "id"
|
||||||
|
in: "path"
|
||||||
|
description: "ID of user"
|
||||||
|
required: true
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
- name: "quota"
|
||||||
|
in: "formData"
|
||||||
|
required: true
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
description: "New quota"
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
"400":
|
||||||
|
description: "Invalid parameter"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
"403":
|
||||||
|
description: "No access"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
"404":
|
||||||
|
description: "User not found"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
/users/{id}/homefolder/{folderid}:
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- "user"
|
||||||
|
summary: "Change quota of user by ID"
|
||||||
|
description: "Change the quota of a single user"
|
||||||
|
operationId: "changeUserHomefolder"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
consumes:
|
||||||
|
- "application/x-www-form-urlencoded"
|
||||||
|
parameters:
|
||||||
|
- name: "id"
|
||||||
|
in: "path"
|
||||||
|
description: "ID of user"
|
||||||
|
required: true
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
- name: "folderid"
|
||||||
|
in: "path"
|
||||||
|
description: "ID of folder"
|
||||||
|
required: true
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
"400":
|
||||||
|
description: "Invalid parameter"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
"403":
|
||||||
|
description: "No access"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
"404":
|
||||||
|
description: "User or folder not found"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
/groups:
|
/groups:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
|
@ -463,6 +549,161 @@ paths:
|
||||||
$ref: "#/definitions/ApiResponse"
|
$ref: "#/definitions/ApiResponse"
|
||||||
security:
|
security:
|
||||||
- api_key: []
|
- api_key: []
|
||||||
|
/groups/{id}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- "group"
|
||||||
|
summary: "Find group by ID"
|
||||||
|
description: "Returns a single group"
|
||||||
|
operationId: "getGroupById"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
parameters:
|
||||||
|
- name: "id"
|
||||||
|
in: "path"
|
||||||
|
description: "ID of group to return"
|
||||||
|
required: true
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponseUser"
|
||||||
|
"404":
|
||||||
|
description: "Group not found"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
delete:
|
||||||
|
tags:
|
||||||
|
- "group"
|
||||||
|
summary: "Delete group by ID"
|
||||||
|
description: "Delete a single group"
|
||||||
|
operationId: "deleteGroupById"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
parameters:
|
||||||
|
- name: "id"
|
||||||
|
in: "path"
|
||||||
|
description: "ID of group to delete"
|
||||||
|
required: true
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
"500":
|
||||||
|
description: "Error deleting group"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
"403":
|
||||||
|
description: "No access"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
"404":
|
||||||
|
description: "Group not found"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
/groups/{id}/addUser:
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- "group"
|
||||||
|
summary: "Add user to group"
|
||||||
|
description: "Adds an existing user as a new member of a group"
|
||||||
|
operationId: "addUserToGroup"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
consumes:
|
||||||
|
- "application/x-www-form-urlencoded"
|
||||||
|
parameters:
|
||||||
|
- name: "id"
|
||||||
|
in: "path"
|
||||||
|
description: "ID of group"
|
||||||
|
required: true
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
- name: "userid"
|
||||||
|
in: "formData"
|
||||||
|
description: "ID of user"
|
||||||
|
required: true
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
"400":
|
||||||
|
description: "Invalid parameter"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
"403":
|
||||||
|
description: "No access"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
"404":
|
||||||
|
description: "User or group not found"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
"500":
|
||||||
|
description: "Internal error"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
/groups/{id}/removeUser:
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- "group"
|
||||||
|
summary: "Remove user from group"
|
||||||
|
description: "Remove a user as a new member of a group"
|
||||||
|
operationId: "removeUserToGroup"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
consumes:
|
||||||
|
- "application/x-www-form-urlencoded"
|
||||||
|
parameters:
|
||||||
|
- name: "id"
|
||||||
|
in: "path"
|
||||||
|
description: "ID of group"
|
||||||
|
required: true
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
- name: "userid"
|
||||||
|
in: "formData"
|
||||||
|
description: "ID of user"
|
||||||
|
required: true
|
||||||
|
type: "integer"
|
||||||
|
format: "int64"
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
"400":
|
||||||
|
description: "Invalid parameter"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
"403":
|
||||||
|
description: "No access"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
"404":
|
||||||
|
description: "User or group not found"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
"500":
|
||||||
|
description: "Internal error"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
/document/{id}:
|
/document/{id}:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
|
@ -562,7 +803,8 @@ paths:
|
||||||
"200":
|
"200":
|
||||||
description: "preview image file"
|
description: "preview image file"
|
||||||
schema:
|
schema:
|
||||||
type: "file"
|
type: "string"
|
||||||
|
format: "binary"
|
||||||
"403":
|
"403":
|
||||||
description: "No access"
|
description: "No access"
|
||||||
schema:
|
schema:
|
||||||
|
@ -595,7 +837,8 @@ paths:
|
||||||
"200":
|
"200":
|
||||||
description: "content file"
|
description: "content file"
|
||||||
schema:
|
schema:
|
||||||
type: "file"
|
type: "string"
|
||||||
|
format: "binary"
|
||||||
"403":
|
"403":
|
||||||
description: "No access"
|
description: "No access"
|
||||||
schema:
|
schema:
|
||||||
|
@ -634,7 +877,8 @@ paths:
|
||||||
"200":
|
"200":
|
||||||
description: "attached file"
|
description: "attached file"
|
||||||
schema:
|
schema:
|
||||||
type: "file"
|
type: "string"
|
||||||
|
format: "binary"
|
||||||
"403":
|
"403":
|
||||||
description: "No access"
|
description: "No access"
|
||||||
schema:
|
schema:
|
||||||
|
@ -673,7 +917,8 @@ paths:
|
||||||
"200":
|
"200":
|
||||||
description: "content file"
|
description: "content file"
|
||||||
schema:
|
schema:
|
||||||
type: "file"
|
type: "string"
|
||||||
|
format: "binary"
|
||||||
"403":
|
"403":
|
||||||
description: "No access"
|
description: "No access"
|
||||||
schema:
|
schema:
|
||||||
|
@ -1554,6 +1799,53 @@ paths:
|
||||||
$ref: "#/definitions/ApiResponse"
|
$ref: "#/definitions/ApiResponse"
|
||||||
security:
|
security:
|
||||||
- api_key: []
|
- api_key: []
|
||||||
|
/folder/{id}/owner/{userid}:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- "folder"
|
||||||
|
summary: "Set owner of folder"
|
||||||
|
description: "Set owner of folder"
|
||||||
|
operationId: "setFolderOwner"
|
||||||
|
produces:
|
||||||
|
- "application/json"
|
||||||
|
consumes:
|
||||||
|
- "application/x-www-form-urlencoded"
|
||||||
|
parameters:
|
||||||
|
- name: "id"
|
||||||
|
in: "path"
|
||||||
|
description: "ID of folder."
|
||||||
|
type: "integer"
|
||||||
|
required: true
|
||||||
|
format: "int64"
|
||||||
|
- name: "userid"
|
||||||
|
in: "path"
|
||||||
|
description: "ID of user."
|
||||||
|
type: "integer"
|
||||||
|
required: true
|
||||||
|
format: "int64"
|
||||||
|
responses:
|
||||||
|
"201":
|
||||||
|
description: "successful operation"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
"400":
|
||||||
|
description: "No folder or user given"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
"403":
|
||||||
|
description: "No access"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
"404":
|
||||||
|
description: "Folder not found"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
"500":
|
||||||
|
description: "Internal error"
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiResponse"
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
/categories:
|
/categories:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
|
@ -1779,15 +2071,21 @@ paths:
|
||||||
description: "Invalid status value"
|
description: "Invalid status value"
|
||||||
security:
|
security:
|
||||||
- api_key: []
|
- api_key: []
|
||||||
/echo:
|
/echo/{data}:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- "misc"
|
- "misc"
|
||||||
summary: "Return what was send in the body"
|
summary: "Return what was send in the path"
|
||||||
description: "Just returns the body content"
|
description: "Just returns the path"
|
||||||
operationId: "echoData"
|
operationId: "echoData"
|
||||||
produces:
|
produces:
|
||||||
- "application/json"
|
- "application/json"
|
||||||
|
parameters:
|
||||||
|
- name: "data"
|
||||||
|
in: "path"
|
||||||
|
description: "Data to be echoed"
|
||||||
|
required: true
|
||||||
|
type: "string"
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: "successful operation"
|
description: "successful operation"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user