Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix public calendars #26112

Merged
merged 3 commits into from Sep 26, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions apps/dav/lib/CalDAV/CalDavBackend.php
Expand Up @@ -1589,6 +1589,23 @@ public function getPublishStatus($calendar) {
return reset($row) > 0;
}

/**
* @param \OCA\DAV\CalDAV\Calendar $calendar
* @return string
*/
public function getPublishToken($calendar) {
$query = $this->db->getQueryBuilder();
$result = $query->select('publicuri')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to add this to the overall loading query where we already join calendar table with the shares table

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workaround. Not the best, but only one request.

->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
Expand Down
4 changes: 4 additions & 0 deletions apps/dav/lib/CalDAV/Calendar.php
Expand Up @@ -266,6 +266,10 @@ function getPublishStatus() {
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'];
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/CalDAV/Publishing/PublishPlugin.php
Expand Up @@ -97,7 +97,7 @@ public function propFind(PropFind $propFind, INode $node) {
$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);
Expand Down