[Vtigercrm-commits] [vtiger-commits] r6726 - in /vtigercrm/trunk/modules/Webmails: WebmailsAjax.php webmails.js

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Mon May 29 18:40:09 EDT 2006


Author: mmbrich
Date: Mon May 29 16:40:08 2006
New Revision: 6726

Log:
more speed improvements with imap_status

Modified:
    vtigercrm/trunk/modules/Webmails/WebmailsAjax.php
    vtigercrm/trunk/modules/Webmails/webmails.js

Modified: vtigercrm/trunk/modules/Webmails/WebmailsAjax.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/WebmailsAjax.php (original)
+++ vtigercrm/trunk/modules/Webmails/WebmailsAjax.php Mon May 29 16:40:08 2006
@@ -70,20 +70,19 @@
 		$mailbox=$key;
 		$mbox = getImapMbox($mailbox,$temprow,"true");
 
-		$search = imap_search($mbox, "NEW ALL");
-		if($search != false) {
-			$boxes[$i]["name"] = $mailbox;
-			if($val == sizeof($search))
-				$boxes[$i]["newmsgs"] = 0;
-			elseif($val < sizeof($search)) {
-				$boxes[$i]["newmsgs"] = (sizeof($search)-$val);
-				$_SESSION["mailboxes"][$key] = (sizeof($search));
-			} else {
-				$boxes[$i]["newmsgs"] = 0;
-				$_SESSION["mailboxes"][$key] = 0;
-			}
-			$i++;
+		$box = imap_status($mbox, "{".$imapServerAddress."}".$mailbox, SA_ALL);
+
+		$boxes[$i]["name"] = $mailbox;
+		if($val == $box->unseen)
+			$boxes[$i]["newmsgs"] = 0;
+		elseif($val < $box->unseen) {
+			$boxes[$i]["newmsgs"] = ($box->unseen-$val);
+			$_SESSION["mailboxes"][$mailbox] = $box->unseen;
+		} else {
+			$boxes[$i]["newmsgs"] = 0;
+			$_SESSION["mailboxes"][$mailbox] = $box->unseen;
 		}
+		$i++;
 		imap_close($mbox);
 	}
 

Modified: vtigercrm/trunk/modules/Webmails/webmails.js
==============================================================================
--- vtigercrm/trunk/modules/Webmails/webmails.js (original)
+++ vtigercrm/trunk/modules/Webmails/webmails.js Mon May 29 16:40:08 2006
@@ -84,7 +84,6 @@
 	if(degraded_service == 'true') {
 		return;
 	}
-        $("status").style.display="block";
         new Ajax.Request(
                 'index.php',
                 {queue: {position: 'end', scope: 'command'},
@@ -92,13 +91,13 @@
                         postBody: 'module=Webmails&action=WebmailsAjax&command=check_mbox_all&ajax=true',
                         onComplete: function(t) {
 				//alert(t.responseText);
-				try {
 				if(t.responseText != "") {
                                 	var data = eval('(' + t.responseText + ')');
                                 	for (var i=0;i<data.msgs.length;i++) {
 						if(mbox != mymbox) {
                                         		var mbox = data.msgs[i].msg.box;
                                         		var numnew = parseInt(data.msgs[i].msg.newmsgs);
+
 
 							var read  = parseInt($(mbox+"_read").innerHTML);
 							$(mbox+"_read").innerHTML = (read+numnew);
@@ -107,11 +106,10 @@
 						}
 					}
 				}
-				}catch(e){alert(e);}
+        			$("status").style.display="none";
 			}
 		}
 	);
-        $("status").style.display="none";
 }
 function check_for_new_mail(mbox) {
 	if(degraded_service == 'true') {
@@ -247,8 +245,7 @@
                                         new Effect.Appear("row_"+mailid);
                                 }
                             }catch(e) {}
-			    window.setTimeout("check_in_all_boxes('"+mailbox+"')",0);
-                            $("status").style.display="none";
+			    check_in_all_boxes('"+mailbox+"');
                         }
                 }
         );





More information about the vtigercrm-commits mailing list