From: Bjoern Schiessle Date: Thu, 1 Aug 2013 11:04:55 +0000 (+0200) Subject: cancel sharing if some users doesn't have a working encryption set-up. X-Git-Tag: v5.0.10~31 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e75dcf51c7607fdcc2d1a2ede7bf025328555374;p=nextcloud-server.git cancel sharing if some users doesn't have a working encryption set-up. Conflicts: lib/public/share.php --- diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php index b2a17f6bca5..be95037784e 100644 --- a/apps/files_encryption/hooks/hooks.php +++ b/apps/files_encryption/hooks/hooks.php @@ -250,21 +250,18 @@ class Hooks { break; } - $error = false; + $notConfigured = array(); foreach ($users as $user) { if (!$view->file_exists($user . '.public.key')) { - $error = true; - break; + $notConfigured[] = $user; } } - if ($error) // Set flag var 'run' to notify emitting - // script that hook execution failed - { - $params['run']->run = false; + if (count($notConfigured) > 0) { + $params['run'] = false; + $params['error'] = 'Following users are not set up for encryption: ' . join(', ' , $notConfigured); } - // TODO: Make sure files_sharing provides user - // feedback on failed share + } /** diff --git a/lib/public/share.php b/lib/public/share.php index cb7798874ac..37931932a5f 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -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) {