$imptree = IMP_Imap_Tree::singleton();
$result->poll = array();
- foreach ($imptree->getPollList(true) as $val) {
+ foreach ($imptree->getPollList() as $val) {
if ($info = $imptree->getElementInfo($val)) {
$result->poll[$val] = intval($info['unseen']);
}
/* Get list of mailboxes to poll. */
$imptree = IMP_Imap_Tree::singleton();
- $folders = $imptree->getPollList(true, true);
+ $folders = $imptree->getPollList(true);
$anyUnseen = false;
$newmsgs = array();
/* Get list of mailboxes to poll. */
$imaptree = IMP_Imap_Tree::singleton();
- $folders = $imaptree->getPollList(true, true);
+ $folders = $imaptree->getPollList(true);
/* Quota info, if available. */
$quota_msg = Horde_Util::bufferOutput(array('IMP', 'quota'));
/* Store in VFS. */
if ($conf['compose']['use_vfs']) {
$vfs = VFS::singleton($conf['vfs']['type'], Horde::getDriverConfig('vfs', $conf['vfs']['type']));
- VFS_GC::gc($vfs, self::VFS_ATTACH_PATH, 86400);
$cacheID = uniqid(mt_rand());
$result = $vfs_file
/**
* Set the sorting preference for the current mailbox.
- * TODO: Purge non-existant search sorts (i.e. non VFolder entries).
*
* @param integer $by The sort type.
* @param integer $dir The sort direction.
}
if ($delete || !empty($entry)) {
- $GLOBALS['prefs']->setValue('sortpref', @serialize($sortpref));
+ $GLOBALS['prefs']->setValue('sortpref', serialize($sortpref));
}
}
/**
* Initializes and returns the list of mailboxes to poll.
*
- * @param boolean $prune Prune non-existent folders from list?
* @param boolean $sort Sort the directory list?
+ * @param boolean $prune Prune non-existent folders from list?
*
* @return array The list of mailboxes to poll.
*/
- public function getPollList($prune = false, $sort = false)
+ public function getPollList($sort = false, $prune = false)
{
$this->_initPollList();
--- /dev/null
+<?php
+/**
+ * Login system task for performing periodical garbage collection.
+ *
+ * Copyright 2009 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>
+ * @package Horde_LoginTasks
+ */
+class IMP_LoginTasks_SystemTask_GarbageCollection extends Horde_LoginTasks_SystemTask
+{
+ /**
+ * The interval at which to run the task.
+ *
+ * @var integer
+ */
+ public $interval = Horde_LoginTasks::WEEKLY;
+
+ /**
+ * Perform all functions for this task.
+ */
+ public function execute()
+ {
+ IMP::initialize();
+
+ /* Purge non-existent nav_poll entries. */
+ $imaptree = IMP_Imap_Tree::singleton();
+ $imaptree->getPollList(true, true);
+
+ /* Do garbage collection on sentmail entries. */
+ $sentmail = IMP_Sentmail::factory();
+ $sentmail->gc();
+
+ /* Do garbage collection on compose VFS data. */
+ if ($GLOBALS['conf']['compose']['use_vfs']) {
+ $vfs = VFS::singleton($GLOBALS['conf']['vfs']['type'], Horde::getDriverConfig('vfs', $GLOBALS['conf']['vfs']['type']));
+ VFS_GC::gc($vfs, IMP_Compose::VFS_ATTACH_PATH, 86400);
+ }
+
+ /* Purge non-existent search sorts. */
+ $update = false;
+ $sortpref = @unserialize($GLOBALS['prefs']->getValue('sortpref'));
+ foreach (array_keys($sortpref) as $key) {
+ if ($GLOBALS['imp_search']->isSearchMbox($key) &&
+ !$GLOBALS['imp_search']->isEditableVFolder($key)) {
+ unset($sortpref[$key]);
+ $update = true;
+ }
+ }
+ if ($update) {
+ $GLOBALS['prefs']->setValue('sortpref', serialize($sortpref));
+ }
+ }
+
+}
return;
}
- /* Create Virtual INBOX with nav_poll list. Filter out any nav_poll
- * entries that don't exist. Sort the list also. */
+ /* Create Virtual INBOX with nav_poll list. */
$imaptree = IMP_Imap_Tree::singleton();
- $flist = $imaptree->getPollList(true, true);
+ $flist = $imaptree->getPollList();
$query = new Horde_Imap_Client_Search_Query();
$query->flag('\\seen', false);
$this->_log($action, $message_id, $recipient, $success);
}
}
-
- $this->gc();
}
/**
}
/**
- * Garbage collect log entries with a probability of 1%.
+ * Garbage collect log entries.
*/
public function gc()
{
- /* A 1% chance we will run garbage collection during a call. */
- if (rand(0, 99) == 0) {
- $this->_deleteOldEntries(time() - $this->_params['threshold'] * 86400);
- }
+ $this->_deleteOldEntries(time() - $this->_params['threshold'] * 86400);
}
/**