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.

UserAddressBooks.php 2.0KB

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