list of folders that can't be modified (deleted, renamed, etc) by the user,
e.g.: "Drafts, Trash". (The mailbox value must be encoded in the
UTF7-IMAP charset; see RFC 3501 [5.1.3])"/>
- <configboolean name="cache_folders" desc="If using IMAP, should we cache the
- list of folders so that the list does not need to be rebuilt on every page
- load? If set to true, note that any folders created on the server during an
- IMP session that are NOT created via IMP will not be displayed until the
- next login. If IMP will be the exclusive means of accessing the mail server,
- or you are not concerned about this behavior, this setting should be set to
- true.">true</configboolean>
</configsection>
</configtab>
'IMP_Contents' => new IMP_Injector_Binder_Contents(),
'IMP_Crypt_Pgp' => new IMP_Injector_Binder_Pgp(),
'IMP_Crypt_Smime' => new IMP_Injector_Binder_Smime(),
- 'IMP_Folder' => new IMP_Injector_Binder_Folder(),
'IMP_Identity' => new IMP_Injector_Binder_Identity(),
'IMP_Imap' => new IMP_Injector_Binder_Imap(),
'IMP_Imap_Tree' => new IMP_Injector_Binder_Imaptree(),
*/
public function mailboxesChanged()
{
- $GLOBALS['injector']->getInstance('IMP_Folder')->clearFlistCache();
$GLOBALS['injector']->getInstance('IMP_Imap_Tree')->init();
}
);
/**
- * Keep around identical lists so that we don't hit the server more that
- * once in the same page for the same thing.
- *
- * @var array
- */
- protected $_listCache = null;
-
- /**
- * The cache ID used to store mailbox info.
- *
- * @var string
- */
- protected $_cacheid = null;
-
- /**
- * Constructor.
- *
- * @param string $cacheid The cache ID to use, if folder list caching is
- * enabled.
- */
- public function __construct($cacheid = null)
- {
- $this->_cacheid = $cacheid;
- }
-
- /**
* Lists folders.
*
* @param array $filter An list of mailboxes that should be left out of
$sub = $GLOBALS['prefs']->getValue('subscribe');
}
- /* Compute values that will uniquely identify this list. */
- $sig = hash('md5', serialize(array(intval($sub), $filter)));
-
- /* Either get the list from the cache, or go to the IMAP server to
- obtain it. */
- $cache = null;
- if (is_null($this->_listCache)) {
- if (!is_null($this->_cacheid) && ($cache = $GLOBALS['injector']->getInstance('Horde_Cache'))) {
- $ret = $cache->get($this->_cacheid, 3600);
- if (!empty($ret)) {
- $this->_listCache = unserialize($ret);
- }
- }
-
- if (empty($this->_listCache)) {
- $this->_listCache = array();
- }
- }
-
- if (isset($this->_listCache[$sig])) {
- return $this->_listCache[$sig];
- }
-
$imaptree = $GLOBALS['injector']->getInstance('IMP_Imap_Tree');
$list_mask = IMP_Imap_Tree::FLIST_CONTAINER;
if (!$sub) {
$list = $inbox_entry + $list;
}
- $this->_listCache[$sig] = $list;
-
- /* Save in cache, if needed. */
- if (!is_null($cache)) {
- $cache->set($this->_cacheid, serialize($this->_listCache), 3600);
- }
-
return $list;
}
/**
- * Clears the flist folder cache.
- */
- public function clearFlistCache()
- {
- if (!is_null($this->_cacheid) &&
- ($cache = $GLOBALS['injector']->getInstance('Horde_Cache'))) {
- $cache->expire($this->_cacheid);
- }
- $this->_listCache = array();
- }
-
- /**
* Deletes one or more folders.
*
* @param array $folders Folders to be deleted (UTF7-IMAP).
*/
protected function _onDelete($deleted)
{
- /* Reset the folder cache. */
- $this->clearFlistCache();
-
/* Recreate Virtual Folders. */
$GLOBALS['injector']->getInstance('IMP_Search')->initialize(true);
$this->subscribe(array($folder));
}
- /* Reset the folder cache. */
- $this->clearFlistCache();
-
/* Update the mailbox tree. */
$GLOBALS['injector']->getInstance('IMP_Imap_Tree')->insert($folder);
if (!empty($subscribed)) {
$GLOBALS['injector']->getInstance('IMP_Imap_Tree')->subscribe($subscribed);
-
- /* Reset the folder cache. */
- $this->clearFlistCache();
}
return $return_value;
if (!empty($unsubscribed)) {
$GLOBALS['injector']->getInstance('IMP_Imap_Tree')->unsubscribe($unsubscribed);
-
- /* Reset the folder cache. */
- $this->clearFlistCache();
}
return $return_value;
+++ /dev/null
-<?php
-/**
- * Binder for IMP_Folder::.
- *
- * 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_Folder implements Horde_Injector_Binder
-{
- /**
- */
- public function create(Horde_Injector $injector)
- {
- $cacheid = empty($GLOBALS['conf']['server']['cache_folders'])
- ? null
- : 'imp_folder_cache|' . $GLOBALS['registry']->getAuth() . '|' . $_SESSION['imp']['server_key'];
-
- return new IMP_Folder($cacheid);
- }
-
- /**
- */
- public function equals(Horde_Injector_Binder $binder)
- {
- return false;
- }
-
-}