diff --git a/src/messenger/webim/libs/groups.php b/src/messenger/webim/libs/groups.php new file mode 100644 index 00000000..2e4b790c --- /dev/null +++ b/src/messenger/webim/libs/groups.php @@ -0,0 +1,35 @@ + $active != 0 ? "$webimroot/operator/group.php?gid=$gid" : "", + getlocal("page_group.tab.members") => $active != 1 ? "$webimroot/operator/groupmembers.php?gid=$gid" : "", + ); + } else { + $page['tabs'] = array(); + } +} + +?> diff --git a/src/messenger/webim/libs/operator.php b/src/messenger/webim/libs/operator.php index d5c7b3a6..70dfb6f9 100644 --- a/src/messenger/webim/libs/operator.php +++ b/src/messenger/webim/libs/operator.php @@ -125,9 +125,24 @@ function get_operator_name($operator) { return $operator['vccommonname']; } -function generate_button($title,$locale,$style,$inner,$showhost,$forcesecure) { - $link = get_app_location($showhost,$forcesecure)."/client.php". ($locale?"?locale=$locale" : "").($style ? ($locale?"&":"?")."style=$style" : ""); - $temp = get_popup($link, "'$link".($locale||$style?"&":"?")."url='+escape(document.location.href)+'&referrer='+escape(document.referrer)", +function append_query($link,$pv) { + $infix = '?'; + if( strstr($link,$infix) !== FALSE ) + $infix = '&'; + return "$link$infix$pv"; +} + +function generate_button($title,$locale,$style,$group,$inner,$showhost,$forcesecure) { + $link = get_app_location($showhost,$forcesecure)."/client.php"; + if($locale) + $link = append_query($link, "locale=$locale"); + if($style) + $link = append_query($link, "style=$style"); + if($group) + $link = append_query($link, "group=$group"); + + $jslink = append_query("'".$link,"url='+escape(document.location.href)+'&referrer='+escape(document.referrer)"); + $temp = get_popup($link, "$jslink", $inner, $title, "webim", "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=640,height=480,resizable=1" ); return "".$temp.""; } @@ -228,8 +243,10 @@ function prepare_menu($operator,$hasright=true) { function get_groups($countagents) { $link = connect(); - $query = "select groupid, vclocalname, vclocaldescription". - ($countagents ? ", 0 as inumofagents" : ""). + $query = "select chatgroup.groupid as groupid, vclocalname, vclocaldescription". + ($countagents + ? ", (SELECT count(*) from chatgroupoperator where chatgroup.groupid = chatgroupoperator.groupid) as inumofagents" + : ""). " from chatgroup order by vclocalname"; $result = select_multi_assoc($query, $link); mysql_close($link); diff --git a/src/messenger/webim/locales/en/properties b/src/messenger/webim/locales/en/properties index 5daa8ae0..07ca1acb 100644 --- a/src/messenger/webim/locales/en/properties +++ b/src/messenger/webim/locales/en/properties @@ -80,6 +80,7 @@ confirm.take.yes=Yes, I'm sure content.blocked=Here you can defend from malicious visitors. content.history=Search the dialogs history content.logoff=Log out of the system. +data.saved=Changes saved demo.chat.question=There are so many browsers to choose from. Which one(s) do you recommend? demo.chat.welcome=Hello, how may I help you? errors.failed.uploading.file=Error uploading file "{0}": {1}. @@ -206,14 +207,18 @@ page.group.intro=On this page you can edit group details. page.group.membersnum=Agents page.group.no_such=No such group page.group.title=Group details +page.groupmembers.title=Members +page.groupmembers.intro=Edit group members page.groups.title=Groups page.groups.intro=This page displays list of groups in your company. Each group can have separate button and canned responses. page.groups.new=Create new group... +page.gen_button.choose_group=Select a group page.gen_button.choose_image=Choose image page.gen_button.choose_locale=Target locale page.gen_button.choose_style=Chat window style page.gen_button.code.description=Caution! Please don't change
the code manually because
we don't guarantee that
it will work! page.gen_button.code=HTML code +page.gen_button.default_group=All operators page.gen_button.include_site_name=Include host name into code page.gen_button.intro=You can generate HTML code to place at your site here. page.gen_button.sample=Example @@ -270,6 +275,8 @@ page_bans.list=List of banned IPs: page_bans.title=Blocked page_bans.to=Till page_client.pending_users=You can find awaiting visitors. +page_group.tab.main=General +page_group.tab.members=Members page_login.error=Entered login/password is incorrect page_login.intro=Please enter your username and password to access administrative tools, see your visitors and browse the history. page_login.login=Login: diff --git a/src/messenger/webim/operator/getcode.php b/src/messenger/webim/operator/getcode.php index 327734b6..5464a99e 100644 --- a/src/messenger/webim/operator/getcode.php +++ b/src/messenger/webim/operator/getcode.php @@ -14,8 +14,10 @@ require_once('../libs/common.php'); require_once('../libs/operator.php'); +require_once('../libs/groups.php'); $operator = check_login(); +loadsettings(); $imageLocales = array(); $allLocales = get_available_locales(); @@ -55,6 +57,18 @@ if($style && !in_array($style, $stylelist)) { $style = ""; } +$groupid = ""; +if($settings['enablegroups'] == '1') { + $groupid = verifyparam( "group", "/^\d{0,8}$/", ""); + if($groupid) { + $group = group_by_id($groupid); + if(!$group) { + $errors[] = getlocal("page.group.no_such"); + $groupid = ""; + } + } +} + $showhost = verifyparam("hostname","/^on$/", "") == "on"; $forcesecure = verifyparam("secure","/^on$/", "") == "on"; @@ -68,11 +82,21 @@ $size = get_gifimage_size($file); $message = get_image(get_app_location($showhost,$forcesecure)."/button.php?image=$image&lang=$lang",$size[0],$size[1]); $page = array(); -$page['buttonCode'] = generate_button("",$lang,$style,$message,$showhost,$forcesecure); +$page['buttonCode'] = generate_button("",$lang,$style,$groupid,$message,$showhost,$forcesecure); $page['availableImages'] = array_keys($imageLocales); $page['availableLocales'] = $image_locales; $page['availableStyles'] = $stylelist; +if($settings['enablegroups'] == '1') { + $allgroups = get_groups(false); + $page['groups'] = array(); + $page['groups'][] = array('groupid' => '', 'vclocalname' => getlocal("page.gen_button.default_group")); + foreach($allgroups as $g) { + $page['groups'][] = $g; + } +} + +$page['formgroup'] = $groupid; $page['formstyle'] = $style; $page['formimage'] = $image; $page['formlang'] = $lang; diff --git a/src/messenger/webim/operator/group.php b/src/messenger/webim/operator/group.php index 07a8719f..1567939c 100644 --- a/src/messenger/webim/operator/group.php +++ b/src/messenger/webim/operator/group.php @@ -14,6 +14,7 @@ require_once('../libs/common.php'); require_once('../libs/operator.php'); +require_once('../libs/groups.php'); $operator = check_login(); @@ -21,14 +22,6 @@ $page = array('grid' => ''); $errors = array(); $groupid = ''; -function group_by_id($id) { - $link = connect(); - $group = select_one_row( - "select * from chatgroup where groupid = $id", $link ); - mysql_close($link); - return $group; -} - function group_by_name($name) { $link = connect(); $group = select_one_row( @@ -87,11 +80,11 @@ if( isset($_POST['name'])) { if( count($errors) == 0 ) { if (!$groupid) { $newdep = create_group($name,$description,$commonname,$commondescription); - header("Location: $webimroot/operator/groups.php"); + header("Location: $webimroot/operator/groupmembers.php?gid=".$newdep['groupid']); exit; } else { update_group($groupid,$name,$description,$commonname,$commondescription); - header("Location: $webimroot/operator/groups.php"); + header("Location: $webimroot/operator/group.php?gid=$groupid&stored"); exit; } } else { @@ -118,7 +111,9 @@ if( isset($_POST['name'])) { } } +$page['stored'] = isset($_GET['stored']); prepare_menu($operator); +setup_group_settings_tabs($groupid, 0); start_html_output(); require('../view/group.php'); ?> \ No newline at end of file diff --git a/src/messenger/webim/operator/groupmembers.php b/src/messenger/webim/operator/groupmembers.php new file mode 100644 index 00000000..2a5b8b4c --- /dev/null +++ b/src/messenger/webim/operator/groupmembers.php @@ -0,0 +1,74 @@ + $groupid); +$page['operators'] = get_operators(); +$errors = array(); + +$group = group_by_id($groupid); + +if( !$group ) { + $errors[] = getlocal("page.group.no_such"); + +} else if( isset($_POST['gid']) ) { + + $new_members = array(); + foreach($page['operators'] as $op) { + if( verifyparam("op".$op['operatorid'],"/^on$/", "") == "on") { + $new_members[] = $op['operatorid']; + } + } + + update_group_members($groupid, $new_members); + header("Location: $webimroot/operator/groupmembers.php?gid=$groupid&stored"); + exit; +} + +$page['formop'] = array(); +$page['currentgroup'] = $group ? topage(htmlspecialchars($group['vclocalname'])) : ""; + +foreach(get_group_members($groupid) as $rel) { + $page['formop'][] = $rel['operatorid']; +} + +$page['stored'] = isset($_GET['stored']); +prepare_menu($operator); +setup_group_settings_tabs($groupid, 1); +start_html_output(); +require('../view/groupmembers.php'); +?> \ No newline at end of file diff --git a/src/messenger/webim/operator/groups.php b/src/messenger/webim/operator/groups.php index 1eda8bcf..679bc6b0 100644 --- a/src/messenger/webim/operator/groups.php +++ b/src/messenger/webim/operator/groups.php @@ -19,7 +19,7 @@ $operator = check_login(); if( isset($_GET['act']) && $_GET['act'] == 'del' ) { - // TODO check permissions, delete in other places + // TODO check permissions $groupid = verifyparam( "gid", "/^(\d{1,9})?$/"); diff --git a/src/messenger/webim/operator/operator.php b/src/messenger/webim/operator/operator.php index f9bdc182..f16c2ef9 100644 --- a/src/messenger/webim/operator/operator.php +++ b/src/messenger/webim/operator/operator.php @@ -60,7 +60,7 @@ if( isset($_POST['login']) && isset($_POST['password']) ) { exit; } else { update_operator($opId,$login,$password,$localname,$commonname); - header("Location: $webimroot/operator/operators.php"); + header("Location: $webimroot/operator/operator.php?op=$opId&stored"); exit; } } else { @@ -85,6 +85,7 @@ if( isset($_POST['login']) && isset($_POST['password']) ) { } } +$page['stored'] = isset($_GET['stored']); prepare_menu($operator); setup_operator_settings_tabs($opId,0); start_html_output(); diff --git a/src/messenger/webim/operator/opgroups.php b/src/messenger/webim/operator/opgroups.php index 6639859f..9ccfd09c 100644 --- a/src/messenger/webim/operator/opgroups.php +++ b/src/messenger/webim/operator/opgroups.php @@ -47,7 +47,7 @@ if( !$op ) { } update_operator_groups($op['operatorid'],$new_groups); - header("Location: $webimroot/operator/operator.php?op=$opId"); + header("Location: $webimroot/operator/opgroups.php?op=$opId&stored"); exit; } @@ -60,6 +60,7 @@ if($opId) { } } +$page['stored'] = isset($_GET['stored']); prepare_menu($operator); setup_operator_settings_tabs($opId,2); start_html_output(); diff --git a/src/messenger/webim/operator/permissions.php b/src/messenger/webim/operator/permissions.php index a5bd7bda..a03ccfaa 100644 --- a/src/messenger/webim/operator/permissions.php +++ b/src/messenger/webim/operator/permissions.php @@ -53,7 +53,7 @@ if( !$op ) { if ($opId && $_SESSION['operator'] && $operator['operatorid'] == $opId) { $_SESSION['operator']['iperm'] = $new_permissions; } - header("Location: $webimroot/operator/operator.php?op=$opId"); + header("Location: $webimroot/operator/permissions.php?op=$opId&stored"); exit; } @@ -69,6 +69,7 @@ foreach($permission_ids as $perm => $id) { } } +$page['stored'] = isset($_GET['stored']); prepare_menu($operator); setup_operator_settings_tabs($opId,3); start_html_output(); diff --git a/src/messenger/webim/view/agent.php b/src/messenger/webim/view/agent.php index 4f022102..36fd875e 100644 --- a/src/messenger/webim/view/agent.php +++ b/src/messenger/webim/view/agent.php @@ -30,6 +30,9 @@ function tpl_content() { global $page, $webimroot, $errors; + +
+
diff --git a/src/messenger/webim/view/gen_button.php b/src/messenger/webim/view/gen_button.php index 4b020966..1cfe7e2d 100644 --- a/src/messenger/webim/view/gen_button.php +++ b/src/messenger/webim/view/gen_button.php @@ -16,12 +16,15 @@ require_once("inc_menu.php"); $page['title'] = getlocal("page.gen_button.title"); $page['menuid'] = "getcode"; -function tpl_content() { global $page, $webimroot; +function tpl_content() { global $page, $webimroot, $errors; ?>

+
@@ -41,6 +44,15 @@ function tpl_content() { global $page, $webimroot;
+ +
+
+
+ +
+
+ +
diff --git a/src/messenger/webim/view/group.php b/src/messenger/webim/view/group.php index 2f5df1fa..e453d0d9 100644 --- a/src/messenger/webim/view/group.php +++ b/src/messenger/webim/view/group.php @@ -30,10 +30,22 @@ function tpl_content() { global $page, $webimroot, $errors; + +
+
+ +
    + + $v) { if($v) { ?> +
  • + +
  • +
+
diff --git a/src/messenger/webim/view/groupmembers.php b/src/messenger/webim/view/groupmembers.php new file mode 100644 index 00000000..be703fdb --- /dev/null +++ b/src/messenger/webim/view/groupmembers.php @@ -0,0 +1,71 @@ + + + +
+
+ + +
+ + + + +
+ +
    + + $v) { if($v) { ?> +
  • + +
  • +
+ +
+ +

+ +

+ +
+
+ /> + () +
+
+ + +
+ +
+ +
+
+ + + \ No newline at end of file diff --git a/src/messenger/webim/view/groups.php b/src/messenger/webim/view/groups.php index 9a9ca298..5c0c6263 100644 --- a/src/messenger/webim/view/groups.php +++ b/src/messenger/webim/view/groups.php @@ -59,7 +59,9 @@ if(count($page['groups']) > 0) { - + + + diff --git a/src/messenger/webim/view/operator_groups.php b/src/messenger/webim/view/operator_groups.php index 5f37eb1f..96fc3977 100644 --- a/src/messenger/webim/view/operator_groups.php +++ b/src/messenger/webim/view/operator_groups.php @@ -25,6 +25,9 @@ function tpl_content() { global $page, $webimroot, $errors; + +
+
diff --git a/src/messenger/webim/view/permissions.php b/src/messenger/webim/view/permissions.php index 4f34ab28..7619fc43 100644 --- a/src/messenger/webim/view/permissions.php +++ b/src/messenger/webim/view/permissions.php @@ -16,7 +16,7 @@ require_once("inc_menu.php"); $page['title'] = getlocal("permissions.title"); $page['menuid'] = "operators"; -function tpl_content() { global $page, $webimroot; +function tpl_content() { global $page, $webimroot, $errors; ?> @@ -25,6 +25,9 @@ function tpl_content() { global $page, $webimroot; + +
+