From: Gunnar Wrobel Date: Thu, 11 Mar 2010 21:22:22 +0000 (+0100) Subject: Move the getOwner() method into the namespace handler. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b725d86942510a85ecba48230efdbafb075b5ccd;p=horde.git Move the getOwner() method into the namespace handler. --- diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder.php index bfea56776..a35ac9016 100644 --- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder.php +++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder.php @@ -484,25 +484,9 @@ class Horde_Kolab_Storage_Folder { if (!isset($this->_owner)) { if (!isset($this->name) && isset($this->new_name)) { - $name = $this->new_name; + $this->_owner = $this->_namespace->getOwner($this->new_name); } else { - $name = $this->name; - } - - if (!preg_match(";(shared\.|INBOX[/]?|user/([^/]+)[/]?)([^@]*)(@.*)?;", $name, $matches)) { - return PEAR::raiseError(sprintf(_("Owner of folder %s cannot be determined."), $name)); - } - - $this->_subpath = $matches[3]; - - if (substr($matches[1], 0, 6) == 'INBOX/') { - $this->_owner = Horde_Auth::getAuth(); - } elseif (substr($matches[1], 0, 5) == 'user/') { - $domain = strstr(Horde_Auth::getAuth(), '@'); - $user_domain = isset($matches[4]) ? $matches[4] : $domain; - $this->_owner = $matches[2] . $user_domain; - } elseif ($matches[1] == 'shared.') { - $this->_owner = 'anonymous'; + $this->_owner = $this->_namespace->getOwner($this->name); } } return $this->_owner; diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace.php index 0401a2318..c0cf2a9f8 100644 --- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace.php +++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Namespace.php @@ -34,6 +34,8 @@ class Horde_Kolab_Storage_Namespace * Return the title of a folder. * * @param string $name The name of the folder. + * + * @return sring The title of the folder. */ public function getTitle($name) { @@ -43,4 +45,30 @@ class Horde_Kolab_Storage_Namespace $name = str_replace('/', ':', $name); return Horde_String::convertCharset($name, 'UTF7-IMAP'); } + + /** + * Return the owner of a folder. + * + * @param string $name The name of the folder. + * + * @return string The owner of the folder. + */ + public function getOwner($name) + { + if (!preg_match(";(shared\.|INBOX[/]?|user/([^/]+)[/]?)([^@]*)(@.*)?;", $name, $matches)) { + throw new Horde_Kolab_Storage_Exception( + 'Owner of folder %s cannot be determined.', $name + ); + } + + if (substr($matches[1], 0, 6) == 'INBOX/') { + return Horde_Auth::getAuth(); + } elseif (substr($matches[1], 0, 5) == 'user/') { + $domain = strstr(Horde_Auth::getAuth(), '@'); + $user_domain = isset($matches[4]) ? $matches[4] : $domain; + return $matches[2] . $user_domain; + } elseif ($matches[1] == 'shared.') { + return 'anonymous'; + } + } } \ No newline at end of file