]> source.dussan.org Git - nextcloud-server.git/commitdiff
OCP\Share::unshareAll(): Deduplicate hook parameters.
authorAndreas Fischer <bantu@owncloud.com>
Mon, 23 Sep 2013 14:22:48 +0000 (16:22 +0200)
committerMorris Jobke <morris.jobke@gmail.com>
Sun, 3 Nov 2013 11:33:31 +0000 (12:33 +0100)
lib/public/share.php

index e4f68017d26b6681dc0274d65b3f4723fbe7e0ae..a8d1436e10084a804e6680428cb1b64b6b4d8a3b 100644 (file)
@@ -665,19 +665,16 @@ class Share {
        public static function unshareAll($itemType, $itemSource) {
                if ($shares = self::getItemShared($itemType, $itemSource)) {
                        // Pass all the vars we have for now, they may be useful
-                       \OC_Hook::emit('OCP\Share', 'pre_unshareAll', array(
+                       $hookParams = array(
                                'itemType' => $itemType,
                                'itemSource' => $itemSource,
-                               'shares' => $shares
-                       ));
+                               'shares' => $shares,
+                       );
+                       \OC_Hook::emit('OCP\Share', 'pre_unshareAll', $hookParams);
                        foreach ($shares as $share) {
                                self::delete($share['id']);
                        }
-                       \OC_Hook::emit('OCP\Share', 'post_unshareAll', array(
-                                       'itemType' => $itemType,
-                                       'itemSource' => $itemSource,
-                                       'shares' => $shares
-                       ));
+                       \OC_Hook::emit('OCP\Share', 'post_unshareAll', $hookParams);
                        return true;
                }
                return false;
@@ -852,6 +849,27 @@ class Share {
                return false;
        }
 
+       /**
+        * Unshares a share given a share data array
+        * @param array $item Share data (usually database row)
+        * @return null
+        */
+       protected static function unshareItem(array $item) {
+               // Pass all the vars we have for now, they may be useful
+               $hookParams = array(
+                       'itemType'              => $item['item_type'],
+                       'itemSource'    => $item['item_source'],
+                       'shareType'             => $item['share_type'],
+                       'shareWith'             => $item['share_with'],
+                       'itemParent'    => $item['parent'],
+               );
+               \OC_Hook::emit('OCP\Share', 'pre_unshare', $hookParams + array(
+                       'fileSource'    => $item['file_source'],
+               ));
+               self::delete($item['id']);
+               \OC_Hook::emit('OCP\Share', 'post_unshare', $hookParams);
+       }
+
        /**
         * Get the backend class for the specified item type
         * @param string $itemType