You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Plugin.php 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud GmbH.
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Georg Ehrke <oc.list@georgehrke.com>
  7. * @author Thomas Müller <thomas.mueller@tmit.eu>
  8. *
  9. * @license AGPL-3.0
  10. *
  11. * This code is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License, version 3,
  13. * as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License, version 3,
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>
  22. *
  23. */
  24. namespace OCA\DAV\CalDAV;
  25. class Plugin extends \Sabre\CalDAV\Plugin {
  26. public const SYSTEM_CALENDAR_ROOT = 'system-calendars';
  27. /**
  28. * Returns the path to a principal's calendar home.
  29. *
  30. * The return url must not end with a slash.
  31. * This function should return null in case a principal did not have
  32. * a calendar home.
  33. *
  34. * @param string $principalUrl
  35. * @return string|null
  36. */
  37. public function getCalendarHomeForPrincipal($principalUrl) {
  38. if (strrpos($principalUrl, 'principals/users', -strlen($principalUrl)) !== false) {
  39. [, $principalId] = \Sabre\Uri\split($principalUrl);
  40. return self::CALENDAR_ROOT . '/' . $principalId;
  41. }
  42. if (strrpos($principalUrl, 'principals/calendar-resources', -strlen($principalUrl)) !== false) {
  43. [, $principalId] = \Sabre\Uri\split($principalUrl);
  44. return self::SYSTEM_CALENDAR_ROOT . '/calendar-resources/' . $principalId;
  45. }
  46. if (strrpos($principalUrl, 'principals/calendar-rooms', -strlen($principalUrl)) !== false) {
  47. [, $principalId] = \Sabre\Uri\split($principalUrl);
  48. return self::SYSTEM_CALENDAR_ROOT . '/calendar-rooms/' . $principalId;
  49. }
  50. }
  51. }