aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/CalDAV/Publishing
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2016-07-06 12:39:07 +0200
committerLukas Reschke <lukas@statuscode.ch>2016-09-26 11:55:34 +0200
commit5824c2493b695562e3a58305ff2599819b4de105 (patch)
tree7ee0d1906b4421cb8f158f927b97cb52c103d0e2 /apps/dav/lib/CalDAV/Publishing
parent69d3601dcbb17ea9e2d868144159867a79d8e25c (diff)
downloadnextcloud-server-5824c2493b695562e3a58305ff2599819b4de105.tar.gz
nextcloud-server-5824c2493b695562e3a58305ff2599819b4de105.zip
Make little corrections
Function getPublishedStatus) is not working atm.
Diffstat (limited to 'apps/dav/lib/CalDAV/Publishing')
-rw-r--r--apps/dav/lib/CalDAV/Publishing/PublishPlugin.php45
-rw-r--r--apps/dav/lib/CalDAV/Publishing/Xml/Publisher.php15
2 files changed, 36 insertions, 24 deletions
diff --git a/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php b/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php
index e6a5f0eb32b..b1c42624201 100644
--- a/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php
+++ b/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php
@@ -6,13 +6,12 @@ namespace OCA\DAV\CalDAV\Publishing;
use Sabre\DAV\PropFind;
use Sabre\DAV\INode;
-use OCP\IRequest;
-use Sabre\CalDAV\IShareableCalendar;
use Sabre\DAV\Server;
use Sabre\DAV\ServerPlugin;
use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;
use OCA\DAV\CalDAV\Publishing\Xml\Publisher;
+use OCA\DAV\CalDAV\Calendar;
class PublishPlugin extends ServerPlugin
{
@@ -70,36 +69,42 @@ class PublishPlugin extends ServerPlugin
$this->server->on('propFind', [$this, 'propFind']);
}
- function propFind(PropFind $propFind, INode $node) {
- if ($node instanceof IShareableCalendar) {
- $token = md5(\OC::$server->getConfig()->getSystemValue('secret','') . $node->getName());
- // $propFind->handle('{' . self::NS_CALENDARSERVER . '}publish-url', function() use ($node, $token) {
- // return new Publisher($token);
- // });
+ 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 . '}pre-publish-url', function() use ($node, $token) {
+ $propFind->handle('{'.self::NS_CALENDARSERVER.'}publish-url', function () use ($node, $token) {
if ($node->getPublishStatus()) {
- return new Publisher($token);
+ 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);
+ }
+ });
+ }
}
- }
/**
* We intercept this to handle POST requests on calendars.
*
* @param RequestInterface $request
* @param ResponseInterface $response
+ *
* @return null|bool
*/
- function httpPost(RequestInterface $request, ResponseInterface $response) {
-
+ public function httpPost(RequestInterface $request, ResponseInterface $response)
+ {
$path = $request->getPath();
// Only handling xml
$contentType = $request->getHeader('Content-Type');
- if (strpos($contentType, 'application/xml') === false && strpos($contentType, 'text/xml') === false)
+ if (strpos($contentType, 'application/xml') === false && strpos($contentType, 'text/xml') === false) {
return;
+ }
// Making sure the node exists
try {
@@ -123,11 +128,10 @@ class PublishPlugin extends ServerPlugin
switch ($documentType) {
-
- case '{' . self::NS_CALENDARSERVER . '}publish-calendar' :
+ case '{'.self::NS_CALENDARSERVER.'}publish-calendar' :
// We can only deal with IShareableCalendar objects
- if (!$node instanceof IShareableCalendar) {
+ if (!$node instanceof Calendar) {
return;
}
$this->server->transactionType = 'post-publish-calendar';
@@ -152,10 +156,10 @@ class PublishPlugin extends ServerPlugin
// Breaking the event chain
return false;
- case '{' . self::NS_CALENDARSERVER . '}unpublish-calendar' :
+ case '{'.self::NS_CALENDARSERVER.'}unpublish-calendar' :
// We can only deal with IShareableCalendar objects
- if (!$node instanceof IShareableCalendar) {
+ if (!$node instanceof Calendar) {
return;
}
$this->server->transactionType = 'post-unpublish-calendar';
@@ -180,8 +184,5 @@ class PublishPlugin extends ServerPlugin
return false;
}
-
-
-
}
}
diff --git a/apps/dav/lib/CalDAV/Publishing/Xml/Publisher.php b/apps/dav/lib/CalDAV/Publishing/Xml/Publisher.php
index 597652d0ef1..008b5df9125 100644
--- a/apps/dav/lib/CalDAV/Publishing/Xml/Publisher.php
+++ b/apps/dav/lib/CalDAV/Publishing/Xml/Publisher.php
@@ -14,10 +14,17 @@ class Publisher implements XmlSerializable {
protected $publishUrl;
/**
+ * @var $isPublished
+ */
+ protected $isPublished;
+
+ /**
* @param str $publishUrl
+ * @param boolean $isPublished
*/
- function __construct($publishUrl) {
+ function __construct($publishUrl, $isPublished) {
$this->publishUrl = $publishUrl;
+ $this->isPublished = $isPublished;
}
/**
@@ -49,7 +56,11 @@ class Publisher implements XmlSerializable {
function xmlSerialize(Writer $writer) {
$cs = '{' . Plugin::NS_CALENDARSERVER . '}';
- $writer->write($this->publishUrl);
+ if (!$this->isPublished) {
+ $writer->write($this->publishUrl);
+ } else {
+ $writer->writeElement('{DAV:}href', $this->publishUrl);
+ }
}
}