summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2016-07-07 10:16:56 +0200
committerLukas Reschke <lukas@statuscode.ch>2016-09-26 11:55:35 +0200
commit7e5a82b968b2c40576e6bbc051022a6699ff9092 (patch)
tree0c5acfa516ab1f9f5e7971e89d2a3acef06ef27d /apps
parent72f35f8862f92cefb0e4dc8fb0b4f75f0270690a (diff)
downloadnextcloud-server-7e5a82b968b2c40576e6bbc051022a6699ff9092.tar.gz
nextcloud-server-7e5a82b968b2c40576e6bbc051022a6699ff9092.zip
Use urlgenerator to generate an absolute url
And pass Config the correct way too
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/CalDAV/Publishing/PublishPlugin.php39
-rw-r--r--apps/dav/lib/Server.php5
2 files changed, 36 insertions, 8 deletions
diff --git a/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php b/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php
index 67e04d7a8b1..c12071e3670 100644
--- a/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php
+++ b/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php
@@ -2,8 +2,6 @@
namespace OCA\DAV\CalDAV\Publishing;
-//use OCA\DAV\CalDAV\Publishing\Xml;
-
use Sabre\DAV\PropFind;
use Sabre\DAV\INode;
use Sabre\DAV\Server;
@@ -12,10 +10,11 @@ use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;
use OCA\DAV\CalDAV\Publishing\Xml\Publisher;
use OCA\DAV\CalDAV\Calendar;
+use OCP\IURLGenerator;
+use OCP\IConfig;
class PublishPlugin extends ServerPlugin
{
- const NS_OWNCLOUD = 'http://owncloud.org/ns';
const NS_CALENDARSERVER = 'http://calendarserver.org/ns/';
/**
@@ -26,6 +25,31 @@ class PublishPlugin extends ServerPlugin
protected $server;
/**
+ * Config instance to get instance secret.
+ *
+ * @var OCP\IConfig
+ */
+ protected $config;
+
+ /**
+ * URL Generator for absolute URLs.
+ *
+ * @var OCP\IURLGenerator
+ */
+ protected $urlGenerator;
+
+ /**
+ * PublishPlugin constructor.
+ *
+ * @param IURLGenerator $urlGenerator
+ */
+ public function __construct(IConfig $config, IURLGenerator $urlGenerator)
+ {
+ $this->config = $config;
+ $this->urlGenerator = $urlGenerator;
+ }
+
+ /**
* This method should return a list of server-features.
*
* This is for example 'versioning' and is added to the DAV: header
@@ -72,16 +96,17 @@ class PublishPlugin extends ServerPlugin
public function propFind(PropFind $propFind, INode $node)
{
if ($node instanceof Calendar) {
- $token = md5(\OC::$server->getConfig()->getSystemValue('secret', '').$node->getResourceId());
- $publishUrl = $this->server->getBaseUri() . 'public-calendars/' . $token;
+ $token = md5($this->config->getSystemValue('secret', '').$node->getResourceId());
+
+ $publishUrl = $this->urlGenerator->getAbsoluteURL($this->server->getBaseUri().'public-calendars/').$token;
- $propFind->handle('{'.self::NS_CALENDARSERVER.'}publish-url', function () use ($node, $publishUrl) {
+ $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) {
+ $propFind->handle('{'.self::NS_CALENDARSERVER.'}pre-publish-url', function () use ($node, $publishUrl) {
return new Publisher($publishUrl, false);
});
}
diff --git a/apps/dav/lib/Server.php b/apps/dav/lib/Server.php
index defaddbd642..a344885fd29 100644
--- a/apps/dav/lib/Server.php
+++ b/apps/dav/lib/Server.php
@@ -114,7 +114,10 @@ class Server {
$this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());
$this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
$this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
- $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin());
+ $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin(
+ \OC::$server->getConfig(),
+ \OC::$server->getUrlGenerator()
+ ));
// addressbook plugins
$this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin());