diff options
author | Bart Visscher <bartv@thisnet.nl> | 2014-02-21 22:58:29 +0100 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2014-02-21 23:07:35 +0100 |
commit | 1d7564dc2f4ec9e06f9047846cd6bf023a1c26ed (patch) | |
tree | 58e98dcd9625fe244766fc338135576496d6ed44 /lib | |
parent | f4f72e77d8bf312b6fc693d43ef5fc831130db3b (diff) | |
download | nextcloud-server-1d7564dc2f4ec9e06f9047846cd6bf023a1c26ed.tar.gz nextcloud-server-1d7564dc2f4ec9e06f9047846cd6bf023a1c26ed.zip |
Only check for existence of shared files when doing shared storage setup
The getItemsSharedWith function also retrieves related information,
resulting in work that isn't used here.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/public/share.php | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/public/share.php b/lib/public/share.php index ebc555dba5f..8cfe7417bee 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 |