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
This commit is contained in:
Evgeny Gryaznov 2010-02-27 14:33:59 +00:00
parent 190f7914f4
commit 491676f37e
3 changed files with 26 additions and 14 deletions

View File

@ -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 "";
}
}
?>

View File

@ -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);

View File

@ -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";