[Vtigercrm-commits] [vtiger-commits] r6336 - in /vtigercrm/trunk: Smarty/templates/Webmails.tpl modules/Webmails/ListView.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Tue May 23 19:51:46 EDT 2006


Author: mmbrich
Date: Tue May 23 17:51:45 2006
New Revision: 6336

Log:
show msg info for mailbox list, use ajax to check for new messages before refreshing

Modified:
    vtigercrm/trunk/Smarty/templates/Webmails.tpl
    vtigercrm/trunk/modules/Webmails/ListView.php

Modified: vtigercrm/trunk/Smarty/templates/Webmails.tpl
==============================================================================
--- vtigercrm/trunk/Smarty/templates/Webmails.tpl (original)
+++ vtigercrm/trunk/Smarty/templates/Webmails.tpl Tue May 23 17:51:45 2006
@@ -36,7 +36,7 @@
 									<tr>
 											<td width="10%">
 												<img src="{$IMAGE_PATH}check_mail.gif" align="absmiddle" />
-												&nbsp;<a href="javascript:window.location = window.location;" class="webMnu" >{$MOD.LBL_CHK_MAIL}</a>
+												&nbsp;<a href="javascript:;" class="webMnu" onclick="check_for_new_mail('{$MAILBOX}');" >{$MOD.LBL_CHK_MAIL}</a>
 											</td>
 											<td width="10%">
 												<img src="{$IMAGE_PATH}compose.gif" align="absmiddle" />

Modified: vtigercrm/trunk/modules/Webmails/ListView.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/ListView.php (original)
+++ vtigercrm/trunk/modules/Webmails/ListView.php Tue May 23 17:51:45 2006
@@ -39,6 +39,22 @@
                         method: 'post',
                         postBody: 'module=Webmails&action=Save&mailid='+mid+'&ajax=true',
                         onComplete: function(t) {
+				$("status").style.display="none";
+			}
+		}
+	);
+}
+function check_for_new_mail(mbox) {
+	$("status").style.display="block";
+        new Ajax.Request(
+                'index.php',
+                {queue: {position:'front', scope: 'command', limit:1},
+                        method: 'post',
+                        postBody: 'module=Webmails&action=ListView&mailbox='+mbox+'&command=check_mbox&ajax=true',
+                        onComplete: function(t) {
+				if(!t.responseText.match(/NORELOAD/))
+					window.location=window.location;
+
 				$("status").style.display="none";
 			}
 		}
@@ -167,6 +183,17 @@
 if($sslmeth == "") {$sslmeth = "novalidate-cert";}
 $mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$mailbox, $login_username, $secretkey) or die("Connection to server failed ".imap_last_error());
 
+if($_POST["command"] == "check_mbox" && $_POST["ajax"] == "true") {
+	$check = imap_mailboxmsginfo($mbox);
+	if($check->Unread > 0)
+		return "RELOAD";
+	else
+		return "NORELOAD";
+
+	imap_close($mbox);
+	flush();
+	exit();
+}
 
 
 function SureRemoveDir($dir) {
@@ -336,12 +363,18 @@
 			$img = "webmail_uparrow.gif";
 		else
 			$img = "webmail_downarrow.gif";
-		if ($_REQUEST["mailbox"] == $tmpval) {
+		if ($mailbox == $tmpval) {
          		$boxes .= '<option value="'.$tmpval.'" SELECTED>'.$tmpval;
-			$folders .= '<li><img src="'.$image_path.'/'.$img.'" align="absmiddle" />&nbsp;&nbsp;<a href="javascript:changeMbox(\''.$tmpval.'\');" class="webMnu">'.$tmpval.'</a>&nbsp;<b>('.$numEmails.')</b></li>';
+			$box = imap_mailboxmsginfo($mbox);
+			$folders .= '<li><img src="'.$image_path.'/'.$img.'" align="absmiddle" />&nbsp;&nbsp;<a href="javascript:changeMbox(\''.$tmpval.'\');" class="webMnu">'.$tmpval.'</a>&nbsp;&nbsp;<b>('.$box->Unread.' of '.$box->Nmsgs.')</b></li>';
 		} else {
+			if($ssltype == "") {$ssltype = "notls";}
+			if($sslmeth == "") {$sslmeth = "novalidate-cert";}
+			$tmbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$tmpval, $login_username, $secretkey) or die("Connection to server failed ".imap_last_error());
+			$box = imap_mailboxmsginfo($tmbox);
          		$boxes .= '<option value="'.$tmpval.'">'.$tmpval;
-			$folders .= '<li><img src="'.$image_path.'/'.$img.'" align="absmiddle" />&nbsp;&nbsp;<a href="javascript:changeMbox(\''.$tmpval.'\');" class="webMnu">'.$tmpval.'</a>&nbsp;</li>';
+			$folders .= '<li><img src="'.$image_path.'/'.$img.'" align="absmiddle" />&nbsp;&nbsp;<a href="javascript:changeMbox(\''.$tmpval.'\');" class="webMnu">'.$tmpval.'</a>&nbsp;<b>('.$box->Unread.' of '.$box->Nmsgs.')</b></li>';
+			imap_close($tmbox);
 		}
  	}
 	$boxes .= '</select>';





More information about the vtigercrm-commits mailing list