/** * Creates a new collection. * * This method will receive a MkCol object with all the information about * the new collection that's being created. * * The MkCol object contains information about the resourceType of the new * collection. If you don't support the specified resourceType, you should * throw Exception\InvalidResourceType. * * The object also contains a list of WebDAV properties for the new * collection. * * You should call the handle() method on this object to specify exactly * which properties you are storing. This allows the system to figure out * exactly which properties you didn't store, which in turn allows other * plugins (such as the propertystorage plugin) to handle storing the * property for you. * * @param string $name * @param MkCol $mkCol * @throws Exception\InvalidResourceType * @return void */ function createExtendedCollection($name, MkCol $mkCol) { if (!$mkCol->hasResourceType('{DAV:}principal')) { throw new InvalidResourceType('Only resources of type {DAV:}principal may be created here'); } $this->principalBackend->createPrincipal($this->principalPrefix . '/' . $name, $mkCol); }
/** * 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'); } }
/** * 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); }