namespace OCA\DAV\CalDAV\Publishing;
-//use OCA\DAV\CalDAV\Publishing\Xml;
-
use Sabre\DAV\PropFind;
use Sabre\DAV\INode;
use Sabre\DAV\Server;
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/';
/**
*/
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.
*
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);
});
}
$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());