/** * This function handles the MKCALENDAR HTTP method, which creates * a new calendar. * * @param string $uri * @return void */ public function httpMkCalendar($uri) { // Due to unforgivable bugs in iCal, we're completely disabling MKCALENDAR support // for clients matching iCal in the user agent //$ua = $this->server->httpRequest->getHeader('User-Agent'); //if (strpos($ua,'iCal/')!==false) { // throw new Sabre_DAV_Exception_Forbidden('iCal has major bugs in it\'s RFC3744 support. Therefore we are left with no other choice but disabling this feature.'); //} $body = $this->server->httpRequest->getBody(true); $properties = array(); if ($body) { $dom = Sabre_DAV_XMLUtil::loadDOMDocument($body); foreach ($dom->firstChild->childNodes as $child) { if (Sabre_DAV_XMLUtil::toClarkNotation($child) !== '{DAV:}set') { continue; } foreach (Sabre_DAV_XMLUtil::parseProperties($child, $this->server->propertyMap) as $k => $prop) { $properties[$k] = $prop; } } } $resourceType = array('{DAV:}collection', '{urn:ietf:params:xml:ns:caldav}calendar'); $this->server->createCollection($uri, $resourceType, $properties); $this->server->httpResponse->sendStatus(201); $this->server->httpResponse->setHeader('Content-Length', 0); }
/** * This method allows us to intercept the 'mkcalendar' sabreAction. This * action enables the user to create new calendars from the browser plugin. * * @param string $uri * @param string $action * @param array $postVars * @return bool */ public function browserPostAction($uri, $action, array $postVars) { if ($action !== 'mkaddressbook') { return; } $resourceType = array('{DAV:}collection', '{urn:ietf:params:xml:ns:carddav}addressbook'); $properties = array(); if (isset($postVars['{DAV:}displayname'])) { $properties['{DAV:}displayname'] = $postVars['{DAV:}displayname']; } $this->server->createCollection($uri . '/' . $postVars['name'], $resourceType, $properties); return false; }