$result->ViewPort = $this->_viewPortData(true);
} else {
$result->ViewPort = new stdClass;
- $result->ViewPort->updatecacheid = $GLOBALS['injector']->getInstance('IMP_Mailbox_List')->getList($this->_vars->view)->getCacheID($this->_vars->view);
+ $result->ViewPort->updatecacheid = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_MailboxList')->create($this->_vars->view)->getCacheID($this->_vars->view);
$result->ViewPort->view = $this->_vars->view;
}
return $result;
$result = $this->_checkUidvalidity($result);
} elseif (!$change) {
/* Only update cacheid info if it changed. */
- $cacheid = $GLOBALS['injector']->getInstance('IMP_Mailbox_List')->getList($this->_vars->view)->getCacheID($this->_vars->view);
+ $cacheid = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_MailboxList')->create($this->_vars->view)->getCacheID($this->_vars->view);
if ($cacheid != $this->_vars->cacheid) {
$result->ViewPort = new stdClass;
$result->ViewPort->updatecacheid = $cacheid;
$result->ViewPort = $this->_viewPortData(true);
} else {
$result->ViewPort = new stdClass;
- $result->ViewPort->updatecacheid = $GLOBALS['injector']->getInstance('IMP_Mailbox_List')->getList($this->_vars->view)->getCacheID($this->_vars->view);
+ $result->ViewPort->updatecacheid = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_MailboxList')->create($this->_vars->view)->getCacheID($this->_vars->view);
$result->ViewPort->view = $this->_vars->view;
}
}
}
- return ($GLOBALS['injector']->getInstance('IMP_Mailbox_List')->getList($this->_vars->view)->getCacheID($this->_vars->view) != $this->_vars->cacheid);
+ return ($GLOBALS['injector']->getInstance('IMP_Injector_Factory_MailboxList')->create($this->_vars->view)->getCacheID($this->_vars->view) != $this->_vars->cacheid);
}
/**
'IMP_Identity' => new IMP_Injector_Binder_Identity(),
'IMP_Imap_Tree' => new IMP_Injector_Binder_Imaptree(),
'IMP_Mail' => new IMP_Injector_Binder_Mail(),
- 'IMP_Mailbox_List' => new IMP_Injector_Binder_MailboxList(),
'IMP_Quota' => new IMP_Injector_Binder_Quota(),
'IMP_Search' => new IMP_Injector_Binder_Search(),
'IMP_Sentmail' => new IMP_Injector_Binder_Sentmail()
+++ /dev/null
-<?php
-/**
- * Binder for IMP_Mailbox_List::.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @package IMP
- */
-class IMP_Injector_Binder_MailboxList implements Horde_Injector_Binder
-{
- /**
- */
- public function create(Horde_Injector $injector)
- {
- return new IMP_Injector_Factory_MailboxList($injector);
- }
-
- /**
- */
- public function equals(Horde_Injector_Binder $binder)
- {
- return false;
- }
-
-}
*
* @var array
*/
- private $_instances = array(
- 'list' => array(),
- 'track' => array()
- );
+ private $_instances = array();
/**
* Constructor.
}
/**
- * Return the IMP_Mailbox_List:: instance.
- *
- * @param string $mailbox The mailbox name.
- *
- * @return IMP_Mailbox_List The singleton mailbox instance.
- * @throws IMP_Exception
- */
- public function getList($mailbox)
- {
- if (!isset($this->_instances['list'][$mailbox])) {
- $this->_instances['list'][$mailbox] = new IMP_Mailbox_List($mailbox);
- }
-
- return $this->_instances['list'][$mailbox];
- }
-
- /**
- * Return the IMP_Mailbox_List_Track:: instance.
+ * Return the mailbox list instance.
+ * For IMP/MIMP, returns an IMP_Mailbox_List_Track object.
+ * For DIMP, returns an IMP_Mailbox_List object.
*
* @param string $mailbox The mailbox name.
* @param IMP_Indices $indices An indices object.
*
- *
- * @return IMP_Mailbox_List_Track The singleton mailbox instance.
+ * @return IMP_Mailbox_List The singleton instance.
* @throws IMP_Exception
*/
- public function getListTrack($mailbox, $indices = null)
+ public function create($mailbox, $indices = null)
{
- if (!isset($this->_instances['track'][$mailbox])) {
- $ob = null;
- if (isset($_SESSION['imp']['cache']['imp_mailbox'][$mailbox])) {
- try {
- $ob = @unserialize($_SESSION['imp']['cache']['imp_mailbox'][$mailbox]);
- } catch (Exception $e) {}
- }
+ $mode = IMP::getViewMode();
+
+ if (!isset($this->_instances[$mailbox])) {
+ switch ($mode) {
+ case 'dimp':
+ $ob = new IMP_Mailbox_List($mailbox);
+ break;
+
+ case 'imp':
+ case 'mimp':
+ $ob = null;
+ if (isset($_SESSION['imp']['cache']['imp_mailbox'][$mailbox])) {
+ try {
+ $ob = @unserialize($_SESSION['imp']['cache']['imp_mailbox'][$mailbox]);
+ } catch (Exception $e) {}
+ }
- if (!$ob) {
- $ob = new IMP_Mailbox_List_Track($mailbox);
+ if (!$ob) {
+ $ob = new IMP_Mailbox_List_Track($mailbox);
+ }
+ break;
}
- $this->_instances['track'][$mailbox] = $ob;
+ $this->_instances[$mailbox] = $ob;
}
- if (!is_null($indices)) {
- $this->_instances['track'][$mailbox]->setIndex($indices);
+ switch ($mode) {
+ case 'imp':
+ case 'mimp':
+ $this->_instances[$mailbox]->setIndex($indices);
+ break;
}
- return $this->_instances['track'][$mailbox];
+ return $this->_instances[$mailbox];
}
/**
*/
public function shutdown()
{
- /* Cache mailbox information if viewing in standard (IMP) message
- * mode. Needed to keep navigation consistent when moving through the
- * message list, and to ensure messages aren't marked as missing in
- * search mailboxes (e.g. if search is dependent on unseen flag). */
- foreach ($this->_instances['track'] as $key => $val) {
- if ($val->changed) {
- $_SESSION['imp']['cache']['imp_mailbox'][$key] = serialize($val);
+ switch (IMP::getViewMode()) {
+ case 'imp':
+ case 'mimp':
+ /* Cache mailbox information if viewing in standard (IMP) message
+ * mode. Needed to keep navigation consistent when moving through
+ * the message list, and to ensure messages aren't marked as
+ * missing in search mailboxes (e.g. if search is dependent on
+ * unseen flag). */
+ foreach ($this->_instances as $key => $val) {
+ if ($val->changed) {
+ $_SESSION['imp']['cache']['imp_mailbox'][$key] = serialize($val);
+ }
}
}
}
*
* @param mixed $data If an integer, the number of messages to increase
* array index by. If an indices object, sets array
- * index to the index value.
+ * index to the index value. If null, rebuilds the
+ * internal index.
*/
public function setIndex($data)
{
$this->_rebuild(true);
$this->_index = $this->getArrayIndex($uid, $mailbox);
}
- } elseif (!is_null($this->_index)) {
+ } elseif (is_null($this->_index)) {
+ $this->_index = null;
+ $this->_rebuild(true);
+ } else {
$index = $this->_index += $data;
if (isset($this->_sorted[$this->_index])) {
$this->_rebuild();
}
/* Generate the sorted mailbox list now. */
- $imp_mailbox = $GLOBALS['injector']->getInstance('IMP_Mailbox_List')->getList($mbox);
+ $imp_mailbox = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_MailboxList')->create($mbox);
$sorted_list = $imp_mailbox->getSortedList();
$msgcount = count($sorted_list['s']);
}
/* Build the list of messages in the mailbox. */
-$imp_mailbox = $injector->getInstance('IMP_Mailbox_List')->getList(IMP::$mailbox);
+$imp_mailbox = $injector->getInstance('IMP_Injector_Factory_MailboxList')->create(IMP::$mailbox);
$pageOb = $imp_mailbox->buildMailboxPage($vars->p, $vars->s);
/* Generate page title. */
}
/* Build the list of messages in the mailbox. */
-$imp_mailbox = $injector->getInstance('IMP_Mailbox_List')->getList(IMP::$mailbox);
+$imp_mailbox = $injector->getInstance('IMP_Injector_Factory_MailboxList')->create(IMP::$mailbox);
$pageOb = $imp_mailbox->buildMailboxPage($vars->page, $start);
$show_preview = $prefs->getValue('preview_enabled');
$vars = Horde_Variables::getDefaultVariables();
/* Make sure we have a valid index. */
-$imp_mailbox = $injector->getInstance('IMP_Mailbox_List')->getListTrack(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
+$imp_mailbox = $injector->getInstance('IMP_Injector_Factory_MailboxList')->create(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
if (!$imp_mailbox->isValidIndex()) {
IMP::generateIMPUrl('mailbox-mimp.php', IMP::$mailbox)->add('a', 'm')->redirect();
}
}
/* Make sure we have a valid index. */
-$imp_mailbox = $injector->getInstance('IMP_Mailbox_List')->getListTrack(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
+$imp_mailbox = $injector->getInstance('IMP_Injector_Factory_MailboxList')->create(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
if (!$imp_mailbox->isValidIndex()) {
_returnToMailbox(null, 'message_missing');
require IMP_BASE . '/mailbox.php';
$new_mail = (isset($request_parts[1]) && ($request_parts[1] === 'new'));
}
-$imp_mailbox = $injector->getInstance('IMP_Mailbox_List')->getList($mailbox);
+$imp_mailbox = $injector->getInstance('IMP_Injector_Factory_MailboxList')->create($mailbox);
$imp_search = $injector->getInstance('IMP_Search');
/* Obtain some information describing the mailbox state. */
: 'thread';
$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
-$imp_mailbox = $injector->getInstance('IMP_Mailbox_List')->getListTrack(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
+$imp_mailbox = $injector->getInstance('IMP_Injector_Factory_MailboxList')->create(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
$error = false;
if ($mode == 'thread') {