$notification->push(sprintf(_("The folder \"%s\" may not be deleted."), IMP::displayFolder($val)), 'horde.error');
continue;
}
- $elt_info = $imaptree->getElementInfo($val);
+
+ try {
+ $elt_info = $imp_imap->ob()->status($val, Horde_Imap_Client::STATUS_MESSAGES);
+ } catch (Horde_Imap_Client_Exception $e) {
+ $elt_info = null;
+ }
+
$data = array(
'class' => (++$rowct % 2) ? 'item0' : 'item1',
'name' => htmlspecialchars(IMP::displayFolder($val)),
if ($vars->add) {
$imptree->addPollList($vars->view);
- if ($info = $imptree->getElementInfo($vars->view)) {
- $result->poll = array($vars->view => intval($info['unseen']));
- }
+ try {
+ if ($info = $GLOBALS['imp_imap']->ob()->status($vars->view, Horde_Imap_Client::STATUS_UNSEEN)) {
+ $result->poll = array($vars->view => intval($info['unseen']));
+ }
+ } catch (Horde_Imap_Client_Exception $e) {}
$GLOBALS['notification']->push(sprintf(_("\"%s\" mailbox now polled for new mail."), $display_folder), 'horde.success');
} else {
$imptree->removePollList($vars->view);
return array();
}
- $info = $imptree->getElementInfo($mbox);
- return array($mbox => isset($info['unseen']) ? intval($info['unseen']) : 0);
+ try {
+ $count = ($info = $GLOBALS['imp_imap']->ob()->status($mbox, Horde_Imap_Client::STATUS_UNSEEN))
+ ? intval($info['unseen'])
+ : 0;
+ } catch (Horde_Imap_Client_Exception $e) {
+ $count = 0;
+ }
+
+ return array($mbox => $count);
}
/**
}
/**
- * Get information about new/unseen/total messages for the given element.
- *
- * @param string $name The element name (UTF7-IMAP).
- *
- * @return array Array with the following fields:
- * <pre>
- * 'messages' - (integer) Number of total messages.
- * 'recent' - (integer) Number of new messages.
- * 'unseen' - (integer) Number of unseen messages.
- * </pre>
- */
- public function getElementInfo($name)
- {
- try {
- return $GLOBALS['imp_imap']->ob()->status($name, Horde_Imap_Client::STATUS_MESSAGES | Horde_Imap_Client::STATUS_RECENT | Horde_Imap_Client::STATUS_UNSEEN);
- } catch (Horde_Imap_Client_Exception $e) {
- return array();
- }
- }
-
- /**
* Sorts a list of mailboxes.
*
* @param array &$mbox The list of mailboxes to sort.
if ($this->isPolled($mailbox)) {
/* If we need message information for this folder, update
* it now. */
- $msgs_info = $this->getElementInfo($mailbox['v']);
- if (!empty($msgs_info)) {
- $row['polled'] = true;
- if (!empty($msgs_info['recent'])) {
- $row['recent'] = $msgs_info['recent'];
+ try {
+ if ($msgs_info = $GLOBALS['imp_imap']->ob()->status($mailbox['v'], Horde_Imap_Client::STATUS_RECENT | Horde_Imap_Client::STATUS_UNSEEN | Horde_Imap_Client::STATUS_MESSAGES)) {
+ $row['polled'] = true;
+ if (!empty($msgs_info['recent'])) {
+ $row['recent'] = $msgs_info['recent'];
+ }
+ $row['msgs'] = $msgs_info['messages'];
+ $row['unseen'] = $msgs_info['unseen'];
}
- $row['msgs'] = $msgs_info['messages'];
- $row['unseen'] = $msgs_info['unseen'];
- }
+ } catch (Horde_Imap_Client_Exception $e) {}
}
switch ($mailbox['v']) {
/* Get unseen/thread information. */
if (!$is_search) {
- $imptree = IMP_Imap_Tree::singleton();
- $info = $imptree->getElementInfo($mbox);
- if (!empty($info)) {
- $md->unseen = intval($info['unseen']);
- }
+ try {
+ if ($info = $GLOBALS['imp_imap']->ob()->status($mbox, Horde_Imap_Client::STATUS_UNSEEN)) {
+ $md->unseen = intval($info['unseen']);
+ }
+ } catch (Horde_Imap_Client_Exception $e) {}
if ($sortpref['by'] == Horde_Imap_Client::SORT_THREAD) {
$threadob = $imp_mailbox->getThreadOb();