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.

CalendarManager.php 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * @copyright 2017, Georg Ehrke <oc.list@georgehrke.com>
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Georg Ehrke <oc.list@georgehrke.com>
  7. * @author Morris Jobke <hey@morrisjobke.de>
  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 OCP\Calendar\IManager;
  27. use OCP\IConfig;
  28. use OCP\IL10N;
  29. class CalendarManager {
  30. /** @var CalDavBackend */
  31. private $backend;
  32. /** @var IL10N */
  33. private $l10n;
  34. /** @var IConfig */
  35. private $config;
  36. /**
  37. * CalendarManager constructor.
  38. *
  39. * @param CalDavBackend $backend
  40. * @param IL10N $l10n
  41. * @param IConfig $config
  42. */
  43. public function __construct(CalDavBackend $backend, IL10N $l10n, IConfig $config) {
  44. $this->backend = $backend;
  45. $this->l10n = $l10n;
  46. $this->config = $config;
  47. }
  48. /**
  49. * @param IManager $cm
  50. * @param string $userId
  51. */
  52. public function setupCalendarProvider(IManager $cm, $userId) {
  53. $calendars = $this->backend->getCalendarsForUser("principals/users/$userId");
  54. $this->register($cm, $calendars);
  55. }
  56. /**
  57. * @param IManager $cm
  58. * @param array $calendars
  59. */
  60. private function register(IManager $cm, array $calendars) {
  61. foreach ($calendars as $calendarInfo) {
  62. $calendar = new Calendar($this->backend, $calendarInfo, $this->l10n, $this->config);
  63. $cm->registerCalendar(new CalendarImpl(
  64. $calendar,
  65. $calendarInfo,
  66. $this->backend
  67. ));
  68. }
  69. }
  70. }