diff --git a/src/messenger/webim/button.php b/src/messenger/webim/button.php index c58929a6..3f7d4d2c 100644 --- a/src/messenger/webim/button.php +++ b/src/messenger/webim/button.php @@ -14,6 +14,7 @@ require_once('libs/common.php'); require_once('libs/operator.php'); +require_once('libs/groups.php'); $image = verifyparam("image","/^\w+$/", "webim"); $lang = verifyparam(isset($_GET['language']) ? "language" : "lang", "/^[\w-]{2,5}$/", ""); @@ -21,7 +22,20 @@ if(!$lang || !locale_exists($lang)) { $lang = $current_locale; } -$image_postfix = has_online_operators() ? "on" : "off"; +$groupid = verifyparam( "group", "/^\d{1,8}$/", ""); +if($groupid) { + loadsettings(); + if($settings['enablegroups'] == '1') { + $group = group_by_id($groupid); + if(!$group) { + $groupid = ""; + } + } else { + $groupid = ""; + } +} + +$image_postfix = has_online_operators($groupid) ? "on" : "off"; $filename = "locales/${lang}/button/${image}_${image_postfix}.gif"; $fp = fopen($filename, 'rb') or die("no image"); diff --git a/src/messenger/webim/client.php b/src/messenger/webim/client.php index 9db041c3..3e03470f 100644 --- a/src/messenger/webim/client.php +++ b/src/messenger/webim/client.php @@ -43,16 +43,6 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) { } if( !$thread ) { - if(!has_online_operators()) { - $page = array(); - setup_logo(); - $page['formname'] = topage(getgetparam('name')); - $page['formemail'] = topage($email); - $page['info'] = topage($info); - expand("styles", getchatstyle(), "leavemessage.tpl"); - exit; - } - $groupid = ""; if($settings['enablegroups'] == '1') { $groupid = verifyparam( "group", "/^\d{1,8}$/", ""); @@ -63,6 +53,16 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) { } } } + + if(!has_online_operators($groupid)) { + $page = array(); + setup_logo(); + $page['formname'] = topage(getgetparam('name')); + $page['formemail'] = topage($email); + $page['info'] = topage($info); + expand("styles", getchatstyle(), "leavemessage.tpl"); + exit; + } $visitor = visitor_from_request(); $referer = isset($_GET['url']) ? $_GET['url'] : diff --git a/src/messenger/webim/install/whatsnew.txt b/src/messenger/webim/install/whatsnew.txt index 186ed9c0..79b1f863 100644 --- a/src/messenger/webim/install/whatsnew.txt +++ b/src/messenger/webim/install/whatsnew.txt @@ -4,6 +4,7 @@ [+] new permission: "Ability to modify profile" [+] new project name: Mibew Messenger [!] fixed localization of dates for all languages + [!] fixed online/offline image for groups 1.6.0 ----- diff --git a/src/messenger/webim/libs/operator.php b/src/messenger/webim/libs/operator.php index 1ddac7b7..5df463ba 100644 --- a/src/messenger/webim/libs/operator.php +++ b/src/messenger/webim/libs/operator.php @@ -110,11 +110,15 @@ function notify_operator_alive($operatorid) { mysql_close($link); } -function has_online_operators() { +function has_online_operators($groupid="") { global $settings; loadsettings(); $link = connect(); - $row = select_one_row("select min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time from chatoperator",$link); + $query = "select min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time from chatoperator"; + if($groupid) { + $query .= ", chatgroupoperator where groupid = $groupid and chatoperator.operatorid = chatgroupoperator.operatorid"; + } + $row = select_one_row($query,$link); mysql_close($link); return $row['time'] < $settings['online_timeout']; } diff --git a/src/messenger/webim/operator/getcode.php b/src/messenger/webim/operator/getcode.php index 470e040a..a9afc630 100644 --- a/src/messenger/webim/operator/getcode.php +++ b/src/messenger/webim/operator/getcode.php @@ -79,7 +79,11 @@ if( !$lang || !in_array($lang,$image_locales) ) $file = "../locales/${lang}/button/${image}_on.gif"; $size = get_gifimage_size($file); -$message = get_image(get_app_location($showhost,$forcesecure)."/button.php?image=$image&lang=$lang",$size[0],$size[1]); +$imagehref = get_app_location($showhost,$forcesecure)."/button.php?image=$image&lang=$lang"; +if($groupid) { + $imagehref .= "&group=$groupid"; +} +$message = get_image($imagehref,$size[0],$size[1]); $page = array(); $page['buttonCode'] = generate_button("",$lang,$style,$groupid,$message,$showhost,$forcesecure);