]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix permissions functions for webdav external storages
authorRobin Appelman <icewind@owncloud.com>
Fri, 13 Jun 2014 13:28:24 +0000 (15:28 +0200)
committerBjoern Schiessle <schiessle@owncloud.com>
Sat, 14 Jun 2014 08:22:38 +0000 (10:22 +0200)
apps/files_external/lib/webdav.php

index 6c268ea00be8738a5992a54130a0c76a20d50bed..c532c5eaa7d14426752e1521b7a7d767c430a39f 100644 (file)
@@ -355,7 +355,7 @@ class DAV extends \OC\Files\Storage\Common {
         * @param string $path
         */
        public function cleanPath($path) {
-               if ($path === ""){
+               if ($path === "") {
                        return $path;
                }
                $path = \OC\Files\Filesystem::normalizePath($path);
@@ -400,6 +400,22 @@ class DAV extends \OC\Files\Storage\Common {
                }
        }
 
+       public function isUpdatable($path) {
+               return (bool)($this->getPermissions($path) & \OCP\PERMISSION_UPDATE);
+       }
+
+       public function isCreatable($path) {
+               return (bool)($this->getPermissions($path) & \OCP\PERMISSION_CREATE);
+       }
+
+       public function isSharable($path) {
+               return (bool)($this->getPermissions($path) & \OCP\PERMISSION_SHARE);
+       }
+
+       public function isDeletable($path) {
+               return (bool)($this->getPermissions($path) & \OCP\PERMISSION_DELETE);
+       }
+
        public function getPermissions($path) {
                $this->init();
                $response = $this->client->propfind($this->encodePath($path), array('{http://owncloud.org/ns}permissions'));
@@ -419,8 +435,12 @@ class DAV extends \OC\Files\Storage\Common {
                                $permissions |= \OCP\PERMISSION_CREATE;
                        }
                        return $permissions;
+               } else if ($this->is_dir($path)) {
+                       return \OCP\PERMISSION_ALL;
+               } else if ($this->file_exists($path)) {
+                       return \OCP\PERMISSION_ALL - \OCP\PERMISSION_CREATE;
                } else {
-                       return parent::getPermissions($path);
+                       return 0;
                }
        }
 }