From 21a0a96e4395fedb7fae8fe5f731ca283ce937b1 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Wed, 4 Sep 2013 17:25:15 +0200 Subject: [PATCH] intermediate results, share api --- apps/files_sharing/appinfo/routes.php | 14 -------- apps/files_sharing/lib/api.php | 48 +++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 apps/files_sharing/lib/api.php diff --git a/apps/files_sharing/appinfo/routes.php b/apps/files_sharing/appinfo/routes.php index 15af5226e1..2e26033cad 100644 --- a/apps/files_sharing/appinfo/routes.php +++ b/apps/files_sharing/appinfo/routes.php @@ -19,20 +19,6 @@ OC_API::register('get', array('path' => ''), array('path' => '.+')); //allow slashes in parameter path /* -OC_API::register('get', - '/apps/files_sharing/api/share/group/{path}', - array('\OCA\Files\Share\Api', 'getShare'), - 'files_sharing', - OC_API::USER_AUTH, - array('path' => '')); - -OC_API::register('get', - '/apps/files_sharing/api/share/user/{path}', - array('\OCA\Files\Share\Api', 'getShare'), - 'files_sharing', - OC_API::USER_AUTH, - array('path' => '')); - OC_API::register('get', '/apps/files_sharing/api/permission/{path}', array('\OCA\Files\Share\Api', 'getShare'), diff --git a/apps/files_sharing/lib/api.php b/apps/files_sharing/lib/api.php new file mode 100644 index 0000000000..cfe1fc2da4 --- /dev/null +++ b/apps/files_sharing/lib/api.php @@ -0,0 +1,48 @@ +. + * + */ + +namespace OCA\Files\Share; + +class Api { + + /** + * @brief get share information for a given file/folder + * + * @param array $params which contains a 'path' to a file/folder + * @return \OC_OCS_Result share information + */ + public static function getShare($params) { + $path = $params['path']; + + $view = new \OC\Files\View('/'.\OCP\User::getUser().'/files'); + $fileInfo = $view->getFileInfo($path); + if ($fileInfo) { + $share = \OCP\Share::getItemShared('file', $fileInfo['fileid']); + } else { + \OCP\Util::writeLog('files_sharing', 'OCS API getShare, file ' . $path . ' does not exists', \OCP\Util::WARN); + $share = array(); + } + + return new \OC_OCS_Result($share); + } + +} \ No newline at end of file