summaryrefslogtreecommitdiff
path: root/plugins/kolab_files
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2014-08-18 18:36:53 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2014-08-18 18:36:53 (GMT)
commit96205f1347190f99a8cbdde7ebc3749418b9d990 (patch)
tree7977d20af7cc18f1571d92985986766fb76fa614 /plugins/kolab_files
parentda430777b15fe2d3e1f6c31322001ea1fb5ac5ca (diff)
downloadroundcubemail-plugins-kolab-96205f1347190f99a8cbdde7ebc3749418b9d990.tar.gz
Support relative URL as Chwala destination (#2436)
Diffstat (limited to 'plugins/kolab_files')
-rw-r--r--plugins/kolab_files/lib/kolab_files_engine.php28
1 files changed, 27 insertions, 1 deletions
diff --git a/plugins/kolab_files/lib/kolab_files_engine.php b/plugins/kolab_files/lib/kolab_files_engine.php
index 425f3be..6e81e1a 100644
--- a/plugins/kolab_files/lib/kolab_files_engine.php
+++ b/plugins/kolab_files/lib/kolab_files_engine.php
@@ -34,7 +34,7 @@ class kolab_files_engine
*/
public function __construct($plugin, $url)
{
- $this->url = $url;
+ $this->url = $this->resolve_url($url);
$this->plugin = $plugin;
$this->rc = $plugin->rc;
}
@@ -1017,4 +1017,30 @@ class kolab_files_engine
return $mimetypes;
}
+
+ /**
+ * Resolve relative URL
+ */
+ protected function resolve_url($url)
+ {
+ // prepend protocol://hostname:port
+ if (!preg_match('|^https?://|', $url)) {
+ $schema = 'http';
+ $default_port = 80;
+
+ if (rcube_utils::https_check()) {
+ $schema = 'https';
+ $default_port = 443;
+ }
+
+ $prefix = $schema . '://' . preg_replace('/:\d+$/', '', $_SERVER['HTTP_HOST']);
+ if ($_SERVER['SERVER_PORT'] != $default_port) {
+ $prefix .= ':' . $_SERVER['SERVER_PORT'];
+ }
+
+ $url = $prefix . ($url[0] == '/' ? '' : '/') . $url;
+ }
+
+ return $url;
+ }
}