[Vtigercrm-commits] [vtiger-commits] r6445 - in /vtigercrm/trunk: Smarty/templates/Webmails.tpl modules/Webmails/ListView.php modules/Webmails/WebmailsAjax.php themes/blue/style.css
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Fri May 26 02:43:41 EDT 2006
Author: mmbrich
Date: Fri May 26 00:43:39 2006
New Revision: 6445
Log:
removed full page refresh and enabled a JSON connector to check for new emails
Modified:
vtigercrm/trunk/Smarty/templates/Webmails.tpl
vtigercrm/trunk/modules/Webmails/ListView.php
vtigercrm/trunk/modules/Webmails/WebmailsAjax.php
vtigercrm/trunk/themes/blue/style.css
Modified: vtigercrm/trunk/Smarty/templates/Webmails.tpl
==============================================================================
--- vtigercrm/trunk/Smarty/templates/Webmails.tpl (original)
+++ vtigercrm/trunk/Smarty/templates/Webmails.tpl Fri May 26 00:43:39 2006
@@ -66,7 +66,7 @@
</tr>
<tr>
<td rowspan="6" valign="top" bgcolor="#FFFFFF" style="padding:10px; ">
- <img src="{$IMAGE_PATH}webmail_root.gif" align="absmiddle" /> <b class="txtGreen">{$MOD.LBL_MY_MAILS}</b>
+ <img src="{$IMAGE_PATH}webmail_root.gif" align="absmiddle" /> <span onmouseover="show_addfolder();" onmouseout="show_addfolder();" style="cursor:pointer;"><b class="txtGreen">{$MOD.LBL_MY_MAILS}</b> <span id="folderOpts" style="position:absolute;display:none">Add Folder[X]</span></span>
<ul style="list-style-type:none;">
@@ -116,7 +116,7 @@
<td> </td>
<td style="padding:1px;" align="left">
<div id="rssScroll">
- <table class="rssTable" cellspacing="0" cellpadding="0" border="0" width="100%">
+ <table class="rssTable" cellspacing="0" cellpadding="0" border="0" width="100%" id="message_table">
<tr>
<th width="5%"><input type="checkbox" name="checkbox" value="checkbox" onclick="select_all();"/></th>
{foreach item=element from=$LISTHEADER}
Modified: vtigercrm/trunk/modules/Webmails/ListView.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/ListView.php (original)
+++ vtigercrm/trunk/modules/Webmails/ListView.php Fri May 26 00:43:39 2006
@@ -1,15 +1,16 @@
-<script language="JavaScript" type="text/javascript" src="include/js/prototype_fade.js"></script>
+<script language="JavaScript" type="text/javascript" src="include/scriptaculous/prototype.js"></script>
+<script language="JavaScript" type="text/javascript" src="include/scriptaculous/scriptaculous.js?load=effects,builder"></script>
<?php
if($_REQUEST["mailbox"] && $_REQUEST["mailbox"] != "") {$mailbox=$_REQUEST["mailbox"];} else {$mailbox="INBOX";}
if($_REQUEST["start"] && $_REQUEST["start"] != "") {$start=$_REQUEST["start"];} else {$start="1";}
?>
<script type="text/javascript">
+var webmail = new Array();
function load_webmail(mid) {
var node = $("row_"+mid);
- var newhtml = remove(remove(node.innerHTML,'<b>'),'</b>');
- node.innerHTML = newhtml;
+ node.className='read_email';
try {
- var node = $("unread_img_"+mid).innerHTML = '<a href="javascript:;" onclick="OpenCompose(\''+mid+'\',\'reply\');"><img src="modules/Webmails/images/stock_mail-read.png" border="0" width="10" height="11"></a>';
+ $("unread_img_"+mid).innerHTML = '<a href="javascript:;" onclick="OpenCompose(\''+mid+'\',\'reply\');"><img src="modules/Webmails/images/stock_mail-read.png" border="0" width="10" height="11"></a>';
}catch(e){}
$("from_addy").innerHTML = " "+webmail[mid]["from"];
$("to_addy").innerHTML = " "+webmail[mid]["to"];
@@ -41,7 +42,7 @@
$("status").style.display="block";
new Ajax.Request(
'index.php',
- {queue: {position:'front', scope: 'command', limit:1},
+ {queue: {position: 'end', scope: 'command'},
method: 'post',
postBody: 'module=Webmails&action=Save&mailid='+mid+'&ajax=true',
onComplete: function(t) {
@@ -62,16 +63,70 @@
function check_for_new_mail(mbox) {
$("status").style.display="block";
new Ajax.Request(
- 'index.php',
- {queue: {position:'front', scope: 'command', limit:1},
+ 'modules/Webmails/WebmailsAjax.php',
+ {queue: {position: 'end', scope: 'command'},
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";
- timer = window.setTimeout("check_for_new_mail()",box_refresh);
+ try {
+ var data = eval('(' + t.responseText + ')');
+ for (var i=0;i<data.mails.length;i++)
+ {
+ var mailid = data.mails[i].mail.mailid;
+ var date = data.mails[i].mail.date;
+ var subject=data.mails[i].mail.subject;
+ var attachments=data.mails[i].mail.attachments;
+ var from=data.mails[i].mail.from;
+
+ webmail[mailid] = new Array();
+ webmail[mailid]["from"] = from;
+ webmail[mailid]["to"] = "myname";
+ webmail[mailid]["subject"] = subject;
+ webmail[mailid]["date"] = date;
+
+ // main row
+ var tr = Builder.node('tr',{id:'row_'+mailid, className: 'unread_email'});
+ // checkbox
+ var check = Builder.node('td',[Builder.node('input',{type: 'checkbox', name: 'checkbox_'+mailid, className: 'msg_check'})]);
+ tr.appendChild(check);
+
+ // images
+ // Attachment
+ if(attachments > 0)
+ tr.innerHTML += '<a href="javascript:;" onclick="displayAttachments('+mailid+');"><img src="modules/Webmails/images/stock_attach.png" border="0" width="14px" height="14"></a>';
+ else
+ tr.innerHTML += '<a href="javascript:;" onclick="displayAttachments('+mailid+');"><img src="modules/Webmails/images/blank.png" border="0" width="14px" height="14"></a>';
+
+ // read/unread/forward/reply
+ tr.innerHTML += '<span id="unread_img_'+mailid+'"><a href="index.php?module=Webmails&action=DetailView&<?php echo $detailParams;?>"><img src="modules/Webmails/images/stock_mail-unread.png" border="0" width="10" height="14"></a></span> ';
+
+ // Urgent Flag
+ tr.innerHTML += '<span id="set_td_'+mailid+'"><a href="javascript:void(0);" onclick="runEmailCommand(\'set_flag\','+mailid+');"><img src="modules/Webmails/images/plus.gif" border="0" width="11" height="11" id="set_flag_img_'+mailid+'"></a></span>';
+
+
+ // MSG details
+ tr.innerHTML += '<td colspan="1" align="left" ><b><a href="javascript:;" onclick="load_webmail(\''+mailid+'\');" id="ndeleted_subject_'+mailid+'">'+subject+'</a></b></td>';
+ tr.innerHTML += '<td colspan="1" align="left" nowrap id="ndeleted_date_'+mailid+'"><b>'+date+'</b> </td>';
+ tr.innerHTML += '<td colspan="1" align="left" id="ndeleted_from_'+mailid+'"><b>'+from+'</b></td>';
+
+ tr.innerHTML += '<td nowrap colspan="1" align="center" id="ndeleted_td_'+mailid+'"><span id="del_link_'+mailid+'"><a href="javascript:void(0);" onclick="runEmailCommand(\'delete_msg\','+mailid+');"><img src="modules/Webmails/images/gnome-fs-trash-empty.png" border="0" width="14" height="14" alt="del"></a></span></td>';
+
+ tr.style.display='none';
+
+ var tels = $("message_table").childNodes[1].childNodes;
+ for(var j=0;j<tels.length;j++) {
+ try {
+ if(tels[j].id.match(/row_/)) {
+ $("message_table").childNodes[1].insertBefore(tr,tels[j]);
+ break;
+ }
+ }catch(e){}
+ }
+ new Effect.Appear("row_"+mailid);
+ }
+ }catch(e) {}
+ $("status").style.display="none";
+ window.setTimeout("check_for_new_mail('<?php echo $mailbox;?>')",box_refresh);
}
}
);
@@ -80,9 +135,9 @@
var els = document.getElementsByClassName("deletedRow");
for(var i=0;i<els.length;i++) {
if(els[i].style.display == "none")
- new Effect.Appear(els[i],{queue:{position:'end',scope:'effect',limit:'1'}});
+ new Effect.Appear(els[i],{queue: {position: 'end', scope: 'command'}, duration: 0.3});
else
- new Effect.Fade(els[i],{queue:{position:'end',scope:'effect',limit:'1'}});
+ new Effect.Fade(els[i],{queue: {position: 'end', scope: 'command'}, duration: 0.3});
}
}
function move_messages() {
@@ -95,7 +150,7 @@
var mvmbox = $("mailbox_select").value;
new Ajax.Request(
'index.php',
- {queue: {position:'end', scope: 'command', limit:1},
+ {queue: {position: 'end', scope: 'command'},
method: 'post',
postBody: 'module=Webmails&action=ListView&mailbox=INBOX&command=move_msg&ajax=true&mailid='+nid+'&mvbox='+mvmbox,
onComplete: function(t) {
@@ -144,15 +199,10 @@
$show_hidden=$_REQUEST["show_hidden"];
?>
-<script language="Javascript" type="text/javascript" src="modules/Webmails/js/ajax_connection.js"></script>
-<script language="Javascript" type="text/javascript" src="modules/Webmails/js/script.js"></script>
-<script language="JavaScript" type="text/javascript" src="general.js"></script>
-<script language="JavaScript" type="text/javascript" src="include/js/prototype.js"></script>
-
<script type="text/Javascript">
var box_refresh=<?php echo $box_refresh;?>;
var timer = addOnloadEvent(function() {
- window.setTimeout("check_for_new_mail()",box_refresh);
+ window.setTimeout("check_for_new_mail('<?php echo $mailbox;?>')",box_refresh);
}
);
@@ -164,7 +214,7 @@
id=id;
new Ajax.Request(
'index.php',
- {queue: {position:'front', scope: 'command', limit:1},
+ {queue: {position: 'end', scope: 'command'},
method: 'post',
postBody: 'module=Webmails&action=body&command='+command+'&mailid='+id+'&mailbox=<?php echo $_REQUEST["mailbox"];?>',
onComplete: function(t) {
@@ -190,7 +240,7 @@
}
$("del_link_"+id).innerHTML = '<a href="javascript:void(0);" onclick="runEmailCommand(\'undelete_msg\','+id+');"><img src="modules/Webmails/images/gnome-fs-trash-full.png" border="0" width="14" height="14" alt="del"></a>';
- new Effect.Fade(row,{queue:{position:'end',scope:'effect',limit:'1'}});
+ new Effect.Fade(row,{queue: {position: 'end', scope: 'effect'}});
tmp = document.getElementsByClassName("previewWindow");
for(var i=0;i<tmp.length;i++) {
if(tmp[i].style.visibility === "visible") {
@@ -243,6 +293,20 @@
function changeMbox(box) {
location.href = "index.php?module=Webmails&action=index&parenttab=My%20Home%20Page&mailbox="+box+"&start=<?php echo $start;?>";
}
+function show_addfolder() {
+ var fldr = $("folderOpts");
+ if(fldr.style.display == 'none')
+ $("folderOpts").style.display="";
+ else
+ $("folderOpts").style.display="none";
+}
+function show_remfolder(mb) {
+ var fldr = $("remove_"+mb);
+ if(fldr.style.display == 'none')
+ fldr.style.display="";
+ else
+ fldr.style.display="none";
+}
</script>
<?
@@ -258,6 +322,8 @@
//<<<<<customview>>>>>
+echo "<div id='writeroot'> </div>";
+
global $mbox,$displayed_msgs;
if($ssltype == "") {$ssltype = "notls";}
if($sslmeth == "") {$sslmeth = "novalidate-cert";}
@@ -270,18 +336,6 @@
$mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/}".$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();
-}
-
if($_POST["command"] == "move_msg" && $_POST["ajax"] == "true") {
imap_mail_move($mbox,$_REQUEST["mailid"],$_REQUEST["mvbox"]);
imap_close($mbox);
@@ -289,7 +343,6 @@
flush();
exit();
}
-
function SureRemoveDir($dir) {
if(!$dh = @opendir($dir)) return;
@@ -338,7 +391,6 @@
<!-- MAIN MSG LIST TABLE -->
<script type="text/javascript">
-var webmail = new Array();
var msgCount = "<?php echo $numEmails;?>";
<?
$mails = array();
@@ -384,6 +436,8 @@
$displayed_msgs--;
} elseif ($mails[$start_message]->deleted && $show_hidden)
$flags = "<tr id='row_".$mails[$start_message]->msgno."' class='deletedRow'><td colspan='1'><input type='checkbox' name='checkbox_".$mails[$start_message]->msgno."' class='msg_check'></td><td colspan='1'>";
+ elseif (!$mails[$start_message]->seen || $mails[$start_message]->recent)
+ $flags = "<tr class='unread_email' id='row_".$mails[$start_message]->msgno."'><td colspan='1'><input type='checkbox' name='checkbox_".$mails[$start_message]->msgno."' class='msg_check'></td><td colspan='1'>";
else
$flags = "<tr id='row_".$mails[$start_message]->msgno."'><td colspan='1'><input type='checkbox' name='checkbox_".$mails[$start_message]->msgno."' class='msg_check'></td><td colspan='1'>";
@@ -423,9 +477,9 @@
$listview_entries[$num][] = '<td colspan="1" align="left" nowrap id="deleted_date_'.$num.'"><s>'.$mails[$start_message]->date.'</s></td>';
$listview_entries[$num][] = '<td colspan="1" align="left" id="deleted_from_'.$num.'"><s>'.substr($from,0,30).'</s></td>';
} elseif(!$mails[$start_message]->seen || $mails[$start_message]->recent) {
- $listview_entries[$num][] = '<td colspan="1" align="left" ><b><a href="javascript:;" onclick="load_webmail(\''.$num.'\');" id="ndeleted_subject_'.$num.'">'.substr($mails[$start_message]->subject,0,50).'</a></b></td>';
- $listview_entries[$num][] = '<td colspan="1" align="left" nowrap id="ndeleted_date_'.$num.'"><b>'.$mails[$start_message]->date.'</b> </td>';
- $listview_entries[$num][] = '<td colspan="1" align="left" id="ndeleted_from_'.$num.'"><b>'.substr($from,0,30).'</b></td>';
+ $listview_entries[$num][] = '<td colspan="1" align="left" ><a href="javascript:;" onclick="load_webmail(\''.$num.'\');" id="ndeleted_subject_'.$num.'">'.substr($mails[$start_message]->subject,0,50).'</a></td>';
+ $listview_entries[$num][] = '<td colspan="1" align="left" nowrap id="ndeleted_date_'.$num.'" >'.$mails[$start_message]->date.' </td>';
+ $listview_entries[$num][] = '<td colspan="1" align="left" id="ndeleted_from_'.$num.'">'.substr($from,0,30).'</td>';
} else {
$listview_entries[$num][] = '<td colspan="1" align="left" ><a href="javascript:;" onclick="load_webmail(\''.$num.'\');" id="ndeleted_subject_'.$num.'">'.substr($mails[$start_message]->subject,0,50).'</a></td>';
$listview_entries[$num][] = '<td colspan="1" align="left" nowrap id="ndeleted_date_'.$num.'">'.$mails[$start_message]->date.'</td>';
@@ -433,9 +487,9 @@
}
if($mails[$start_message]->deleted)
- $listview_entries[$num][] = '<td colspan="1" nowrap align="center" id="deleted_td_'.$num.'"><span id="del_link_'.$num.'"><a href="javascript:void(0);" onclick="runEmailCommand(\'undelete_msg\','.$num.');"><img src="modules/Webmails/images/gnome-fs-trash-full.png" border="0" width="14" height="14" alt="del"></a></span></td>';
+ $listview_entries[$num][] = '<td colspan="1" nowrap align="center" id="deleted_td_'.$num.'"><span id="del_link_'.$num.'"><a href="javascript:void(0);" onclick="runEmailCommand(\'undelete_msg\','.$num.');"><img src="modules/Webmails/images/gnome-fs-trash-full.png" border="0" width="14" height="14" alt="del"></a></span></td></tr>';
else
- $listview_entries[$num][] = '<td nowrap colspan="1" align="center" id="ndeleted_td_'.$num.'"><span id="del_link_'.$num.'"><a href="javascript:void(0);" onclick="runEmailCommand(\'delete_msg\','.$num.');"><img src="modules/Webmails/images/gnome-fs-trash-empty.png" border="0" width="14" height="14" alt="del"></a></span></td>';
+ $listview_entries[$num][] = '<td nowrap colspan="1" align="center" id="ndeleted_td_'.$num.'"><span id="del_link_'.$num.'"><a href="javascript:void(0);" onclick="runEmailCommand(\'delete_msg\','.$num.');"><img src="modules/Webmails/images/gnome-fs-trash-empty.png" border="0" width="14" height="14" alt="del"></a></span></td></tr>';
return $listview_entries[$num];
}
@@ -494,7 +548,7 @@
if ($mailbox == $tmpval) {
$boxes .= '<option value="'.$tmpval.'" SELECTED>'.$tmpval;
$box = imap_mailboxmsginfo($mbox);
- $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" onmouseover="show_remfolder(\''.$tmpval.'\');" onmouseout="show_remfolder(\''.$tmpval.'\');">'.$tmpval.'</a> <b>('.$box->Unread.' of '.$box->Nmsgs.')</b> <span id="remove_'.$tmpval.'" style="position:relative;display:none">Remove</span></li>';
} else {
if($ssltype == "") {$ssltype = "notls";}
if($sslmeth == "") {$sslmeth = "novalidate-cert";}
@@ -536,5 +590,4 @@
$smarty->assign("BOXLIST",$folders);
$smarty->display("Webmails.tpl");
//$smarty->display("ListView.tpl");
-
?>
Modified: vtigercrm/trunk/modules/Webmails/WebmailsAjax.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/WebmailsAjax.php (original)
+++ vtigercrm/trunk/modules/Webmails/WebmailsAjax.php Fri May 26 00:43:39 2006
@@ -9,13 +9,82 @@
*
********************************************************************************/
+session_start();
+if(!isset($_SESSION["authenticated_user_id"]) || $_SESSION["authenticated_user_id"] == "") {exit();}
+
+ini_set("include_path","../../");
+require_once('config.php');
+require_once('include/database/PearDatabase.php');
require_once('include/logging.php');
-require_once('modules/Emails/Email.php');
-require_once('include/database/PearDatabase.php');
-global $adb;
+require_once('include/utils/utils.php');
+require_once('include/utils/UserInfoUtil.php');
-$local_log =& LoggerManager::getLogger('EmailsAjax');
+global $adb,$mbox,$current_user;
-$ajaxaction = $_REQUEST["ajxaction"];
+$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);
+$login_username= $temprow["mail_username"];
+$secretkey=$temprow["mail_password"];
+$imapServerAddress=$temprow["mail_servername"];
+$box_refresh=$temprow["box_refresh"];
+$mails_per_page=$temprow["mails_per_page"];
+$mail_protocol=$temprow["mail_protocol"];
+$ssltype=$temprow["ssltype"];
+$sslmeth=$temprow["sslmeth"];
+$account_name=$temprow["account_name"];
+$show_hidden=$_REQUEST["show_hidden"];
+
+
+if($ssltype == "") {$ssltype = "notls";}
+if($sslmeth == "") {$sslmeth = "novalidate-cert";}
+// bug in windows PHP having to do with SSL not being linked correctly
+// causes this open command to fail.
+if(!preg_match("/windows/i",php_uname()))
+ $mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$_REQUEST["mailbox"], $login_username, $secretkey);
+
+
+$check = imap_check($mbox);
+
+//if($check->Recent > 0) {
+$search = imap_search($mbox, "NEW ALL");
+if($search === false) {echo "";flush();exit();}
+
+//echo $search[0];flush();exit();
+
+$data = imap_fetch_overview($mbox,implode(',',$search));
+$num=sizeof($data);
+
+$ret = '';
+if($num > 0) {
+ $ret = '{"mails":[';
+ for($i=0;$i<$num;$i++) {
+ $part = imap_fetchstructure($mbox,$data[$i]->msgno);
+ $ret .= '{"mail":';
+ $ret .= '{';
+ $ret .= '"mailid":"'.$data[$i]->msgno.'",';
+ $ret .= '"subject":"'.substr($data[$i]->subject,0,50).'",';
+ $ret .= '"date":"'.$data[$i]->date.'",';
+ $ret .= '"from":"'.$data[$i]->from.'",';
+ if(sizeof($part->parts) >0)
+ $ret .= '"attachments":"0"}';
+ else
+ $ret .= '"attachments":"1"}';
+ if(($i+1) == $num)
+ $ret .= '}';
+ else
+ $ret .= '},';
+ }
+ $ret .= ']}';
+}
+
+echo $ret;
+flush();
+imap_close($mbox);
?>
Modified: vtigercrm/trunk/themes/blue/style.css
==============================================================================
--- vtigercrm/trunk/themes/blue/style.css (original)
+++ vtigercrm/trunk/themes/blue/style.css Fri May 26 00:43:39 2006
@@ -2344,6 +2344,10 @@
background-color:#FFFFFF;
}
+.unread_email {
+ font-weight:bold;
+}
+
/* MY SITES */
@@ -2391,6 +2395,6 @@
font-size:11px;
text-decoration:none;
}
-
-
-
+.unread_email {
+ font-weight:bold;
+}
More information about the vtigercrm-commits
mailing list