mirror of
https://github.com/Mibew/tray.git
synced 2025-01-22 18:10:34 +03:00
operator is away support
git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@594 c66351dc-e62f-0410-b875-e3a5c0b9693f
This commit is contained in:
parent
507f0c9d60
commit
65bb8f0f97
@ -527,6 +527,19 @@ table.awaiting td.visitor {
|
||||
margin: 10px 10px;
|
||||
}
|
||||
|
||||
#connlinks {
|
||||
margin: 10px 10px;
|
||||
}
|
||||
|
||||
#connlinks a {
|
||||
color: #777;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#connlinks a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* search */
|
||||
|
||||
#searchtext {
|
||||
|
@ -63,6 +63,7 @@ $dbtables = array(
|
||||
"vclocalename" => "varchar(64) NOT NULL",
|
||||
"vccommonname" => "varchar(64) NOT NULL",
|
||||
"dtmlastvisited" => "datetime DEFAULT 0",
|
||||
"istatus" => "int DEFAULT 0", /* 0 - online, 1 - away */
|
||||
"vcavatar" => "varchar(255)",
|
||||
"vcjabbername" => "varchar(255)",
|
||||
"iperm" => "int DEFAULT 65535",
|
||||
@ -105,7 +106,7 @@ $memtables = array();
|
||||
$dbtables_can_update = array(
|
||||
"chatthread" => array("agentId", "userTyping", "agentTyping", "messageCount", "nextagent", "shownmessageid", "userid", "userAgent", "groupid"),
|
||||
"chatmessage" => array("agentId"),
|
||||
"chatoperator" => array("vcavatar", "vcjabbername", "iperm"),
|
||||
"chatoperator" => array("vcavatar", "vcjabbername", "iperm", "istatus"),
|
||||
"chatban" => array(),
|
||||
"chatgroup" => array(),
|
||||
"chatgroupoperator" => array(),
|
||||
|
@ -111,6 +111,10 @@ if ($act == "silentcreateall") {
|
||||
runsql("ALTER TABLE chatoperator ADD iperm int DEFAULT 65535", $link);
|
||||
}
|
||||
|
||||
if( in_array("chatoperator.istatus", $absent) ) {
|
||||
runsql("ALTER TABLE chatoperator ADD istatus int DEFAULT 0", $link);
|
||||
}
|
||||
|
||||
if( in_array("chatoperator.vcavatar", $absent) ) {
|
||||
runsql("ALTER TABLE chatoperator ADD vcavatar varchar(255)", $link);
|
||||
}
|
||||
@ -127,10 +131,9 @@ if ($act == "silentcreateall") {
|
||||
runsql("ALTER TABLE chatthread ADD userAgent varchar(255)", $link);
|
||||
}
|
||||
|
||||
$res = runsql("select null from information_schema.statistics where table_name = 'chatmessage' and index_name = 'idx_agentid'", $link);
|
||||
if(mysql_num_rows($res) == 0) {
|
||||
$res = mysql_query("select null from information_schema.statistics where table_name = 'chatmessage' and index_name = 'idx_agentid'", $link);
|
||||
if($res && mysql_num_rows($res) == 0) {
|
||||
runsql("ALTER TABLE chatmessage ADD INDEX idx_agentid (agentid)", $link);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
//- onComplete, obj, params, $apply$
|
||||
//- threadParams, servl, frequency, user, threadid, token, cssfile
|
||||
//- updaterOptions, url, company, agentservl, noclients, wroot, havemenu, showpopup, ignorectrl
|
||||
//- updaterOptions, url, company, agentservl, noclients, wroot, havemenu, showpopup, ignorectrl, istatus
|
||||
|
||||
|
||||
var Class = {
|
||||
|
@ -117,7 +117,7 @@ Class.inherit( Ajax.ThreadListUpdater, Ajax.Base, {
|
||||
},
|
||||
|
||||
updateParams: function() {
|
||||
return "company=" + this._options.company + "&since=" + this._options.lastrevision;
|
||||
return "since=" + this._options.lastrevision + "&status=" + this._options.istatus;
|
||||
},
|
||||
|
||||
setStatus: function(msg) {
|
||||
@ -272,7 +272,7 @@ Class.inherit( Ajax.ThreadListUpdater, Ajax.Base, {
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
updateContent: function(root) {
|
||||
var newAdded = false;
|
||||
if( root.tagName == 'threads' ) {
|
||||
@ -292,7 +292,7 @@ Class.inherit( Ajax.ThreadListUpdater, Ajax.Base, {
|
||||
}
|
||||
this.updateQueueMessages();
|
||||
this.updateTimers();
|
||||
this.setStatus( "Up to date" );
|
||||
this.setStatus(this._options.istatus ? "Away" : "Up to date");
|
||||
if( newAdded ) {
|
||||
playSound(webimRoot+'/sounds/new_user.wav');
|
||||
window.focus();
|
||||
@ -322,6 +322,8 @@ if($("sidebar") && $("wcontent") && $("togglemenu")) {
|
||||
}
|
||||
}
|
||||
|
||||
var webimRoot = "";
|
||||
|
||||
Behaviour.register({
|
||||
'#togglemenu' : function(el) {
|
||||
el.onclick = function() {
|
||||
@ -330,11 +332,9 @@ Behaviour.register({
|
||||
}
|
||||
});
|
||||
|
||||
var webimRoot = "";
|
||||
|
||||
EventHelper.register(window, 'onload', function(){
|
||||
webimRoot = updaterOptions.wroot;
|
||||
new Ajax.ThreadListUpdater(({table:$("threadlist"),status:$("connstatus")}).extend(updaterOptions || {}));
|
||||
new Ajax.ThreadListUpdater(({table:$("threadlist"),status:$("connstatus"),istatus:0}).extend(updaterOptions || {}));
|
||||
if(!updaterOptions.havemenu) {
|
||||
togglemenu();
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -283,7 +283,7 @@ function setup_survey($name, $email, $groupid, $info, $referrer) {
|
||||
|
||||
if($settings['enablegroups'] == '1' && $settings["surveyaskgroup"] == "1") {
|
||||
$link = connect();
|
||||
$allgroups = get_groups($link,true,true);
|
||||
$allgroups = get_groups($link,false);
|
||||
mysql_close($link);
|
||||
$val = "";
|
||||
foreach($allgroups as $k) {
|
||||
@ -294,7 +294,7 @@ function setup_survey($name, $email, $groupid, $info, $referrer) {
|
||||
if($k['ilastseen'] !== NULL && $k['ilastseen'] < $settings['online_timeout']) {
|
||||
$groupname .= " (online)";
|
||||
if(!$groupid) {
|
||||
$groupid = $k['groupid'];
|
||||
$groupid = $k['groupid']; // select first online group
|
||||
}
|
||||
}
|
||||
$isselected = $k['groupid'] == $groupid;
|
||||
|
@ -95,9 +95,9 @@ function create_operator($login,$password,$localename,$commonname,$avatar) {
|
||||
return $newop;
|
||||
}
|
||||
|
||||
function notify_operator_alive($operatorid) {
|
||||
function notify_operator_alive($operatorid, $istatus) {
|
||||
$link = connect();
|
||||
perform_query("update chatoperator set dtmlastvisited = CURRENT_TIMESTAMP where operatorid = $operatorid",$link);
|
||||
perform_query("update chatoperator set istatus = $istatus, dtmlastvisited = CURRENT_TIMESTAMP where operatorid = $operatorid",$link);
|
||||
mysql_close($link);
|
||||
}
|
||||
|
||||
@ -107,7 +107,9 @@ function has_online_operators($groupid="") {
|
||||
$link = connect();
|
||||
$query = "select count(*) as total, min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time from chatoperator";
|
||||
if($groupid) {
|
||||
$query .= ", chatgroupoperator where groupid = $groupid and chatoperator.operatorid = chatgroupoperator.operatorid";
|
||||
$query .= ", chatgroupoperator where groupid = $groupid and chatoperator.operatorid = chatgroupoperator.operatorid and istatus = 0";
|
||||
} else {
|
||||
$query .= " where istatus = 0";
|
||||
}
|
||||
$row = select_one_row($query,$link);
|
||||
mysql_close($link);
|
||||
@ -206,12 +208,12 @@ function setup_redirect_links($threadid,$token) {
|
||||
prepare_pagination(max($operatorscount,$groupscount),8);
|
||||
$limit = $page['pagination']['limit'];
|
||||
|
||||
$query = "select operatorid, vclogin, vclocalename, vccommonname, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
|
||||
$query = "select operatorid, vclogin, vclocalename, vccommonname, istatus, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
|
||||
"from chatoperator order by vclogin $limit";
|
||||
$operators = select_multi_assoc($query, $link);
|
||||
|
||||
if($settings['enablegroups'] == "1") {
|
||||
$groups = get_groups($link, true, true);
|
||||
$groups = get_groups($link, true);
|
||||
}
|
||||
|
||||
mysql_close($link);
|
||||
@ -220,11 +222,16 @@ function setup_redirect_links($threadid,$token) {
|
||||
$params = array('thread' => $threadid, 'token' => $token);
|
||||
foreach($operators as $agent) {
|
||||
$params['nextAgent'] = $agent['operatorid'];
|
||||
$online = $agent['time'] < $settings['online_timeout'] ? getlocal("char.redirect.operator.online_suff") : "";
|
||||
$status = $agent['time'] < $settings['online_timeout']
|
||||
? ($agent['istatus'] == 0
|
||||
? getlocal("char.redirect.operator.online_suff")
|
||||
: getlocal("char.redirect.operator.away_suff")
|
||||
)
|
||||
: "";
|
||||
$agent_list .= "<li><a href=\"".add_params($webimroot."/operator/redirect.php",$params).
|
||||
"\" title=\"".topage(get_operator_name($agent))."\">".
|
||||
topage(get_operator_name($agent)).
|
||||
"</a> $online</li>";
|
||||
"</a> $status</li>";
|
||||
}
|
||||
$page['redirectToAgent'] = $agent_list;
|
||||
|
||||
@ -236,11 +243,15 @@ function setup_redirect_links($threadid,$token) {
|
||||
continue;
|
||||
}
|
||||
$params['nextGroup'] = $group['groupid'];
|
||||
$online = $group['ilastseen'] < $settings['online_timeout'] ? getlocal("char.redirect.operator.online_suff") : "";
|
||||
$status = $group['ilastseen'] !== NULL && $group['ilastseen'] < $settings['online_timeout']
|
||||
? getlocal("char.redirect.operator.online_suff")
|
||||
: ($group['ilastseenaway'] !== NULL && $group['ilastseenaway'] < $settings['online_timeout']
|
||||
? getlocal("char.redirect.operator.away_suff")
|
||||
: "");
|
||||
$group_list .= "<li><a href=\"".add_params($webimroot."/operator/redirect.php",$params).
|
||||
"\" title=\"".topage(get_group_name($group))."\">".
|
||||
topage(get_group_name($group)).
|
||||
"</a> $online</li>";
|
||||
"</a> $status</li>";
|
||||
}
|
||||
}
|
||||
$page['redirectToGroup'] = $group_list;
|
||||
@ -279,17 +290,23 @@ function prepare_menu($operator,$hasright=true) {
|
||||
}
|
||||
}
|
||||
|
||||
function get_groups($link,$countagents, $checkonline=false) {
|
||||
function get_all_groups($link) {
|
||||
$query = "select chatgroup.groupid as groupid, vclocalname, vclocaldescription from chatgroup order by vclocalname";
|
||||
return select_multi_assoc($query, $link);
|
||||
}
|
||||
|
||||
function get_groups($link,$checkaway) {
|
||||
$query = "select chatgroup.groupid as groupid, vclocalname, vclocaldescription".
|
||||
($countagents
|
||||
? ", (SELECT count(*) from chatgroupoperator where chatgroup.groupid = chatgroupoperator.groupid) as inumofagents"
|
||||
: "").
|
||||
($checkonline
|
||||
? ", (SELECT min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
|
||||
"from chatgroupoperator, chatoperator where chatgroup.groupid = chatgroupoperator.groupid ".
|
||||
"and chatgroupoperator.operatorid = chatoperator.operatorid) as ilastseen"
|
||||
: "").
|
||||
|
||||
", (SELECT count(*) from chatgroupoperator where chatgroup.groupid = chatgroupoperator.groupid) as inumofagents".
|
||||
", (SELECT min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
|
||||
"from chatgroupoperator, chatoperator where istatus = 0 and chatgroup.groupid = chatgroupoperator.groupid ".
|
||||
"and chatgroupoperator.operatorid = chatoperator.operatorid) as ilastseen".
|
||||
($checkaway
|
||||
? ", (SELECT min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
|
||||
"from chatgroupoperator, chatoperator where istatus <> 0 and chatgroup.groupid = chatgroupoperator.groupid ".
|
||||
"and chatgroupoperator.operatorid = chatoperator.operatorid) as ilastseenaway"
|
||||
: ""
|
||||
).
|
||||
" from chatgroup order by vclocalname";
|
||||
return select_multi_assoc($query, $link);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ cannededit.title=Edit Message
|
||||
cannednew.descr=Add new message.
|
||||
cannednew.title=New Message
|
||||
char.redirect.operator.online_suff=(online)
|
||||
char.redirect.operator.away_suff=(away)
|
||||
chat.came.from=Vistor came from page {0}
|
||||
chat.client.changename=Change name
|
||||
chat.client.name=You are
|
||||
@ -292,6 +293,7 @@ page_agents.agents=Full list of operators:
|
||||
page_agents.confirm=Are you sure that you want to delete operator "{0}"?
|
||||
page_agents.intro=This page displays a list of company operators.
|
||||
page_agents.isonline=Online
|
||||
page_agents.isaway=Away
|
||||
page_agents.login=Login
|
||||
page_agents.new_agent=Add operator...
|
||||
page_agents.status=Last active
|
||||
@ -325,7 +327,9 @@ page_settings.tab.main=General
|
||||
page_settings.tab.themes=Themes preview
|
||||
pending.menu.hide=Hide menu >>
|
||||
pending.menu.show=Show menu >>
|
||||
pending.popup_notification=New visitor is waiting for an answer.
|
||||
pending.popup_notification=New visitor is waiting for an answer.
|
||||
pending.status.setaway=Set "Away" status
|
||||
pending.status.setonline=Set "Available" status
|
||||
pending.table.ban=Ban the visitor
|
||||
pending.table.head.contactid=Visitor's address
|
||||
pending.table.head.etc=Misc
|
||||
|
@ -82,7 +82,7 @@ if($settings['enablegroups'] == '1') {
|
||||
}
|
||||
|
||||
$link = connect();
|
||||
$allgroups = get_groups($link, false);
|
||||
$allgroups = get_all_groups($link);
|
||||
mysql_close($link);
|
||||
$page['groups'] = array();
|
||||
$page['groups'][] = array('groupid' => '', 'vclocalname' => getlocal("page.gen_button.default_group"));
|
||||
|
@ -93,7 +93,7 @@ $page['availableStyles'] = $stylelist;
|
||||
|
||||
if($settings['enablegroups'] == '1') {
|
||||
$link = connect();
|
||||
$allgroups = get_groups($link,false);
|
||||
$allgroups = get_all_groups($link);
|
||||
mysql_close($link);
|
||||
$page['groups'] = array();
|
||||
$page['groups'][] = array('groupid' => '', 'vclocalname' => getlocal("page.gen_button.default_group"));
|
||||
|
@ -42,12 +42,18 @@ if( isset($_GET['act']) && $_GET['act'] == 'del' ) {
|
||||
|
||||
function is_online($group) {
|
||||
global $settings;
|
||||
return $group['ilastseen'] && $group['ilastseen'] < $settings['online_timeout'] ? "1" : "";
|
||||
return $group['ilastseen'] !== NULL && $group['ilastseen'] < $settings['online_timeout'] ? "1" : "";
|
||||
}
|
||||
|
||||
function is_away($group) {
|
||||
global $settings;
|
||||
return $group['ilastseenaway'] !== NULL && $group['ilastseenaway'] < $settings['online_timeout'] ? "1" : "";
|
||||
}
|
||||
|
||||
|
||||
$page = array();
|
||||
$link = connect();
|
||||
$page['groups'] = get_groups($link, true, true);
|
||||
$page['groups'] = get_groups($link, true);
|
||||
mysql_close($link);
|
||||
$page['canmodify'] = is_capable($can_administrate, $operator);
|
||||
|
||||
|
@ -54,13 +54,18 @@ if( isset($_GET['act']) && $_GET['act'] == 'del' ) {
|
||||
|
||||
function is_online($operator) {
|
||||
global $settings;
|
||||
return $operator['time'] < $settings['online_timeout'] ? "1" : "";
|
||||
return $operator['istatus'] == 0 && $operator['time'] < $settings['online_timeout'] ? "1" : "";
|
||||
}
|
||||
|
||||
function is_away($operator) {
|
||||
global $settings;
|
||||
return $operator['istatus'] != 0 && $operator['time'] < $settings['online_timeout'] ? "1" : "";
|
||||
}
|
||||
|
||||
function get_operators() {
|
||||
$link = connect();
|
||||
|
||||
$query = "select operatorid, vclogin, vclocalename, vccommonname, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
|
||||
$query = "select operatorid, vclogin, vclocalename, vccommonname, istatus, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ".
|
||||
"from chatoperator order by vclogin";
|
||||
$operators = select_multi_assoc($query, $link);
|
||||
mysql_close($link);
|
||||
|
@ -31,7 +31,7 @@ function update_operator_groups($operatorid,$newvalue) {
|
||||
$opId = verifyparam( "op","/^\d{1,9}$/");
|
||||
$page = array('opid' => $opId);
|
||||
$link = connect();
|
||||
$page['groups'] = get_groups($link, false);
|
||||
$page['groups'] = get_all_groups($link);
|
||||
mysql_close($link);
|
||||
$errors = array();
|
||||
|
||||
|
@ -141,11 +141,12 @@ function print_pending_threads($groupids,$since) {
|
||||
}
|
||||
|
||||
$since = verifyparam( "since", "/^\d{1,9}$/", 0);
|
||||
$status = verifyparam( "status", "/^\d{1,2}$/", 0);
|
||||
|
||||
loadsettings();
|
||||
$groupids = $_SESSION['operatorgroups'];
|
||||
print_pending_threads($groupids,$since);
|
||||
notify_operator_alive($operator['operatorid']);
|
||||
notify_operator_alive($operator['operatorid'], $status);
|
||||
exit;
|
||||
|
||||
?>
|
||||
|
@ -16,8 +16,9 @@ require_once('../libs/common.php');
|
||||
require_once('../libs/operator.php');
|
||||
|
||||
$operator = check_login();
|
||||
$status = isset($_GET['away']) ? 1 : 0;
|
||||
|
||||
notify_operator_alive($operator['operatorid']);
|
||||
notify_operator_alive($operator['operatorid'], $status);
|
||||
|
||||
loadsettings();
|
||||
if($settings['enablegroups'] == '1') {
|
||||
@ -37,6 +38,7 @@ $page = array();
|
||||
$page['havemenu'] = isset($_GET['nomenu']) ? "0" : "1";
|
||||
$page['showpopup'] = $settings['enablepopupnotification'] == '1' ? "1" : "0";
|
||||
$page['frequency'] = $settings['updatefrequency_operator'];
|
||||
$page['istatus'] = $status;
|
||||
|
||||
prepare_menu($operator);
|
||||
start_html_output();
|
||||
|
@ -71,6 +71,8 @@ require_once('inc_errors.php');
|
||||
<td>
|
||||
<?php if(is_online($a)) { ?>
|
||||
<?php echo getlocal("page_agents.isonline") ?>
|
||||
<?php } else if(is_away($a)) { ?>
|
||||
<?php echo getlocal("page_agents.isaway") ?>
|
||||
<?php } else { ?>
|
||||
<?php echo date_to_text(time() - $a['time']) ?>
|
||||
<?php } ?>
|
||||
|
@ -75,6 +75,8 @@ if(count($page['groups']) > 0) {
|
||||
<td class="notlast">
|
||||
<?php if(is_online($grp)) { ?>
|
||||
<?php echo getlocal("page_agents.isonline") ?>
|
||||
<?php } else if(is_away($grp)) { ?>
|
||||
<?php echo getlocal("page_agents.isaway") ?>
|
||||
<?php } else { ?>
|
||||
<?php echo date_to_text(time() - ($grp['ilastseen'] ? $grp['ilastseen'] : time())) ?>
|
||||
<?php } ?>
|
||||
|
@ -31,7 +31,7 @@ var localized = new Array(
|
||||
);
|
||||
var updaterOptions = {
|
||||
url:"<?php echo $webimroot ?>/operator/update.php",wroot:"<?php echo $webimroot ?>",
|
||||
agentservl:"<?php echo $webimroot ?>/operator/agent.php", frequency:<?php echo $page['frequency'] ?>,
|
||||
agentservl:"<?php echo $webimroot ?>/operator/agent.php", frequency:<?php echo $page['frequency'] ?>, istatus:<?php echo $page['istatus'] ?>,
|
||||
noclients:"<?php echo getlocal("clients.no_clients") ?>", havemenu: <?php echo $page['havemenu'] ?>, showpopup: <?php echo $page['showpopup'] ?> };
|
||||
//--></script>
|
||||
<script type="text/javascript" language="javascript" src="<?php echo $webimroot ?>/js/users.js?v=161"></script>
|
||||
@ -81,7 +81,13 @@ function tpl_content() { global $page, $webimroot;
|
||||
<div id="connstatus">
|
||||
</div>
|
||||
|
||||
|
||||
<div id="connlinks">
|
||||
<?php if($page['istatus']) { ?>
|
||||
<a href="users.php<?php echo $page['havemenu'] ? "" : "?nomenu" ?>"><?php echo getlocal("pending.status.setonline") ?></a>
|
||||
<?php } else { ?>
|
||||
<a href="users.php?away<?php echo $page['havemenu'] ? "" : "&nomenu" ?>"><?php echo getlocal("pending.status.setaway") ?></a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
} /* content */
|
||||
|
Loading…
Reference in New Issue
Block a user