diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-11-16 15:49:46 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-11-16 15:49:46 +0100 |
commit | 867fd94dc663652da1465de8537f01b8c7b4db07 (patch) | |
tree | b7c682e73246f51a04faea271c3a01d870f20974 /apps/dav/lib | |
parent | 23e7a62717fe6ee84c54ce1d3c601b477119696e (diff) | |
download | nextcloud-server-867fd94dc663652da1465de8537f01b8c7b4db07.tar.gz nextcloud-server-867fd94dc663652da1465de8537f01b8c7b4db07.zip |
Add scheduling backend
Diffstat (limited to 'apps/dav/lib')
-rw-r--r-- | apps/dav/lib/caldav/caldavbackend.php | 58 |
1 files changed, 54 insertions, 4 deletions
diff --git a/apps/dav/lib/caldav/caldavbackend.php b/apps/dav/lib/caldav/caldavbackend.php index 6dd60c43336..4dcd1bed3de 100644 --- a/apps/dav/lib/caldav/caldavbackend.php +++ b/apps/dav/lib/caldav/caldavbackend.php @@ -982,7 +982,26 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription * @return array */ function getSchedulingObject($principalUri, $objectUri) { - // TODO: Implement getSchedulingObject() method. + $query = $this->db->getQueryBuilder(); + $stmt = $query->select(['uri', 'calendardata', 'lastmodified', 'etag', 'size']) + ->from('schedulingobjects') + ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))) + ->andWhere($query->expr()->eq('uri', $query->createNamedParameter($objectUri))) + ->execute(); + + $row = $stmt->fetch(\PDO::FETCH_ASSOC); + + if(!$row) { + return null; + } + + return [ + 'uri' => $row['uri'], + 'calendardata' => $row['calendardata'], + 'lastmodified' => $row['lastmodified'], + 'etag' => '"' . $row['etag'] . '"', + 'size' => (int)$row['size'], + ]; } /** @@ -997,7 +1016,24 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription * @return array */ function getSchedulingObjects($principalUri) { - // TODO: Implement getSchedulingObjects() method. + $query = $this->db->getQueryBuilder(); + $stmt = $query->select(['uri', 'calendardata', 'lastmodified', 'etag', 'size']) + ->from('schedulingobjects') + ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))) + ->execute(); + + $result = []; + foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { + $result[] = [ + 'calendardata' => $row['calendardata'], + 'uri' => $row['uri'], + 'lastmodified' => $row['lastmodified'], + 'etag' => '"' . $row['etag'] . '"', + 'size' => (int)$row['size'], + ]; + } + + return $result; } /** @@ -1008,7 +1044,11 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription * @return void */ function deleteSchedulingObject($principalUri, $objectUri) { - // TODO: Implement deleteSchedulingObject() method. + $query = $this->db->getQueryBuilder(); + $query->delete('schedulingobjects') + ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))) + ->andWhere($query->expr()->eq('uri', $query->createNamedParameter($objectUri))) + ->execute(); } /** @@ -1020,7 +1060,17 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription * @return void */ function createSchedulingObject($principalUri, $objectUri, $objectData) { - // TODO: Implement createSchedulingObject() method. + $query = $this->db->getQueryBuilder(); + $query->insert('schedulingobjects') + ->values([ + 'principaluri' => $query->createNamedParameter($principalUri), + 'calendardata' => $query->createNamedParameter($objectData), + 'uri' => $query->createNamedParameter($objectUri), + 'lastmodified' => $query->createNamedParameter(time()), + 'etag' => $query->createNamedParameter(md5($objectData)), + 'size' => $query->createNamedParameter(strlen($objectData)) + ]) + ->execute(); } /** |