aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2017-09-20 17:33:51 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2017-12-11 16:28:40 +0100
commit4c32de22bbe8b21477e5d7c5043768ad8ad77d0c (patch)
tree83dc4eb5a61ca3cb25c805be85b8ebb330399808 /apps/dav/lib
parent80b27fdb93ac0c170d0b5e214f67a2eff6c366ad (diff)
downloadnextcloud-server-4c32de22bbe8b21477e5d7c5043768ad8ad77d0c.tar.gz
nextcloud-server-4c32de22bbe8b21477e5d7c5043768ad8ad77d0c.zip
Create activities for (un)publishing calendar events
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/AppInfo/Application.php9
-rw-r--r--apps/dav/lib/CalDAV/Activity/Backend.php10
-rw-r--r--apps/dav/lib/CalDAV/Activity/Provider/Calendar.php9
-rw-r--r--apps/dav/lib/CalDAV/CalDavBackend.php10
4 files changed, 38 insertions, 0 deletions
diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php
index a6ca99bfff5..b38f38044f3 100644
--- a/apps/dav/lib/AppInfo/Application.php
+++ b/apps/dav/lib/AppInfo/Application.php
@@ -178,6 +178,15 @@ class Application extends App {
);
});
+ $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::publishCalendar', function(GenericEvent $event) {
+ /** @var Backend $backend */
+ $backend = $this->getContainer()->query(Backend::class);
+ $backend->onCalendarPublication(
+ $event->getArgument('calendarData'),
+ $event->getArgument('public')
+ );
+ });
+
$listener = function(GenericEvent $event, $eventName) {
/** @var Backend $backend */
$backend = $this->getContainer()->query(Backend::class);
diff --git a/apps/dav/lib/CalDAV/Activity/Backend.php b/apps/dav/lib/CalDAV/Activity/Backend.php
index f1f1b43d53f..9f929dc195b 100644
--- a/apps/dav/lib/CalDAV/Activity/Backend.php
+++ b/apps/dav/lib/CalDAV/Activity/Backend.php
@@ -93,6 +93,16 @@ class Backend {
}
/**
+ * Creates activities when a calendar was (un)published
+ *
+ * @param array $calendarData
+ * @param bool $publishStatus
+ */
+ public function onCalendarPublication(array $calendarData, $publishStatus) {
+ $this->triggerCalendarActivity($publishStatus ? Calendar::SUBJECT_PUBLISH : Calendar::SUBJECT_UNPUBLISH, $calendarData);
+ }
+
+ /**
* Creates activities for all related users when a calendar was touched
*
* @param string $action
diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php b/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php
index 1d524ce354c..2cdb804f91e 100644
--- a/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php
+++ b/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php
@@ -36,6 +36,8 @@ class Calendar extends Base {
const SUBJECT_ADD = 'calendar_add';
const SUBJECT_UPDATE = 'calendar_update';
const SUBJECT_DELETE = 'calendar_delete';
+ const SUBJECT_PUBLISH = 'calendar_publish';
+ const SUBJECT_UNPUBLISH = 'calendar_unpublish';
const SUBJECT_SHARE_USER = 'calendar_user_share';
const SUBJECT_SHARE_GROUP = 'calendar_group_share';
const SUBJECT_UNSHARE_USER = 'calendar_user_unshare';
@@ -105,6 +107,11 @@ class Calendar extends Base {
} else if ($event->getSubject() === self::SUBJECT_UPDATE . '_self') {
$subject = $this->l->t('You updated calendar {calendar}');
+ } else if ($event->getSubject() === self::SUBJECT_PUBLISH . '_self') {
+ $subject = $this->l->t('You published calendar {calendar}');
+ } else if ($event->getSubject() === self::SUBJECT_UNPUBLISH . '_self') {
+ $subject = $this->l->t('You unpublished calendar {calendar}');
+
} else if ($event->getSubject() === self::SUBJECT_SHARE_USER) {
$subject = $this->l->t('{actor} shared calendar {calendar} with you');
} else if ($event->getSubject() === self::SUBJECT_SHARE_USER . '_you') {
@@ -215,6 +222,8 @@ class Calendar extends Base {
case self::SUBJECT_DELETE . '_self':
case self::SUBJECT_UPDATE:
case self::SUBJECT_UPDATE . '_self':
+ case self::SUBJECT_PUBLISH . '_self':
+ case self::SUBJECT_UNPUBLISH . '_self':
case self::SUBJECT_SHARE_USER:
case self::SUBJECT_UNSHARE_USER:
case self::SUBJECT_UNSHARE_USER . '_self':
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php
index 2f591a262a2..2dc9300f156 100644
--- a/apps/dav/lib/CalDAV/CalDavBackend.php
+++ b/apps/dav/lib/CalDAV/CalDavBackend.php
@@ -2151,6 +2151,16 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
* @return string|null
*/
public function setPublishStatus($value, $calendar) {
+
+ $calendarId = $calendar->getResourceId();
+ $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::publishCalendar', new GenericEvent(
+ '\OCA\DAV\CalDAV\CalDavBackend::updateShares',
+ [
+ 'calendarId' => $calendarId,
+ 'calendarData' => $this->getCalendarById($calendarId),
+ 'public' => $value,
+ ]));
+
$query = $this->db->getQueryBuilder();
if ($value) {
$publicUri = $this->random->generate(16, ISecureRandom::CHAR_HUMAN_READABLE);