From ded2b7e166d4b0acab09c00f22f379fbabba709a Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Fri, 05 May 2006 12:53:21 -0400
Subject: [PATCH] Changed login page title regarding product name (Bug #1476413)

---
 program/include/rcube_imap.inc |   60 ++++++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 40 insertions(+), 20 deletions(-)

diff --git a/program/include/rcube_imap.inc b/program/include/rcube_imap.inc
index f515b44..30e6eb8 100644
--- a/program/include/rcube_imap.inc
+++ b/program/include/rcube_imap.inc
@@ -55,7 +55,7 @@
   var $default_folders = array('inbox', 'drafts', 'sent', 'junk', 'trash');
   var $cache = array();
   var $cache_keys = array();  
-  var $cache_changes = array();  
+  var $cache_changes = array();
   var $uid_id_map = array();
   var $msg_headers = array();
   var $capabilities = array();
@@ -503,7 +503,7 @@
       $begin = 0;
       $end = $max;
       }
-    else if ($this->sort_order=='DESC')
+    else if (!$this->get_capability('sort') && $this->sort_order=='DESC')
       {
       $begin = $max - $this->page_size - $start_msg;
       $end =   $max - $start_msg;
@@ -581,8 +581,13 @@
 
 
     // if not already sorted
-    if (!$headers_sorted)
-      $a_msg_headers = iil_SortHeaders($a_msg_headers, $this->sort_field, $this->sort_order);
+//    if (!$headers_sorted)
+//      $a_msg_headers = iil_SortHeaders($a_msg_headers, $this->sort_field, $this->sort_order);
+
+
+      if (!$headers_sorted && $this->sort_order == 'DESC')
+        $a_msg_headers = array_reverse($a_msg_headers);
+      
 
     return array_values($a_msg_headers);
     }
@@ -728,8 +733,7 @@
     return $deleted_count;
     }
     
-
-
+  
   // return sorted array of message UIDs
   function message_index($mbox='', $sort_field=NULL, $sort_order=NULL)
     {
@@ -759,17 +763,13 @@
 
     // fetch complete message index
     $msg_count = $this->_messagecount($mailbox);
-    if ($this->get_capability('sort') && ($a_index = iil_C_Sort($this->conn, $mailbox, $this->sort_field)))
+    if ($this->get_capability('sort') && ($a_index = iil_C_Sort($this->conn, $mailbox, $this->sort_field, '', TRUE)))
       {
-      $a_uids = iil_C_FetchUIDs($this->conn, $mailbox);
-
       if ($this->sort_order == 'DESC')
         $a_index = array_reverse($a_index);
 
-      $i = 0;
-      $this->cache[$key] = array();
-      foreach ($a_index as $index => $value)
-        $this->cache[$key][$i++] = $a_uids[$value];
+      $this->cache[$key] = $a_index;
+
       }
     else
       {
@@ -856,7 +856,7 @@
     $mailbox = $mbox ? $this->_mod_mailbox($mbox) : $this->mailbox;
     if ($str && $criteria)
       {
-      $criteria .= " \"$str\"";
+      $criteria .= ' CHARSET UTF-8 "'.UTF7EncodeString($str).'"';
       return $this->_search_index($mailbox, $criteria);
       }
     else
@@ -934,18 +934,21 @@
 
 
   // set message flag to one or several messages
-  // possible flgs are: SEEN, DELETED, RECENT, ANSWERED, DRAFT
+  // possible flags are: SEEN, UNDELETED, DELETED, RECENT, ANSWERED, DRAFT
   function set_flag($uids, $flag)
     {
     $flag = strtoupper($flag);
     $msg_ids = array();
     if (!is_array($uids))
-      $uids = array($uids);
+      $uids = explode(',',$uids);
       
-    foreach ($uids as $uid)
+    foreach ($uids as $uid) {
       $msg_ids[$uid] = $this->_uid2id($uid);
+    }
       
-    if ($flag=='UNSEEN')
+    if ($flag=='UNDELETED')
+      $result = iil_C_Undelete($this->conn, $this->mailbox, join(',', array_values($msg_ids)));
+    else if ($flag=='UNSEEN')
       $result = iil_C_Unseen($this->conn, $this->mailbox, join(',', array_values($msg_ids)));
     else
       $result = iil_C_Flag($this->conn, $this->mailbox, join(',', array_values($msg_ids)), $flag);
@@ -1479,14 +1482,14 @@
       $header = iil_C_FetchHeader($this->conn, $mailbox, "$msg_count");
       $cache_uid = array_pop($cache_index);
       
-      // uids of highes message matches -> cache seems OK
+      // uids of highest message matches -> cache seems OK
       if ($cache_uid == $header->uid)
         return 1;
 
       // cache is dirty
       return -1;
       }
-    // if cache count differs less that 10% report as dirty
+    // if cache count differs less than 10% report as dirty
     else if (abs($msg_count - $cache_count) < $msg_count/10)
       return -1;
     else
@@ -1835,6 +1838,15 @@
     return array_merge($a_defaults, $a_out);
     }
 
+  function get_id($uid) 
+    {
+      return $this->_uid2id($uid);
+    }
+  
+  function get_uid($id)
+    {
+      return $this->_id2uid($id);
+    }
 
   function _uid2id($uid, $mbox=NULL)
     {
@@ -1847,6 +1859,14 @@
     return $this->uid_id_map[$mbox][$uid];
     }
 
+  function _id2uid($id, $mbox=NULL)
+    {
+    if (!$mbox)
+      $mbox = $this->mailbox;
+      
+    return iil_C_ID2UID($this->conn, $mbox, $id);
+    }
+
 
   // parse string or array of server capabilities and put them in internal array
   function _parse_capability($caps)

--
Gitblit v1.9.1