$changed = _changed($mbox, $cacheid, false);
- if ($changed ||
- Horde_Util::getPost('rangeslice') ||
- !Horde_Util::getPost('checkcache')) {
+ if (is_null($changed)) {
+ $list_msg = new IMP_Views_ListMessages();
+ $result = new stdClass;
+ $result->ViewPort = $list_msg->getBaseOb($mbox);
+
+ $req_id = Horde_Util::getPost('requestid');
+ if (!is_null($req_id)) {
+ $result->ViewPort->requestid = intval($req_id);
+ }
+ } elseif ($changed ||
+ Horde_Util::getPost('rangeslice') ||
+ !Horde_Util::getPost('checkcache')) {
$result = new stdClass;
$result->ViewPort = _getListMessages($mbox, $changed);
}
}
}
- $label = IMP::getLabel($mbox);
-
/* Set the current time zone. */
Horde_Nls::setTimeZone();
$msgcount = count($sorted_list['s']);
/* Create the base object. */
- $result = new stdClass;
- $result->view = $mbox;
- $result->totalrows = $msgcount;
- $result->label = $label;
+ $result = $this->getBaseOb($mbox);
$result->cacheid = $imp_mailbox->getCacheID();
+ $result->totalrows = $msgcount;
/* If this is the initial request for a mailbox, figure out the
* starting location based on user's preferences. */
$slice_end = min($msgcount, $slice_end);
/* Mail-specific viewport information. */
- $result->metadata = new stdClass;
$md = &$result->metadata;
if (!IMP::threadSortAvailable($mbox)) {
$md->nothread = 1;
if (empty($msgcount) && !isset($md->search)) {
$imp_folder = IMP_Folder::singleton();
if (!$imp_folder->exists($mbox)) {
- $GLOBALS['notification']->push(sprintf(_("Mailbox %s does not exist."), $label), 'horde.error');
+ $GLOBALS['notification']->push(sprintf(_("Mailbox %s does not exist."), IMP::getLabel($mbox)), 'horde.error');
}
- $result->data = $result->rowlist = array();
return $result;
}
return $msgs;
}
+ /**
+ * Prepare the base object used by the ViewPort javascript object.
+ *
+ * @param string $mbox The mailbox name.
+ *
+ * @return object The base ViewPort object.
+ */
+ public function getBaseOb($mbox)
+ {
+ $ob = new stdClass;
+ $ob->cacheid = 0;
+ $ob->data = array();
+ $ob->label = IMP::getLabel($mbox);
+ $ob->metadata = new stdClass;
+ $ob->rowlist = array();
+ $ob->totalrows = 0;
+ $ob->view = $mbox;
+
+ return $ob;
+ }
+
}
* select it on the IMAP server (saves some STATUS calls). Open R/W to clear
* the RECENT flag. */
if (!$search_mbox) {
- $imp_imap->ob()->openMailbox($imp_mbox['mailbox'], Horde_Imap_Client::OPEN_READWRITE);
+ try {
+ $imp_imap->ob()->openMailbox($imp_mbox['mailbox'], Horde_Imap_Client::OPEN_READWRITE);
+ } catch (Horde_Imap_Client_Exception $e) {
+ $actionID = null;
+ }
}
/* Determine if mailbox is readonly. */