[Svn] r3419 - in trunk/roundcubemail: . program/include program/js program/lib program/localization/en_US program/localization/pl_PL program/steps/mail skins/default skins/default/images skins/default/templates

trac at roundcube.net trac at roundcube.net
Thu Mar 25 17:29:02 CET 2010


Author: alec
Date: 2010-03-25 11:29:02 -0500 (Thu, 25 Mar 2010)
New Revision: 3419

Modified:
   trunk/roundcubemail/CHANGELOG
   trunk/roundcubemail/program/include/rcube_imap.php
   trunk/roundcubemail/program/js/app.js
   trunk/roundcubemail/program/lib/imap.inc
   trunk/roundcubemail/program/localization/en_US/labels.inc
   trunk/roundcubemail/program/localization/pl_PL/labels.inc
   trunk/roundcubemail/program/steps/mail/mark.inc
   trunk/roundcubemail/program/steps/mail/move_del.inc
   trunk/roundcubemail/skins/default/images/mail_footer.png
   trunk/roundcubemail/skins/default/mail.css
   trunk/roundcubemail/skins/default/templates/mail.html
Log:
- Added possibility to select all messages in a folder (#1484756)


Modified: trunk/roundcubemail/CHANGELOG
===================================================================
--- trunk/roundcubemail/CHANGELOG	2010-03-25 14:25:59 UTC (rev 3418)
+++ trunk/roundcubemail/CHANGELOG	2010-03-25 16:29:02 UTC (rev 3419)
@@ -1,6 +1,7 @@
 CHANGELOG RoundCube Webmail
 ===========================
 
+- Added possibility to select all messages in a folder (#1484756)
 - Added 'imap_force_caps' option for after-login CAPABILITY checking (#1485750)
 - Password: Support dovecotpw encryption
 - TinyMCE 3.3.1

Modified: trunk/roundcubemail/program/include/rcube_imap.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_imap.php	2010-03-25 14:25:59 UTC (rev 3418)
+++ trunk/roundcubemail/program/include/rcube_imap.php	2010-03-25 16:29:02 UTC (rev 3419)
@@ -2115,7 +2115,7 @@
     $mailbox = $mbox_name ? $this->mod_mailbox($mbox_name) : $this->mailbox;
 
     $flag = strtoupper($flag);
-    list($uids, $all_mode) = $this->_parse_uids($uids);
+    list($uids, $all_mode) = $this->_parse_uids($uids, $mailbox);
 
     if (strpos($flag, 'UN') === 0)
       $result = iil_C_UnFlag($this->conn, $mailbox, $uids, substr($flag, 2));
@@ -2209,7 +2209,7 @@
     $to_mbox = $this->mod_mailbox($to_mbox);
     $from_mbox = $from_mbox ? $this->mod_mailbox($from_mbox) : $this->mailbox;
 
-    list($uids, $all_mode) = $this->_parse_uids($uids);
+    list($uids, $all_mode) = $this->_parse_uids($uids, $from_mbox);
 
     // exit if no message uids are specified
     if (empty($uids))
@@ -2291,7 +2291,7 @@
     $to_mbox = $this->mod_mailbox($to_mbox);
     $from_mbox = $from_mbox ? $this->mod_mailbox($from_mbox) : $this->mailbox;
 
-    list($uids, $all_mode) = $this->_parse_uids($uids);
+    list($uids, $all_mode) = $this->_parse_uids($uids, $from_mbox);
 
     // exit if no message uids are specified
     if (empty($uids))
@@ -2329,7 +2329,7 @@
   {
     $mailbox = $mbox_name ? $this->mod_mailbox($mbox_name) : $this->mailbox;
 
-    list($uids, $all_mode) = $this->_parse_uids($uids);
+    list($uids, $all_mode) = $this->_parse_uids($uids, $mailbox);
 
     // exit if no message uids are specified
     if (empty($uids))
@@ -2450,14 +2450,32 @@
    * Parse message UIDs input
    *
    * @param mixed  UIDs array or comma-separated list or '*' or '1:*'
+   * @param string Mailbox name
    * @return array Two elements array with UIDs converted to list and ALL flag 
    * @access private
    */
-  private function _parse_uids($uids)
+  private function _parse_uids($uids, $mailbox)
     {
     if ($uids === '*' || $uids === '1:*') {
-      $uids = '1:*';
-      $all = true;
+      if (empty($this->search_set)) {
+        $uids = '1:*';
+        $all = true;
+        }
+      // get UIDs from current search set
+      // @TODO: skip iil_C_FetchUIDs() and work with IDs instead of UIDs (?)
+      else {
+        if ($this->search_threads)
+          $uids = iil_C_FetchUIDs($this->conn, $mailbox, array_keys($this->search_set['depth']));
+        else
+          $uids = iil_C_FetchUIDs($this->conn, $mailbox, $this->search_set);
+      
+        // save ID-to-UID mapping in local cache
+        if (is_array($uids))
+          foreach ($uids as $id => $uid)
+            $this->uid_id_map[$mailbox][$uid] = $id;
+
+        $uids = join(',', $uids);
+        }
       }
     else {
       if (is_array($uids))

Modified: trunk/roundcubemail/program/js/app.js
===================================================================
--- trunk/roundcubemail/program/js/app.js	2010-03-25 14:25:59 UTC (rev 3418)
+++ trunk/roundcubemail/program/js/app.js	2010-03-25 16:29:02 UTC (rev 3419)
@@ -489,8 +489,8 @@
 
       case 'menu-open':
       case 'menu-save':
-	this.triggerEvent(command, {props:props});
-	return false;
+	    this.triggerEvent(command, {props:props});
+	    return false;
         break;
 
       case 'open':
@@ -753,10 +753,11 @@
         break;
         
       case 'select-all':
+        this.select_all_mode = props ? false : true;
         if (props == 'invert')
           this.message_list.invert_selection();
         else
-          this.message_list.select_all(props);
+          this.message_list.select_all(props == 'page' ? '' : props);
         break;
 
       case 'select-none':
@@ -1833,9 +1834,10 @@
 
     // unselect selected messages
     this.last_selected = 0;
-    if (this.message_list)
+    if (this.message_list) {
       this.message_list.clear_selection();
-    
+      this.select_all_mode = false;
+    }
     this.select_folder(mbox, this.env.mailbox);
     this.env.mailbox = mbox;
 
@@ -2254,8 +2256,8 @@
   // @private
   this._with_selected_messages = function(action, lock, add_url)
   {
-    var a_uids = new Array();
-    var count = 0;
+    var a_uids = new Array(),
+      count = 0;
 
     if (this.env.uid)
       a_uids[0] = this.env.uid;
@@ -2287,8 +2289,10 @@
       // remove threads from the end of the list
       this.delete_excessive_thread_rows();
 
+    add_url += '&_uid='+this.uids_to_list(a_uids);
+
     // send request to server
-    this.http_post(action, '_uid='+a_uids.join(',')+'&_mbox='+urlencode(this.env.mailbox)+add_url, lock);
+    this.http_post(action, '_mbox='+urlencode(this.env.mailbox)+add_url, lock);
   };
 
   // set a specific flag to one or more messages
@@ -2355,7 +2359,7 @@
     for (var i=0; i<a_uids.length; i++)
       this.set_message(a_uids[i], 'unread', (flag=='unread' ? true : false));
 
-    this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag='+flag);
+    this.http_post('mark', '_uid='+this.uids_to_list(a_uids)+'&_flag='+flag);
 
     for (var i=0; i<a_uids.length; i++)
       this.update_thread_root(a_uids[i], flag);
@@ -2368,7 +2372,7 @@
     for (var i=0; i<a_uids.length; i++)
       this.set_message(a_uids[i], 'flagged', (flag=='flagged' ? true : false));
 
-    this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag='+flag);
+    this.http_post('mark', '_uid='+this.uids_to_list(a_uids)+'&_flag='+flag);
   };
   
   // mark all message rows as deleted/undeleted
@@ -2412,49 +2416,48 @@
     for (var i=0; i<a_uids.length; i++)
       this.set_message(a_uids[i], 'deleted', false);
 
-    this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag=undelete');
+    this.http_post('mark', '_uid='+this.uids_to_list(a_uids)+'&_flag=undelete');
     return true;
   };
 
   this.flag_as_deleted = function(a_uids)
   {
-    var add_url = '';
-    var r_uids = new Array();
-    var rows = this.message_list ? this.message_list.rows : new Array();
-    var count = 0;
+    var add_url = '',
+      r_uids = new Array(),
+      rows = this.message_list ? this.message_list.rows : new Array(),
+      count = 0;
 
-    for (var i=0; i<a_uids.length; i++)
-      {
+    for (var i=0; i<a_uids.length; i++) {
       uid = a_uids[i];
-      if (rows[uid])
-        {
+      if (rows[uid]) {
         if (rows[uid].unread)
           r_uids[r_uids.length] = uid;
 
-	if (this.env.skip_deleted) {
-	  count += this.update_thread(uid);
+	    if (this.env.skip_deleted) {
+	      count += this.update_thread(uid);
           this.message_list.remove_row(uid, (this.env.display_next && i == this.message_list.selection.length-1));
-	  }
-	else
-	  this.set_message(uid, 'deleted', true);
-        }
+	    }
+	    else
+	      this.set_message(uid, 'deleted', true);
       }
+    }
 
     // make sure there are no selected rows
     if (this.env.skip_deleted && this.message_list) {
       if(!this.env.display_next)
-      this.message_list.clear_selection();
+        this.message_list.clear_selection();
       if (count < 0)
         add_url += '&_count='+(count*-1);
       else if (count > 0) 
         // remove threads from the end of the list
         this.delete_excessive_thread_rows();
-      }
+    }
 
     add_url = '&_from='+(this.env.action ? this.env.action : '');
     
+    // ??
     if (r_uids.length)
-      add_url += '&_ruid='+r_uids.join(',');
+      add_url += '&_ruid='+this.uids_to_list(r_uids);
 
     if (this.env.skip_deleted) {
       // also send search request to get the right messages 
@@ -2464,7 +2467,7 @@
         add_url += '&_next_uid='+this.env.next_uid;
     }
     
-    this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag=delete'+add_url);
+    this.http_post('mark', '_uid='+this.uids_to_list(a_uids)+'&_flag=delete'+add_url);
     return true;  
   };
 
@@ -2472,21 +2475,25 @@
   // argument should be a coma-separated list of uids
   this.flag_deleted_as_read = function(uids)
   {
-    var icn_src;
-    var rows = this.message_list ? this.message_list.rows : new Array();
-    var str = String(uids);
-    var a_uids = new Array();
+    var icn_src, uid,
+      rows = this.message_list ? this.message_list.rows : new Array(),
+      str = String(uids),
+      a_uids = str.split(',');
 
-    a_uids = str.split(',');
-
-    for (var uid, i=0; i<a_uids.length; i++)
-      {
+    for (var i=0; i<a_uids.length; i++) {
       uid = a_uids[i];
       if (rows[uid])
         this.set_message(uid, 'unread', false);
       }
   };
 
+  // Converts array of message UIDs to comma-separated list for use in URL
+  // with select_all mode checking
+  this.uids_to_list = function(uids)
+  {
+    return this.select_all_mode ? '*' : uids.join(',');
+  };
+  
 
   /*********************************************************/
   /*********       mailbox folders methods         *********/

Modified: trunk/roundcubemail/program/lib/imap.inc
===================================================================
--- trunk/roundcubemail/program/lib/imap.inc	2010-03-25 14:25:59 UTC (rev 3418)
+++ trunk/roundcubemail/program/lib/imap.inc	2010-03-25 16:29:02 UTC (rev 3419)
@@ -1066,16 +1066,15 @@
         return false;
 }
 
-function iil_C_FetchUIDs(&$conn,$mailbox) {
+function iil_C_FetchUIDs(&$conn, $mailbox, $message_set=null) {
 	global $clock;
+
+	if (is_array($message_set))
+		$message_set = join(',', $message_set);
+    else if (empty($message_set))
+		$message_set = '1:*';
 	
-	$num = iil_C_CountMessages($conn, $mailbox);
-	if ($num == 0) {
-	    return array();
-	}
-	$message_set = '1' . ($num>1?':' . $num:'');
-	
-	return iil_C_FetchHeaderIndex($conn, $mailbox, $message_set, 'UID');
+	return iil_C_FetchHeaderIndex($conn, $mailbox, $message_set, 'UID', false);
 }
 
 function iil_C_FetchHeaders(&$conn, $mailbox, $message_set, $uidfetch=false, $bodystr=false, $add='')

Modified: trunk/roundcubemail/program/localization/en_US/labels.inc
===================================================================
--- trunk/roundcubemail/program/localization/en_US/labels.inc	2010-03-25 14:25:59 UTC (rev 3418)
+++ trunk/roundcubemail/program/localization/en_US/labels.inc	2010-03-25 16:29:02 UTC (rev 3419)
@@ -146,6 +146,7 @@
 $labels['select'] = 'Select';
 $labels['all'] = 'All';
 $labels['none'] = 'None';
+$labels['currpage'] = 'Current page';
 $labels['unread'] = 'Unread';
 $labels['flagged'] = 'Flagged';
 $labels['unanswered'] = 'Unanswered';

Modified: trunk/roundcubemail/program/localization/pl_PL/labels.inc
===================================================================
--- trunk/roundcubemail/program/localization/pl_PL/labels.inc	2010-03-25 14:25:59 UTC (rev 3418)
+++ trunk/roundcubemail/program/localization/pl_PL/labels.inc	2010-03-25 16:29:02 UTC (rev 3419)
@@ -132,6 +132,7 @@
 $labels['messageactions'] = 'Więcej akcji...';
 $labels['select'] = 'Zaznacz';
 $labels['all'] = 'Wszystkie';
+$labels['currpage'] = 'Bieżąca strona';
 $labels['none'] = 'Brak';
 $labels['unread'] = 'Nieprzeczytane';
 $labels['flagged'] = 'Oznaczone';

Modified: trunk/roundcubemail/program/steps/mail/mark.inc
===================================================================
--- trunk/roundcubemail/program/steps/mail/mark.inc	2010-03-25 14:25:59 UTC (rev 3418)
+++ trunk/roundcubemail/program/steps/mail/mark.inc	2010-03-25 16:29:02 UTC (rev 3419)
@@ -52,14 +52,14 @@
     exit;
   }
 
-  if($flag == 'DELETED' && $CONFIG['read_when_deleted'] && !empty($_POST['_ruid'])) {
-    $uids = get_input_value('_ruid', RCUBE_INPUT_POST);
-    $read = $IMAP->set_flag($uids, 'SEEN');
+  if ($flag == 'DELETED' && $CONFIG['read_when_deleted'] && !empty($_POST['_ruid'])) {
+    $ruids = get_input_value('_ruid', RCUBE_INPUT_POST);
+    $read = $IMAP->set_flag($ruids, 'SEEN');
     
     if ($read != -1 && !$CONFIG['skip_deleted'])
-      $OUTPUT->command('flag_deleted_as_read', $uids);
+      $OUTPUT->command('flag_deleted_as_read', $ruids);
   }
-    
+
   if ($flag == 'SEEN' || $flag == 'UNSEEN' || ($flag == 'DELETED' && !$CONFIG['skip_deleted'])) {
     rcmail_send_unread_count($IMAP->get_mailbox_name());
   }
@@ -99,20 +99,20 @@
 
       if ($old_unseen != $unseen_count) {
         $OUTPUT->command('set_unread_count', $mbox, $unseen_count, ($mbox == 'INBOX'));
-	$_SESSION['unseen_count'][$mbox] = $unseen_count;
+	    $_SESSION['unseen_count'][$mbox] = $unseen_count;
       }
       $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count));
 
       if ($IMAP->threading)
-	$count = get_input_value('_count', RCUBE_INPUT_POST);
+	    $count = get_input_value('_count', RCUBE_INPUT_POST);
 
       // add new rows from next page (if any)
-      if ($count && ($jump_back || $nextpage_count > 0)) {
+      if ($count && $uids != '*' && ($jump_back || $nextpage_count >