1
0

CalendarRoot.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Georg Ehrke <oc.list@georgehrke.com>
  7. * @author Lukas Reschke <lukas@statuscode.ch>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. * @author Thomas Müller <thomas.mueller@tmit.eu>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. namespace OCA\DAV\CalDAV;
  27. use Psr\Log\LoggerInterface;
  28. use Sabre\CalDAV\Backend;
  29. use Sabre\DAVACL\PrincipalBackend;
  30. class CalendarRoot extends \Sabre\CalDAV\CalendarRoot {
  31. private LoggerInterface $logger;
  32. public function __construct(
  33. PrincipalBackend\BackendInterface $principalBackend,
  34. Backend\BackendInterface $caldavBackend,
  35. $principalPrefix,
  36. LoggerInterface $logger
  37. ) {
  38. parent::__construct($principalBackend, $caldavBackend, $principalPrefix);
  39. $this->logger = $logger;
  40. }
  41. public function getChildForPrincipal(array $principal) {
  42. return new CalendarHome($this->caldavBackend, $principal, $this->logger);
  43. }
  44. public function getName() {
  45. if ($this->principalPrefix === 'principals/calendar-resources' ||
  46. $this->principalPrefix === 'principals/calendar-rooms') {
  47. $parts = explode('/', $this->principalPrefix);
  48. return $parts[1];
  49. }
  50. return parent::getName();
  51. }
  52. }