[Vtigercrm-commits] [vtiger-commits] r7899 - in /branches/VTIGERCRM-5.0.2-MMBRICH: include/js/objects/CommSystem.js modules/CommSystem/CommSystem.php modules/CommSystem/CommSystemAjax.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Fri Jul 7 14:46:44 EDT 2006
Author: mmbrich
Date: Fri Jul 7 12:46:43 2006
New Revision: 7899
Log:
enabled stateful tracking of IM's in new comm system
Modified:
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
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 12:46:43 2006
@@ -22,13 +22,20 @@
*
*/
CommUpdate: function() {
- window.clearTimeout(this.timer);
globalCommSystem = this;
+ window.clearTimeout(globalCommSystem.timer);
+ if(globalCommSystem.tmpCount == 0 || typeof(globalCommSystem.tmpCount) == "undefined") {
+ var first = 'true';
+ globalCommSystem.tmpCount++;
+ } else {
+ var first = 'false';
+ globalCommSystem.tmpCount++;
+ }
new Ajax.Request(
'index.php',
{queue: {position: 'end', scope: 'commsys'},
method: 'post',
- postBody: 'module=CommSystem&action=CommSystemAjax&command=getPeriodicalInfo',
+ postBody: 'module=CommSystem&action=CommSystemAjax&command=getPeriodicalInfo&first_load='+first,
onComplete: globalCommSystem.HandleEvent,
onFailure: function() {
alert("Failed");
@@ -266,24 +273,28 @@
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();
- },4500);
- },
- function() {
- new Effect.Appear($("alert_display"));
- window.setTimeout(function() {
- globalCommSystem.HideAlertSlider();
- },4500);
+ $("alert_display").style.display = "block";
+
+ new Effect.Highlight("alert_display",{startcolor:'#ff99ff',endcolor:'#999999',
+ queue: {position: 'end', scope: 'commsys'},
+ afterFinish:function() {
+ new Effect.Highlight("alert_display",{
+ startcolor:'#ff99ff',endcolor:'#999999',
+ queue: {position: 'end', scope: 'commsys'}
+ }
+ )
+ }
}
);
+ window.setTimeout(function() {
+ globalCommSystem.HideAlertSlider();
+ },4500);
},
HideAlertSlider: function() {
- new Effect.Fold($("alert_display"), {onFinish: function() {
+ new Effect.Squish($("alert_display"), {
+ queue: {position: 'end', scope: 'commsys'},
+ afterFinish: function() {
$("alert_display").innerHTML = "";
}
}
@@ -326,10 +337,7 @@
'index.php',
{queue: {position: 'end', scope: 'commsys'},
method: 'post',
- postBody: 'module=CommSystem&action=CommSystemAjax&command=markAsRead&msgid='+msgid,
- onComplete: function(response) {
-
- }
+ postBody: 'module=CommSystem&action=CommSystemAjax&command=markAsRead&msgid='+msgid
}
);
},
@@ -343,7 +351,6 @@
*/
HandleEvent: function(responseData) {
//$("debug_win").innerHTML += "<BR>"+responseData.responseText;
- globalCommSystem.tmpCount++;
try {
if(!responseData.responseText.match(/none/)) {
var msgs = eval('(' + responseData.responseText + ')');
@@ -352,25 +359,26 @@
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) {
case 'P2PIM':
+ window.setTimeout('globalCommSystem.MarkAsRead("'+msgid+'")',2000);
globalCommSystem.ShowNewChatMessage(msg,"Chatting with "+msg.user_name);
break;
case 'GRPIM':
+ window.setTimeout('globalCommSystem.MarkAsRead("'+msgid+'")',2000);
alert(msgs.CommSysMessages[i].message.msg_data);
break;
case 'EMAIL':
+ window.setTimeout('globalCommSystem.MarkAsRead("'+msgid+'")',2000);
globalCommSystem.ShowAlertSlider("<b>New Email:</b><br> "+msgs.CommSysMessages[i].message.recordid);
break;
case 'INPHONE':
+ window.setTimeout('globalCommSystem.MarkAsRead("'+msgid+'")',2000);
globalCommSystem.ShowAlertSlider("<b>Incoming Call:</b><br> "+msgs.CommSysMessages[i].message.msg_data);
break;
case 'VOICEMAIL':
+ window.setTimeout('globalCommSystem.MarkAsRead("'+msgid+'")',2000);
globalCommSystem.ShowAlertSlider("<b>New Voicemial:</b><br> "+msgs.CommSysMessages[i].message.msg_data);
break;
}
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 12:46:43 2006
@@ -78,13 +78,19 @@
return "false";
}
- function GetNewAlerts($userid) {
+ function GetNewAlerts($userid,$get_old='') {
// This query will get all non-group/non-broadcast messages
- $q = "SELECT vtiger_comm_system.*,vtiger_users.user_name FROM vtiger_comm_system INNER JOIN vtiger_users ON vtiger_users.id=vtiger_comm_system.sending_user WHERE receivers='".$userid."' AND viewed = '0'";
+ if($get_old == 'true')
+ $q = "SELECT vtiger_comm_system.*,vtiger_users.user_name FROM vtiger_comm_system INNER JOIN vtiger_users ON vtiger_users.id=vtiger_comm_system.sending_user WHERE receivers='".$userid."' AND viewed = '0' OR viewed = '1' AND msg_type='P2PIM'";
+ else
+ $q = "SELECT vtiger_comm_system.*,vtiger_users.user_name FROM vtiger_comm_system INNER JOIN vtiger_users ON vtiger_users.id=vtiger_comm_system.sending_user WHERE receivers='".$userid."' AND viewed = '0' AND msg_type='P2PIM'";
$p2p = $this->db->query($q);
// This query will get all group/broadcast messages
- $q = "SELECT vtiger_comm_system.*,vtiger_users.user_name FROM vtiger_comm_system INNER JOIN vtiger_users ON vtiger_users.id=vtiger_comm_system.sending_user WHERE receivers LIKE '%,".$userid.",%' OR receivers LIKE '".$userid.",%' OR receivers LIKE '%,".$userid."' AND viewed = '0'";
+ if($get_old == 'true')
+ $q = "SELECT vtiger_comm_system.*,vtiger_users.user_name FROM vtiger_comm_system INNER JOIN vtiger_users ON vtiger_users.id=vtiger_comm_system.sending_user WHERE receivers LIKE '%,".$userid.",%' OR receivers LIKE '".$userid.",%' OR receivers LIKE '%,".$userid."' AND viewed = '0' OR viewed = '1' AND msg_type='GRPIM'";
+ else
+ $q = "SELECT vtiger_comm_system.*,vtiger_users.user_name FROM vtiger_comm_system INNER JOIN vtiger_users ON vtiger_users.id=vtiger_comm_system.sending_user WHERE receivers LIKE '%,".$userid.",%' OR receivers LIKE '".$userid.",%' OR receivers LIKE '%,".$userid."' AND viewed = '0' AND msg_type='GRPIM'";
$grp = $this->db->query($q);
$ret = array();
@@ -117,7 +123,11 @@
}
}
- $q = "UPDATE vtiger_comm_system SET viewed='1' WHERE ";
+ if($get_old == 'true')
+ $viewed='2';
+ else
+ $viewed='1';
+ $q = "UPDATE vtiger_comm_system SET viewed='".$viewed."' WHERE ";
for($i=0,$cnt=count($ret);$i<$cnt;$i++) {
if($i==0)
$q .= "msgid='".$ret[$i]["msgid"]."'";
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 12:46:43 2006
@@ -29,13 +29,18 @@
if($_REQUEST["command"] == "getPeriodicalInfo") {
require_once("modules/CommSystem/CommSystem.php");
- if(!isset($_SESSION["refresh_count"]))
+ if(!isset($_SESSION["refresh_count"])) {
$_SESSION["refresh_count"]=0;
- else
+ } else
$_SESSION["refresh_count"]++;
+ if($_SESSION["refresh_count"] <= 0 || $_REQUEST["first_load"] == 'true')
+ $get_old = 'true';
+ else
+ $get_old = 'false';
+
$commSys = new CommSystem();
- $msg = $commSys->GetNewAlerts($_SESSION["authenticated_user_id"]);
+ $msg = $commSys->GetNewAlerts($_SESSION["authenticated_user_id"],$get_old);
$ret = '';
$cnt=count($msg);
if($cnt == 0)
@@ -59,8 +64,8 @@
$ret .= '},';
}
}
- if($_SESSION["refresh_count"] >= 20) {
- $_SESSION["refresh_count"] = 0;
+ if($_SESSION["refresh_count"] >= 5) {
+ $_SESSION["refresh_count"] = 1;
$email_cnt = $commSys->CheckEmails();
if($email_cnt > 0) {
@@ -78,8 +83,7 @@
if($email_cnt > 0) {
$ret .= '{"email":';
$ret .= '{';
- $ret .= '"unseen_emails":"'.$email_cnt.'",';
- $ret .= '"total_emails":"'.$email_cnt.'"';
+ $ret .= '"unseen_emails":"'.$email_cnt.'"';
$ret .= '}';
$ret .= '}';
$ret .= ']}';
More information about the vtigercrm-commits
mailing list