diff options
author | Joas Schilling <coding@schilljs.com> | 2016-10-13 09:19:14 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2016-11-03 12:07:58 +0100 |
commit | 35ce4c772c38a5a10ac18440734f0d38b96f73ae (patch) | |
tree | e013d0492ff278d354852f308f8cdb2b0379cc10 /apps | |
parent | 9a7c522cc6c6b371f3e51ce92910740ceaa2c633 (diff) | |
download | nextcloud-server-35ce4c772c38a5a10ac18440734f0d38b96f73ae.tar.gz nextcloud-server-35ce4c772c38a5a10ac18440734f0d38b96f73ae.zip |
Fix unshare actions for author != owner
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/lib/CalDAV/Activity.php | 16 | ||||
-rw-r--r-- | apps/dav/lib/CalDAV/CalDavBackend.php | 54 |
2 files changed, 54 insertions, 16 deletions
diff --git a/apps/dav/lib/CalDAV/Activity.php b/apps/dav/lib/CalDAV/Activity.php index 10945f887bc..d42e9704a88 100644 --- a/apps/dav/lib/CalDAV/Activity.php +++ b/apps/dav/lib/CalDAV/Activity.php @@ -148,9 +148,13 @@ class Activity implements IExtension { case self::SUBJECT_UNSHARE_USER . '_you': return (string) $l->t('You unshared calendar %2$s from %1$s', $params); case self::SUBJECT_UNSHARE_USER . '_by': + return (string) $l->t('%3$s unshared calendar %2$s from %1$s', $params); + case self::SUBJECT_UNSHARE_USER . '_self': return (string) $l->t('%1$s unshared calendar %2$s from themselves', $params); case self::SUBJECT_UNSHARE_GROUP . '_you': return (string) $l->t('You unshared calendar %2$s from group %1$s', $params); + case self::SUBJECT_UNSHARE_GROUP . '_by': + return (string) $l->t('%3$s unshared calendar %2$s from group %1$s', $params); } return false; @@ -178,16 +182,28 @@ class Activity implements IExtension { case self::SUBJECT_UPDATE . '_self': case self::SUBJECT_UNSHARE_USER: case self::SUBJECT_UNSHARE_USER . '_you': + case self::SUBJECT_UNSHARE_USER . '_self': + return [ + 0 => 'username', + //1 => 'calendar', + ]; case self::SUBJECT_UNSHARE_USER . '_by': return [ 0 => 'username', //1 => 'calendar', + 2 => 'username', ]; case self::SUBJECT_UNSHARE_GROUP . '_you': return [ //0 => 'group', //1 => 'calendar', ]; + case self::SUBJECT_UNSHARE_GROUP . '_by': + return [ + //0 => 'group', + //1 => 'calendar', + 2 => 'username', + ]; } } diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index a707b2c5afa..3e1f720cd01 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -1823,27 +1823,49 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $this->triggerActivityUnshareUser($principal[2], $event, $properties); if ($owner !== $principal[2]) { + $parameters = [ + $principal[2], + $properties['{DAV:}displayname'], + ]; + + if ($owner === $event->getAuthor()) { + $subject = Activity::SUBJECT_UNSHARE_USER . '_you'; + } else if ($principal[2] === $event->getAuthor()) { + $subject = Activity::SUBJECT_UNSHARE_USER . '_self'; + } else { + $event->setAffectedUser($event->getAuthor()) + ->setSubject(Activity::SUBJECT_UNSHARE_USER . '_you', $parameters); + $aM->publish($event); + + $subject = Activity::SUBJECT_UNSHARE_USER . '_by'; + $parameters[] = $event->getAuthor(); + } + $event->setAffectedUser($owner) - ->setSubject( - $owner === $event->getAuthor() ? Activity::SUBJECT_UNSHARE_USER . '_you' : Activity::SUBJECT_UNSHARE_USER . '_by', - [ - $principal[2], - $properties['{DAV:}displayname'], - ] - ); + ->setSubject($subject, $parameters); $aM->publish($event); } } else if ($principal[1] === 'groups') { $this->triggerActivityUnshareGroup($principal[2], $event, $properties); - $event->setAffectedUser($currentUser) - ->setSubject( - Activity::SUBJECT_UNSHARE_GROUP . '_you', - [ - $principal[2], - $properties['{DAV:}displayname'], - ] - ); + $parameters = [ + $principal[2], + $properties['{DAV:}displayname'], + ]; + + if ($owner === $event->getAuthor()) { + $subject = Activity::SUBJECT_UNSHARE_GROUP . '_you'; + } else { + $event->setAffectedUser($event->getAuthor()) + ->setSubject(Activity::SUBJECT_UNSHARE_GROUP . '_you', $parameters); + $aM->publish($event); + + $subject = Activity::SUBJECT_UNSHARE_GROUP . '_by'; + $parameters[] = $event->getAuthor(); + } + + $event->setAffectedUser($owner) + ->setSubject($subject, $parameters); $aM->publish($event); } } @@ -1856,7 +1878,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription if ($group instanceof IGroup) { foreach ($group->getUsers() as $user) { // Exclude current user - if ($user !== $event->getAuthor()) { + if ($user->getUID() !== $event->getAuthor()) { $this->triggerActivityUnshareUser($user->getUID(), $event, $properties); } } |