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
if ($shareType == self::SHARE_TYPE_GROUP) {
$groupItemTarget = self::generateTarget($itemType, $itemSource, $shareType, $shareWith['group'],
$uidOwner, $suggestedItemTarget);
+ $run = true;
+ $error = '';
\OC_Hook::emit('OCP\Share', 'pre_shared', array(
'itemType' => $itemType,
'itemSource' => $itemSource,
'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) {
} else {
$itemTarget = self::generateTarget($itemType, $itemSource, $shareType, $shareWith, $uidOwner,
$suggestedItemTarget);
+ $run = true;
+ $error = '';
\OC_Hook::emit('OCP\Share', 'pre_shared', array(
'itemType' => $itemType,
'itemSource' => $itemSource,
'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) {