Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Started implementing search function

  • Loading branch information...
commit 4647e1bbb5beba82605695c4dc989ca867e53244 1 parent d1dfb1e
Thomas B. authored March 23, 2006
8  CHANGELOG
... ...
@@ -1,6 +1,14 @@
1 1
 CHANGELOG RoundCube Webmail
2 2
 ---------------------------
3 3
 
  4
+2006/03/23
  5
+----------
  6
+- Auto-detect mail header delimiters
  7
+- Regard daylight savings
  8
+- Localized quota display
  9
+- Started implementing search function
  10
+
  11
+
4 12
 2006/03/20
5 13
 ----------
6 14
 - Avoid error message when saving an unchanged identity (Bug #1429510)
6  config/main.inc.php.dist
@@ -138,7 +138,8 @@ $rcmail_config['skip_deleted'] = FALSE;
138 138
 $rcmail_config['generic_message_footer'] = '';
139 139
 
140 140
 // this string is used as a delimiter for message headers when sending
141  
-$rcmail_config['mail_header_delimiter'] = "\r\n";
  141
+// leave empty for auto-detection
  142
+$rcmail_config['mail_header_delimiter'] = NULL;
142 143
 
143 144
 // in order to enable public ldap search, create a config array
144 145
 // like the Verisign example below. if you would like to test, 
@@ -165,6 +166,9 @@ $rcmail_config['pagesize'] = 40;
165 166
 // use this timezone to display date/time
166 167
 $rcmail_config['timezone'] = 1;
167 168
 
  169
+// daylight savings are On
  170
+$rcmail_config['dst_active'] = TRUE;
  171
+
168 172
 // prefer displaying HTML messages
169 173
 $rcmail_config['prefer_html'] = TRUE;
170 174
 
5  index.php
@@ -266,9 +266,12 @@
266 266
   if ($_action=='getunread')
267 267
     include('program/steps/mail/getunread.inc');
268 268
     
269  
-  if ($_action=='list' && $_GET['_remote'])
  269
+  if ($_action=='list' && isset($_GET['_remote']))
270 270
     include('program/steps/mail/list.inc');
271 271
 
  272
+   if ($_action=='search')
  273
+     include('program/steps/mail/search.inc'); 
  274
+
272 275
   if ($_action=='rss')
273 276
     include('program/steps/mail/rss.inc');
274 277
 
26  program/include/main.inc
@@ -613,13 +613,13 @@ function rcmail_overwrite_action($action)
613 613
   }
614 614
 
615 615
 
616  
-function show_message($message, $type='notice')
  616
