From 2cd1dbe3930020ab9a960dda2df9aea8f469e352 Mon Sep 17 00:00:00 2001 From: Evgeny Gryaznov Date: Wed, 25 Mar 2009 00:33:14 +0000 Subject: [PATCH] show threads only for group members, show group name in the list git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@437 c66351dc-e62f-0410-b875-e3a5c0b9693f --- src/messenger/webim/operator/update.php | 22 +++++++++++++++++----- src/messenger/webim/operator/users.php | 14 ++++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/messenger/webim/operator/update.php b/src/messenger/webim/operator/update.php index d560f97b..42c35b4f 100644 --- a/src/messenger/webim/operator/update.php +++ b/src/messenger/webim/operator/update.php @@ -53,6 +53,10 @@ function thread_to_xml($thread,$link) { $nextagent = $thread['nextagent'] != 0 ? operator_by_id_($thread['nextagent'],$link) : null; $threadoperator = $nextagent ? get_operator_name($nextagent) : ($thread['agentName'] ? $thread['agentName'] : "-"); + + if($threadoperator == "-" && $thread['groupname']) { + $threadoperator = "- ".$thread['groupname']." -"; + } if(!($thread['istate'] == $state_chatting && $thread['agentId'] != $operator['operatorid'] && !is_capable($can_takeover,$operator))) { $result .= " canopen=\"true\""; @@ -99,15 +103,22 @@ function thread_to_xml($thread,$link) { return $result; } -function print_pending_threads($since) { - global $webim_encoding; +function print_pending_threads($groupids,$since) { + global $webim_encoding, $settings; $link = connect(); $revision = $since; $output = array(); $query = "select threadid, userName, agentName, unix_timestamp(dtmcreated), userTyping, ". - "unix_timestamp(dtmmodified), lrevision, istate, remote, nextagent, agentId, userid, shownmessageid, userAgent ". - "from chatthread where lrevision > $since ORDER BY threadid"; + "unix_timestamp(dtmmodified), lrevision, istate, remote, nextagent, agentId, userid, shownmessageid, userAgent, (select vclocalname from chatgroup where chatgroup.groupid = chatthread.groupid) as groupname ". + "from chatthread where lrevision > $since ". + ($settings['enablegroups'] == '1' + ? "AND (groupid is NULL".($groupids + ? " OR groupid IN ($groupids)" + : ""). + ") " + : ""). + "ORDER BY threadid"; $rows = select_multi_assoc($query, $link); foreach ($rows as $row) { $thread = thread_to_xml($row,$link); @@ -129,7 +140,8 @@ function print_pending_threads($since) { $since = verifyparam( "since", "/^\d{1,9}$/", 0); loadsettings(); -print_pending_threads($since); +$groupids = $_SESSION['operatorgroups']; +print_pending_threads($groupids,$since); notify_operator_alive($operator['operatorid']); exit; diff --git a/src/messenger/webim/operator/users.php b/src/messenger/webim/operator/users.php index 9a0940a8..a8ac2543 100644 --- a/src/messenger/webim/operator/users.php +++ b/src/messenger/webim/operator/users.php @@ -19,6 +19,20 @@ $operator = check_login(); notify_operator_alive($operator['operatorid']); +loadsettings(); +if($settings['enablegroups'] == '1') { + $link = connect(); + $groupids = array(); + $allgroups = select_multi_assoc("select groupid from chatgroupoperator where operatorid = ".$operator['operatorid']." order by groupid",$link); + foreach($allgroups as $g) { + $groupids[] = $g['groupid']; + } + $_SESSION['operatorgroups'] = implode(",", $groupids); + mysql_close($link); +} else { + $_SESSION['operatorgroups'] = ""; +} + $page = array(); $page['havemenu'] = isset($_GET['nomenu']) ? "0" : "1";