示例#1
0
 /**
  * Creates a new calendar or subscription.
  *
  * @param string $name
  * @param MkCol $mkCol
  * @throws DAV\Exception\InvalidResourceType
  * @return void
  */
 function createExtendedCollection($name, MkCol $mkCol)
 {
     $isCalendar = false;
     $isSubscription = false;
     foreach ($mkCol->getResourceType() as $rt) {
         switch ($rt) {
             case '{DAV:}collection':
             case '{http://calendarserver.org/ns/}shared-owner':
                 // ignore
                 break;
             case '{urn:ietf:params:xml:ns:caldav}calendar':
                 $isCalendar = true;
                 break;
             case '{http://calendarserver.org/ns/}subscribed':
                 $isSubscription = true;
                 break;
             default:
                 throw new DAV\Exception\InvalidResourceType('Unknown resourceType: ' . $rt);
         }
     }
     $properties = $mkCol->getRemainingValues();
     $mkCol->setRemainingResultCode(201);
     if ($isSubscription) {
         if (!$this->caldavBackend instanceof Backend\SubscriptionSupport) {
             throw new DAV\Exception\InvalidResourceType('This backend does not support subscriptions');
         }
         $this->caldavBackend->createSubscription($this->principalInfo['uri'], $name, $properties);
     } elseif ($isCalendar) {
         $this->caldavBackend->createCalendar($this->principalInfo['uri'], $name, $properties);
     } else {
         throw new DAV\Exception\InvalidResourceType('You can only create calendars and subscriptions in this collection');
     }
 }
示例#2
0
 /**
  * Creates a new address book.
  *
  * @param string $name
  * @param MkCol $mkCol
  * @throws DAV\Exception\InvalidResourceType
  * @return void
  */
 function createExtendedCollection($name, MkCol $mkCol)
 {
     if (!$mkCol->hasResourceType('{' . Plugin::NS_CARDDAV . '}addressbook')) {
         throw new DAV\Exception\InvalidResourceType('Unknown resourceType for this collection');
     }
     $properties = $mkCol->getRemainingValues();
     $mkCol->setRemainingResultCode(201);
     $this->carddavBackend->createAddressBook($this->principalUri, $name, $properties);
 }