[Vtigercrm-commits] [vtiger-commits] r6605 - in /vtigercrm/trunk/modules/Webmails: ListView.php WebmailsAjax.php webmails.js
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Sun May 28 06:17:35 EDT 2006
Author: mmbrich
Date: Sun May 28 04:17:34 2006
New Revision: 6605
Log:
new mail check for all folders
Modified:
vtigercrm/trunk/modules/Webmails/ListView.php
vtigercrm/trunk/modules/Webmails/WebmailsAjax.php
vtigercrm/trunk/modules/Webmails/webmails.js
Modified: vtigercrm/trunk/modules/Webmails/ListView.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/ListView.php (original)
+++ vtigercrm/trunk/modules/Webmails/ListView.php Sun May 28 04:17:34 2006
@@ -264,6 +264,7 @@
$list = imap_getmailboxes($mbox, "{".$imapServerAddress."}", "*");
sort($list);
+$i=0;
if (is_array($list)) {
$boxes = '<select name="mailbox" id="mailbox_select">';
foreach ($list as $key => $val) {
@@ -275,6 +276,9 @@
else
$img = "webmail_downarrow.gif";
+ $_SESSION["mailboxes"][$i] = $tmpval;
+ $i++;
+
if ($mailbox == $tmpval) {
$boxes .= '<option value="'.$tmpval.'" SELECTED>'.$tmpval;
$box = imap_mailboxmsginfo($mbox);
@@ -283,7 +287,7 @@
$tmpbox = getImapMbox($tmpval,$temprow);
$box = imap_mailboxmsginfo($tmpbox);
$boxes .= '<option value="'.$tmpval.'">'.$tmpval;
- $folders .= '<li><img src="'.$image_path.'/'.$img.'" align="absmiddle" /> <a href="javascript:changeMbox(\''.$tmpval.'\');" class="webMnu">'.$tmpval.'</a> <b>('.$box->Unread.' of '.$box->Nmsgs.')</b></li>';
+ $folders .= '<li><img src="'.$image_path.'/'.$img.'" align="absmiddle" /> <a href="javascript:changeMbox(\''.$tmpval.'\');" class="webMnu">'.$tmpval.'</a> <span id="'.$tmpval.'_count" style="font-weight:bold">(<span id="'.$tmpval.'_unread">'.$box->Unread.'</span> of <span id="'.$tmpval.'_read">'.$box->Nmsgs.'</span>)</span></li>';
imap_close($tmpbox);
}
}
Modified: vtigercrm/trunk/modules/Webmails/WebmailsAjax.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/WebmailsAjax.php (original)
+++ vtigercrm/trunk/modules/Webmails/WebmailsAjax.php Sun May 28 04:17:34 2006
@@ -9,10 +9,10 @@
*
********************************************************************************/
-if($_POST["command"]) {
+session_start();
+if(!isset($_SESSION["authenticated_user_id"]) || $_SESSION["authenticated_user_id"] == "") {exit();}
- session_start();
- if(!isset($_SESSION["authenticated_user_id"]) || $_SESSION["authenticated_user_id"] == "") {exit();}
+if($_POST["command"] == "check_mbox") {
ini_set("include_path","../../");
require_once('config.php');
@@ -74,4 +74,63 @@
flush();
imap_close($mbox);
}
+if($_POST["command"] == "check_mbox_all") {
+ ini_set("include_path","../../");
+ require_once('config.php');
+ require_once('include/database/PearDatabase.php');
+ require_once('include/logging.php');
+ require_once('include/utils/utils.php');
+ require_once('include/utils/UserInfoUtil.php');
+ require_once('modules/Webmails/MailParse.php');
+
+ global $adb,$mbox,$current_user;
+
+ $sql = "select * from mail_accounts where status=1 and user_id='".$_SESSION["authenticated_user_id"]."'";
+ $mailInfo = $adb->query($sql);
+
+ if($adb->num_rows($mailInfo) < 1) {
+ echo "<center><font color='red'><h3>Please configure your mail settings</h3></font></center>";
+ exit();
+ }
+
+ $temprow = $adb->fetch_array($mailInfo);
+ $imapServerAddress=$temprow["mail_servername"];
+
+ $boxes = array();
+ $i=0;
+ foreach ($_SESSION["mailboxes"] as $key => $val) {
+ $mailbox=$val;
+ $mbox = getImapMbox($mailbox,$temprow,"true");
+
+ $search = imap_search($mbox, "NEW ALL");
+ if($search != false) {
+ $boxes[$i]["name"] = $mailbox;
+ $boxes[$i]["newmsgs"] = sizeof($search);
+
+ $i++;
+ }
+ imap_close($mbox);
+ }
+
+ $ret = '';
+ if(count($boxes) > 0) {
+ $ret = '{"msgs":[';
+ for($i=0,$num=count($boxes);$i<$num;$i++) {
+ $ret .= '{"msg":';
+ $ret .= '{';
+ $ret .= '"box":"'.$boxes[$i]["name"].'",';
+ $ret .= '"newmsgs":"'.$boxes[$i]["newmsgs"].'"}';
+
+ if(($i+1) == $num)
+ $ret .= '}';
+ else
+ $ret .= '},';
+ }
+ $ret .= ']}';
+ }
+
+ echo $ret;
+ flush();
+ exit();
+}
?>
Modified: vtigercrm/trunk/modules/Webmails/webmails.js
==============================================================================
--- vtigercrm/trunk/modules/Webmails/webmails.js (original)
+++ vtigercrm/trunk/modules/Webmails/webmails.js Sun May 28 04:17:34 2006
@@ -78,6 +78,34 @@
else
els[i].checked = true;
}
+}
+function check_in_all_boxes(mymbox) {
+ $("status").style.display="block";
+ new Ajax.Request(
+ 'modules/Webmails/WebmailsAjax.php',
+ {queue: {position: 'end', scope: 'command'},
+ method: 'post',
+ postBody: '&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);
+ }
+ }
+ }
+ }catch(e){alert(e);}
+ }
+ }
+ );
+ $("status").style.display="none";
}
function check_for_new_mail(mbox) {
if(degraded_service == 'true') {
@@ -220,6 +248,7 @@
function periodic_event() {
window.clearTimeout(timer);
check_for_new_mail(mailbox);
+ check_in_all_boxes(mailbox);
timer = window.setTimeout("periodic_event()",box_refresh);
}
function show_hidden() {
More information about the vtigercrm-commits
mailing list