cancel sharing if some users doesn't have a working encryption set-up.

This commit is contained in:
Bjoern Schiessle 2013-08-01 13:04:55 +02:00
parent 30963d60bc
commit 9253627327
2 changed files with 26 additions and 11 deletions

View File

@ -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
}
/**

View File

@ -1288,6 +1288,8 @@ class Share {
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,
@ -1297,8 +1299,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) {
@ -1374,6 +1383,8 @@ class Share {
} 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,
@ -1383,8 +1394,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) {