[Pkg-owncloud-commits] [owncloud] 19/153: Only check for existence of shared files when doing shared storage setup

David Prévot taffit at moszumanska.debian.org
Tue May 27 03:05:28 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 1d7564dc2f4ec9e06f9047846cd6bf023a1c26ed
Author: Bart Visscher <bartv at thisnet.nl>
Date:   Fri Feb 21 22:58:29 2014 +0100

    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.
---
 apps/files_sharing/lib/sharedstorage.php |  2 +-
 lib/public/share.php                     | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php
index b922654..18c8a4f 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 ebc555d..8cfe741 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

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list