PageRenderTime 60ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/lib/Sabre/CalDAV/Plugin.php

https://github.com/KOLANICH/SabreDAV
PHP | 1387 lines | 733 code | 291 blank | 363 comment | 102 complexity | d5503b292457e3a8da3edbe1199227c6 MD5 | raw file
Possible License(s): BSD-3-Clause

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. namespace Sabre\CalDAV;
  3. use
  4. Sabre\DAV,
  5. Sabre\DAVACL,
  6. Sabre\VObject;
  7. /**
  8. * CalDAV plugin
  9. *
  10. * This plugin provides functionality added by CalDAV (RFC 4791)
  11. * It implements new reports, and the MKCALENDAR method.
  12. *
  13. * @copyright Copyright (C) 2007-2013 fruux GmbH (https://fruux.com/).
  14. * @author Evert Pot (http://evertpot.com/)
  15. * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
  16. */
  17. class Plugin extends DAV\ServerPlugin {
  18. /**
  19. * This is the official CalDAV namespace
  20. */
  21. const NS_CALDAV = 'urn:ietf:params:xml:ns:caldav';
  22. /**
  23. * This is the namespace for the proprietary calendarserver extensions
  24. */
  25. const NS_CALENDARSERVER = 'http://calendarserver.org/ns/';
  26. /**
  27. * The hardcoded root for calendar objects. It is unfortunate
  28. * that we're stuck with it, but it will have to do for now
  29. */
  30. const CALENDAR_ROOT = 'calendars';
  31. /**
  32. * Reference to server object
  33. *
  34. * @var DAV\Server
  35. */
  36. protected $server;
  37. /**
  38. * The email handler for invites and other scheduling messages.
  39. *
  40. * @var Schedule\IMip
  41. */
  42. protected $imipHandler;
  43. /**
  44. * Sets the iMIP handler.
  45. *
  46. * iMIP = The email transport of iCalendar scheduling messages. Setting
  47. * this is optional, but if you want the server to allow invites to be sent
  48. * out, you must set a handler.
  49. *
  50. * Specifically iCal will plain assume that the server supports this. If
  51. * the server doesn't, iCal will display errors when inviting people to
  52. * events.
  53. *
  54. * @param Schedule\IMip $imipHandler
  55. * @return void
  56. */
  57. public function setIMipHandler(Schedule\IMip $imipHandler) {
  58. $this->imipHandler = $imipHandler;
  59. }
  60. /**
  61. * Use this method to tell the server this plugin defines additional
  62. * HTTP methods.
  63. *
  64. * This method is passed a uri. It should only return HTTP methods that are
  65. * available for the specified uri.
  66. *
  67. * @param string $uri
  68. * @return array
  69. */
  70. public function getHTTPMethods($uri) {
  71. // The MKCALENDAR is only available on unmapped uri's, whose
  72. // parents extend IExtendedCollection
  73. list($parent, $name) = DAV\URLUtil::splitPath($uri);
  74. $node = $this->server->tree->getNodeForPath($parent);
  75. if ($node instanceof DAV\IExtendedCollection) {
  76. try {
  77. $node->getChild($name);
  78. } catch (DAV\Exception\NotFound $e) {
  79. return array('MKCALENDAR');
  80. }
  81. }
  82. return array();
  83. }
  84. /**
  85. * Returns the path to a principal's calendar home.
  86. *
  87. * The return url must not end with a slash.
  88. *
  89. * @param string $principalUrl
  90. * @return string
  91. */
  92. public function getCalendarHomeForPrincipal($principalUrl) {
  93. // The default is a bit naive, but it can be overwritten.
  94. list(, $nodeName) = DAV\URLUtil::splitPath($principalUrl);
  95. return self::CALENDAR_ROOT . '/' . $nodeName;
  96. }
  97. /**
  98. * Returns a list of features for the DAV: HTTP header.
  99. *
  100. * @return array
  101. */
  102. public function getFeatures() {
  103. return array('calendar-access', 'calendar-proxy');
  104. }
  105. /**
  106. * Returns a plugin name.
  107. *
  108. * Using this name other plugins will be able to access other plugins
  109. * using DAV\Server::getPlugin
  110. *
  111. * @return string
  112. */
  113. public function getPluginName() {
  114. return 'caldav';
  115. }
  116. /**
  117. * Returns a list of reports this plugin supports.
  118. *
  119. * This will be used in the {DAV:}supported-report-set property.
  120. * Note that you still need to subscribe to the 'report' event to actually
  121. * implement them
  122. *
  123. * @param string $uri
  124. * @return array
  125. */
  126. public function getSupportedReportSet($uri) {
  127. $node = $this->server->tree->getNodeForPath($uri);
  128. $reports = array();
  129. if ($node instanceof ICalendar || $node instanceof ICalendarObject) {
  130. $reports[] = '{' . self::NS_CALDAV . '}calendar-multiget';
  131. $reports[] = '{' . self::NS_CALDAV . '}calendar-query';
  132. }
  133. if ($node instanceof ICalendar) {
  134. $reports[] = '{' . self::NS_CALDAV . '}free-busy-query';
  135. }
  136. // iCal has a bug where it assumes that sync support is enabled, only
  137. // if we say we support it on the calendar-home, even though this is
  138. // not actually the case.
  139. if ($node instanceof UserCalendars && $this->server->getPlugin('sync')) {
  140. $reports[] = '{DAV:}sync-collection';
  141. }
  142. return $reports;
  143. }
  144. /**
  145. * Initializes the plugin
  146. *
  147. * @param DAV\Server $server
  148. * @return void
  149. */
  150. public function initialize(DAV\Server $server) {
  151. $this->server = $server;
  152. $server->subscribeEvent('unknownMethod',array($this,'unknownMethod'));
  153. //$server->subscribeEvent('unknownMethod',array($this,'unknownMethod2'),1000);
  154. $server->subscribeEvent('report',array($this,'report'));
  155. $server->subscribeEvent('beforeGetProperties',array($this,'beforeGetProperties'));
  156. $server->subscribeEvent('onHTMLActionsPanel', array($this,'htmlActionsPanel'));
  157. $server->subscribeEvent('onBrowserPostAction', array($this,'browserPostAction'));
  158. $server->subscribeEvent('beforeWriteContent', array($this, 'beforeWriteContent'));
  159. $server->subscribeEvent('beforeCreateFile', array($this, 'beforeCreateFile'));
  160. $server->subscribeEvent('beforeMethod', array($this,'beforeMethod'));
  161. $server->xmlNamespaces[self::NS_CALDAV] = 'cal';
  162. $server->xmlNamespaces[self::NS_CALENDARSERVER] = 'cs';
  163. $server->propertyMap['{' . self::NS_CALDAV . '}supported-calendar-component-set'] = 'Sabre\\CalDAV\\Property\\SupportedCalendarComponentSet';
  164. $server->propertyMap['{' . self::NS_CALDAV . '}schedule-calendar-transp'] = 'Sabre\\CalDAV\\Property\\ScheduleCalendarTransp';
  165. $server->resourceTypeMapping['\\Sabre\\CalDAV\\ICalendar'] = '{urn:ietf:params:xml:ns:caldav}calendar';
  166. $server->resourceTypeMapping['\\Sabre\\CalDAV\\Schedule\\IOutbox'] = '{urn:ietf:params:xml:ns:caldav}schedule-outbox';
  167. $server->resourceTypeMapping['\\Sabre\\CalDAV\\Principal\\IProxyRead'] = '{http://calendarserver.org/ns/}calendar-proxy-read';
  168. $server->resourceTypeMapping['\\Sabre\\CalDAV\\Principal\\IProxyWrite'] = '{http://calendarserver.org/ns/}calendar-proxy-write';
  169. $server->resourceTypeMapping['\\Sabre\\CalDAV\\Notifications\\ICollection'] = '{' . self::NS_CALENDARSERVER . '}notification';
  170. array_push($server->protectedProperties,
  171. '{' . self::NS_CALDAV . '}supported-calendar-component-set',
  172. '{' . self::NS_CALDAV . '}supported-calendar-data',
  173. '{' . self::NS_CALDAV . '}max-resource-size',
  174. '{' . self::NS_CALDAV . '}min-date-time',
  175. '{' . self::NS_CALDAV . '}max-date-time',
  176. '{' . self::NS_CALDAV . '}max-instances',
  177. '{' . self::NS_CALDAV . '}max-attendees-per-instance',
  178. '{' . self::NS_CALDAV . '}calendar-home-set',
  179. '{' . self::NS_CALDAV . '}supported-collation-set',
  180. '{' . self::NS_CALDAV . '}calendar-data',
  181. // scheduling extension
  182. '{' . self::NS_CALDAV . '}schedule-inbox-URL',
  183. '{' . self::NS_CALDAV . '}schedule-outbox-URL',
  184. '{' . self::NS_CALDAV . '}calendar-user-address-set',
  185. '{' . self::NS_CALDAV . '}calendar-user-type',
  186. // CalendarServer extensions
  187. '{' . self::NS_CALENDARSERVER . '}getctag',
  188. '{' . self::NS_CALENDARSERVER . '}calendar-proxy-read-for',
  189. '{' . self::NS_CALENDARSERVER . '}calendar-proxy-write-for',
  190. '{' . self::NS_CALENDARSERVER . '}notification-URL',
  191. '{' . self::NS_CALENDARSERVER . '}notificationtype'
  192. );
  193. }
  194. /**
  195. * This function handles support for the MKCALENDAR method
  196. *
  197. * @param string $method
  198. * @param string $uri
  199. * @return bool
  200. */
  201. public function unknownMethod($method, $uri) {
  202. switch ($method) {
  203. case 'MKCALENDAR' :
  204. $this->httpMkCalendar($uri);
  205. // false is returned to stop the propagation of the
  206. // unknownMethod event.
  207. return false;
  208. case 'POST' :
  209. // Checking if this is a text/calendar content type
  210. $contentType = $this->server->httpRequest->getHeader('Content-Type');
  211. if (strpos($contentType, 'text/calendar')!==0) {
  212. return;
  213. }
  214. // Checking if we're talking to an outbox
  215. try {
  216. $node = $this->server->tree->getNodeForPath($uri);
  217. } catch (DAV\Exception\NotFound $e) {
  218. return;
  219. }
  220. if (!$node instanceof Schedule\IOutbox)
  221. return;
  222. $this->server->transactionType = 'post-caldav-outbox';
  223. $this->outboxRequest($node, $uri);
  224. return false;
  225. }
  226. }
  227. /**
  228. * This functions handles REPORT requests specific to CalDAV
  229. *
  230. * @param string $reportName
  231. * @param \DOMNode $dom
  232. * @return bool
  233. */
  234. public function report($reportName,$dom) {
  235. switch($reportName) {
  236. case '{'.self::NS_CALDAV.'}calendar-multiget' :
  237. $this->server->transactionType = 'report-calendar-multiget';
  238. $this->calendarMultiGetReport($dom);
  239. return false;
  240. case '{'.self::NS_CALDAV.'}calendar-query' :
  241. $this->server->transactionType = 'report-calendar-query';
  242. $this->calendarQueryReport($dom);
  243. return false;
  244. case '{'.self::NS_CALDAV.'}free-busy-query' :
  245. $this->server->transactionType = 'report-free-busy-query';
  246. $this->freeBusyQueryReport($dom);
  247. return false;
  248. }
  249. }
  250. /**
  251. * This function handles the MKCALENDAR HTTP method, which creates
  252. * a new calendar.
  253. *
  254. * @param string $uri
  255. * @return void
  256. */
  257. public function httpMkCalendar($uri) {
  258. // Due to unforgivable bugs in iCal, we're completely disabling MKCALENDAR support
  259. // for clients matching iCal in the user agent
  260. //$ua = $this->server->httpRequest->getHeader('User-Agent');
  261. //if (strpos($ua,'iCal/')!==false) {
  262. // 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.');
  263. //}
  264. $body = $this->server->httpRequest->getBody(true);
  265. $properties = array();
  266. if ($body) {
  267. $dom = DAV\XMLUtil::loadDOMDocument($body);
  268. foreach($dom->firstChild->childNodes as $child) {
  269. if (DAV\XMLUtil::toClarkNotation($child)!=='{DAV:}set') continue;
  270. foreach(DAV\XMLUtil::parseProperties($child,$this->server->propertyMap) as $k=>$prop) {
  271. $properties[$k] = $prop;
  272. }
  273. }
  274. }
  275. $resourceType = array('{DAV:}collection','{urn:ietf:params:xml:ns:caldav}calendar');
  276. $this->server->createCollection($uri,$resourceType,$properties);
  277. $this->server->httpResponse->sendStatus(201);
  278. $this->server->httpResponse->setHeader('Content-Length',0);
  279. }
  280. /**
  281. * beforeGetProperties
  282. *
  283. * This method handler is invoked before any after properties for a
  284. * resource are fetched. This allows us to add in any CalDAV specific
  285. * properties.
  286. *
  287. * @param string $path
  288. * @param DAV\INode $node
  289. * @param array $requestedProperties
  290. * @param array $returnedProperties
  291. * @return void
  292. */
  293. public function beforeGetProperties($path, DAV\INode $node, &$requestedProperties, &$returnedProperties) {
  294. if ($node instanceof DAVACL\IPrincipal) {
  295. $principalUrl = $node->getPrincipalUrl();
  296. // calendar-home-set property
  297. $calHome = '{' . self::NS_CALDAV . '}calendar-home-set';
  298. if (in_array($calHome,$requestedProperties)) {
  299. $calendarHomePath = $this->getCalendarHomeForPrincipal($principalUrl) . '/';
  300. unset($requestedProperties[array_search($calHome, $requestedProperties)]);
  301. $returnedProperties[200][$calHome] = new DAV\Property\Href($calendarHomePath);
  302. }
  303. // schedule-outbox-URL property
  304. $scheduleProp = '{' . self::NS_CALDAV . '}schedule-outbox-URL';
  305. if (in_array($scheduleProp,$requestedProperties)) {
  306. $calendarHomePath = $this->getCalendarHomeForPrincipal($principalUrl);
  307. $outboxPath = $calendarHomePath . '/outbox';
  308. unset($requestedProperties[array_search($scheduleProp, $requestedProperties)]);
  309. $returnedProperties[200][$scheduleProp] = new DAV\Property\Href($outboxPath);
  310. }
  311. // calendar-user-address-set property
  312. $calProp = '{' . self::NS_CALDAV . '}calendar-user-address-set';
  313. if (in_array($calProp,$requestedProperties)) {
  314. $addresses = $node->getAlternateUriSet();
  315. $addresses[] = $this->server->getBaseUri() . $node->getPrincipalUrl() . '/';
  316. unset($requestedProperties[array_search($calProp, $requestedProperties)]);
  317. $returnedProperties[200][$calProp] = new DAV\Property\HrefList($addresses, false);
  318. }
  319. // These two properties are shortcuts for ical to easily find
  320. // other principals this principal has access to.
  321. $propRead = '{' . self::NS_CALENDARSERVER . '}calendar-proxy-read-for';
  322. $propWrite = '{' . self::NS_CALENDARSERVER . '}calendar-proxy-write-for';
  323. if (in_array($propRead,$requestedProperties) || in_array($propWrite,$requestedProperties)) {
  324. $aclPlugin = $this->server->getPlugin('acl');
  325. $membership = $aclPlugin->getPrincipalMembership($path);
  326. $readList = array();
  327. $writeList = array();
  328. foreach($membership as $group) {
  329. $groupNode = $this->server->tree->getNodeForPath($group);
  330. // If the node is either ap proxy-read or proxy-write
  331. // group, we grab the parent principal and add it to the
  332. // list.
  333. if ($groupNode instanceof Principal\IProxyRead) {
  334. list($readList[]) = DAV\URLUtil::splitPath($group);
  335. }
  336. if ($groupNode instanceof Principal\IProxyWrite) {
  337. list($writeList[]) = DAV\URLUtil::splitPath($group);
  338. }
  339. }
  340. if (in_array($propRead,$requestedProperties)) {
  341. unset($requestedProperties[$propRead]);
  342. $returnedProperties[200][$propRead] = new DAV\Property\HrefList($readList);
  343. }
  344. if (in_array($propWrite,$requestedProperties)) {
  345. unset($requestedProperties[$propWrite]);
  346. $returnedProperties[200][$propWrite] = new DAV\Property\HrefList($writeList);
  347. }
  348. }
  349. // notification-URL property
  350. $notificationUrl = '{' . self::NS_CALENDARSERVER . '}notification-URL';
  351. if (($index = array_search($notificationUrl, $requestedProperties)) !== false) {
  352. $principalId = $node->getName();
  353. $notificationPath = $this->getCalendarHomeForPrincipal($principalUrl) . '/notifications/';
  354. unset($requestedProperties[$index]);
  355. $returnedProperties[200][$notificationUrl] = new DAV\Property\Href($notificationPath);
  356. }
  357. } // instanceof IPrincipal
  358. if ($node instanceof Notifications\INode) {
  359. $propertyName = '{' . self::NS_CALENDARSERVER . '}notificationtype';
  360. if (($index = array_search($propertyName, $requestedProperties)) !== false) {
  361. $returnedProperties[200][$propertyName] =
  362. $node->getNotificationType();
  363. unset($requestedProperties[$index]);
  364. }
  365. } // instanceof Notifications_INode
  366. if ($node instanceof ICalendarObject) {
  367. // The calendar-data property is not supposed to be a 'real'
  368. // property, but in large chunks of the spec it does act as such.
  369. // Therefore we simply expose it as a property.
  370. $calDataProp = '{' . Plugin::NS_CALDAV . '}calendar-data';
  371. if (in_array($calDataProp, $requestedProperties)) {
  372. unset($requestedProperties[$calDataProp]);
  373. $val = $node->get();
  374. if (is_resource($val))
  375. $val = stream_get_contents($val);
  376. // Taking out \r to not screw up the xml output
  377. $returnedProperties[200][$calDataProp] = str_replace("\r","", $val);
  378. }
  379. }
  380. }
  381. /**
  382. * This function handles the calendar-multiget REPORT.
  383. *
  384. * This report is used by the client to fetch the content of a series
  385. * of urls. Effectively avoiding a lot of redundant requests.
  386. *
  387. * @param \DOMNode $dom
  388. * @return void
  389. */
  390. public function calendarMultiGetReport($dom) {
  391. $properties = array_keys(DAV\XMLUtil::parseProperties($dom->firstChild));
  392. $hrefElems = $dom->getElementsByTagNameNS('urn:DAV','href');
  393. $xpath = new \DOMXPath($dom);
  394. $xpath->registerNameSpace('cal',Plugin::NS_CALDAV);
  395. $xpath->registerNameSpace('dav','urn:DAV');
  396. $expand = $xpath->query('/cal:calendar-multiget/dav:prop/cal:calendar-data/cal:expand');
  397. if ($expand->length>0) {
  398. $expandElem = $expand->item(0);
  399. $start = $expandElem->getAttribute('start');
  400. $end = $expandElem->getAttribute('end');
  401. if(!$start || !$end) {
  402. throw new DAV\Exception\BadRequest('The "start" and "end" attributes are required for the CALDAV:expand element');
  403. }
  404. $start = VObject\DateTimeParser::parseDateTime($start);
  405. $end = VObject\DateTimeParser::parseDateTime($end);
  406. if ($end <= $start) {
  407. throw new DAV\Exception\BadRequest('The end-date must be larger than the start-date in the expand element.');
  408. }
  409. $expand = true;
  410. } else {
  411. $expand = false;
  412. }
  413. $uris = [];
  414. foreach($hrefElems as $elem) {
  415. $uris[] = $this->server->calculateUri($elem->nodeValue);
  416. }
  417. foreach($this->server->getPropertiesForMultiplePaths($uris, $properties) as $uri=>$objProps) {
  418. if ($expand && isset($objProps[200]['{' . self::NS_CALDAV . '}calendar-data'])) {
  419. $vObject = VObject\Reader::read($objProps[200]['{' . self::NS_CALDAV . '}calendar-data']);
  420. $vObject->expand($start, $end);
  421. $objProps[200]['{' . self::NS_CALDAV . '}calendar-data'] = $vObject->serialize();
  422. }
  423. $propertyList[]=$objProps;
  424. }
  425. $prefer = $this->server->getHTTPPRefer();
  426. $this->server->httpResponse->sendStatus(207);
  427. $this->server->httpResponse->setHeader('Content-Type','application/xml; charset=utf-8');
  428. $this->server->httpResponse->setHeader('Vary','Brief,Prefer');
  429. $this->server->httpResponse->sendBody($this->server->generateMultiStatus($propertyList, $prefer['return-minimal']));
  430. }
  431. /**
  432. * This function handles the calendar-query REPORT
  433. *
  434. * This report is used by clients to request calendar objects based on
  435. * complex conditions.
  436. *
  437. * @param \DOMNode $dom
  438. * @return void
  439. */
  440. public function calendarQueryReport($dom) {
  441. $parser = new CalendarQueryParser($dom);
  442. $parser->parse();
  443. $node = $this->server->tree->getNodeForPath($this->server->getRequestUri());
  444. $depth = $this->server->getHTTPDepth(0);
  445. // The default result is an empty array
  446. $result = array();
  447. // The calendarobject was requested directly. In this case we handle
  448. // this locally.
  449. if ($depth == 0 && $node instanceof ICalendarObject) {
  450. $requestedCalendarData = true;
  451. $requestedProperties = $parser->requestedProperties;
  452. if (!in_array('{urn:ietf:params:xml:ns:caldav}calendar-data', $requestedProperties)) {
  453. // We always retrieve calendar-data, as we need it for filtering.
  454. $requestedProperties[] = '{urn:ietf:params:xml:ns:caldav}calendar-data';
  455. // If calendar-data wasn't explicitly requested, we need to remove
  456. // it after processing.
  457. $requestedCalendarData = false;
  458. }
  459. $properties = $this->server->getPropertiesForPath(
  460. $this->server->getRequestUri(),
  461. $requestedProperties,
  462. 0
  463. );
  464. // This array should have only 1 element, the first calendar
  465. // object.
  466. $properties = current($properties);
  467. // If there wasn't any calendar-data returned somehow, we ignore
  468. // this.
  469. if (isset($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data'])) {
  470. $validator = new CalendarQueryValidator();
  471. $vObject = VObject\Reader::read($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']);
  472. if ($validator->validate($vObject,$parser->filters)) {
  473. // If the client didn't require the calendar-data property,
  474. // we won't give it back.
  475. if (!$requestedCalendarData) {
  476. unset($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']);
  477. } else {
  478. if ($parser->expand) {
  479. $vObject->expand($parser->expand['start'], $parser->expand['end']);
  480. $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = $vObject->serialize();
  481. }
  482. }
  483. $result = array($properties);
  484. }
  485. }
  486. }
  487. // If we're dealing with a calendar, the calendar itself is responsible
  488. // for the calendar-query.
  489. if ($node instanceof ICalendar && $depth = 1) {
  490. $nodePaths = $node->calendarQuery($parser->filters);
  491. foreach($nodePaths as $path) {
  492. list($properties) =
  493. $this->server->getPropertiesForPath($this->server->getRequestUri() . '/' . $path, $parser->requestedProperties);
  494. if ($parser->expand) {
  495. // We need to do some post-processing
  496. $vObject = VObject\Reader::read($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']);
  497. $vObject->expand($parser->expand['start'], $parser->expand['end']);
  498. $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = $vObject->serialize();
  499. }
  500. $result[] = $properties;
  501. }
  502. }
  503. $prefer = $this->server->getHTTPPRefer();
  504. $this->server->httpResponse->sendStatus(207);
  505. $this->server->httpResponse->setHeader('Content-Type','application/xml; charset=utf-8');
  506. $this->server->httpResponse->setHeader('Vary','Brief,Prefer');
  507. $this->server->httpResponse->sendBody($this->server->generateMultiStatus($result, $prefer['return-minimal']));
  508. }
  509. /**
  510. * This method is responsible for parsing the request and generating the
  511. * response for the CALDAV:free-busy-query REPORT.
  512. *
  513. * @param \DOMNode $dom
  514. * @return void
  515. */
  516. protected function freeBusyQueryReport(\DOMNode $dom) {
  517. $start = null;
  518. $end = null;
  519. foreach($dom->firstChild->childNodes as $childNode) {
  520. $clark = DAV\XMLUtil::toClarkNotation($childNode);
  521. if ($clark == '{' . self::NS_CALDAV . '}time-range') {
  522. $start = $childNode->getAttribute('start');
  523. $end = $childNode->getAttribute('end');
  524. break;
  525. }
  526. }
  527. if ($start) {
  528. $start = VObject\DateTimeParser::parseDateTime($start);
  529. }
  530. if ($end) {
  531. $end = VObject\DateTimeParser::parseDateTime($end);
  532. }
  533. if (!$start && !$end) {
  534. throw new DAV\Exception\BadRequest('The freebusy report must have a time-range filter');
  535. }
  536. $acl = $this->server->getPlugin('acl');
  537. if (!$acl) {
  538. throw new DAV\Exception('The ACL plugin must be loaded for free-busy queries to work');
  539. }
  540. $uri = $this->server->getRequestUri();
  541. $acl->checkPrivileges($uri,'{' . self::NS_CALDAV . '}read-free-busy');
  542. $calendar = $this->server->tree->getNodeForPath($uri);
  543. if (!$calendar instanceof ICalendar) {
  544. throw new DAV\Exception\NotImplemented('The free-busy-query REPORT is only implemented on calendars');
  545. }
  546. // Doing a calendar-query first, to make sure we get the most
  547. // performance.
  548. $urls = $calendar->calendarQuery(array(
  549. 'name' => 'VCALENDAR',
  550. 'comp-filters' => array(
  551. array(
  552. 'name' => 'VEVENT',
  553. 'comp-filters' => array(),
  554. 'prop-filters' => array(),
  555. 'is-not-defined' => false,
  556. 'time-range' => array(
  557. 'start' => $start,
  558. 'end' => $end,
  559. ),
  560. ),
  561. ),
  562. 'prop-filters' => array(),
  563. 'is-not-defined' => false,
  564. 'time-range' => null,
  565. ));
  566. $objects = array_map(function($url) use ($calendar) {
  567. $obj = $calendar->getChild($url)->get();
  568. return $obj;
  569. }, $urls);
  570. $generator = new VObject\FreeBusyGenerator();
  571. $generator->setObjects($objects);
  572. $generator->setTimeRange($start, $end);
  573. $result = $generator->getResult();
  574. $result = $result->serialize();
  575. $this->server->httpResponse->sendStatus(200);
  576. $this->server->httpResponse->setHeader('Content-Type', 'text/calendar');
  577. $this->server->httpResponse->setHeader('Content-Length', strlen($result));
  578. $this->server->httpResponse->sendBody($result);
  579. }
  580. /**
  581. * This method is triggered before a file gets updated with new content.
  582. *
  583. * This plugin uses this method to ensure that CalDAV objects receive
  584. * valid calendar data.
  585. *
  586. * @param string $path
  587. * @param DAV\IFile $node
  588. * @param resource $data
  589. * @param bool $modified Should be set to true, if this event handler
  590. * changed &$data.
  591. * @return void
  592. */
  593. public function beforeWriteContent($path, DAV\IFile $node, &$data, &$modified) {
  594. if (!$node instanceof ICalendarObject)
  595. return;
  596. $this->validateICalendar($data, $path, $modified);
  597. }
  598. /**
  599. * This method is triggered before a new file is created.
  600. *
  601. * This plugin uses this method to ensure that newly created calendar
  602. * objects contain valid calendar data.
  603. *
  604. * @param string $path
  605. * @param resource $data
  606. * @param DAV\ICollection $parentNode
  607. * @param bool $modified Should be set to true, if this event handler
  608. * changed &$data.
  609. * @return void
  610. */
  611. public function beforeCreateFile($path, &$data, DAV\ICollection $parentNode, &$modified) {
  612. if (!$parentNode instanceof Calendar)
  613. return;
  614. $this->validateICalendar($data, $path, $modified);
  615. }
  616. /**
  617. * This event is triggered before any HTTP request is handled.
  618. *
  619. * We use this to intercept GET calls to notification nodes, and return the
  620. * proper response.
  621. *
  622. * @param string $method
  623. * @param string $path
  624. * @return void
  625. */
  626. public function beforeMethod($method, $path) {
  627. if ($method!=='GET') return;
  628. try {
  629. $node = $this->server->tree->getNodeForPath($path);
  630. } catch (DAV\Exception\NotFound $e) {
  631. return;
  632. }
  633. if (!$node instanceof Notifications\INode)
  634. return;
  635. if (!$this->server->checkPreconditions(true)) return false;
  636. $dom = new \DOMDocument('1.0', 'UTF-8');
  637. $dom->formatOutput = true;
  638. $root = $dom->createElement('cs:notification');
  639. foreach($this->server->xmlNamespaces as $namespace => $prefix) {
  640. $root->setAttribute('xmlns:' . $prefix, $namespace);
  641. }
  642. $dom->appendChild($root);
  643. $node->getNotificationType()->serializeBody($this->server, $root);
  644. $this->server->httpResponse->setHeader('Content-Type','application/xml');
  645. $this->server->httpResponse->setHeader('ETag',$node->getETag());
  646. $this->server->httpResponse->sendStatus(200);
  647. $this->server->httpResponse->sendBody($dom->saveXML());
  648. return false;
  649. }
  650. /**
  651. * Checks if the submitted iCalendar data is in fact, valid.
  652. *
  653. * An exception is thrown if it's not.
  654. *
  655. * @param resource|string $data
  656. * @param string $path
  657. * @param bool $modified Should be set to true, if this event handler
  658. * changed &$data.
  659. * @return void
  660. */
  661. protected function validateICalendar(&$data, $path, &$modified) {
  662. // If it's a stream, we convert it to a string first.
  663. if (is_resource($data)) {
  664. $data = stream_get_contents($data);
  665. }
  666. $before = md5($data);
  667. // Converting the data to unicode, if needed.
  668. $data = DAV\StringUtil::ensureUTF8($data);
  669. if ($before!==md5($data)) $modified = true;
  670. try {
  671. $vobj = VObject\Reader::read($data);
  672. } catch (VObject\ParseException $e) {
  673. throw new DAV\Exception\UnsupportedMediaType('This resource only supports valid iCalendar 2.0 data. Parse error: ' . $e->getMessage());
  674. }
  675. if ($vobj->name !== 'VCALENDAR') {
  676. throw new DAV\Exception\UnsupportedMediaType('This collection can only support iCalendar objects.');
  677. }
  678. // Get the Supported Components for the target calendar
  679. list($parentPath,$object) = DAV\URLUtil::splitPath($path);
  680. $calendarProperties = $this->server->getProperties($parentPath,array('{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set'));
  681. $supportedComponents = $calendarProperties['{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set']->getValue();
  682. $foundType = null;
  683. $foundUID = null;
  684. foreach($vobj->getComponents() as $component) {
  685. switch($component->name) {
  686. case 'VTIMEZONE' :
  687. continue 2;
  688. case 'VEVENT' :
  689. case 'VTODO' :
  690. case 'VJOURNAL' :
  691. if (is_null($foundType)) {
  692. $foundType = $component->name;
  693. if (!in_array($foundType, $supportedComponents)) {
  694. throw new Exception\InvalidComponentType('This calendar only supports ' . implode(', ', $supportedComponents) . '. We found a ' . $foundType);
  695. }
  696. if (!isset($component->UID)) {
  697. throw new DAV\Exception\BadRequest('Every ' . $component->name . ' component must have an UID');
  698. }
  699. $foundUID = (string)$component->UID;
  700. } else {
  701. if ($foundType !== $component->name) {
  702. throw new DAV\Exception\BadRequest('A calendar object must only contain 1 component. We found a ' . $component->name . ' as well as a ' . $foundType);
  703. }
  704. if ($foundUID !== (string)$component->UID) {
  705. throw new DAV\Exception\BadRequest('Every ' . $component->name . ' in this object must have identical UIDs');
  706. }
  707. }
  708. break;
  709. default :
  710. throw new DAV\Exception\BadRequest('You are not allowed to create components of type: ' . $component->name . ' here');
  711. }
  712. }
  713. if (!$foundType)
  714. throw new DAV\Exception\BadRequest('iCalendar object must contain at least 1 of VEVENT, VTODO or VJOURNAL');
  715. }
  716. /**
  717. * This method handles POST requests to the schedule-outbox.
  718. *
  719. * Currently, two types of requests are support:
  720. * * FREEBUSY requests from RFC 6638
  721. * * Simple iTIP messages from draft-desruisseaux-caldav-sched-04
  722. *
  723. * The latter is from an expired early draft of the CalDAV scheduling
  724. * extensions, but iCal depends on a feature from that spec, so we
  725. * implement it.
  726. *
  727. * @param Schedule\IOutbox $outboxNode
  728. * @param string $outboxUri
  729. * @return void
  730. */
  731. public function outboxRequest(Schedule\IOutbox $outboxNode, $outboxUri) {
  732. // Parsing the request body
  733. try {
  734. $vObject = VObject\Reader::read($this->server->httpRequest->getBody(true));
  735. } catch (VObject\ParseException $e) {
  736. throw new DAV\Exception\BadRequest('The request body must be a valid iCalendar object. Parse error: ' . $e->getMessage());
  737. }
  738. // The incoming iCalendar object must have a METHOD property, and a
  739. // component. The combination of both determines what type of request
  740. // this is.
  741. $componentType = null;
  742. foreach($vObject->getComponents() as $component) {
  743. if ($component->name !== 'VTIMEZONE') {
  744. $componentType = $component->name;
  745. break;
  746. }
  747. }
  748. if (is_null($componentType)) {
  749. throw new DAV\Exception\BadRequest('We expected at least one VTODO, VJOURNAL, VFREEBUSY or VEVENT component');
  750. }
  751. // Validating the METHOD
  752. $method = strtoupper((string)$vObject->METHOD);
  753. if (!$method) {
  754. throw new DAV\Exception\BadRequest('A METHOD property must be specified in iTIP messages');
  755. }
  756. // So we support two types of requests:
  757. //
  758. // REQUEST with a VFREEBUSY component
  759. // REQUEST, REPLY, ADD, CANCEL on VEVENT components
  760. $acl = $this->server->getPlugin('acl');
  761. if ($componentType === 'VFREEBUSY' && $method === 'REQUEST') {
  762. $acl && $acl->checkPrivileges($outboxUri,'{' . Plugin::NS_CALDAV . '}schedule-query-freebusy');
  763. $this->handleFreeBusyRequest($outboxNode, $vObject);
  764. } elseif ($componentType === 'VEVENT' && in_array($method, array('REQUEST','REPLY','ADD','CANCEL'))) {
  765. $acl && $acl->checkPrivileges($outboxUri,'{' . Plugin::NS_CALDAV . '}schedule-post-vevent');
  766. $this->handleEventNotification($outboxNode, $vObject);
  767. } else {
  768. throw new DAV\Exception\NotImplemented('SabreDAV supports only VFREEBUSY (REQUEST) and VEVENT (REQUEST, REPLY, ADD, CANCEL)');
  769. }
  770. }
  771. /**
  772. * This method handles the REQUEST, REPLY, ADD and CANCEL methods for
  773. * VEVENT iTip messages.
  774. *
  775. * @return void
  776. */
  777. protected function handleEventNotification(Schedule\IOutbox $outboxNode, VObject\Component $vObject) {
  778. $originator = $this->server->httpRequest->getHeader('Originator');
  779. $recipients = $this->server->httpRequest->getHeader('Recipient');
  780. if (!$originator) {
  781. throw new DAV\Exception\BadRequest('The Originator: header must be specified when making POST requests');
  782. }
  783. if (!$recipients) {
  784. throw new DAV\Exception\BadRequest('The Recipient: header must be specified when making POST requests');
  785. }
  786. $recipients = explode(',',$recipients);
  787. foreach($recipients as $k=>$recipient) {
  788. $recipient = trim($recipient);
  789. if (!preg_match('/^mailto:(.*)@(.*)$/i', $recipient)) {
  790. throw new DAV\Exception\BadRequest('Recipients must start with mailto: and must be valid email address');
  791. }
  792. $recipient = substr($recipient, 7);
  793. $recipients[$k] = $recipient;
  794. }
  795. // We need to make sure that 'originator' matches the currently
  796. // authenticated user.
  797. $aclPlugin = $this->server->getPlugin('acl');
  798. if (is_null($aclPlugin)) throw new DAV\Exception('The ACL plugin must be loaded for scheduling to work');
  799. $principal = $aclPlugin->getCurrentUserPrincipal();
  800. $props = $this->server->getProperties($principal,array(
  801. '{' . self::NS_CALDAV . '}calendar-user-address-set',
  802. ));
  803. $addresses = array();
  804. if (isset($props['{' . self::NS_CALDAV . '}calendar-user-address-set'])) {
  805. $addresses = $props['{' . self::NS_CALDAV . '}calendar-user-address-set']->getHrefs();
  806. }
  807. $found = false;
  808. foreach($addresses as $address) {
  809. // Trimming the / on both sides, just in case..
  810. if (rtrim(strtolower($originator),'/') === rtrim(strtolower($address),'/')) {
  811. $found = true;
  812. break;
  813. }
  814. }
  815. if (!$found) {
  816. throw new DAV\Exception\Forbidden('The addresses specified in the Originator header did not match any addresses in the owners calendar-user-address-set header');
  817. }
  818. // If the Originator header was a url, and not a mailto: address..
  819. // we're going to try to pull the mailto: from the vobject body.
  820. if (strtolower(substr($originator,0,7)) !== 'mailto:') {
  821. $originator = (string)$vObject->VEVENT->ORGANIZER;
  822. }
  823. if (strtolower(substr($originator,0,7)) !== 'mailto:') {
  824. throw new DAV\Exception\Forbidden('Could not find mailto: address in both the Orignator header, and the ORGANIZER property in the VEVENT');
  825. }
  826. $originator = substr($originator,7);
  827. $result = $this->iMIPMessage($originator, $recipients, $vObject, $principal);
  828. $this->server->httpResponse->sendStatus(200);
  829. $this->server->httpResponse->setHeader('Content-Type','application/xml');
  830. $this->server->httpResponse->sendBody($this->generateScheduleResponse($result));
  831. }
  832. /**
  833. * Sends an iMIP message by email.
  834. *
  835. * This method must return an array with status codes per recipient.
  836. * This should look something like:
  837. *
  838. * array(
  839. * 'user1@example.org' => '2.0;Success'
  840. * )
  841. *
  842. * Formatting for this status code can be found at:
  843. * https://tools.ietf.org/html/rfc5545#section-3.8.8.3
  844. *
  845. * A list of valid status codes can be found at:
  846. * https://tools.ietf.org/html/rfc5546#section-3.6
  847. *
  848. * @param string $originator
  849. * @param array $recipients
  850. * @param VObject\Component $vObject
  851. * @param string $principal Principal url
  852. * @return array
  853. */
  854. protected function iMIPMessage($originator, array $recipients, VObject\Component $vObject, $principal) {
  855. if (!$this->imipHandler) {
  856. $resultStatus = '5.2;This server does not support this operation';
  857. } else {
  858. $this->imipHandler->sendMessage($originator, $recipients, $vObject, $principal);
  859. $resultStatus = '2.0;Success';
  860. }
  861. $result = array();
  862. foreach($recipients as $recipient) {
  863. $result[$recipient] = $resultStatus;
  864. }
  865. return $result;
  866. }
  867. /**
  868. * Generates a schedule-response XML body
  869. *
  870. * The recipients array is a key->value list, containing email addresses
  871. * and iTip status codes. See the iMIPMessage method for a description of
  872. * the value.
  873. *
  874. * @param array $recipients
  875. * @return string
  876. */
  877. public function generateScheduleResponse(array $recipients) {
  878. $dom = new \DOMDocument('1.0','utf-8');
  879. $dom->formatOutput = true;
  880. $xscheduleResponse = $dom->createElement('cal:schedule-response');
  881. $dom->appendChild($xscheduleResponse);
  882. foreach($this->server->xmlNamespaces as $namespace=>$prefix) {
  883. $xscheduleResponse->setAttribute('xmlns:' . $prefix, $namespace);
  884. }
  885. foreach($recipients as $recipient=>$status) {
  886. $xresponse = $dom->createElement('cal:response');
  887. $xrecipient = $dom->createElement('cal:recipient');
  888. $xrecipient->appendChild($dom->createTextNode($recipient));
  889. $xresponse->appendChild($xrecipient);
  890. $xrequestStatus = $dom->createElement('cal:request-status');
  891. $xrequestStatus->appendChild($dom->createTextNode($status));
  892. $xresponse->appendChild($xrequestStatus);
  893. $xscheduleResponse->appendChild($xresponse);
  894. }
  895. return $dom->saveXML();
  896. }
  897. /**
  898. * This method is responsible for parsing a free-busy query request and
  899. * returning it's result.
  900. *
  901. * @param Schedule\IOutbox $outbox
  902. * @param string $request
  903. * @return string
  904. */
  905. protected function handleFreeBusyRequest(Schedule\IOutbox $outbox, VObject\Component $vObject) {
  906. $vFreeBusy = $vObject->VFREEBUSY;
  907. $organizer = $vFreeBusy->organizer;
  908. $organizer = (string)$organizer;
  909. // Validating if the organizer matches the owner of the inbox.
  910. $owner = $outbox->getOwner();
  911. $caldavNS = '{' . Plugin::NS_CALDAV . '}';
  912. $uas = $caldavNS . 'calendar-user-address-set';
  913. $props = $this->server->getProperties($owner,array($uas));
  914. if (empty($props[$uas]) || !in_array($organizer, $props[$uas]->getHrefs())) {
  915. throw new DAV\Exception\Forbidden('The organizer in the request did not match any of the addresses for the owner of this inbox');
  916. }
  917. if (!isset($vFreeBusy->ATTENDEE)) {
  918. throw new DAV\Exception\BadRequest('You must at least specify 1 attendee');
  919. }
  920. $attendees = array();
  921. foreach($vFreeBusy->ATTENDEE as $attendee) {
  922. $attendees[]= (string)$attendee;
  923. }
  924. if (!isset($vFreeBusy->DTSTART) || !isset($vFreeBusy->DTEND)) {
  925. throw new DAV\Exception\BadRequest('DTSTART and DTEND must both be specified');
  926. }
  927. $startRange = $vFreeBusy->DTSTART->getDateTime();
  928. $endRange = $vFreeBusy->DTEND->getDateTime();
  929. $results = array();
  930. foreach($attendees as $attendee) {
  931. $results[] = $this->getFreeBusyForEmail($attendee, $startRange, $endRange, $vObject);
  932. }
  933. $dom = new \DOMDocument('1.0','utf-8');
  934. $dom->formatOutput = true;
  935. $scheduleResponse = $dom->createElement('cal:schedule-response');
  936. foreach($this->server->xmlNamespaces as $namespace=>$prefix) {
  937. $scheduleResponse->setAttribute('xmlns:' . $prefix,$namespace);
  938. }
  939. $dom->appendChild($scheduleResponse);
  940. foreach($results as $result) {
  941. $response = $dom->createElement('cal:response');
  942. $recipient = $dom->createElement('cal:recipient');
  943. $recipientHref = $dom->createElement('d:href');
  944. $recipientHref->appendChild($dom->createTextNode($result['href']));
  945. $recipient->appendChild($recipientHref);
  946. $response->appendChild($recipient);
  947. $reqStatus = $dom->createElement('cal:request-status');
  948. $reqStatus->appendChild($dom->createTextNode($result['request-status']));
  949. $response->appendChild($reqStatus);
  950. if (isset($result['calendar-data'])) {
  951. $calendardata = $dom->createElement('cal:calendar-data');
  952. $calendardata->appendChild($dom->createTextNode(str_replace("\r\n","\n",$result['calendar-data']->serialize())));
  953. $response->appendChild($calendardata);
  954. }
  955. $scheduleResponse->appendChild($response);
  956. }
  957. $this->server->httpResponse->sendStatus(200);
  958. $this->server->httpResponse->setHeader('Content-Type','application/xml');
  959. $this->server->httpResponse->sendBody($dom->saveXML());
  960. }
  961. /**
  962. * Returns free-busy information for a specific address. The returned
  963. * data is an array containing the following properties:
  964. *
  965. * calendar-data : A VFREEBUSY VObject
  966. * request-status : an iTip status code.
  967. * href: The principal's email address, as requested
  968. *
  969. * The following request status codes may be returned:
  970. * * 2.0;description
  971. * * 3.7;description
  972. *
  973. * @param string $email address
  974. * @param \DateTime $start
  975. * @param \DateTime $end
  976. * @param VObject\Component $request
  977. * @return array
  978. */
  979. protected function getFreeBusyForEmail($email, \DateTime $start, \DateTime $end, VObject\Component $request) {
  980. $caldavNS = '{' . Plugin::NS_CALDAV . '}';
  981. $aclPlugin = $this->server->getPlugin('acl');
  982. if (substr($email,0,7)==='mailto:') $email = substr($email,7);
  983. $result = $aclPlugin->principalSearch(
  984. array('{http://sabredav.org/ns}email-address' => $email),
  985. array(
  986. '{DAV:}principal-URL', $caldavNS . 'calendar-home-set',
  987. '{http://sabredav.org/ns}email-address',
  988. )
  989. );
  990. if (!count($result)) {
  991. return array(
  992. 'request-status' => '3.7;Could not find principal',
  993. 'href' => 'mailto:' . $email,
  994. );
  995. }
  996. if (!isset($result[0][200][$caldavNS . 'calendar-home-set'])) {
  997. return array(
  998. 'request-status' => '3.7;No calendar-home-set property found',
  999. 'href' => 'mailto:' . $email,
  1000. );
  1001. }
  1002. $homeSet = $result[0][200][$caldavNS . 'calendar-home-set']->getHref();
  1003. // Grabbing the calendar list
  1004. $objects = array();
  1005. foreach($this->server->tree->getNodeForPath($homeSet)->getChildren() as $node) {
  1006. if (!$node instanceof ICalendar) {
  1007. continue;
  1008. }
  1009. $aclPlugin->checkPrivileges($homeSet . $node->getName() ,$caldavNS . 'read-free-busy');
  1010. // Getting the list of object uris within the time-range
  1011. $urls = $node->calendarQuery(array(
  1012. 'name' => 'VCALENDAR',
  1013. 'comp-filters' => array(
  1014. array(
  1015. 'name' => 'VEVENT',
  1016. 'comp-filters' => array(),
  1017. 'prop-filters' => array(),
  1018. 'is-not-defined' => false,
  1019. 'time-range' => array(
  1020. 'start' => $start,
  1021. 'end' => $end,
  1022. ),
  1023. ),
  1024. ),
  1025. 'prop-filters' => array(),
  1026. 'is-not-defined' => false,
  1027. 'time-range' => null,
  1028. ));
  1029. $calObjects = array_map(function($url) use ($node) {
  1030. $obj = $node->getChild($url)->get();
  1031. return $obj;
  1032. }, $urls);
  1033. $objects = array_merge($objects,$calObjects);
  1034. }
  1035. $vcalendar = new VObject\Component\VCalendar();
  1036. $vcalendar->VERSION = '2.0';
  1037. $vcalendar->METHOD = 'REPLY';
  1038. $vcalendar->CALSCALE = 'GREGORIAN';
  1039. $vcalendar->PRODID = '-//SabreDAV//SabreDAV ' . DAV\Version::VERSION . '//EN';
  1040. $generator = new VObject\FreeBusyGenerator();
  1041. $generator->setObjects($objects);
  1042. $generator->setTimeRange($start, $end);
  1043. $generator->setBaseObject($vcalendar);
  1044. $result = $generator->getResult();
  1045. $vcalendar->VFREEBUSY->ATTENDEE = 'mailto:' . $email;
  1046. $vcalendar->VFREEBUSY->UID = (string)$request->VFREEBUSY->UID;
  1047. $vcalendar->VFREEBUSY->ORGANIZER = clone $request->VFREEBUSY->ORGANIZER;
  1048. return array(
  1049. 'calendar-data' => $result,
  1050. 'request-status' => '2.0;Success',
  1051. 'href' => 'mailto:' . $email,
  1052. );
  1053. }
  1054. /**
  1055. * This method is used to generate HTML output for the
  1056. * DAV\Browser\Plugin. This allows us to generate an interface users
  1057. * can use to create new calendars.
  1058. *
  1059. * @param DAV\INode $node
  1060. * @param string $output
  1061. * @return bool
  1062. */
  1063. public function htmlActionsPanel(DAV\INode $node, &$output) {
  1064. if (!$node instanceof UserCalendars)
  1065. return;
  1066. $output.= '<tr><td colspan="2"><form method="post" action="">
  1067. <h3>Create new calendar</h3>
  1068. <input type="hidden" name="sabreAction" value="mkcalendar" />
  1069. <label>Name (uri):</label> <input type="text" name="name" /><br />
  1070. <label>Display name:</label> <input type="text" name="{DAV:}displayname" /><br />
  1071. <input type="submit" value="create" />
  1072. </form>
  1073. </td></tr>';
  1074. return false;
  1075. }
  1076. /**
  1077. * This method allows us to intercept the 'mkcalendar' sabreAction. This
  1078. * action enables the user to create new calendars from the browser plugin.
  1079. *
  1080. * @param string…

Large files files are truncated, but you can click here to view the full file