]> source.dussan.org Git - nextcloud-server.git/commitdiff
Check if resharing is allowed by the admin, fixes issue #341
authorMichael Gapczynski <mtgap@owncloud.com>
Sat, 10 Nov 2012 05:31:52 +0000 (00:31 -0500)
committerMichael Gapczynski <mtgap@owncloud.com>
Sat, 10 Nov 2012 05:31:52 +0000 (00:31 -0500)
lib/public/share.php

index 107b54615b7b9ec7e5a13ec6167f250893d0e0fa..47726fbbe7f1141e1a20db87a7af557cf8f74e08 100644 (file)
@@ -58,6 +58,7 @@ class Share {
        private static $shareTypeGroupUserUnique = 2;\r
        private static $backends = array();\r
        private static $backendTypes = array();\r
+       private static $isResharingAllowed;\r
 \r
        /**\r
        * @brief Register a sharing backend class that implements OCP\Share_Backend for an item type\r
@@ -482,6 +483,24 @@ class Share {
                throw new \Exception($message);\r
        }\r
 \r
+       /**\r
+       * @brief Check if resharing is allowed\r
+       * @return Returns true if allowed or false\r
+       *\r
+       * Resharing is allowed by default if not configured\r
+       *\r
+       */\r
+       private static function isResharingAllowed() {\r
+               if (!isset(self::$isResharingAllowed)) {\r
+                       if (\OC_Appconfig::getValue('core', 'shareapi_allow_resharing', 'yes') == 'yes') {\r
+                               self::$isResharingAllowed = true;\r
+                       } else {\r
+                               self::$isResharingAllowed = false;\r
+                       }\r
+               }\r
+               return self::$isResharingAllowed;\r
+       }\r
+\r
        /**\r
        * @brief Get a list of collection item types for the specified item type\r
        * @param string Item type\r
@@ -726,6 +745,10 @@ class Share {
                                        continue;\r
                                }\r
                        }\r
+                       // Check if resharing is allowed, if not remove share permission\r
+                       if (isset($row['permissions']) && !self::isResharingAllowed()) {\r
+                               $row['permissions'] &= ~self::PERMISSION_SHARE;\r
+                       }\r
                        $items[$row['id']] = $row;\r
                }\r
                if (!empty($items)) {\r
@@ -844,7 +867,7 @@ class Share {
                                throw new \Exception($message);\r
                        }\r
                        // Check if share permissions is granted\r
-                       if ((int)$checkReshare['permissions'] & self::PERMISSION_SHARE) {\r
+                       if (self::isResharingAllowed() && (int)$checkReshare['permissions'] & self::PERMISSION_SHARE) {\r
                                if (~(int)$checkReshare['permissions'] & $permissions) {\r
                                        $message = 'Sharing '.$itemSource.' failed, because the permissions exceed permissions granted to '.$uidOwner;\r
                                        \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);\r