CalendarRoot.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace Sabre\CalDAV;
  3. use Sabre\DAVACL\PrincipalBackend;
  4. /**
  5. * Calendars collection
  6. *
  7. * This object is responsible for generating a list of calendar-homes for each
  8. * user.
  9. *
  10. * This is the top-most node for the calendars tree. In most servers this class
  11. * represents the "/calendars" path.
  12. *
  13. * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
  14. * @author Evert Pot (http://evertpot.com/)
  15. * @license http://sabre.io/license/ Modified BSD License
  16. */
  17. class CalendarRoot extends \Sabre\DAVACL\AbstractPrincipalCollection {
  18. /**
  19. * CalDAV backend
  20. *
  21. * @var Sabre\CalDAV\Backend\BackendInterface
  22. */
  23. protected $caldavBackend;
  24. /**
  25. * Constructor
  26. *
  27. * This constructor needs both an authentication and a caldav backend.
  28. *
  29. * By default this class will show a list of calendar collections for
  30. * principals in the 'principals' collection. If your main principals are
  31. * actually located in a different path, use the $principalPrefix argument
  32. * to override this.
  33. *
  34. * @param PrincipalBackend\BackendInterface $principalBackend
  35. * @param Backend\BackendInterface $caldavBackend
  36. * @param string $principalPrefix
  37. */
  38. function __construct(PrincipalBackend\BackendInterface $principalBackend, Backend\BackendInterface $caldavBackend, $principalPrefix = 'principals') {
  39. parent::__construct($principalBackend, $principalPrefix);
  40. $this->caldavBackend = $caldavBackend;
  41. }
  42. /**
  43. * Returns the nodename
  44. *
  45. * We're overriding this, because the default will be the 'principalPrefix',
  46. * and we want it to be Sabre\CalDAV\Plugin::CALENDAR_ROOT
  47. *
  48. * @return string
  49. */
  50. function getName() {
  51. return Plugin::CALENDAR_ROOT;
  52. }
  53. /**
  54. * This method returns a node for a principal.
  55. *
  56. * The passed array contains principal information, and is guaranteed to
  57. * at least contain a uri item. Other properties may or may not be
  58. * supplied by the authentication backend.
  59. *
  60. * @param array $principal
  61. * @return \Sabre\DAV\INode
  62. */
  63. function getChildForPrincipal(array $principal) {
  64. return new CalendarHome($this->caldavBackend, $principal);
  65. }
  66. }