From 8e528fd7bf2e2bd1e20c7e7de5eefb26bf6b19d9 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Wed, 23 May 2012 14:09:57 -0400
Subject: [PATCH] hide_blockquote - a new plugin for hiding citation blocks

---
 program/include/rcube_imap_cache.php |   31 ++++++++++++++++++++++++++++---
 1 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/program/include/rcube_imap_cache.php b/program/include/rcube_imap_cache.php
index 1b6a165..ee53dc2 100644
--- a/program/include/rcube_imap_cache.php
+++ b/program/include/rcube_imap_cache.php
@@ -6,7 +6,10 @@
  |                                                                       |
  | This file is part of the Roundcube Webmail client                     |
  | Copyright (C) 2005-2011, The Roundcube Dev Team                       |
- | Licensed under the GNU GPL                                            |
+ |                                                                       |
+ | Licensed under the GNU General Public License version 3 or            |
+ | any later version with exceptions for skins & plugins.                |
+ | See the README file for a full license statement.                     |
  |                                                                       |
  | PURPOSE:                                                              |
  |   Caching of IMAP folder contents (messages and index)                |
@@ -350,8 +353,9 @@
     function get_message($mailbox, $uid, $update = true, $cache = true)
     {
         // Check internal cache
-        if (($message = $this->icache['message'])
-            && $message['mailbox'] == $mailbox && $message['object']->uid == $uid
+        if ($this->icache['message']
+            && $this->icache['message']['mailbox'] == $mailbox
+            && $this->icache['message']['object']->uid == $uid
         ) {
             return $this->icache['message']['object'];
         }
@@ -596,6 +600,27 @@
 
 
     /**
+     * Delete cache entries older than TTL
+     *
+     * @param string $ttl  Lifetime of message cache entries
+     */
+    function expunge($ttl)
+    {
+        // get expiration timestamp
+        $ts = get_offset_time($ttl, -1);
+
+        $this->db->query("DELETE FROM ".get_table_name('cache_messages')
+              ." WHERE changed < " . $this->db->fromunixtime($ts));
+
+        $this->db->query("DELETE FROM ".get_table_name('cache_index')
+              ." WHERE changed < " . $this->db->fromunixtime($ts));
+
+        $this->db->query("DELETE FROM ".get_table_name('cache_thread')
+              ." WHERE changed < " . $this->db->fromunixtime($ts));
+    }
+
+
+    /**
      * Fetches index data from database
      */
     private function get_index_row($mailbox)

--
Gitblit v1.9.1