diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2014-05-30 13:42:24 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2014-05-30 13:42:24 +0200 |
commit | 517501ffbf369b24191d8b9a9f2ce44a9891fb97 (patch) | |
tree | f638ba7e2f3554b7b1a31f628496c7d0740fd2ac /apps/files_sharing/lib/api.php | |
parent | 929882a32a020b6c05605f416fa55024b9a60d33 (diff) | |
parent | 7fac2b62e954b0f8a693516da1151c97efa2ee99 (diff) | |
download | nextcloud-server-517501ffbf369b24191d8b9a9f2ce44a9891fb97.tar.gz nextcloud-server-517501ffbf369b24191d8b9a9f2ce44a9891fb97.zip |
Merge pull request #8417 from owncloud/share-overview
Sharing overview page
Diffstat (limited to 'apps/files_sharing/lib/api.php')
-rw-r--r-- | apps/files_sharing/lib/api.php | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/apps/files_sharing/lib/api.php b/apps/files_sharing/lib/api.php index 21fd5d00a4c..dc4e5cf6c49 100644 --- a/apps/files_sharing/lib/api.php +++ b/apps/files_sharing/lib/api.php @@ -31,6 +31,9 @@ class Api { * @return \OC_OCS_Result share information */ public static function getAllShares($params) { + if (isset($_GET['shared_with_me']) && $_GET['shared_with_me'] !== 'false') { + return self::getFilesSharedWithMe(); + } // if a file is specified, get the share for this file if (isset($_GET['path'])) { $params['itemSource'] = self::getFileId($_GET['path']); @@ -49,12 +52,20 @@ class Api { return self::collectShares($params); } - $share = \OCP\Share::getItemShared('file', null); + $shares = \OCP\Share::getItemShared('file', null); - if ($share === false) { + if ($shares === false) { return new \OC_OCS_Result(null, 404, 'could not get shares'); } else { - return new \OC_OCS_Result($share); + foreach ($shares as &$share) { + // file_target might not be set if the target user hasn't mounted + // the filesystem yet + if ($share['item_type'] === 'file' && isset($share['file_target'])) { + $share['mimetype'] = \OC_Helper::getFileNameMimeType($share['file_target']); + } + $newShares[] = $share; + } + return new \OC_OCS_Result($shares); } } @@ -196,6 +207,27 @@ class Api { } /** + * get files shared with the user + * @return \OC_OCS_Result + */ + private static function getFilesSharedWithMe() { + try { + $shares = \OCP\Share::getItemsSharedWith('file'); + foreach ($shares as &$share) { + if ($share['item_type'] === 'file') { + $share['mimetype'] = \OC_Helper::getFileNameMimeType($share['file_target']); + } + } + $result = new \OC_OCS_Result($shares); + } catch (\Exception $e) { + $result = new \OC_OCS_Result(null, 403, $e->getMessage()); + } + + return $result; + + } + + /** * create a new share * @param array $params * @return \OC_OCS_Result |