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.

PublicCalendar.php 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017, Georg Ehrke
  4. *
  5. * @author Gary Kim <gary@garykim.dev>
  6. * @author Georg Ehrke <oc.list@georgehrke.com>
  7. * @author Roeland Jago Douma <roeland@famdouma.nl>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. namespace OCA\DAV\CalDAV;
  26. use Sabre\DAV\Exception\NotFound;
  27. class PublicCalendar extends Calendar {
  28. /**
  29. * @param string $name
  30. * @throws NotFound
  31. * @return PublicCalendarObject
  32. */
  33. public function getChild($name) {
  34. $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name);
  35. if (!$obj) {
  36. throw new NotFound('Calendar object not found');
  37. }
  38. if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) {
  39. throw new NotFound('Calendar object not found');
  40. }
  41. $obj['acl'] = $this->getChildACL();
  42. return new PublicCalendarObject($this->caldavBackend, $this->l10n, $this->calendarInfo, $obj);
  43. }
  44. /**
  45. * @return PublicCalendarObject[]
  46. */
  47. public function getChildren() {
  48. $objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id']);
  49. $children = [];
  50. foreach ($objs as $obj) {
  51. if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) {
  52. continue;
  53. }
  54. $obj['acl'] = $this->getChildACL();
  55. $children[] = new PublicCalendarObject($this->caldavBackend, $this->l10n, $this->calendarInfo, $obj);
  56. }
  57. return $children;
  58. }
  59. /**
  60. * @param string[] $paths
  61. * @return PublicCalendarObject[]
  62. */
  63. public function getMultipleChildren(array $paths) {
  64. $objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths);
  65. $children = [];
  66. foreach ($objs as $obj) {
  67. if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) {
  68. continue;
  69. }
  70. $obj['acl'] = $this->getChildACL();
  71. $children[] = new PublicCalendarObject($this->caldavBackend, $this->l10n, $this->calendarInfo, $obj);
  72. }
  73. return $children;
  74. }
  75. /**
  76. * public calendars are always shared
  77. * @return bool
  78. */
  79. protected function isShared() {
  80. return true;
  81. }
  82. }