+function show_message($message, $type='notice', $vars=NULL)
617 617
   {
618 618
   global $OUTPUT, $JS_OBJECT_NAME, $REMOTE_REQUEST;
619  
-
  619
+  
620 620
   $framed = $GLOBALS['_framed'];
621 621
   $command = sprintf("display_message('%s', '%s');",
622  
-                     addslashes(rep_specialchars_output(rcube_label($message))),
  622
+                     addslashes(rep_specialchars_output(rcube_label(array('name' => $message, 'vars' => $vars)))),
623 623
                      $type);
624 624
                      
625 625
   if ($REMOTE_REQUEST)
@@ -1099,6 +1099,7 @@ function rcube_xml_command($command, $str_attrib, $a_attrib=NULL)
1099 1099
         'composeattachment' => 'rcmail_compose_attachment_field',
1100 1100
         'priorityselector' => 'rcmail_priority_selector',
1101 1101
         'charsetselector' => 'rcmail_charset_selector',
  1102
+        'searchform' => 'rcmail_search_form',
1102 1103
         
1103 1104
         // ADDRESS BOOK
1104 1105
         'addresslist' => 'rcmail_contacts_list',
@@ -1416,25 +1417,30 @@ function format_date($date, $format=NULL)
1416 1417
   {
1417 1418
   global $CONFIG, $sess_user_lang;
1418 1419
   
  1420
+  $ts = NULL;
  1421
+  
1419 1422
   if (is_numeric($date))
1420 1423
     $ts = $date;
1421 1424
   else if (!empty($date))
1422  
-    $ts = strtotime($date);
1423  
-  else
  1425
+    $ts = @strtotime($date);
  1426
+    
  1427
+  if (empty($ts))
1424 1428
     return '';
  1429
+   
  1430
+  // get user's timezone
  1431
+  $tz = $CONFIG['timezone'];
  1432
+  if ($CONFIG['dst_active'])
  1433
+    $tz++;
1425 1434
 
1426 1435
   // convert time to user's timezone
1427  
-  $timestamp = $ts - date('Z', $ts) + ($CONFIG['timezone'] * 3600);
  1436
+  $timestamp = $ts - date('Z', $ts) + ($tz * 3600);
1428 1437
   
1429 1438
   // get current timestamp in user's timezone
1430 1439
   $now = time();  // local time
1431 1440
   $now -= (int)date('Z'); // make GMT time
1432  
-  $now += ($CONFIG['timezone'] * 3600); // user's time
  1441
+  $now += ($tz * 3600); // user's time
1433 1442
   $now_date = getdate();
1434 1443
 
1435  
-  //$day_secs = 60*((int)date('H', $now)*60 + (int)date('i', $now));
1436  
-  //$week_secs = 60 * 60 * 24 * 7;
1437  
-  //$diff = $now - $timestamp;
1438 1444
   $today_limit = mktime(0, 0, 0, $now_date['mon'], $now_date['mday'], $now_date['year']);
1439 1445
   $week_limit = mktime(0, 0, 0, $now_date['mon'], $now_date['mday']-6, $now_date['year']);
1440 1446
 
171  program/include/rcube_imap.inc
@@ -98,7 +98,7 @@ class rcube_imap
98 98
    */
99 99
   function connect($host, $user, $pass, $port=143, $use_ssl=FALSE)
100 100
     {
101  
-    global $ICL_SSL, $ICL_PORT;
  101
+    global $ICL_SSL, $ICL_PORT, $IMAP_USE_INTERNAL_DATE;
102 102
     
103 103
     // check for Open-SSL support in PHP build
104 104
     if ($use_ssl && in_array('openssl', get_loaded_extensions()))
@@ -111,6 +111,8 @@ class rcube_imap
111 111
       }
112 112
 
113 113
     $ICL_PORT = $port;
  114
+    $IMAP_USE_INTERNAL_DATE = false;
  115
+    
114 116
     $this->conn = iil_Connect($host, $user, $pass, array('imap' => 'check'));
115 117
     $this->host = $host;
116 118
     $this->user = $user;
@@ -475,7 +477,7 @@ class rcube_imap
475 477
 
476 478
 
477 479
   /**
478  
-   * Private method for listing message header
  480
+   * Private method for listing message headers
479 481
    *
480 482
    * @access  private
481 483
    * @see     rcube_imap::list_headers
@@ -493,6 +495,9 @@ class rcube_imap
493 495
     $max = $this->_messagecount($mailbox);
494 496
     $start_msg = ($this->list_page-1) * $this->page_size;
495 497
     
  498
+    list($begin, $end) = $this->_get_message_range($max, $page);
  499
+    
  500
+    /*    
496 501
     if ($page=='all')
497 502
       {
498 503
       $begin = 0;
@@ -512,7 +517,8 @@ class rcube_imap
512 517
     if ($begin < 0) $begin = 0;
513 518
     if ($end < 0) $end = $max;
514 519
     if ($end > $max) $end = $max;
515  
-
  520
+	*/
  521
+	
516 522
 //console("fetch headers $start_msg to ".($start_msg+$this->page_size)." (msg $begin to $end)");
517 523
 
518 524
     $headers_sorted = FALSE;
@@ -536,12 +542,7 @@ class rcube_imap
536 542
         
537 543
         $msgs = $msg_index[$begin];
538 544
         for ($i=$begin+1; $i < $end; $i++)
539  
-          {
540  
-          //if ($this->sort_order == 'DESC')
541  
-          //  $msgs = $msg_index[$i].','.$msgs;
542  
-          //else
543  
-            $msgs = $msgs.','.$msg_index[$i];
544  
-          }
  545
+          $msgs = $msgs.','.$msg_index[$i];
545 546
 
546 547
         $sorted = TRUE;
547 548
         }
@@ -585,14 +586,111 @@ class rcube_imap
585 586
 
586 587
     return array_values($a_msg_headers);
587 588
     }
  589
+    
  590
+
  591
+  /**
  592
+   * Public method for listing a specific set of headers
  593
+   * convert mailbox name with root dir first
  594
+   *
  595
+   * @param   string   Mailbox/folder name
  596
+   * @param   array    List of message ids to list
  597
+   * @param   number   Current page to list
  598
+   * @param   string   Header field to sort by
  599
+   * @param   string   Sort order [ASC|DESC]
  600
+   * @return  array    Indexed array with message header objects
  601
+   * @access  public   
  602
+   */
  603
+  function list_header_set($mbox='', $msgs, $page=NULL, $sort_field=NULL, $sort_order=NULL)
  604
+    {
  605
+    $mailbox = $mbox ? $this->_mod_mailbox($mbox) : $this->mailbox;
  606
+    return $this->_list_header_set($mailbox, $msgs, $page, $sort_field, $sort_order);    
  607
+    }
  608
+    
  609
+
  610
