diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php index b922654e5ec2db2e2e8f711eed54d68e843e622d..18c8a4f42a211f71a7df672c7e25405ebf5666e2 100644 --- a/apps/files_sharing/lib/sharedstorage.php +++ b/apps/files_sharing/lib/sharedstorage.php @@ -394,7 +394,7 @@ class Shared extends \OC\Files\Storage\Common { public static function setup($options) { if (!\OCP\User::isLoggedIn() || \OCP\User::getUser() != $options['user'] - || \OCP\Share::getItemsSharedWith('file') + || \OCP\Share::hasFilesSharedWith() ) { $user_dir = $options['user_dir']; \OC\Files\Filesystem::mount('\OC\Files\Storage\Shared', diff --git a/lib/public/share.php b/lib/public/share.php index ebc555dba5fe5bf784a2b5c703ac4e522d1f8474..8cfe7417bee75df7852abf00723d9c93c628fdbf 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -243,6 +243,29 @@ class Share { return array("users" => array_unique($shares), "public" => $publicShare); } + public static function hasFilesSharedWith() { + if (!self::isEnabled()) { + return false; + } + $shareWith = \OC_User::getUser(); + $where = 'INNER JOIN `*PREFIX*filecache` ON `file_source` = `*PREFIX*filecache`.`fileid`'; + $where .= ' WHERE `file_target` IS NOT NULL'; + $queryArgs = array(); + $where .= ' AND `share_type` IN (?,?,?)'; + $queryArgs[] = self::SHARE_TYPE_USER; + $queryArgs[] = self::SHARE_TYPE_GROUP; + $queryArgs[] = self::$shareTypeGroupUserUnique; + $userAndGroups = array_merge(array($shareWith), \OC_Group::getUserGroups($shareWith)); + $placeholders = join(',', array_fill(0, count($userAndGroups), '?')); + $where .= ' AND `share_with` IN ('.$placeholders.')'; + $queryArgs = array_merge($queryArgs, $userAndGroups); + // Don't include own group shares + $where .= ' AND `uid_owner` != ?'; + $queryArgs[] = $shareWith; + $result = \OC_DB::executeAudited('SELECT COUNT(*) FROM `*PREFIX*share` '.$where, $queryArgs); + return $result->fetchOne() > 0; + } + /** * Get the items of item type shared with the current user * @param string Item type