Skip to content

Commit

Permalink
Fix mailbox display labels
Browse files Browse the repository at this point in the history
Only special mailboxes have translated labels. Submailboxes don't.

i.e. if the Drafts mailbox is A, A.B is not displayed as Drafts.B

I'm not sure why we ever did it this way, but this makes absolutely no
sense in the folder list display.  Especially since we don't allow
children of special mailboxes (in the display), so there's no benefit in
labeling them this way.

This fixes a bunch of display issues with submailboxes of special
mailboxes.
  • Loading branch information
slusarz committed Jun 10, 2014
1 parent 74abc87 commit 6d6c1a5
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions imp/lib/Mailbox.php
Expand Up @@ -1551,57 +1551,59 @@ protected function _getDisplay($notranslate = false)
return $out;
}

/* Substitute any translated prefix text. */
$sub = array(
'INBOX' => _("Inbox")
);

/* Bug #9971: Special mailboxes can be empty IMP_Mailbox objects -
* catch this with the strlen check below. */
foreach ($this->getSpecialMailboxes() as $key => $val) {
switch ($key) {
case self::SPECIAL_COMPOSETEMPLATES:
$sub[strval($val)] = _("Templates");
if (strval($val) == $this->_mbox) {
$out = _("Templates");
}
break;

case self::SPECIAL_DRAFTS:
$sub[strval($val)] = _("Drafts");
if (strval($val) == $this->_mbox) {
$out = _("Drafts");
}
break;

case self::SPECIAL_SENT:
if (count($val) == 1) {
$sub[strval(reset($val))] = _("Sent");
if (strval(reset($val)) == $this->_mbox) {
$out = _("Sent");
}
} else {
$sent = self::getPref(self::MBOX_SENT);
foreach ($val as $mbox) {
if ($mbox == $sent) {
$sub[strval($mbox)] = _("Sent");
if (($mbox == $sent) &&
(strval($mbox) == $this->_mbox)) {
$out = _("Sent");
break;
}
}
}
break;

case self::SPECIAL_SPAM:
$sub[strval($val)] = _("Spam");
if (strval($val) == $this->_mbox) {
$out = _("Spam");
}
break;

case self::SPECIAL_TRASH:
$sub[strval($val)] = _("Trash");
if (strval($val) == $this->_mbox) {
$out = _("Trash");
}
break;
}
}

foreach ($sub as $key => $val) {
if (strlen($key) &&
(($key != 'INBOX') || ($this->_mbox == $out)) &&
strpos($this->_mbox, $key) === 0) {
$len = strlen($key);
if ((strlen($this->_mbox) == $len) || ($this->_mbox[$len] == (is_null($ns_info) ? '' : $ns_info->delimiter))) {
$out = substr_replace($this->_mbox, $val, 0, $len);
break;
}
}
if ($this->inbox) {
$out = _("Inbox");
} elseif (($this->_mbox == $out) &&
!is_null($ns_info) &&
(strpos($out, 'INBOX' . $ns_info->delimiter) === 0)) {
$out = substr_replace($out, _("Inbox"), 0, 5);
}

$cache->setDisplay($this->_mbox, $out);
Expand Down

0 comments on commit 6d6c1a5

Please sign in to comment.