diff options
author | Joas Schilling <coding@schilljs.com> | 2016-10-07 13:44:02 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2016-11-03 12:07:58 +0100 |
commit | 9a7c522cc6c6b371f3e51ce92910740ceaa2c633 (patch) | |
tree | 26e123f7de151048fd10c3737ef428796d0ab1e0 /apps | |
parent | 83d51afab1eabfdad50c6408aa6a030d8727227c (diff) | |
download | nextcloud-server-9a7c522cc6c6b371f3e51ce92910740ceaa2c633.tar.gz nextcloud-server-9a7c522cc6c6b371f3e51ce92910740ceaa2c633.zip |
Add activity for unshare from group
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/lib/CalDAV/Activity.php | 11 | ||||
-rw-r--r-- | apps/dav/lib/CalDAV/CalDavBackend.php | 26 |
2 files changed, 37 insertions, 0 deletions
diff --git a/apps/dav/lib/CalDAV/Activity.php b/apps/dav/lib/CalDAV/Activity.php index fbdc7b054d7..10945f887bc 100644 --- a/apps/dav/lib/CalDAV/Activity.php +++ b/apps/dav/lib/CalDAV/Activity.php @@ -39,6 +39,7 @@ class Activity implements IExtension { const SUBJECT_UPDATE = 'calendar_update'; const SUBJECT_DELETE = 'calendar_delete'; const SUBJECT_UNSHARE_USER = 'calendar_user_unshare'; + const SUBJECT_UNSHARE_GROUP = 'calendar_group_unshare'; /** * Subject keys for translation of the subjections @@ -148,6 +149,8 @@ class Activity implements IExtension { return (string) $l->t('You unshared calendar %2$s from %1$s', $params); case self::SUBJECT_UNSHARE_USER . '_by': 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); } return false; @@ -168,8 +171,11 @@ class Activity implements IExtension { if ($app === self::APP) { switch ($text) { case self::SUBJECT_ADD: + case self::SUBJECT_ADD . '_self': case self::SUBJECT_DELETE: + case self::SUBJECT_DELETE . '_self': case self::SUBJECT_UPDATE: + case self::SUBJECT_UPDATE . '_self': case self::SUBJECT_UNSHARE_USER: case self::SUBJECT_UNSHARE_USER . '_you': case self::SUBJECT_UNSHARE_USER . '_by': @@ -177,6 +183,11 @@ class Activity implements IExtension { 0 => 'username', //1 => 'calendar', ]; + case self::SUBJECT_UNSHARE_GROUP . '_you': + return [ + //0 => 'group', + //1 => 'calendar', + ]; } } diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index 25cb3ce484d..a707b2c5afa 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -1833,6 +1833,32 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription ); $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'], + ] + ); + $aM->publish($event); + } + } + } + + protected function triggerActivityUnshareGroup($gid, IEvent $event, array $properties) { + $gM = \OC::$server->getGroupManager(); + + $group = $gM->get($gid); + if ($group instanceof IGroup) { + foreach ($group->getUsers() as $user) { + // Exclude current user + if ($user !== $event->getAuthor()) { + $this->triggerActivityUnshareUser($user->getUID(), $event, $properties); + } } } } |