diff options
author | Julius Härtl <jus@bitgrid.net> | 2019-01-29 12:23:14 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-03-01 20:56:18 +0100 |
commit | e404ce7096b9e4666f91cdca2e837d8ecd802357 (patch) | |
tree | 59a12d81420cc7803d881384b2f012ab9db9faa7 /core | |
parent | 53ac9bdda17e5141fceaec1a895f733c13c73c7a (diff) | |
download | nextcloud-server-e404ce7096b9e4666f91cdca2e837d8ecd802357.tar.gz nextcloud-server-e404ce7096b9e4666f91cdca2e837d8ecd802357.zip |
Implement search and rename in backend
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'core')
-rw-r--r-- | core/Controller/CollaborationResourcesController.php | 44 | ||||
-rw-r--r-- | core/routes.php | 3 |
2 files changed, 46 insertions, 1 deletions
diff --git a/core/Controller/CollaborationResourcesController.php b/core/Controller/CollaborationResourcesController.php index a15904a4c2a..3c9937aade2 100644 --- a/core/Controller/CollaborationResourcesController.php +++ b/core/Controller/CollaborationResourcesController.php @@ -88,6 +88,22 @@ class CollaborationResourcesController extends OCSController { * @NoAdminRequired * * @param int $collectionId + * @return DataResponse + */ + public function searchCollections(string $filter): DataResponse { + try { + $collections = $this->manager->searchCollections($this->userSession->getUser(), $filter); + } catch (CollectionException $e) { + return new DataResponse([], Http::STATUS_NOT_FOUND); + } + + return new DataResponse(array_map([$this, 'prepareCollection'], $collections)); + } + + /** + * @NoAdminRequired + * + * @param int $collectionId * @param string $resourceType * @param string $resourceId * @return DataResponse @@ -189,6 +205,31 @@ class CollaborationResourcesController extends OCSController { return new DataResponse($this->prepareCollection($collection)); } + /** + * @NoAdminRequired + * + * @param int $collectionId + * @param string $collectionName + * @return DataResponse + */ + public function renameCollection(int $collectionId, string $collectionName): DataResponse { + try { + $collection = $this->manager->getCollection($collectionId); + if (!$collection->canAccess($this->userSession->getUser())) { + throw new CollectionException('Not found'); + } + } catch (CollectionException $exception) { + return new DataResponse([], Http::STATUS_NOT_FOUND); + } + + try { + $collection = $this->manager->renameCollection($collectionId, $collectionName); + } catch (CollectionException $e) { + return new DataResponse([], Http::STATUS_NOT_FOUND); + } + return new DataResponse($this->prepareCollection($collection)); + } + protected function prepareCollection(ICollection $collection): array { return [ 'id' => $collection->getId(), @@ -206,7 +247,8 @@ class CollaborationResourcesController extends OCSController { 'type' => $resource->getType(), 'id' => $resource->getId(), 'name' => $resource->getName(), - 'iconClass' => $resource->getIconClass() + 'iconClass' => $resource->getIconClass(), + 'link' => $resource->getLink(), ]; } } diff --git a/core/routes.php b/core/routes.php index 079f99d265f..974d644000a 100644 --- a/core/routes.php +++ b/core/routes.php @@ -91,8 +91,11 @@ $application->registerRoutes($this, [ ['root' => '/core', 'name' => 'WhatsNew#dismiss', 'url' => '/whatsnew', 'verb' => 'POST'], ['root' => '/core', 'name' => 'AppPassword#getAppPassword', 'url' => '/getapppassword', 'verb' => 'GET'], + ['root' => '/collaboration', 'name' => 'CollaborationResources#searchCollections', 'url' => '/resources/collections/search/{filter}', 'verb' => 'GET'], ['root' => '/collaboration', 'name' => 'CollaborationResources#listCollection', 'url' => '/resources/collections/{collectionId}', 'verb' => 'GET'], + ['root' => '/collaboration', 'name' => 'CollaborationResources#renameCollection', 'url' => '/resources/collections/{collectionId}', 'verb' => 'PUT'], ['root' => '/collaboration', 'name' => 'CollaborationResources#addResource', 'url' => '/resources/collections/{collectionId}', 'verb' => 'POST'], + ['root' => '/collaboration', 'name' => 'CollaborationResources#removeResource', 'url' => '/resources/collections/{collectionId}', 'verb' => 'DELETE'], ['root' => '/collaboration', 'name' => 'CollaborationResources#getCollectionsByResource', 'url' => '/resources/{resourceType}/{resourceId}', 'verb' => 'GET'], ['root' => '/collaboration', 'name' => 'CollaborationResources#createCollectionOnResource', 'url' => '/resources/{baseResourceType}/{baseResourceId}', 'verb' => 'POST'], |