Skip to content

Commit

Permalink
Fix creating mailboxes in non-empty default namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Nov 13, 2013
1 parent f86432e commit f4cddf3
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions imp/lib/Mailbox.php
Expand Up @@ -294,16 +294,16 @@ public function __construct($mbox)
throw new IMP_Exception('Mailbox name must not be empty.');
}

$this->_mbox = ($mbox == IMP_Ftree::BASE_ELT)
? ''
: $mbox;
$this->_mbox = $mbox;
}

/**
*/
public function __toString()
{
return strval($this->_mbox);
return strval(
($this->_mbox == IMP_Ftree::BASE_ELT) ? '' : $this->_mbox
);
}

/**
Expand Down Expand Up @@ -401,7 +401,7 @@ public function __get($key)
}

return (($pos = strrpos($this->_mbox, $this->namespace_delimiter)) === false)
? $this->_mbox
? strval($this)
: substr($this->_mbox, $pos + 1);

case 'cache':
Expand Down Expand Up @@ -465,7 +465,7 @@ public function __get($key)
return $this->_getIcon();

case 'imp_imap':
return $injector->getInstance('IMP_Factory_Imap')->create($this->_mbox);
return $injector->getInstance('IMP_Factory_Imap')->create(strval($this));

case 'imap_mbox':
return strval(
Expand Down Expand Up @@ -583,7 +583,7 @@ public function __get($key)
return $ret;
}

$ns_info = $this->imp_imap->getNamespace($this->_mbox);
$ns_info = $this->imp_imap->getNamespace(strlen($this) ? $this->_mbox : null);
if (is_null($ns_info)) {
$this->_cache[self::CACHE_NAMESPACE] = null;
} else {
Expand All @@ -608,7 +608,7 @@ public function __get($key)
return ($elt = $this->tree_elt) ? $elt->parent->mbox_ob : null;

case 'parent_imap':
return (is_null($p = $this->parent) || ($p == IMP_Ftree::BASE_ELT))
return (is_null($p = $this->parent) || !strlen($p))
? null
: $p;

Expand Down Expand Up @@ -1411,21 +1411,21 @@ public function toBuids(IMP_Indices $uids)
}

/**
* Determines the mailbox name to create given a parent and the new name.
* Return the mailbox name to create given a submailbox name.
*
* @param string $new The new mailbox name (UTF-8).
* @param string $new The submailbox name (UTF-8).
*
* @return IMP_Mailbox The new mailbox.
* @return IMP_Mailbox The mailbox to create.
*/
public function createMailboxName($new)
{
if (strlen($this->_mbox)) {
if ($this->remote_container) {
$new = $this->remote_account->mailbox($new);
} else {
$ns_info = $this->namespace_info;
$new = $this->_mbox . $ns_info['delimiter'] . $new;
}
if ($this->remote_container) {
$new = $this->remote_account->mailbox($new);
} else {
$ns_info = $this->namespace_info;
$new = strlen($this)
? ($this->_mbox . $ns_info['delimiter'] . $new)
: $ns_info['name'] . $new;
}

return self::get($new);
Expand Down

0 comments on commit f4cddf3

Please sign in to comment.