From cc97ea0559af1a92a54dbcdf738ee4d95e67d3ff Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Sun, 19 Apr 2009 13:44:29 -0400
Subject: [PATCH] Merged branch devel-api (from r2208 to r2387) back into trunk (omitting some sample plugins)

---
 program/include/rcube_imap.php |   31 ++++++++++++++++++++-----------
 1 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index da7c5bf..e2b6c0d 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -55,6 +55,7 @@
   var $default_charset = 'ISO-8859-1';
   var $default_folders = array('INBOX');
   var $default_folders_lc = array('inbox');
+  var $fetch_add_headers = '';
   var $cache = array();
   var $cache_keys = array();  
   var $cache_changes = array();
@@ -428,8 +429,16 @@
     if (is_array($a_mboxes))
       return $a_mboxes;
 
-    // retrieve list of folders from IMAP server
-    $a_folders = iil_C_ListSubscribed($this->conn, $this->_mod_mailbox($root), $filter);
+    // Give plugins a chance to provide a list of mailboxes
+    $data = rcmail::get_instance()->plugins->exec_hook('list_mailboxes',array('root'=>$root,'filter'=>$filter));
+    if (isset($data['folders'])) {
+        $a_folders = $data['folders'];
+    }
+    else{
+        // retrieve list of folders from IMAP server
+        $a_folders = iil_C_ListSubscribed($this->conn, $this->_mod_mailbox($root), $filter);
+    }
+
     
     if (!is_array($a_folders) || !sizeof($a_folders))
       $a_folders = array();
@@ -775,7 +784,7 @@
     $cache_index = $this->get_message_cache_index($cache_key);
     
     // fetch reuested headers from server
-    $a_header_index = iil_C_FetchHeaders($this->conn, $mailbox, $msgs);
+    $a_header_index = iil_C_FetchHeaders($this->conn, $mailbox, $msgs, false, $this->fetch_add_headers);
     $deleted_count = 0;
     
     if (!empty($a_header_index))
@@ -829,14 +838,14 @@
         if ($this->sort_field && $this->search_sort_field != $this->sort_field)
           $this->search('', $this->search_string, $this->search_charset, $this->sort_field);
 
-	if ($this->sort_order == 'DESC')
+        if ($this->sort_order == 'DESC')
           $this->cache[$key] = array_reverse($this->search_set);
-	else
-	  $this->cache[$key] = $this->search_set;
+        else
+          $this->cache[$key] = $this->search_set;
         }
       else
         {
-	$a_index = iil_C_FetchHeaderIndex($this->conn, $mailbox, join(',', $this->search_set), $this->sort_field);
+        $a_index = iil_C_FetchHeaderIndex($this->conn, $mailbox, join(',', $this->search_set), $this->sort_field, false);
 
         if ($this->sort_order=="ASC")
           asort($a_index);
@@ -923,7 +932,7 @@
         
 
       // fetch complete headers and add to cache
-      $headers = iil_C_FetchHeader($this->conn, $mailbox, $id);
+      $headers = iil_C_FetchHeader($this->conn, $mailbox, $id, false, $this->fetch_add_headers);
       $this->add_message_cache($cache_key, $headers->id, $headers);
       }
 
@@ -1062,7 +1071,7 @@
     if ($uid && ($headers = &$this->get_cached_message($mailbox.'.msg', $uid)))
       return $headers;
 
-    $headers = iil_C_FetchHeader($this->conn, $mailbox, $id, $is_uid, $bodystr);
+    $headers = iil_C_FetchHeader($this->conn, $mailbox, $id, $is_uid, $bodystr, $this->fetch_add_headers);
 
     // write headers cache
     if ($headers)
@@ -2227,7 +2236,7 @@
     if ($cache_count==$msg_count)
       {
       // get highest index
-      $header = iil_C_FetchHeader($this->conn, $mailbox, "$msg_count");
+      $header = iil_C_FetchHeader($this->conn, $mailbox, "$msg_count", false, $this->fetch_add_headers);
       $cache_uid = array_pop($cache_index);
       
       // uids of highest message matches -> cache seems OK
@@ -2277,7 +2286,7 @@
         
         // featch headers if unserialize failed
         if (empty($this->cache[$cache_key][$uid]))
-          $this->cache[$cache_key][$uid] = iil_C_FetchHeader($this->conn, preg_replace('/.msg$/', '', $key), $uid, true);
+          $this->cache[$cache_key][$uid] = iil_C_FetchHeader($this->conn, preg_replace('/.msg$/', '', $key), $uid, true, $this->fetch_add_headers);
         }
       }
       

--
Gitblit v1.9.1