Heavily refactored, including multiple calendars per user and recurring events. Not in an installable state yet, though

This commit is contained in:
Tobias Hößl 2012-07-08 17:12:58 +00:00
parent 4a5e30ec84
commit fefee23e90
78 changed files with 8026 additions and 1205 deletions

View file

@ -1,14 +1,16 @@
<?php
class Sabre_CalDAV_Backend_Mock extends Sabre_CalDAV_Backend_Abstract {
class Sabre_CalDAV_Backend_Mock extends Sabre_CalDAV_Backend_Abstract implements Sabre_CalDAV_Backend_NotificationSupport {
private $calendarData;
private $calendars;
private $notifications;
function __construct(array $calendars, array $calendarData) {
function __construct(array $calendars, array $calendarData, array $notifications = array()) {
$this->calendars = $calendars;
$this->calendarData = $calendarData;
$this->notifications = $notifications;
}
@ -58,7 +60,15 @@ class Sabre_CalDAV_Backend_Mock extends Sabre_CalDAV_Backend_Abstract {
*/
function createCalendar($principalUri,$calendarUri,array $properties) {
throw new Exception('Not implemented');
$id = Sabre_DAV_UUIDUtil::getUUID();
$this->calendars[] = array_merge(array(
'id' => $id,
'principaluri' => $principalUri,
'uri' => $calendarUri,
'{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet(array('VEVENT','VTODO')),
), $properties);
return $id;
}
@ -112,7 +122,11 @@ class Sabre_CalDAV_Backend_Mock extends Sabre_CalDAV_Backend_Abstract {
*/
public function deleteCalendar($calendarId) {
throw new Exception('Not implemented');
foreach($this->calendars as $k=>$calendar) {
if ($calendar['id'] === $calendarId) {
unset($this->calendars[$k]);
}
}
}
@ -227,4 +241,37 @@ class Sabre_CalDAV_Backend_Mock extends Sabre_CalDAV_Backend_Abstract {
}
/**
* Returns a list of notifications for a given principal url.
*
* The returned array should only consist of implementations of
* Sabre_CalDAV_Notifications_INotificationType.
*
* @param string $principalUri
* @return array
*/
public function getNotificationsForPrincipal($principalUri) {
if (isset($this->notifications[$principalUri])) {
return $this->notifications[$principalUri];
}
return array();
}
/**
* This deletes a specific notifcation.
*
* This may be called by a client once it deems a notification handled.
*
* @param string $principalUri
* @param Sabre_CalDAV_Notifications_INotificationType $notification
* @return void
*/
public function deleteNotification($principalUri, Sabre_CalDAV_Notifications_INotificationType $notification) {
throw new Sabre_DAV_Exception_NotImplemented('This doesn\'t work!');
}
}