summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/CalDAV/CalDavBackend.php
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-07-08 16:13:34 +0200
committerLukas Reschke <lukas@statuscode.ch>2016-09-26 11:55:36 +0200
commit90ab6e4fd9b25a8f031f812d46915e8413483be2 (patch)
tree4184b569d30f621484a0301c22e065a2d641ffbb /apps/dav/lib/CalDAV/CalDavBackend.php
parent8da2100e7d5cc7819624a803e10b18f53ccacd9d (diff)
downloadnextcloud-server-90ab6e4fd9b25a8f031f812d46915e8413483be2.tar.gz
nextcloud-server-90ab6e4fd9b25a8f031f812d46915e8413483be2.zip
Add new root collection public-calendars which holds all public calendars
Diffstat (limited to 'apps/dav/lib/CalDAV/CalDavBackend.php')
-rw-r--r--apps/dav/lib/CalDAV/CalDavBackend.php58
1 files changed, 58 insertions, 0 deletions
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php
index b1d85e09808..303e97fd308 100644
--- a/apps/dav/lib/CalDAV/CalDavBackend.php
+++ b/apps/dav/lib/CalDAV/CalDavBackend.php
@@ -118,6 +118,9 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
/** @var IUserManager */
private $userManager;
+
+ /** @var \OCP\IConfig */
+ private $config;
/**
* CalDavBackend constructor.
@@ -131,6 +134,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
$this->principalBackend = $principalBackend;
$this->userManager = $userManager;
$this->sharingBackend = new Backend($this->db, $principalBackend, 'calendar');
+ // TODO: inject
+ $this->config = \OC::$server->getConfig();
}
/**
@@ -283,6 +288,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
return array_values($calendars);
}
+<<<<<<< HEAD
private function getUserDisplayName($uid) {
if (!isset($this->userDisplayNames[$uid])) {
$user = $this->userManager->get($uid);
@@ -295,6 +301,58 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
}
return $this->userDisplayNames[$uid];
+=======
+
+ public function getPublicCalendars() {
+ $fields = array_values($this->propertyMap);
+ $fields[] = 'a.id';
+ $fields[] = 'a.uri';
+ $fields[] = 'a.synctoken';
+ $fields[] = 'a.components';
+ $fields[] = 'a.principaluri';
+ $fields[] = 'a.transparent';
+ $fields[] = 's.access';
+ $calendars = [];
+ $query = $this->db->getQueryBuilder();
+ $result = $query->select($fields)
+ ->from('dav_shares', 's')
+ ->join('s', 'calendars', 'a', $query->expr()->eq('s.resourceid', 'a.id'))
+ ->where($query->expr()->in('s.access', $query->createNamedParameter(self::ACCESS_PUBLIC)))
+ ->andWhere($query->expr()->eq('s.type', $query->createNamedParameter('calendar')))
+ ->execute();
+
+ while($row = $result->fetch()) {
+ list(, $name) = URLUtil::splitPath($row['principaluri']);
+ $row['displayname'] = $row['displayname'] . "($name)";
+ $components = [];
+ if ($row['components']) {
+ $components = explode(',',$row['components']);
+ }
+ $uri = md5($this->config->getSystemValue('secret', '') . $row['id']);
+ $calendar = [
+ 'id' => $row['id'],
+ 'uri' => $uri,
+ 'principaluri' => $row['principaluri'],
+ '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
+ '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
+ '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
+ '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
+ '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'],
+ '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ,
+ ];
+
+ foreach($this->propertyMap as $xmlName=>$dbName) {
+ $calendar[$xmlName] = $row[$dbName];
+ }
+
+ if (!isset($calendars[$calendar['id']])) {
+ $calendars[$calendar['id']] = $calendar;
+ }
+ }
+ $result->closeCursor();
+
+ return array_values($calendars);
+>>>>>>> bf223b9... Add new root collection public-calendars which holds all public calendars
}
/**