PublicCalendar.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\DAV\CalDAV;
  7. use Sabre\DAV\Exception\NotFound;
  8. class PublicCalendar extends Calendar {
  9. /**
  10. * @param string $name
  11. * @throws NotFound
  12. * @return PublicCalendarObject
  13. */
  14. public function getChild($name) {
  15. $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name);
  16. if (!$obj) {
  17. throw new NotFound('Calendar object not found');
  18. }
  19. if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) {
  20. throw new NotFound('Calendar object not found');
  21. }
  22. $obj['acl'] = $this->getChildACL();
  23. return new PublicCalendarObject($this->caldavBackend, $this->l10n, $this->calendarInfo, $obj);
  24. }
  25. /**
  26. * @return PublicCalendarObject[]
  27. */
  28. public function getChildren() {
  29. $objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id']);
  30. $children = [];
  31. foreach ($objs as $obj) {
  32. if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) {
  33. continue;
  34. }
  35. $obj['acl'] = $this->getChildACL();
  36. $children[] = new PublicCalendarObject($this->caldavBackend, $this->l10n, $this->calendarInfo, $obj);
  37. }
  38. return $children;
  39. }
  40. /**
  41. * @param string[] $paths
  42. * @return PublicCalendarObject[]
  43. */
  44. public function getMultipleChildren(array $paths) {
  45. $objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths);
  46. $children = [];
  47. foreach ($objs as $obj) {
  48. if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) {
  49. continue;
  50. }
  51. $obj['acl'] = $this->getChildACL();
  52. $children[] = new PublicCalendarObject($this->caldavBackend, $this->l10n, $this->calendarInfo, $obj);
  53. }
  54. return $children;
  55. }
  56. /**
  57. * public calendars are always shared
  58. * @return bool
  59. */
  60. public function isShared() {
  61. return true;
  62. }
  63. }