UserAddressBooks.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Thomas Müller <thomas.mueller@tmit.eu>
  6. *
  7. * @license AGPL-3.0
  8. *
  9. * This code is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License, version 3,
  11. * as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License, version 3,
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>
  20. *
  21. */
  22. namespace OCA\DAV\CardDAV;
  23. class UserAddressBooks extends \Sabre\CardDAV\AddressBookHome {
  24. /**
  25. * Returns a list of addressbooks
  26. *
  27. * @return array
  28. */
  29. function getChildren() {
  30. $addressBooks = $this->carddavBackend->getAddressBooksForUser($this->principalUri);
  31. $objects = [];
  32. foreach($addressBooks as $addressBook) {
  33. $objects[] = new AddressBook($this->carddavBackend, $addressBook);
  34. }
  35. return $objects;
  36. }
  37. /**
  38. * Returns a list of ACE's for this node.
  39. *
  40. * Each ACE has the following properties:
  41. * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
  42. * currently the only supported privileges
  43. * * 'principal', a url to the principal who owns the node
  44. * * 'protected' (optional), indicating that this ACE is not allowed to
  45. * be updated.
  46. *
  47. * @return array
  48. */
  49. function getACL() {
  50. $acl = parent::getACL();
  51. if ($this->principalUri === 'principals/system/system') {
  52. $acl[] = [
  53. 'privilege' => '{DAV:}read',
  54. 'principal' => '{DAV:}authenticated',
  55. 'protected' => true,
  56. ];
  57. }
  58. return $acl;
  59. }
  60. }