Skip to content

Commit

Permalink
Fix error when using POP3
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Aug 4, 2014
1 parent 5b72291 commit c2d5b6d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
16 changes: 5 additions & 11 deletions imp/lib/Imap.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class IMP_Imap implements Serializable
const ACCESS_DRAFTS = 11;
const ACCESS_REMOTE = 12;
const ACCESS_IMPORT = 14;
const ACCESS_SORT = 15;

/* Default namespace. */
const NS_DEFAULT = "\0default";
Expand Down Expand Up @@ -221,17 +222,6 @@ public function isPop3()
($this->_ob instanceof Horde_Imap_Client_Socket_Pop3));
}

/**
* Is mailbox sorting available?
*
* @return boolean True if sorting is available.
*/
public function canSort()
{
return ($this->config->sort_force ||
$this->_ob->queryCapability('SORT'));
}

/**
* Create the base Horde_Imap_Client object (from an entry in
* backends.php).
Expand Down Expand Up @@ -413,6 +403,10 @@ public function access($right)

case self::ACCESS_REMOTE:
return $injector->getInstance('Horde_Core_Perms')->hasAppPermission($this->_getPerm('allow_remote'));

case self::ACCESS_SORT:
return ($this->isImap() &&
($this->config->sort_force || $this->_ob->queryCapability('SORT')));
}

return false;
Expand Down
23 changes: 12 additions & 11 deletions imp/lib/Mailbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ public function __get($key)
return $injector->getInstance('IMP_Mbox_Size')->getSize($this);

case 'sortob':
return $this->imp_imap->canSort()
return $this->imp_imap->access(IMP_Imap::ACCESS_SORT)
? $injector->getInstance('IMP_Prefs_Sort')
: $injector->getInstance('IMP_Prefs_Sort_None');

Expand Down Expand Up @@ -1395,17 +1395,18 @@ static public function getSpecialMailboxesSort()
static public function prefFrom($mbox)
{
$imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
if ($imp_imap->isImap()) {
$empty_ns = $imp_imap->getNamespace('');

$empty_ns = $imp_imap->getNamespace('');

if (!is_null($empty_ns) &&
(strpos($mbox, $empty_ns->delimiter) === 0)) {
/* Prefixed with delimiter => from empty namespace. */
return substr($mbox, strlen($empty_ns->delimiter));
} elseif ($imp_imap->getNamespace($mbox, true) === null) {
/* No namespace prefix => from personal namespace. */
$def_ns = $imp_imap->getNamespace($imp_imap::NS_DEFAULT);
return $def_ns->name . $mbox;
if (!is_null($empty_ns) &&
(strpos($mbox, $empty_ns->delimiter) === 0)) {
/* Prefixed with delimiter => from empty namespace. */
return substr($mbox, strlen($empty_ns->delimiter));
} elseif ($imp_imap->getNamespace($mbox, true) === null) {
/* No namespace prefix => from personal namespace. */
$def_ns = $imp_imap->getNamespace($imp_imap::NS_DEFAULT);
return $def_ns->name . $mbox;
}
}

return $mbox;
Expand Down

0 comments on commit c2d5b6d

Please sign in to comment.