fix public calendars

This commit is contained in:
Thomas Citharel 2016-09-14 11:34:21 +02:00 committed by Lukas Reschke
parent d884370844
commit 8360222554
No known key found for this signature in database
GPG key ID: B9F6980CF6E759B1
3 changed files with 22 additions and 1 deletions

View file

@ -1648,6 +1648,23 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
return reset($row) > 0;
}
/**
* @param \OCA\DAV\CalDAV\Calendar $calendar
* @return string
*/
public function getPublishToken($calendar) {
$query = $this->db->getQueryBuilder();
$result = $query->select('publicuri')
->from('dav_shares')
->where($query->expr()->eq('resourceid', $query->createNamedParameter($calendar->getResourceId())))
->andWhere($query->expr()->eq('access', $query->createNamedParameter(self::ACCESS_PUBLIC)))
->execute();
$row = $result->fetch();
$result->closeCursor();
return reset($row);
}
/**
* @param int $resourceId
* @param array $acl

View file

@ -267,6 +267,10 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
return $this->caldavBackend->getPublishStatus($this);
}
function getPublishToken() {
return $this->caldavBackend->getPublishToken($this);
}
private function canWrite() {
if (isset($this->calendarInfo['{http://owncloud.org/ns}read-only'])) {
return !$this->calendarInfo['{http://owncloud.org/ns}read-only'];

View file

@ -97,7 +97,7 @@ class PublishPlugin extends ServerPlugin {
$propFind->handle('{'.self::NS_CALENDARSERVER.'}publish-url', function () use ($node) {
if ($node->getPublishStatus()) {
// We return the publish-url only if the calendar is published.
$token = $node->getName();
$token = $node->getPublishToken();
$publishUrl = $this->urlGenerator->getAbsoluteURL($this->server->getBaseUri().'public-calendars/').$token;
return new Publisher($publishUrl, true);