Example #1
0
 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'])) {
         if (isset($_GET['reshares']) && $_GET['reshares'] !== 'false') {
             $reshares = true;
         } else {
             $reshares = false;
         }
         if (isset($_GET['subfiles']) && $_GET['subfiles'] !== 'false') {
             return self::getSharesFromFolder($_GET['path']);
         }
         return self::collectShares(self::getFileId($_GET['path']), self::getItemType($_GET['path']), false, $_GET['path'], $reshares);
     }
     $shares = \OCP\Share::getItemShared('file', null);
     if ($shares === false) {
         return new \OC_OCS_Result(null, 404, 'could not get shares');
     } else {
         foreach (\OCA\Sharing_Group\Data::readGroups() as $group) {
             $sharing_groups[$group['id']] = $group['name'];
         }
         foreach ($shares as &$share) {
             if ($share['item_type'] === 'file' && isset($share['path'])) {
                 $share['mimetype'] = \OC_Helper::getFileNameMimeType($share['path']);
                 if (\OC::$server->getPreviewManager()->isMimeSupported($share['mimetype'])) {
                     $share['isPreviewAvailable'] = true;
                 }
             }
             if (!is_null($share['token'])) {
                 $share['url'] = \OC::$server->getURLGenerator()->linkToRouteAbsolute('files_sharing.sharecontroller.showShare', ['token' => $share['token']]);
             }
             if (defined('\\OCP\\Share::SHARE_TYPE_SHARING_GROUP') && $share['share_type'] === \OCP\Share::SHARE_TYPE_SHARING_GROUP) {
                 $share['share_with'] = $sharing_groups[$share['share_with']];
                 $share['share_with_displayname'] = $sharing_groups[$share['share_with_displayname']];
             }
         }
         return new \OC_OCS_Result($shares);
     }
 }