fix public calendars
This commit is contained in:
parent
d884370844
commit
8360222554
3 changed files with 22 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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'];
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue