]> source.dussan.org Git - nextcloud-server.git/commitdiff
cancel sharing if some users doesn't have a working encryption set-up.
authorBjoern Schiessle <schiessle@owncloud.com>
Thu, 1 Aug 2013 11:04:55 +0000 (13:04 +0200)
committerBjoern Schiessle <schiessle@owncloud.com>
Thu, 1 Aug 2013 14:46:55 +0000 (16:46 +0200)
Conflicts:
lib/public/share.php

apps/files_encryption/hooks/hooks.php
lib/public/share.php

index b2a17f6bca5e344646a76a8e42354d765f439ed4..be95037784e676909189c6f87adc43cccc0c7a0e 100644 (file)
@@ -250,21 +250,18 @@ class Hooks {
                                break;\r
                }\r
 \r
-               $error = false;\r
+               $notConfigured = array();\r
                foreach ($users as $user) {\r
                        if (!$view->file_exists($user . '.public.key')) {\r
-                               $error = true;\r
-                               break;\r
+                               $notConfigured[] = $user;\r
                        }\r
                }\r
 \r
-               if ($error) // Set flag var 'run' to notify emitting\r
-                       // script that hook execution failed\r
-               {\r
-                       $params['run']->run = false;\r
+               if (count($notConfigured) > 0) {\r
+                       $params['run'] = false;\r
+                       $params['error'] = 'Following users are not set up for encryption: ' . join(', ' , $notConfigured);\r
                }\r
-               // TODO: Make sure files_sharing provides user\r
-               // feedback on failed share\r
+               \r
        }\r
 \r
        /**\r
index cb7798874ac8044315f21f043f30f800ce267cbf..37931932a5f6fe67e771b60bf63ce5d4600e63e2 100644 (file)
@@ -1284,6 +1284,8 @@ class Share {
                        .' `file_target`, `token`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)');
                // Share with a group
                if ($shareType == self::SHARE_TYPE_GROUP) {
+                       $run = true;
+                       $error = '';
                        $groupItemTarget = self::generateTarget($itemType, $itemSource, $shareType, $shareWith['group'], $uidOwner, $suggestedItemTarget);
                        \OC_Hook::emit('OCP\Share', 'pre_shared', array(
                                'itemType' => $itemType,
@@ -1294,8 +1296,15 @@ class Share {
                                'uidOwner' => $uidOwner,
                                'permissions' => $permissions,
                                'fileSource' => $fileSource,
-                               'token' => $token
+                               'token' => $token,
+                               'run' => &$run,
+                               'error' => &$error
                        ));
+                       
+                       if ($run === false) {
+                               throw new \Exception($error);
+                       }
+                       
                        if (isset($fileSource)) {
                                if ($parentFolder) {
                                        if ($parentFolder === true) {
@@ -1369,6 +1378,8 @@ class Share {
                                return $parentFolders;
                        }
                } else {
+                       $run = true;
+                       $error = '';
                        $itemTarget = self::generateTarget($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $suggestedItemTarget);
                        \OC_Hook::emit('OCP\Share', 'pre_shared', array(
                                'itemType' => $itemType,
@@ -1379,8 +1390,15 @@ class Share {
                                'uidOwner' => $uidOwner,
                                'permissions' => $permissions,
                                'fileSource' => $fileSource,
-                               'token' => $token
+                               'token' => $token,
+                               'run' => &$run,
+                               'error' => &$error
                        ));
+                       
+                       if ($run === false) {
+                               throw new \Exception($error);
+                       }
+                       
                        if (isset($fileSource)) {
                                if ($parentFolder) {
                                        if ($parentFolder === true) {