[Pkg-owncloud-commits] [owncloud] 46/69: we can take the permission directly from the share, no need to call the share api first

David Prévot taffit at moszumanska.debian.org
Sat May 10 16:20:38 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 31bf2d4b33ea28cb8db28201312ad48108136926
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date:   Wed May 7 16:49:07 2014 +0200

    we can take the permission directly from the share, no need to call the share api first
---
 apps/files_sharing/lib/sharedstorage.php | 26 ++++++--------------------
 1 file changed, 6 insertions(+), 20 deletions(-)

diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php
index 4733dff..d4a817f 100644
--- a/apps/files_sharing/lib/sharedstorage.php
+++ b/apps/files_sharing/lib/sharedstorage.php
@@ -102,14 +102,15 @@ class Shared extends \OC\Files\Storage\Common {
 	/**
 	 * @brief Get the permissions granted for a shared file
 	 * @param string Shared target file path
-	 * @return int CRUDS permissions granted or false if not found
+	 * @return int CRUDS permissions granted
 	 */
 	public function getPermissions($target) {
-		$source = $this->getFile($target);
-		if ($source) {
-			return $source['permissions'];
+		$permissions = $this->share['permissions'];
+		// part file are always have delete permissions
+		if (pathinfo($target, PATHINFO_EXTENSION) === 'part') {
+			$permissions |= \OCP\PERMISSION_DELETE;
 		}
-		return false;
+		return $permissions;
 	}
 
 	public function mkdir($path) {
@@ -183,9 +184,6 @@ class Shared extends \OC\Files\Storage\Common {
 	}
 
 	public function isCreatable($path) {
-		if ($path == '') {
-			$path = $this->getMountPoint();
-		}
 		return ($this->getPermissions($path) & \OCP\PERMISSION_CREATE);
 	}
 
@@ -194,23 +192,14 @@ class Shared extends \OC\Files\Storage\Common {
 	}
 
 	public function isUpdatable($path) {
-		if ($path == '') {
-			$path = $this->getMountPoint();
-		}
 		return ($this->getPermissions($path) & \OCP\PERMISSION_UPDATE);
 	}
 
 	public function isDeletable($path) {
-		if ($path == '') {
-			$path = $this->getMountPoint();
-		}
 		return ($this->getPermissions($path) & \OCP\PERMISSION_DELETE);
 	}
 
 	public function isSharable($path) {
-		if ($path == '') {
-			$path = $this->getMountPoint();
-		}
 		return ($this->getPermissions($path) & \OCP\PERMISSION_SHARE);
 	}
 
@@ -454,9 +443,6 @@ class Shared extends \OC\Files\Storage\Common {
 	}
 
 	public function free_space($path) {
-		if ($path == '') {
-			$path = $this->getMountPoint();
-		}
 		$source = $this->getSourcePath($path);
 		if ($source) {
 			list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);

-- 
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