+  /**
  611
+   * Private method for listing a set of message headers
  612
+   *
  613
+   * @access  private
  614
+   * @see     rcube_imap::list_header_set
  615
+   */
  616
+  function _list_header_set($mailbox, $msgs, $page=NULL, $sort_field=NULL, $sort_order=NULL)
  617
+    {
  618
+    // also accept a comma-separated list of message ids
  619
+    if (is_string($msgs))
  620
+      $msgs = split(',', $msgs);
  621
+      
  622
+    if (!strlen($mailbox) || empty($msgs))
  623
+      return array();
  624
+
  625
+    if ($sort_field!=NULL)
  626
+      $this->sort_field = $sort_field;
  627
+    if ($sort_order!=NULL)
  628
+      $this->sort_order = strtoupper($sort_order);
  629
+
  630
+    $max = count($msgs);
  631
+    $start_msg = ($this->list_page-1) * $this->page_size;
  632
+    
  633
+    list($begin, $end) = $this->_get_message_range($max, $page);
  634
+
  635
+    // fetch reuested headers from server
  636
+    $a_msg_headers = array();
  637
+    $this->_fetch_headers($mailbox, join(',', $msgs), $a_msg_headers, NULL);
  638
+
  639
+    // return empty array if no messages found
  640
+	if (!is_array($a_msg_headers) || empty($a_msg_headers))
  641
+		return array();
  642
+
  643
+    // if not already sorted
  644
+    $a_msg_headers = iil_SortHeaders($a_msg_headers, $this->sort_field, $this->sort_order);
  645
+
  646
+	// only return the requested part of the set
  647
+	return array_slice(array_values($a_msg_headers), $begin, min($max, $this->page_size));
  648
+    }
  649
+
  650
+
  651
+  /**
  652
+   * Helper function to get first and last index of the requested set
  653
+   *
  654
+   * @param  number  message count
  655
+   * @param  mixed   page number to show, or string 'all'
  656
+   * @return array   array with two values: first index, last index
  657
+   * @access private
  658
+   */
  659
+  function _get_message_range($max, $page)
  660
+    {
  661
+    $start_msg = ($this->list_page-1) * $this->page_size;
  662
+    
  663
+    if ($page=='all')
  664
+      {
  665
+      $begin = 0;
  666
+      $end = $max;
  667
+      }
  668
+    else if ($this->sort_order=='DESC')
  669
+      {
  670
+      $begin = $max - $this->page_size - $start_msg;
  671
+      $end =   $max - $start_msg;
  672
+      }
  673
+    else
  674
+      {
  675
+      $begin = $start_msg;
  676
+      $end   = $start_msg + $this->page_size;
  677
+      }
588 678
 
  679
+    if ($begin < 0) $begin = 0;
  680
+    if ($end < 0) $end = $max;
  681
+    if ($end > $max) $end = $max;
  682
+    
  683
+    return array($begin, $end);
  684
+    }
  685
+    
  686
+    
589 687
 
590 688
   /**
591 689
    * Fetches message headers
592 690
    * Used for loop
593 691
    *
594 692
    * @param  string  Mailbox name
595  
-   * @param  string  Message indey to fetch
  693
+   * @param  string  Message index to fetch
596 694
    * @param  array   Reference to message headers array
597 695
    * @param  array   Array with cache index
598 696
    * @return number  Number of deleted messages
@@ -602,7 +700,7 @@ class rcube_imap
602 700
     {
603 701
     // cache is incomplete
604 702
     $cache_index = $this->get_message_cache_index($cache_key);
605  
-
  703
+    
606 704
     // fetch reuested headers from server
607 705
     $a_header_index = iil_C_FetchHeaders($this->conn, $mailbox, $msgs);
608 706
     $deleted_count = 0;
@@ -746,16 +844,44 @@ class rcube_imap
746 844
     }
747 845
 
748 846
 
749  
-  function search($mbox='', $criteria='ALL')
  847
+  /**
  848
+   * Invoke search request to IMAP server
  849
+   *
  850
+   * @param  string  mailbox name to search in
  851
+   * @param  string  search criteria (ALL, TO, FROM, SUBJECT, etc)
  852
+   * @param  string  search string
  853
+   * @return array   search results as list of message ids
  854
+   * @access public
  855
+   */
  856
+  function search($mbox='', $criteria='ALL', $str=NULL)
750 857
     {
751 858
     $mailbox = $mbox ? $this->_mod_mailbox($mbox) : $this->mailbox;
752  
-    return $this->_search_index($mailbox, $criteria);
753  
-    }
754  
-    
755  
-    
  859
+    if ($str && $criteria)
  860
+      {
  861
+      $criteria .= " \"$str\"";
  862
+      return $this->_search_index($mailbox, $criteria);
  863
+      }
  864
