[Svn] r2959 - in trunk/roundcubemail: . program/steps/mail

trac at roundcube.net trac at roundcube.net
Thu Sep 17 14:07:58 CEST 2009


Author: alec
Date: 2009-09-17 07:07:58 -0500 (Thu, 17 Sep 2009)
New Revision: 2959

Modified:
   trunk/roundcubemail/CHANGELOG
   trunk/roundcubemail/program/steps/mail/check_recent.inc
   trunk/roundcubemail/program/steps/mail/folders.inc
   trunk/roundcubemail/program/steps/mail/getunread.inc
   trunk/roundcubemail/program/steps/mail/list.inc
   trunk/roundcubemail/program/steps/mail/mark.inc
   trunk/roundcubemail/program/steps/mail/move_del.inc
Log:
- Fix incorrect count of new messages in folder list when using multiple IMAP clients (#1485995)
- Fix all folders checking for new messages with disabled caching (#1486128)


Modified: trunk/roundcubemail/CHANGELOG
===================================================================
--- trunk/roundcubemail/CHANGELOG	2009-09-16 06:35:49 UTC (rev 2958)
+++ trunk/roundcubemail/CHANGELOG	2009-09-17 12:07:58 UTC (rev 2959)
@@ -1,6 +1,8 @@
 CHANGELOG RoundCube Webmail
 ===========================
 
+- Fix incorrect count of new messages in folder list when using multiple IMAP clients (#1485995)
+- Fix all folders checking for new messages with disabled caching (#1486128)
 - Support skins in 'archive' and 'markasjunk' plugins
 - Added 'html_editor' hook (#1486068)
 - Fix DB constraint violation when populating messages cache (#1486052)

Modified: trunk/roundcubemail/program/steps/mail/check_recent.inc
===================================================================
--- trunk/roundcubemail/program/steps/mail/check_recent.inc	2009-09-16 06:35:49 UTC (rev 2958)
+++ trunk/roundcubemail/program/steps/mail/check_recent.inc	2009-09-17 12:07:58 UTC (rev 2959)
@@ -68,12 +68,30 @@
         rcmail_js_message_list($result_h, true, false);
       }
     }
+    else {
+      send_unread_count($mbox_name);
+    }
   }
-  else if ($unseen = $IMAP->messagecount($mbox_name, 'UNSEEN', $check_all)) {
-    $OUTPUT->command('set_unread_count', $mbox_name, $unseen);
+  else if ($check_all) {
+    send_unread_count($mbox_name);
   }
 }
 
 $OUTPUT->send();
 
+
+function send_unread_count($mbox_name)
+{
+    global $RCMAIL;
+
+    $old_unseen = $_SESSION['unseen_count'][$mbox_name];
+    $unseen = $RCMAIL->imap->messagecount($mbox_name, 'UNSEEN', true);
+
+    if ($unseen != $old_unseen)
+      $RCMAIL->output->command('set_unread_count', $mbox_name, $unseen, ($mbox_name == 'INBOX'));
+
+    // @TODO: this data is doubled (session and cache tables) if caching is enabled
+    $_SESSION['unseen_count'][$mbox_name] = $unseen;
+}
+
 ?>

Modified: trunk/roundcubemail/program/steps/mail/folders.inc
===================================================================
--- trunk/roundcubemail/program/steps/mail/folders.inc	2009-09-16 06:35:49 UTC (rev 2958)
+++ trunk/roundcubemail/program/steps/mail/folders.inc	2009-09-17 12:07:58 UTC (rev 2959)
@@ -60,6 +60,7 @@
       $OUTPUT->command('message_list.clear');
       $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text());
       $OUTPUT->command('set_unread_count', $mbox_name, 0);
+      $_SESSION['unseen_count'][$mbox_name] = 0;
     }
     else
       $commands = "// purged: $success";
@@ -67,4 +68,5 @@
 }
 
 $OUTPUT->send($commands);
+
 ?>

Modified: trunk/roundcubemail/program/steps/mail/getunread.inc
===================================================================
--- trunk/roundcubemail/program/steps/mail/getunread.inc	2009-09-16 06:35:49 UTC (rev 2958)
+++ trunk/roundcubemail/program/steps/mail/getunread.inc	2009-09-17 12:07:58 UTC (rev 2959)
@@ -24,9 +24,16 @@
 if (!empty($a_folders))
 {
   $inbox = ($IMAP->get_mailbox_name() == 'INBOX');
-  foreach ($a_folders as $mbox_row)
-    $OUTPUT->command('set_unread_count', $mbox_row, $IMAP->messagecount($mbox_row, 'UNSEEN'), $inbox && $mbox_row == 'INBOX');
+  foreach ($a_folders as $mbox_row) {
+    $unseen = $IMAP->messagecount($mbox_row, 'UNSEEN', !isset($_SESSION['unseen_count'][$mbox_row]));
+    $_SESSION['unseen_count'][$mbox_row] = $unseen;
+
+    if ($unseen) {
+      $OUTPUT->command('set_unread_count', $mbox_row, $unseen, $inbox && $mbox_row == 'INBOX');
+    }
+  }
 }
 
 $OUTPUT->send();
+
 ?>

