summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/carddav/carddavbackend.php
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-02-03 15:43:45 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-02-18 11:48:34 +0100
commitc9187cc82084e5b140f52cbaefa7d71c70f989a0 (patch)
tree20418d39a67ea01c4b31e183fd1334b88d442d66 /apps/dav/lib/carddav/carddavbackend.php
parent73d46afc3c5ef237cc8a5431aa1bef4686a7521b (diff)
downloadnextcloud-server-c9187cc82084e5b140f52cbaefa7d71c70f989a0.tar.gz
nextcloud-server-c9187cc82084e5b140f52cbaefa7d71c70f989a0.zip
Sync a users contacts birthday to the users birthday calendar
Diffstat (limited to 'apps/dav/lib/carddav/carddavbackend.php')
-rw-r--r--apps/dav/lib/carddav/carddavbackend.php34
1 files changed, 33 insertions, 1 deletions
diff --git a/apps/dav/lib/carddav/carddavbackend.php b/apps/dav/lib/carddav/carddavbackend.php
index 78706ae6bff..56fa652d798 100644
--- a/apps/dav/lib/carddav/carddavbackend.php
+++ b/apps/dav/lib/carddav/carddavbackend.php
@@ -37,6 +37,8 @@ use Sabre\DAV\Exception\BadRequest;
use Sabre\HTTP\URLUtil;
use Sabre\VObject\Component\VCard;
use Sabre\VObject\Reader;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use Symfony\Component\EventDispatcher\GenericEvent;
class CardDavBackend implements BackendInterface, SyncSupport {
@@ -64,15 +66,22 @@ class CardDavBackend implements BackendInterface, SyncSupport {
const ACCESS_READ_WRITE = 2;
const ACCESS_READ = 3;
+ /** @var EventDispatcherInterface */
+ private $dispatcher;
+
/**
* CardDavBackend constructor.
*
* @param IDBConnection $db
* @param Principal $principalBackend
+ * @param EventDispatcherInterface $dispatcher
*/
- public function __construct(IDBConnection $db, Principal $principalBackend) {
+ public function __construct(IDBConnection $db,
+ Principal $principalBackend,
+ $dispatcher ) {
$this->db = $db;
$this->principalBackend = $principalBackend;
+ $this->dispatcher = $dispatcher;
$this->sharingBackend = new Backend($this->db, $principalBackend, 'addressbook');
}
@@ -492,6 +501,14 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$this->addChange($addressBookId, $cardUri, 1);
$this->updateProperties($addressBookId, $cardUri, $cardData);
+ if (!is_null($this->dispatcher)) {
+ $this->dispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::createCard',
+ new GenericEvent(null, [
+ 'addressBookId' => $addressBookId,
+ 'cardUri' => $cardUri,
+ 'cardData' => $cardData]));
+ }
+
return '"' . $etag . '"';
}
@@ -536,6 +553,14 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$this->addChange($addressBookId, $cardUri, 2);
$this->updateProperties($addressBookId, $cardUri, $cardData);
+ if (!is_null($this->dispatcher)) {
+ $this->dispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::updateCard',
+ new GenericEvent(null, [
+ 'addressBookId' => $addressBookId,
+ 'cardUri' => $cardUri,
+ 'cardData' => $cardData]));
+ }
+
return '"' . $etag . '"';
}
@@ -560,6 +585,13 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$this->addChange($addressBookId, $cardUri, 3);
+ if (!is_null($this->dispatcher)) {
+ $this->dispatcher->dispatch('\OCA\DAV\CardDAV\CardDavBackend::deleteCard',
+ new GenericEvent(null, [
+ 'addressBookId' => $addressBookId,
+ 'cardUri' => $cardUri]));
+ }
+
if ($ret === 1) {
if ($cardId !== null) {
$this->purgeProperties($addressBookId, $cardId);