summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2016-07-06 15:09:27 +0200
committerLukas Reschke <lukas@statuscode.ch>2016-09-26 11:55:34 +0200
commit1652a74febd10e56ec15fc90c93350fb48c796c4 (patch)
treefe7750854fce193bc70573057f7ffaf6d6f04989 /apps
parent981c38f6d91be5a6de0ad319028afc3a4e931a2e (diff)
downloadnextcloud-server-1652a74febd10e56ec15fc90c93350fb48c796c4.tar.gz
nextcloud-server-1652a74febd10e56ec15fc90c93350fb48c796c4.zip
Fix publish-url property & getPublishStatus() fct
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/CalDAV/CalDavBackend.php9
-rw-r--r--apps/dav/lib/CalDAV/Publishing/PublishPlugin.php25
-rw-r--r--apps/dav/lib/CalDAV/Publishing/Xml/Publisher.php4
3 files changed, 20 insertions, 18 deletions
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php
index 43466b235e5..8c651251106 100644
--- a/apps/dav/lib/CalDAV/CalDavBackend.php
+++ b/apps/dav/lib/CalDAV/CalDavBackend.php
@@ -1501,13 +1501,16 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
*/
public function getPublishStatus($calendar) {
$query = $this->db->getQueryBuilder();
- $result = $query->select(['principaluri', 'access'])
+ $result = $query->select('count(id)')
->from('dav_shares')
->where($query->expr()->eq('resourceid', $query->createNamedParameter($calendar->getResourceId())))
- ->andWhere($query->expr()->eq('type', $query->createNamedParameter(self::CLASSIFICATION_PUBLIC)))
+ ->andWhere($query->expr()->eq('access', $query->createNamedParameter(self::ACCESS_PUBLIC)))
->execute();
- return count($result->fetch()) > 0;
+ $row = $result->fetch();
+ $result->closeCursor();
+
+ return $row;
}
/**
diff --git a/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php b/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php
index b1c42624201..f0be2f3a1b6 100644
--- a/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php
+++ b/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php
@@ -72,19 +72,18 @@ class PublishPlugin extends ServerPlugin
public function propFind(PropFind $propFind, INode $node)
{
if ($node instanceof Calendar) {
- $token = md5(\OC::$server->getConfig()->getSystemValue('secret', '').$node->getName());
-
- $propFind->handle('{'.self::NS_CALENDARSERVER.'}publish-url', function () use ($node, $token) {
- if ($node->getPublishStatus()) {
- return new Publisher($token, $node->getPublishStatus());
- }
- });
-
- $propFind->handle('{'.self::NS_CALENDARSERVER.'}pre-publish-url', function () use ($node, $token) {
- if ($node->getPublishStatus()) {
- return new Publisher($token, false);
- }
- });
+ $token = md5(\OC::$server->getConfig()->getSystemValue('secret', '').$node->getName());
+ $publishUrl = $this->server->getBaseUri() . 'public-calendars/' . $token;
+
+ $propFind->handle('{'.self::NS_CALENDARSERVER.'}publish-url', function () use ($node, $publishUrl) {
+ if ($node->getPublishStatus()) {
+ return new Publisher($publishUrl, $node->getPublishStatus());
+ }
+ });
+
+ $propFind->handle('{'.self::NS_CALENDARSERVER.'}pre-publish-url', function () use ($node, $publishUrl) {
+ return new Publisher($publishUrl, false);
+ });
}
}
diff --git a/apps/dav/lib/CalDAV/Publishing/Xml/Publisher.php b/apps/dav/lib/CalDAV/Publishing/Xml/Publisher.php
index 008b5df9125..6a0d8b2ec0c 100644
--- a/apps/dav/lib/CalDAV/Publishing/Xml/Publisher.php
+++ b/apps/dav/lib/CalDAV/Publishing/Xml/Publisher.php
@@ -57,9 +57,9 @@ class Publisher implements XmlSerializable {
$cs = '{' . Plugin::NS_CALENDARSERVER . '}';
if (!$this->isPublished) {
- $writer->write($this->publishUrl);
+ $writer->write($this->publishUrl); // for pre-publish-url
} else {
- $writer->writeElement('{DAV:}href', $this->publishUrl);
+ $writer->writeElement('{DAV:}href', $this->publishUrl); // for publish-url
}
}