+    else
  865
+      return $this->_search_index($mailbox, $criteria);
  866
+    }    
  867
+
  868
+
  869
+  /**
  870
+   * Private search method
  871
+   *
  872
+   * @return array   search results as list of message ids
  873
+   * @access private
  874
+   * @see rcube_imap::search()
  875
+   */
756 876
   function _search_index($mailbox, $criteria='ALL')
757 877
     {
758 878
     $a_messages = iil_C_Search($this->conn, $mailbox, $criteria);
  879
+    
  880
+    // clean message list (there might be some empty entries)
  881
+    foreach ($a_messages as $i => $val)
  882
+      if (empty($val))
  883
+        unset($a_messages[$i]);
  884
+        
759 885
     return $a_messages;
760 886
     }
761 887
 
@@ -1070,10 +1196,11 @@ class rcube_imap
1070 1196
     if ($this->get_capability('QUOTA'))
1071 1197
       {
1072 1198
       $result = iil_C_GetQuota($this->conn);
1073  
-      return sprintf("%.2fMB / %.2fMB (%.0f%%)", $result["used"] / 1000.0, $result["total"] / 1000.0, $result["percent"]);
  1199
+      if ($result["total"])
  1200
+        return sprintf("%.2fMB / %.2fMB (%.0f%%)", $result["used"] / 1000.0, $result["total"] / 1000.0, $result["percent"]);       
1074 1201
       }
1075  
-    else
1076  
-      return 'unknown';
  1202
+
  1203
+    return FALSE;
1077 1204
     }
1078 1205
 
1079 1206
 
