Add activity for unshare from group
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
83d51afab1
commit
9a7c522cc6
2 changed files with 37 additions and 0 deletions
|
@ -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',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue