From 491676f37eac0a08136736ee776fe5b9a455791f Mon Sep 17 00:00:00 2001 From: Evgeny Gryaznov Date: Sat, 27 Feb 2010 14:33:59 +0000 Subject: [PATCH] extract get_operator_groupslist (fix for Java API) git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@747 c66351dc-e62f-0410-b875-e3a5c0b9693f --- src/messenger/webim/libs/groups.php | 14 ++++++++++++++ src/messenger/webim/operator/update.php | 8 +++++++- src/messenger/webim/operator/users.php | 18 +++++------------- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/messenger/webim/libs/groups.php b/src/messenger/webim/libs/groups.php index 7cccc295..0c10d94e 100644 --- a/src/messenger/webim/libs/groups.php +++ b/src/messenger/webim/libs/groups.php @@ -47,4 +47,18 @@ function setup_group_settings_tabs($gid, $active) { } } +function get_operator_groupslist($operatorid, $link) { + global $settings; + if($settings['enablegroups'] == '1') { + $groupids = array(0); + $allgroups = select_multi_assoc("select groupid from chatgroupoperator where operatorid = $operatorid order by groupid",$link); + foreach($allgroups as $g) { + $groupids[] = $g['groupid']; + } + return implode(",", $groupids); + } else { + return ""; + } +} + ?> \ No newline at end of file diff --git a/src/messenger/webim/operator/update.php b/src/messenger/webim/operator/update.php index 3490a604..7b1cc484 100644 --- a/src/messenger/webim/operator/update.php +++ b/src/messenger/webim/operator/update.php @@ -23,6 +23,7 @@ require_once('../libs/common.php'); require_once('../libs/chat.php'); require_once('../libs/userinfo.php'); require_once('../libs/operator.php'); +require_once('../libs/groups.php'); $operator = get_logged_in(); if( !$operator ) { @@ -151,7 +152,12 @@ function print_pending_threads($groupids,$since) { $since = verifyparam( "since", "/^\d{1,9}$/", 0); $status = verifyparam( "status", "/^\d{1,2}$/", 0); -loadsettings(); +$link = connect(); +loadsettings_($link); +if(!isset($_SESSION['operatorgroups'])) { + $_SESSION['operatorgroups'] = get_operator_groupslist($operator['operatorid'], $link); +} +mysql_close($link); $groupids = $_SESSION['operatorgroups']; print_pending_threads($groupids,$since); notify_operator_alive($operator['operatorid'], $status); diff --git a/src/messenger/webim/operator/users.php b/src/messenger/webim/operator/users.php index 38e982de..3e42fa31 100644 --- a/src/messenger/webim/operator/users.php +++ b/src/messenger/webim/operator/users.php @@ -21,25 +21,17 @@ require_once('../libs/common.php'); require_once('../libs/operator.php'); +require_once('../libs/groups.php'); $operator = check_login(); $status = isset($_GET['away']) ? 1 : 0; notify_operator_alive($operator['operatorid'], $status); -loadsettings(); -if($settings['enablegroups'] == '1') { - $link = connect(); - $groupids = array(0); - $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'] = ""; -} +$link = connect(); +loadsettings_($link); +$_SESSION['operatorgroups'] = get_operator_groupslist($operator['operatorid'], $link); +mysql_close($link); $page = array(); $page['havemenu'] = isset($_GET['nomenu']) ? "0" : "1";