{
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;
* 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)
{
$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