summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-03-22 10:31:01 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-03-22 10:31:01 +0100
commit9fc371e436e8f99c862e587efe1b682cb0923e83 (patch)
treeae6fb562aeace99736144d2a723951260977ddf8
parent7426be0937d6c79086c69594b203ce297a5650d5 (diff)
parentfdb7c59e6c4ff1441d605fa4e2e3bdb02a9bf605 (diff)
downloadnextcloud-server-9fc371e436e8f99c862e587efe1b682cb0923e83.tar.gz
nextcloud-server-9fc371e436e8f99c862e587efe1b682cb0923e83.zip
Merge pull request #23320 from owncloud/early-creation-of-birthday-calendar
Create the contact birthday calendar right away as soon as the comman…
-rw-r--r--apps/dav/lib/caldav/birthdayservice.php28
1 files changed, 12 insertions, 16 deletions
diff --git a/apps/dav/lib/caldav/birthdayservice.php b/apps/dav/lib/caldav/birthdayservice.php
index 7e1df189c4e..274341949b3 100644
--- a/apps/dav/lib/caldav/birthdayservice.php
+++ b/apps/dav/lib/caldav/birthdayservice.php
@@ -50,8 +50,7 @@ class BirthdayService {
$book = $this->cardDavBackEnd->getAddressBookById($addressBookId);
$principalUri = $book['principaluri'];
- $calendarUri = self::BIRTHDAY_CALENDAR_URI;
- $calendar = $this->ensureCalendarExists($principalUri, $calendarUri, []);
+ $calendar = $this->ensureCalendarExists($principalUri);
$objectUri = $book['uri'] . '-' . $cardUri. '.ics';
$calendarData = $this->buildBirthdayFromContact($cardData);
$existing = $this->calDavBackEnd->getCalendarObject($calendar['id'], $objectUri);
@@ -77,32 +76,27 @@ class BirthdayService {
public function onCardDeleted($addressBookId, $cardUri) {
$book = $this->cardDavBackEnd->getAddressBookById($addressBookId);
$principalUri = $book['principaluri'];
- $calendarUri = self::BIRTHDAY_CALENDAR_URI;
- $calendar = $this->ensureCalendarExists($principalUri, $calendarUri, []);
+ $calendar = $this->ensureCalendarExists($principalUri);
$objectUri = $book['uri'] . '-' . $cardUri. '.ics';
$this->calDavBackEnd->deleteCalendarObject($calendar['id'], $objectUri);
}
/**
* @param string $principal
- * @param string $id
- * @param array $properties
* @return array|null
* @throws \Sabre\DAV\Exception\BadRequest
*/
- public function ensureCalendarExists($principal, $id, $properties) {
- $properties = array_merge([
- '{DAV:}displayname' => 'Contact birthdays',
- '{http://apple.com/ns/ical/}calendar-color' => '#FFFFCA',
- ], $properties);
-
- $book = $this->calDavBackEnd->getCalendarByUri($principal, $id);
+ public function ensureCalendarExists($principal) {
+ $book = $this->calDavBackEnd->getCalendarByUri($principal, self::BIRTHDAY_CALENDAR_URI);
if (!is_null($book)) {
return $book;
}
- $this->calDavBackEnd->createCalendar($principal, $id, $properties);
+ $this->calDavBackEnd->createCalendar($principal, self::BIRTHDAY_CALENDAR_URI, [
+ '{DAV:}displayname' => 'Contact birthdays',
+ '{http://apple.com/ns/ical/}calendar-color' => '#FFFFCA',
+ ]);
- return $this->calDavBackEnd->getCalendarByUri($principal, $id);
+ return $this->calDavBackEnd->getCalendarByUri($principal, self::BIRTHDAY_CALENDAR_URI);
}
/**
@@ -161,7 +155,9 @@ class BirthdayService {
* @param string $user
*/
public function syncUser($user) {
- $books = $this->cardDavBackEnd->getAddressBooksForUser('principals/users/'.$user);
+ $principal = 'principals/users/'.$user;
+ $this->ensureCalendarExists($principal);
+ $books = $this->cardDavBackEnd->getAddressBooksForUser($principal);
foreach($books as $book) {
$cards = $this->cardDavBackEnd->getCards($book['id']);
foreach($cards as $card) {