2016-07-08 17:13:34 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
namespace OCA\DAV\CalDAV;
|
|
|
|
|
|
|
|
use Sabre\DAV\Collection;
|
2016-07-31 21:18:35 +03:00
|
|
|
use Sabre\DAV\Exception\NotFound;
|
2016-07-08 17:13:34 +03:00
|
|
|
|
|
|
|
class PublicCalendarRoot extends Collection {
|
|
|
|
|
|
|
|
/** @var CalDavBackend */
|
|
|
|
protected $caldavBackend;
|
|
|
|
|
2016-07-31 21:18:35 +03:00
|
|
|
/** @var \OCP\IL10N */
|
|
|
|
protected $l10n;
|
|
|
|
|
2016-07-08 17:13:34 +03:00
|
|
|
function __construct(CalDavBackend $caldavBackend) {
|
|
|
|
$this->caldavBackend = $caldavBackend;
|
2016-07-31 21:18:35 +03:00
|
|
|
$this->l10n = \OC::$server->getL10N('dav');
|
2016-07-08 17:13:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
function getName() {
|
|
|
|
return 'public-calendars';
|
|
|
|
}
|
|
|
|
|
2016-07-31 21:18:35 +03:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2016-07-08 17:13:34 +03:00
|
|
|
function getChild($name) {
|
2016-08-01 16:07:22 +03:00
|
|
|
return $this->caldavBackend->getPublicCalendar($name);
|
2016-07-08 17:13:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
function getChildren() {
|
|
|
|
$calendars = $this->caldavBackend->getPublicCalendars();
|
|
|
|
$children = [];
|
|
|
|
foreach ($calendars as $calendar) {
|
|
|
|
// TODO: maybe implement a new class PublicCalendar ???
|
2016-07-31 21:18:35 +03:00
|
|
|
$children[] = new Calendar($this->caldavBackend, $calendar, $this->l10n);
|
2016-07-08 17:13:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return $children;
|
|
|
|
}
|
|
|
|
}
|