@@ -1444,6 +1571,10 @@ class rcube_imap
1444 1571
     {
1445 1572
     static $sa_message_index = array();
1446 1573
     
  1574
+    // empty key -> empty array
  1575
+    if (empty($key))
  1576
+      return array();
  1577
+    
1447 1578
     if (!empty($sa_message_index[$key]) && !$force)
1448 1579
       return $sa_message_index[$key];
1449 1580
     
@@ -1466,7 +1597,7 @@ class rcube_imap
1466 1597
 
1467 1598
   function add_message_cache($key, $index, $headers)
1468 1599
     {
1469  
-    if (!is_object($headers) || empty($headers->uid))
  1600
+    if (!$key || !is_object($headers) || empty($headers->uid))
1470 1601
       return;
1471 1602
 
1472 1603
     $this->db->query(
46  program/js/app.js
@@ -122,7 +122,7 @@ function rcube_webmail()
122 122
           }
123 123
 
124 124
         // enable mail commands
125  
-        this.enable_command('list', 'compose', 'add-contact', true);
  125
+        this.enable_command('list', 'compose', 'add-contact', 'search', 'reset-search', true);
126 126
         
127 127
         if (this.env.action=='show')
128 128
           {
@@ -574,7 +574,11 @@ function rcube_webmail()
574 574
       // misc list commands
575 575
       case 'list':
576 576
         if (this.task=='mail')
  577
+          {
  578
+          if (this.env.search_request && props != this.env.mailbox)
  579
+            this.reset_qsearch();
577 580
           this.list_mailbox(props);
  581
+          }
578 582
         else if (this.task=='addressbook')
579 583
           this.list_contacts();
580 584
         break;
@@ -904,6 +908,22 @@ function rcube_webmail()
904 908
         this.add_contact(props);
905 909
         break;
906 910
       
  911
+      // mail quicksearch
  912
+      case 'search':
  913
+        if (!props && this.gui_objects.qsearchbox)
  914
+          props = this.gui_objects.qsearchbox.value;
  915
+        if (props)
  916
+          this.qsearch(escape(props), this.env.mailbox);
  917
+        break;
  918
+
  919
+      // reset quicksearch        
  920
+      case 'reset-search':
  921
+        var s = this.env.search_request;
  922
+        this.reset_qsearch();
  923
+        
  924
+        if (s)
  925
+          this.list_mailbox(this.env.mailbox);
  926
+        break;
907 927
 
908 928
       // ldap search
909 929
       case 'ldappublicsearch':
@@ -1368,6 +1388,10 @@ function rcube_webmail()
1368 1388
       this.env.current_page = page;
1369 1389
       this.clear_selection();
1370 1390
       }
  1391
+    
  1392
+    // also send search request to get the right messages
  1393
+    if (this.env.search_request)
  1394
+      add_url += '&_search='+this.env.search_request;
1371 1395
       
1372 1396
     if (this.env.mailbox!=mbox)
1373 1397
       this.select_mailbox(mbox);
@@ -1803,6 +1827,26 @@ function rcube_webmail()
1803 1827
       this.http_request('addcontact', '_address='+value);
1804 1828
     };
1805 1829
 
  1830
+  // send remote request to search mail
  1831
+  this.qsearch = function(value, mbox)
  1832
+    {
  1833
+    if (value && mbox)
  1834
+      {
  1835
+      this.clear_message_list();
  1836
+      this.set_busy(true, 'searching');
  1837
+      this.http_request('search', '_search='+value+'&_mbox='+mbox, true);
  1838
+      }
  1839
+    };
  1840
+
  1841
+  // reset quick-search form
  1842
+  this.reset_qsearch = function()
  1843
+    {
  1844
+    if (this.gui_objects.qsearchbox)
  1845
+      this.gui_objects.qsearchbox.value = '';
  1846
+      
  1847
+    this.env.search_request = null;
  1848
+    };
  1849
+    
1806 1850
 
1807 1851
   /*********************************************************/
1808 1852
   /*********     keyboard live-search methods      *********/
17  program/lib/imap.inc
@@ -39,6 +39,7 @@
39 39
 		- Added BCC and REFERENCE to the list of headers to fetch in iil_C_FetchHeaders()
40 40
 		- Leave messageID unchanged in iil_C_FetchHeaders()
41 41
 		- Avoid stripslahes in iil_Connect()
  42
+		- Added patch to iil_SortHeaders() by Richard Green
42 43
 		- Removed <br> from error messages (better for logging)
43 44
 		- Removed some debuggers (echo ...)
44 45
 
@@ -1396,7 +1397,7 @@ function iil_SortHeaders($a, $field, $flag){
1396 1397
 	if (empty($flag)) $flag="ASC";
1397 1398
 	$flag=strtoupper($flag);
1398 1399
 	$stripArr = ($field=='subject') ? array('Re: ','Fwd: ','Fw: ',"\"") : array("\"");
1399  
-	
  1400
+
1400 1401
 	$c=count($a);
1401 1402
 	if ($c>0){
1402 1403
 		/*
@@ -1410,8 +1411,18 @@ function iil_SortHeaders($a, $field, $flag){
1410 1411
 		$index=array();
1411 1412
 		reset($a);
1412 1413
 		while (list($key, $val)=each($a)){
1413  
-			$data=$a[$key]->$field;
1414  
-			if (is_string($data)) $data=strtoupper(str_replace($stripArr, "", $data));
  1414
+
  1415
+			if ($field=="timestamp"){
  1416
+				$data = @strtotime($value->date);
  1417
+				if ($data != false)
  1418
+					$data = $timestamp;
  1419
+				}
  1420
+			else {
  1421
+				$data=$a[$key]->$field;
  1422
+				if (is_string($data))
  1423
+					$data=strtoupper(str_replace($stripArr, "", $data));
  1424
+				}
  1425
+
1415 1426
 			$index[$key]=$data;
1416 1427
 		}
1417 1428
 		
7  program/localization/de_CH/labels.inc
@@ -111,6 +111,12 @@ $labels['empty'] = 'Leeren';
111 111
 $labels['purge'] = 'Aufräumen';
112 112
 
113 113
 $labels['quota'] = 'Verwendeter Speicherplatz';
  114
+$labels['unknown']  = 'unbekannt';
  115
+$labels['unlimited']  = 'unlimitiert';
  116
+
  117
+$labels['quicksearch']  = 'Schnellsuche';
  118
+$labels['resetsearch']  = 'Löschen';
  119
+
114 120
 
115 121
 // message compose // Nachrichten erstellen
116 122
 $labels['compose']  = 'Neue Nachricht verfassen';
@@ -182,6 +188,7 @@ $labels['language']  = 'Sprache';
182 188
 $labels['timezone']  = 'Zeitzone';
183 189
 $labels['pagesize']  = 'Einträge pro Seite';
184 190
 $labels['signature'] = 'Signatur';
  191
+$labels['dstactive']  = 'Sommerzeit';
185 192
 
186 193
 $labels['folder']  = 'Ordner';
187 194
 $labels['folders']  = 'Ordner';
7  program/localization/de_DE/labels.inc
@@ -112,6 +112,12 @@ $labels['empty'] = 'Leeren';
112 112
 $labels['purge'] = 'Bereinigen';
113 113
 
114 114
 $labels['quota'] = 'Verwendeter Speicherplatz';
  115
+$labels['unknown']  = 'unbekannt';
  116
+$labels['unlimited']  = 'unlimitiert';
  117
+
  118
+$labels['quicksearch']  = 'Schnellsuche';
  119
+$labels['resetsearch']  = 'Löschen';
  120
+
115 121
 
116 122
 // message compose // Nachrichten erstellen
117 123
 $labels['compose']  = 'Neue Nachricht verfassen';
@@ -183,6 +189,7 @@ $labels['language']  = 'Sprache';
183 189
 $labels['timezone']  = 'Zeitzone';
184 190
 $labels['pagesize']  = 'Einträge pro Seite';
185 191
 $labels['signature'] = 'Signatur';
  192
+$labels['dstactive']  = 'Sommerzeit';
186 193
 
187 194
 $labels['folder']  = 'Ordner';
188 195
 $labels['folders']  = 'Ordner';
6  program/localization/en_US/labels.inc
@@ -111,6 +111,11 @@ $labels['empty'] = 'Empty';
111 111
 $labels['purge'] = 'Purge';
112 112
 
113 113
 $labels['quota'] = 'Disk usage';
  114
+$labels['unknown']  = 'unknown';
  115
+$labels['unlimited']  = 'unlimited';
  116
+
  117
+$labels['quicksearch']  = 'Quick search';
  118
+$labels['resetsearch']  = 'Reset search';
114 119
 
115 120
 
116 121
 // message compose
@@ -185,6 +190,7 @@ $labels['language']  = 'Language';
185 190
 $labels['timezone']  = 'Time zone';
186 191
 $labels['pagesize']  = 'Rows per page';
187 192
 $labels['signature'] = 'Signature';
  193
+$labels['dstactive']  = 'Daylight savings';
188 194
 
189 195
 $labels['folder']  = 'Folder';
190 196
 $labels['folders']  = 'Folders';
6  program/localization/en_US/messages.inc
@@ -88,4 +88,10 @@ $messages['nocontactsreturned'] = 'No contacts were found';
88 88
 
89 89
 $messages['nosearchname'] = 'Please enter a contact name or email address';
90 90
 
  91
+$messages['searchsuccessful'] = '$nr messages found';
  92
+
  93
+$messages['searchnomatch'] = 'Search returned no matches';
  94
+
  95
+$messages['searching'] = 'Searching...';
  96
+
91 97
 ?>
53  program/steps/mail/func.inc
@@ -528,6 +528,36 @@ function rcmail_js_message_list($a_headers, $insert_top=FALSE)
528 528
   }
529 529
 
530 530
 
  531
+// return code for search function
  532
+function rcmail_search_form($attrib)
  533
+  {
  534
+  global $OUTPUT, $JS_OBJECT_NAME;
  535
+
  536
+  // add some labels to client
  537
+  rcube_add_label('searching');
  538
+
  539
+  $attrib['name'] = '_q';
  540
+  
  541
+  if (empty($attrib['id']))
  542
+    $attrib['id'] = 'rcmqsearchbox';
  543
+  
  544
+  $input_q = new textfield($attrib);
  545
+  $out = $input_q->show();
  546
+
  547
+  $OUTPUT->add_script(sprintf("%s.gui_object('qsearchbox', '%s');",
  548
+                              $JS_OBJECT_NAME,
  549
+                              $attrib['id']));
  550
+
  551
+  // add form tag around text field
  552
+  if (empty($attrib['form']))
  553
+    $out = sprintf('<form name="rcmqsearchform" action="./" '.
  554
+                   'onsubmit="%s.command(\'search\');return false" style="display:inline;">%s</form>',
  555
+                   $JS_OBJECT_NAME,
  556
+                   $out);
  557
+
  558
+  return $out;
  559
+  } 
  560
+
531 561
 
532 562
 function rcmail_messagecount_display($attrib)
533 563
   {
@@ -536,7 +566,9 @@ function rcmail_messagecount_display($attrib)
536 566
   if (!$attrib['id'])
537 567
     $attrib['id'] = 'rcmcountdisplay';
538 568
 
539  
-  $OUTPUT->add_script(sprintf("%s.gui_object('countdisplay', '%s');", $JS_OBJECT_NAME, $attrib['id']));
  569
+  $OUTPUT->add_script(sprintf("%s.gui_object('countdisplay', '%s');",
  570
+                              $JS_OBJECT_NAME,
  571
+                              $attrib['id']));
540 572
 
541 573
   // allow the following attributes to be added to the <span> tag
542 574
   $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id'));
@@ -560,16 +592,20 @@ function rcmail_quota_display($attrib)
560 592
 
561 593
   // allow the following attributes to be added to the <span> tag
562 594
   $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id'));
563  
-
  595
+  
  596
+  if (!$IMAP->get_capability('QUOTA'))
  597
+    $quota_text = rcube_label('unknown');
  598
+  else if (!($quota_text = $IMAP->get_quota()))
  599
+    $quota_text = rcube_label('unlimited');
564 600
 
565 601
   $out = '<span' . $attrib_str . '>';
566  
-  $out .= $IMAP->get_quota();
  602
+  $out .= $quota_text;
567 603
   $out .= '</span>';
568 604
   return $out;
569 605
   }
570 606
 
571 607
 
572  
-function rcmail_get_messagecount_text()
  608
+function rcmail_get_messagecount_text($count=NULL, $page=NULL)
573 609
   {
574 610
   global $IMAP, $MESSAGE;
575 611
   
@@ -577,11 +613,14 @@ function rcmail_get_messagecount_text()
577 613
     {
578 614
     return rcube_label(array('name' => 'messagenrof',
579 615
                              'vars' => array('nr'  => $MESSAGE['index']+1,
580  
-                                             'count' => $IMAP->messagecount())));
  616
+                                             'count' => $count!==NULL ? $count : $IMAP->messagecount())));
581 617
     }
582 618
 
583  
-  $start_msg = ($IMAP->list_page-1) * $IMAP->page_size + 1;
584  
-  $max = $IMAP->messagecount();
  619
+  if ($page===NULL)
  620
+    $page = $IMAP->list_page;
  621
+    
  622
+  $start_msg = ($page-1) * $IMAP->page_size + 1;
  623
+  $max = $count!==NULL ? $count : $IMAP->messagecount();
585 624
 
586 625
   if ($max==0)
587 626
     $out = rcube_label('mailboxempty');
24  program/steps/mail/list.inc
@@ -22,8 +22,6 @@
22 22
 $REMOTE_REQUEST = TRUE;
23 23
 $OUTPUT_TYPE = 'js';
24 24
 
25  
-$unseen = $IMAP->messagecount($mbox, 'UNSEEN', !empty($_GET['_refresh']) ? TRUE : FALSE);
26  
-$count = $IMAP->messagecount();
27 25
 $sort = isset($_GET['_sort']) ? $_GET['_sort'] : false;
28 26
 
29 27
 // is there a sort type for this request?
@@ -37,13 +35,28 @@ if ($sort)
37 35
   $_SESSION['sort_order'] = $sort_order;
38 36
   }
39 37
 else
40  
-  {        
  38
+  {
41 39
   // use session settings if set, defaults if not
42 40
   $sort_col   = isset($_SESSION['sort_col'])   ? $_SESSION['sort_col']   : $CONFIG['message_sort_col'];
43 41
   $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
44 42
   }
45 43
   
46 44
 
  45
+// we have a saved search request
  46
+if (!empty($_GET['_search']) && isset($_SESSION['search'][$_GET['_search']]))
  47
+  {
  48
+  $a_msgs = split(',', $_SESSION['search'][$_GET['_search']]);
  49
+  $a_headers = $IMAP->list_header_set($mbox, $a_msgs, NULL, $sort_col, $sort_order);
  50
+  $count = count($a_msgs);
  51
+  }
  52
+else
  53
+  {
  54
+  if ($count = $IMAP->messagecount())
  55
+    $a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order);
  56
+  }
  57
+
  58
+$unseen = $IMAP->messagecount($mbox, 'UNSEEN', !empty($_GET['_refresh']) ? TRUE : FALSE);
  59
+
47 60
 // update message count display
48 61
 $pages = ceil($count/$IMAP->page_size);
49 62
 $commands = sprintf("this.set_env('messagecount', %d);\n", $count);
@@ -56,11 +69,8 @@ $commands .= sprintf("this.set_unread_count('%s', %d);\n", addslashes($mbox), $u
56 69
 
57 70
 
58 71
 // add message rows
59  
-if ($count)
60  
-  {
61  
-  $a_headers = $IMAP->list_headers($mbox, null, $sort_col, $sort_order);
  72
+if (isset($a_headers) && count($a_headers))
62 73
   $commands .= rcmail_js_message_list($a_headers);
63  
-  }
64 74
 
65 75
   
66 76
 // send response
11  program/steps/mail/sendmail.inc
@@ -159,9 +159,16 @@ if (!empty($CONFIG['generic_message_footer']))
159 159
     }
160 160
   }
161 161
 
162  
-
  162
+// try to autodetect operating system and use the correct line endings
163 163
 // use the configured delimiter for headers
164  
-$header_delm = $CONFIG['mail_header_delimiter'] ? $CONFIG['mail_header_delimiter'] : "\r\n";
  164
+if (!empty($CONFIG['mail_header_delimiter']))
  165
+  $header_delm = $CONFIG['mail_header_delimiter'];
  166
+else if (strtolower(substr(PHP_OS, 0, 3)=='win')) 
  167
+  $header_delm = "\r\n";
  168
+else if (strtolower(substr(PHP_OS, 0, 3)=='mac'))
  169
+  $header_delm = "\r\n";
  170
+else    
  171
+  $header_delm = "\n";
165 172
 
166 173
 // create PEAR::Mail_mime instance
167 174
 $MAIL_MIME = new Mail_mime($header_delm);
9  program/steps/settings/func.inc
@@ -78,6 +78,7 @@ function rcmail_user_prefs_form($attrib)
78 78
   $select_timezone->add('(GMT -5:00) Eastern Time (US/Canada), Bogota, Lima', '-5');
79 79
   $select_timezone->add('(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz', '-4');
80 80
   $select_timezone->add('(GMT -3:00) Brazil, Buenos Aires, Georgetown', '-3');
  81
+  $select_timezone->add('(GMT -3:30) Nfld Time (Canada), Nfld, S. Labador', '-3.5');
81 82
   $select_timezone->add('(GMT -2:00) Mid-Atlantic', '-2');
82 83
   $select_timezone->add('(GMT -1:00) Azores, Cape Verde Islands', '-1');
83 84
   $select_timezone->add('(GMT) Western Europe, London, Lisbon, Casablanca', '0');
@@ -108,6 +109,14 @@ function rcmail_user_prefs_form($attrib)
108 109
                   $select_timezone->show($CONFIG['timezone']));
109 110
 
110 111
 
  112
+  $field_id = 'rcmfd_dst';
  113
+  $input_dst = new checkbox(array('name' => '_dst_active', 'id' => $field_id, 'value' => 1));
  114
+  $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
  115
+                  $field_id,
  116
+                  rep_specialchars_output(rcube_label('dstactive')),
  117
+                  $input_dst->show($CONFIG['dst_active']));
  118
+
  119
+
111 120
   // show page size selection
112 121
   $field_id = 'rcmfd_pgsize';
113 122
   $input_pagesize = new textfield(array('name' => '_pagesize', 'id' => $field_id, 'size' => 5));
1  program/steps/settings/save_prefs.inc
@@ -25,6 +25,7 @@ if (!is_array($a_user_prefs))
25 25
 
26 26
 
27 27
 $a_user_prefs['timezone'] = isset($_POST['_timezone']) ? floatval($_POST['_timezone']) : $CONFIG['timezone'];
  28
+$a_user_prefs['dst_active'] = isset($_POST['_dst_active']) ? TRUE : FALSE;
28 29
 $a_user_prefs['pagesize'] = is_numeric($_POST['_pagesize']) ? (int)$_POST['_pagesize'] : $CONFIG['pagesize'];
29 30
 $a_user_prefs['prefer_html'] = isset($_POST['_prefer_html']) ? TRUE : FALSE;
30 31
 
BIN  skins/default/images/icons/reset.gif
29  skins/default/mail.css
@@ -82,7 +82,7 @@
82 82
 #messagecountbar
83 83
 {
84 84
   position: absolute;
85  
-  top: 60px;
  85
+  bottom: 16px;
86 86
   right: 40px;
87 87
   width: 300px;
88 88
   height: 20px;
@@ -457,6 +457,33 @@ body.messagelist
457 457
   color: #CCCCCC;
458 458
 }
459 459
 
  460
+#quicksearchbar
  461
+{
  462
+  position: absolute;
  463
+  top: 60px;
  464
+  right: 40px;
  465
+  width: 200px;
  466
+  height: 20px;
  467
+  text-align: right;
  468
+}
  469
+
  470
+#quicksearchbar a
  471
+{
  472
+  text-decoration: none;
  473
+  padding-left: 5px;
  474
+}
  475
+
  476
+#quicksearchbar img
  477
+{
  478
+  vertical-align: middle;
  479
+}
  480
+
  481
+#quicksearchbox
  482
+{
  483
+  width: 150px;
  484
+  border: 1px solid #999999;
  485
+}
  486
+
460 487
 
461 488
 /** message view styles */
462 489
 
4  skins/default/templates/mail.html
@@ -19,6 +19,10 @@
19 19
 <roundcube:button command="print" imageAct="/images/buttons/print_act.png" imagePas="/images/buttons/print_pas.png" width="32" height="32" title="printmessage" />
20 20
 </div>
21 21
 
  22
+<div id="quicksearchbar">
  23
+<roundcube:object name="searchform" id="quicksearchbox" /><roundcube:button command="reset-search" image="/images/icons/reset.gif" title="resetsearch" />
  24
+</div>
  25
+
22 26
 <div id="messagecountbar">
23 27
 <roundcube:button command="previouspage" imageAct="/images/buttons/previous_act.png" imagePas="/images/buttons/previous_pas.png" width="11" height="11" title="previousmessages" />
24 28
 &nbsp;<roundcube:object name="messageCountDisplay" />&nbsp;

0 notes on commit 4647e1b

Please sign in to comment.
Something went wrong with that request. Please try again.