Modified: trunk/roundcubemail/program/steps/mail/list.inc
===================================================================
--- trunk/roundcubemail/program/steps/mail/list.inc	2009-09-16 06:35:49 UTC (rev 2958)
+++ trunk/roundcubemail/program/steps/mail/list.inc	2009-09-17 12:07:58 UTC (rev 2959)
@@ -60,8 +60,15 @@
 if ($count = $IMAP->messagecount($mbox_name, 'ALL', !empty($_REQUEST['_refresh'])))
   $a_headers = $IMAP->list_headers($mbox_name, NULL, $sort_col, $sort_order);
 
+// count UNSEEN messages...
+$old_unseen = $_SESSION['unseen_count'][$mbox_name];
 $unseen = $count ? $IMAP->messagecount($mbox_name, 'UNSEEN', !empty($_REQUEST['_refresh'])) : 0;
+$_SESSION['unseen_count'][$mbox_name] = $unseen;
 
+// ...and update mailboxlist
+if ($unseen != $old_unseen)
+  $OUTPUT->command('set_unread_count', $mbox_name, $unseen, ($mbox_name == 'INBOX'));
+
 // update message count display
 $pages = ceil($count/$IMAP->page_size);
 $OUTPUT->set_env('messagecount', $count);
@@ -80,9 +87,6 @@
   $OUTPUT->show_message('searchnomatch', 'notice');
 else
   $OUTPUT->show_message('nomessagesfound', 'notice');
-  
-// update mailboxlist
-$OUTPUT->command('set_unread_count', $mbox_name, $unseen, ($mbox_name == 'INBOX'));
 
 // send response
 $OUTPUT->send();

Modified: trunk/roundcubemail/program/steps/mail/mark.inc
===================================================================
--- trunk/roundcubemail/program/steps/mail/mark.inc	2009-09-16 06:35:49 UTC (rev 2958)
+++ trunk/roundcubemail/program/steps/mail/mark.inc	2009-09-17 12:07:58 UTC (rev 2959)
@@ -62,7 +62,12 @@
     
   if ($flag == 'SEEN' || $flag == 'UNSEEN' || ($flag == 'DELETED' && !$CONFIG['skip_deleted'])) {
     $mbox_name = $IMAP->get_mailbox_name();
-    $OUTPUT->command('set_unread_count', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN'), ($mbox_name == 'INBOX'));
+    $unseen = $IMAP->messagecount($mbox_name, 'UNSEEN');
+    $old_unseen = $_SESSION['unseen_count'][$mbox_name];
+    if ($old_unseen != $unseen) {
+      $OUTPUT->command('set_unread_count', $mbox_name, $unseen, ($mbox_name == 'INBOX'));
+      $_SESSION['unseen_count'][$mbox_name] = $unseen;
+    }
   }
   else if ($flag == 'DELETED' && $CONFIG['skip_deleted']) {
     if ($_POST['_from'] == 'show') {
@@ -96,7 +101,11 @@
       // update mailboxlist
       $mbox = $IMAP->get_mailbox_name();
       $unseen_count = $msg_count ? $IMAP->messagecount($mbox, 'UNSEEN') : 0;
-      $OUTPUT->command('set_unread_count', $mbox, $unseen_count, ($mbox == 'INBOX'));
+      $old_unseen = $_SESSION['unseen_count'][$mbox];
+      if ($old_unseen != $unseen_count) {
+        $OUTPUT->command('set_unread_count', $mbox, $unseen_count, ($mbox == 'INBOX'));
+	$_SESSION['unseen_count'][$mbox] = $unseen_count;
+      }
       $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count));
 
       // add new rows from next page (if any)

Modified: trunk/roundcubemail/program/steps/mail/move_del.inc
===================================================================
--- trunk/roundcubemail/program/steps/mail/move_del.inc	2009-09-16 06:35:49 UTC (rev 2958)
+++ trunk/roundcubemail/program/steps/mail/move_del.inc	2009-09-17 12:07:58 UTC (rev 2959)
@@ -102,10 +102,20 @@
   // update mailboxlist
   $mbox = $IMAP->get_mailbox_name();
   $unseen_count = $msg_count ? $IMAP->messagecount($mbox, 'UNSEEN') : 0;
-  $OUTPUT->command('set_unread_count', $mbox, $unseen_count, ($mbox == 'INBOX'));
+  $old_unseen = $_SESSION['unseen_count'][$mbox];
+  
+  if ($old_unseen != $unseen_count) {
+    $OUTPUT->command('set_unread_count', $mbox, $unseen_count, ($mbox == 'INBOX'));
+    $_SESSION['unseen_count'][$mbox] = $unseen_count;
+  }
 
   if ($RCMAIL->action=='moveto' && $target) {
-    $OUTPUT->command('set_unread_count', $target, $IMAP->messagecount($target, 'UNSEEN'));
+    $unseen_count = $IMAP->messagecount($target, 'UNSEEN', true);
+    $old_unseen = $_SESSION['unseen_count'][$target];
+    if ($old_unseen != $unseen_count) {
+      $OUTPUT->command('set_unread_count', $target, $unseen_count);
+      $_SESSION['unseen_count'][$target] = $unseen_count;
+    }
   }
 
   $OUTPUT->command('set_quota', rcmail_quota_content($IMAP->get_quota()));

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list