foreach ($this->_folders as $key => $folder) {
$result = $this->getConnection($key);
- $folder->restore($this, $result->connection);
+ $folder->restore($this, $result->connection, $result->connection->getNamespace());
}
$this->connect();
}
if (!isset($this->_folders[$folder])) {
$result = $this->getConnection($folder);
- $kf = new Horde_Kolab_Storage_Folder(
- $result->name,
- $result->connection->getNamespace()
- );
- $kf->restore($this, $result->connection);
+ $kf = new Horde_Kolab_Storage_Folder($result->name);
+ $kf->restore($this, $result->connection, $result->connection->getNamespace());
$this->_folders[$folder] = &$kf;
}
return $this->_folders[$folder];
$connection = &$this->connections[$connection];
}
$folder = new Horde_Kolab_Storage_Folder(null);
- $folder->restore($this, $connection);
+ $folder->restore($this, $connection, $connection->getNamespace());
return $folder;
}
public $name;
/**
+ * A new folder name if the folder should be renamed on the next
+ * save.
+ *
+ * @var string
+ */
+ var $new_name;
+
+ /**
* The connection specific for this folder.
*
* @var Horde_Kolab_Storage_Driver
private $_namespace;
/**
- * A new folder name if the folder should be renamed on the next
- * save.
- *
- * @var string
- */
- var $new_name;
-
- /**
* The handler for the list of Kolab folders.
*
* @var Kolab_storage
* @param Horde_Kolab_Storage_Namespace $namespace The namespace handler for
* this folder.
*/
- function __construct(
- $name = null,
- Horde_Kolab_Storage_Namespace $namespace
- ) {
+ function __construct($name = null)
+ {
$this->name = $name;
- $this->_namespace = $namespace;
$this->__wakeup();
}
* folders.
* @param Horde_Kolab_Storage_Driver $connection The storage connection.
*/
- function restore(Horde_Kolab_Storage &$storage,
- Horde_Kolab_Storage_Driver &$connection)
- {
+ function restore(
+ Horde_Kolab_Storage &$storage,
+ Horde_Kolab_Storage_Driver &$connection,
+ Horde_Kolab_Storage_Namespace $namespace
+ ) {
$this->_storage = $storage;
$this->_connection = $connection;
+ $this->_namespace = $namespace;
}
/**
*/
function getSubpath($name = null)
{
- if (!isset($this->_subpath) || isset($name)) {
- if (!isset($name)) {
- $name = $this->getName();
- }
-
- if (!preg_match(";(shared\.|INBOX[/]?|user/([^/]+)[/]?)([^@]*)(@.*)?;", $name, $matches)) {
- return PEAR::raiseError(sprintf(_("Subpath of folder %s cannot be determined."), $name));
- }
-
- $this->_subpath = $matches[3];
-
+ if (!empty($name)) {
+ return $this->_namespace->getSubpath($name);
+ }
+ if (!isset($this->_subpath)) {
+ $this->_subpath = $this->_namespace->getSubpath($this->getName());
}
return $this->_subpath;
}
}
/**
- * Generate a new name for a folder.
+ * Get the sub path for the given folder name.
*
- * @param string $name The new folder name.
+ * @param string $name The folder name.
+ *
+ * @return string The sub path.
+ */
+ function getSubpath($name)
+ {
+ if (!preg_match(";(shared\.|INBOX[/]?|user/([^/]+)[/]?)([^@]*)(@.*)?;", $name, $matches)) {
+ throw new Horde_Kolab_Storage_Exception(
+ 'Subpath of folder %s cannot be determined.', $name
+ );
+ }
+ return $matches[3];
+ }
+
+ /**
+ * Generate an IMAP folder name.
+ *
+ * @param string $name The new folder name.
+ *
+ * @return string The IMAP folder name.
*/
function setName($name)
{
}
return Horde_String::convertCharset($name, Horde_Nls::getCharset(), 'UTF7-IMAP');
}
-
}
\ No newline at end of file