summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-11-27 08:51:45 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2014-12-23 16:04:25 (GMT)
commitf0a3f9cdf8ced773f70f837ea0dd47e4427cec83 (patch)
tree008ef5ed5c5436a38ccea2205f484859e874a5b5
parent57e42dd6ca0e226b62a67ece54a91c97b1712dba (diff)
downloadroundcubemail-plugins-kolab-f0a3f9cdf8ced773f70f837ea0dd47e4427cec83.tar.gz
Create domain-aware cache identifiers for groupware folders (#3991)
-rw-r--r--plugins/libkolab/SQL/mysql/2014112700.sql2
-rw-r--r--plugins/libkolab/lib/kolab_storage_folder.php24
2 files changed, 17 insertions, 9 deletions
diff --git a/plugins/libkolab/SQL/mysql/2014112700.sql b/plugins/libkolab/SQL/mysql/2014112700.sql
new file mode 100644
index 0000000..90c77b8
--- /dev/null
+++ b/plugins/libkolab/SQL/mysql/2014112700.sql
@@ -0,0 +1,2 @@
+-- delete cache entries for old folder identifiers
+DELETE FROM `kolab_folders` WHERE `resource` LIKE 'imap://anonymous@%';
diff --git a/plugins/libkolab/lib/kolab_storage_folder.php b/plugins/libkolab/lib/kolab_storage_folder.php
index e6a0d9e..11ad287 100644
--- a/plugins/libkolab/lib/kolab_storage_folder.php
+++ b/plugins/libkolab/lib/kolab_storage_folder.php
@@ -144,9 +144,10 @@ class kolab_storage_folder
/**
* Returns the owner of the folder.
*
+ * @param boolean Return a fully qualified owner name (i.e. including domain for shared folders)
* @return string The owner of this folder.
*/
- public function get_owner()
+ public function get_owner($fully_qualified = false)
{
// return cached value
if (isset($this->owner))
@@ -165,16 +166,21 @@ class kolab_storage_folder
break;
default:
- list($prefix, $user) = explode($this->imap->get_hierarchy_delimiter(), $info['name']);
- if (strpos($user, '@') === false) {
- $domain = strstr($rcmail->get_user_name(), '@');
- if (!empty($domain))
- $user .= $domain;
- }
- $this->owner = $user;
+ list($prefix, $this->owner) = explode($this->imap->get_hierarchy_delimiter(), $info['name']);
+ $fully_qualified = true; // enforce email addresses (backwards compatibility)
break;
}
+ if ($fully_qualified && strpos($this->owner, '@') === false) {
+ // extract domain from current user name
+ $domain = strstr($rcmail->get_user_name(), '@');
+ // fall back to mail_domain config option
+ if (empty($domain) && ($mdomain = $rcmail->config->mail_domain($this->imap->options['host']))) {
+ $domain = '@' . $mdomain;
+ }
+ $this->owner .= $domain;
+ }
+
return $this->owner;
}
@@ -260,7 +266,7 @@ class kolab_storage_folder
}
// compose fully qualified ressource uri for this instance
- $this->resource_uri = 'imap://' . urlencode($this->get_owner()) . '@' . $this->imap->options['host'] . '/' . $subpath;
+ $this->resource_uri = 'imap://' . urlencode($this->get_owner(true)) . '@' . $this->imap->options['host'] . '/' . $subpath;
return $this->resource_uri;
}