summaryrefslogtreecommitdiff
path: root/lib/Kolab/CardDAV/Plugin.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Kolab/CardDAV/Plugin.php')
-rw-r--r--lib/Kolab/CardDAV/Plugin.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/Kolab/CardDAV/Plugin.php b/lib/Kolab/CardDAV/Plugin.php
index 5c39c07..3d7aa7d 100644
--- a/lib/Kolab/CardDAV/Plugin.php
+++ b/lib/Kolab/CardDAV/Plugin.php
@@ -36,6 +36,37 @@ class Plugin extends CardDAV\Plugin
// make already parsed vcard blocks available for later use
public static $parsed_vcard;
+ // allow the backend to force a redirect Location
+ public static $redirect_basename;
+
+ /**
+ * Initializes the plugin
+ *
+ * @param DAV\Server $server
+ * @return void
+ */
+ public function initialize(DAV\Server $server)
+ {
+ parent::initialize($server);
+
+ $server->subscribeEvent('afterCreateFile', array($this, 'afterWriteContent'));
+ $server->subscribeEvent('afterWriteContent', array($this, 'afterWriteContent'));
+ }
+
+ /**
+ * Inject some additional HTTP response headers
+ */
+ public function afterWriteContent($uri, $node)
+ {
+ // send Location: header to corrected URI
+ if (self::$redirect_basename) {
+ $path = explode('/', $uri);
+ array_pop($path);
+ array_push($path, self::$redirect_basename);
+ $this->server->httpResponse->setHeader('Location', $this->server->getBaseUri() . join('/', array_map('urlencode', $path)));
+ self::$redirect_basename = null;
+ }
+ }
/**
* Checks if the submitted iCalendar data is in fact, valid.