From 78cdeba1a82dd744f59ebfe625a7d7dd8d23ff41 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sun, 10 May 2009 05:01:18 -0400
Subject: [PATCH] - last commit fix

---
 program/include/rcube_imap.php |   26 ++++++++++----------------
 1 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index c97a5f1..9951bda 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -139,7 +139,7 @@
       if (!empty($this->conn->rootdir))
         {
         $this->set_rootdir($this->conn->rootdir);
-        $this->root_ns = ereg_replace('[\.\/]$', '', $this->conn->rootdir);
+        $this->root_ns = preg_replace('/[.\/]$/', '', $this->conn->rootdir);
         }
       }
 
@@ -195,7 +195,7 @@
    */
   function set_rootdir($root)
     {
-    if (ereg('[\.\/]$', $root)) //(substr($root, -1, 1)==='/')
+    if (preg_match('/[.\/]$/', $root)) //(substr($root, -1, 1)==='/')
       $root = substr($root, 0, -1);
 
     $this->root_dir = $root;
@@ -796,7 +796,7 @@
           {
           // delete from cache
           if ($cache_index[$headers->id] && $cache_index[$headers->id] == $headers->uid)
-            $this->remove_message_cache($cache_key, $headers->id);
+            $this->remove_message_cache($cache_key, $headers->uid);
 
           $deleted_count++;
           continue;
@@ -927,7 +927,7 @@
       // other message at this position
       if (isset($cache_index[$id]))
         {
-        $this->remove_message_cache($cache_key, $id);
+        $this->remove_message_cache($cache_key, $cache_index[$id]);
         unset($cache_index[$id]);
         }
         
@@ -941,7 +941,7 @@
     if (!empty($cache_index))
       {
       foreach ($cache_index as $id => $uid)
-        $this->remove_message_cache($cache_key, $id);
+        $this->remove_message_cache($cache_key, $uid);
       }
     }
 
@@ -1566,14 +1566,8 @@
     if ($this->caching_enabled)
       {
       foreach ($uids as $uid)
-        {
-	$id = $this->_uid2id($uid);
-        if ($cached_headers = $this->get_cached_message($cache_key, $id))
-          {
-          $this->remove_message_cache($cache_key, $id);
-          //$this->get_headers($uid);
-          }
-        }
+        if ($cached_headers = $this->get_cached_message($cache_key, $uid))
+          $this->remove_message_cache($cache_key, $uid);
 
       // close and re-open connection
       // this prevents connection problems with Courier 
@@ -2436,7 +2430,7 @@
   /**
    * @access private
    */
-  function remove_message_cache($key, $index)
+  function remove_message_cache($key, $uid)
     {
     if (!$this->caching_enabled)
       return;
@@ -2445,10 +2439,10 @@
       "DELETE FROM ".get_table_name('messages')."
        WHERE  user_id=?
        AND    cache_key=?
-       AND    idx=?",
+       AND    uid=?",
       $_SESSION['user_id'],
       $key,
-      $index);
+      $uid);
     }
 
   /**

--
Gitblit v1.9.1