[Vtigercrm-commits] [vtiger-commits] r7892 - in /branches/VTIGERCRM-5.0.2-MMBRICH: Smarty/templates/Header.tpl include/js/objects/CommSystem.js modules/CommSystem/CommSystem.php modules/CommSystem/CommSystemAjax.php themes/blue/style.css
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Fri Jul 7 06:54:53 EDT 2006
Author: mmbrich
Date: Fri Jul 7 04:54:52 2006
New Revision: 7892
Log:
more comm system improvements, added email notification
Modified:
branches/VTIGERCRM-5.0.2-MMBRICH/Smarty/templates/Header.tpl
branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/CommSystem.js
branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystem.php
branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystemAjax.php
branches/VTIGERCRM-5.0.2-MMBRICH/themes/blue/style.css
Modified: branches/VTIGERCRM-5.0.2-MMBRICH/Smarty/templates/Header.tpl
==============================================================================
--- branches/VTIGERCRM-5.0.2-MMBRICH/Smarty/templates/Header.tpl (original)
+++ branches/VTIGERCRM-5.0.2-MMBRICH/Smarty/templates/Header.tpl Fri Jul 7 04:54:52 2006
@@ -491,5 +491,5 @@
Drag.init(THandle, TRoot);
</script>
-
-
+<span class="alertDisplay" id="alert_display"> </span>
+
Modified: branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/CommSystem.js
==============================================================================
--- branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/CommSystem.js (original)
+++ branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/CommSystem.js Fri Jul 7 04:54:52 2006
@@ -229,7 +229,7 @@
'div', {id:'msg_wrapper_'+msg.sending_user},
[ Builder.node(
'textarea', {id:'msg_input_'+msg.sending_user,name:msg.sending_user}
- )] //, [ Builder.node('br') ],
+ )]
)],
[ Builder.node(
'p',{id:'status_bar_'+msg.sending_user},'Status Bar'
@@ -243,7 +243,14 @@
$("comm_sys").appendChild(main_table);
try {
- $("chat_data_"+msg.sending_user).innerHTML += "<br>"+msg.msg_data;
+ Try.these (
+ function() {
+ $("chat_data_"+msg.sending_user).innerHTML = "<br><font color='red'>"+msg.user_name+"</font>: "+msg.msg_data;
+ },
+ function() {
+ $("chat_data_"+msg.sending_user).innerHTML += "<br>"+msg.msg_data;
+ }
+ );
$("msg_wrapper_"+msg.sending_user).innerHTML += '<input type="submit" class="button" value="Send" id="send_button_'+msg.sending_user+'" name="'+msg.sending_user+'">';
Event.observe($("msg_input_"+msg.sending_user), 'keypress', globalCommSystem.UserTyping.bindAsEventListener(this));
Event.observe($("send_button_"+msg.sending_user), 'click', globalCommSystem.SendMsg.bindAsEventListener(this));
@@ -253,6 +260,29 @@
new Draggable(main_table);
}
);
+ },
+
+ ShowAlertSlider: function(msg) {
+ $("alert_display").innerHTML = "<b><a href='index.php?module=Webmails&action=index'>"+msg+"</a></b>";
+ Try.these (
+ function() {
+ $("alert_display").style.display = "block";
+ window.setTimeout(function() {
+ globalCommSystem.HideAlertSlider();
+ },3000);
+ },
+ function() {
+ new Effect.Appear($("alert_display"));
+ window.setTimeout(function() {
+ globalCommSystem.HideAlertSlider();
+ },3000);
+ }
+ );
+ },
+
+ HideAlertSlider: function() {
+ new Effect.Fade($("alert_display"));
+ $("alert_display").innerHTML = "";
},
ScrollChatWindow: function(evt) {
@@ -307,19 +337,22 @@
* for messages (IMs) a window object will be built for the message.
*/
HandleEvent: function(responseData) {
+ //$("debug_win").innerHTML += "<BR>"+responseData.responseText;
globalCommSystem.tmpCount++;
+ try {
if(!responseData.responseText.match(/none/)) {
var msgs = eval('(' + responseData.responseText + ')');
for (var i=0;i<msgs.CommSysMessages.length;i++) {
- var msg = msgs.CommSysMessages[i].message;
- var msgid = msg.msgid;
- var msg_type = msg.msg_type;
- if(globalCommSystem.tmpCount >= 2) {
+ try {
+ var msg = msgs.CommSysMessages[i].message;
+ var msgid = msg.msgid;
+ var msg_type = msg.msg_type;
+ if(globalCommSystem.tmpCount >= 2) {
globalCommSystem.tmpCount = 0;
//globalCommSystem.MarkAsRead(msgid);
- }
- if(msg.sending_user == globalCommSystem.user.user_id) {return;}
- switch(msg_type) {
+ }
+ if(msg.sending_user == globalCommSystem.user.user_id) {return;}
+ switch(msg_type) {
case 'P2PIM':
globalCommSystem.ShowNewChatMessage(msg,"Chatting with "+msg.user_name);
break;
@@ -335,9 +368,21 @@
case 'VOICEMAIL':
alert(msgs.CommSysMessages[i].message.msg_data);
break;
- }
- }
- }
+ }
+ }catch(h){}
+ Try.these (
+ function() {
+ if(msgs.CommSysMessages[i].email.email_count > 0)
+ globalCommSystem.ShowAlertSlider("You have "+msgs.CommSysMessages[i].email.email_count+" new emails");
+ },
+ function() {
+ if(msgs.CommSysMessages[(i+1)].email.email_count > 0)
+ globalCommSystem.ShowAlertSlider("You have "+msgs.CommSysMessages[i].email.email_count+" new emails");
+ }
+ );
+ }
+ }
+ }catch(f){}
globalCommSystem.timer = window.setTimeout('globalCommSystem.CommUpdate()',globalCommSystem.refreshtime);
}
}
Modified: branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystem.php
==============================================================================
--- branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystem.php (original)
+++ branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystem.php Fri Jul 7 04:54:52 2006
@@ -22,6 +22,7 @@
require_once('include/logging.php');
require_once('include/database/PearDatabase.php');
require_once('include/utils/utils.php');
+global $current_user;
class CommSystem {
var $user;
@@ -130,5 +131,23 @@
function MarkRead($msgid) {
}
+
+ function CheckEmails() {
+ global $current_user;
+ require_once('include/utils/UserInfoUtil.php');
+ require_once("modules/Webmails/MailParse.php");
+ require_once("modules/Webmails/Webmail.php");
+
+ $mailInfo = getMailServerInfo($current_user);
+ $temprow = $this->db->fetch_array($mailInfo);
+ $imapServerAddress=$temprow["mail_servername"];
+ if($imapServerAddress != "" && isset($imapServerAddress)) {
+ $mbox = getImapMbox("INBOX",$temprow,"true");
+ $box = imap_status($mbox, "{".$imapServerAddress."}"."INBOX", SA_ALL);
+ return $box->unseen;
+ } else {
+ return "0";
+ }
+ }
}
?>
Modified: branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystemAjax.php
==============================================================================
--- branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystemAjax.php (original)
+++ branches/VTIGERCRM-5.0.2-MMBRICH/modules/CommSystem/CommSystemAjax.php Fri Jul 7 04:54:52 2006
@@ -28,6 +28,12 @@
if($_REQUEST["command"] == "getPeriodicalInfo") {
require_once("modules/CommSystem/CommSystem.php");
+
+ if(!isset($_SESSION["refresh_count"]))
+ $_SESSION["refresh_count"]=0;
+ else
+ $_SESSION["refresh_count"]++;
+
$commSys = new CommSystem();
$msg = $commSys->GetNewAlerts($_SESSION["authenticated_user_id"]);
$ret = '';
@@ -52,8 +58,36 @@
else
$ret .= '},';
}
- $ret .= ']}';
}
+ if($_SESSION["refresh_count"] >= 20) {
+ $_SESSION["refresh_count"] = 0;
+ $email_cnt = $commSys->CheckEmails();
+
+ if($email_cnt > 0) {
+ if($ret == "none")
+ $ret = '{"CommSysMessages":[';
+ else
+ $ret .= ',';
+ } else {
+ if($ret == "none")
+ $ret = 'none';
+ else
+ $ret .= '';
+ }
+
+ if($email_cnt > 0) {
+ $ret .= '{"email":';
+ $ret .= '{';
+ $ret .= '"email_count":"'.$email_cnt.'",';
+ $ret .= '}';
+ $ret .= '}';
+ $ret .= ']}';
+ } else if($ret != "none") {
+ $ret .= ']}';
+ }
+ } elseif($ret != "none")
+ $ret .= ']}';
+
echo $ret;
}
if($_REQUEST["command"] == "sendChatMessage") {
@@ -69,4 +103,10 @@
$adb->query($q);
echo "success";
}
+
+function check_email() {
+ require_once("modules/CommSystem/CommSystem.php");
+ $commSys = new CommSystem();
+ echo $commSys->CheckEmails();
+}
?>
Modified: branches/VTIGERCRM-5.0.2-MMBRICH/themes/blue/style.css
==============================================================================
--- branches/VTIGERCRM-5.0.2-MMBRICH/themes/blue/style.css (original)
+++ branches/VTIGERCRM-5.0.2-MMBRICH/themes/blue/style.css Fri Jul 7 04:54:52 2006
@@ -2926,3 +2926,15 @@
background-color: white;
z-index:1900000;
}
+.alertDisplay {
+ position: absolute;
+ width: 220px;
+ height: 100px;
+ bottom: 50px;
+ right: 1px;
+ border: 1px solid gray;
+ text-align: center;
+ background-color: #FFFFCC;
+ z-index:2000000;
+ display: none;
+}
More information about the vtigercrm-commits
mailing list