group members, generate button for group

git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@435 c66351dc-e62f-0410-b875-e3a5c0b9693f
This commit is contained in:
Evgeny Gryaznov 2009-03-24 23:34:57 +00:00
parent 11663d2dd5
commit 11dcfdd91a
17 changed files with 284 additions and 23 deletions

View File

@ -0,0 +1,35 @@
<?php
/*
* This file is part of Web Instant Messenger project.
*
* Copyright (c) 2005-2009 Web Messenger Community
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Evgeny Gryaznov - initial API and implementation
*/
function group_by_id($id) {
$link = connect();
$group = select_one_row(
"select * from chatgroup where groupid = $id", $link );
mysql_close($link);
return $group;
}
function setup_group_settings_tabs($gid, $active) {
global $page, $webimroot, $settings;
if($gid) {
$page['tabs'] = array(
getlocal("page_group.tab.main") => $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();
}
}
?>

View File

@ -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?"&amp;":"?")."style=$style" : "");
$temp = get_popup($link, "'$link".($locale||$style?"&amp;":"?")."url='+escape(document.location.href)+'&amp;referrer='+escape(document.referrer)",
function append_query($link,$pv) {
$infix = '?';
if( strstr($link,$infix) !== FALSE )
$infix = '&amp;';
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)+'&amp;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 "<!-- webim button -->".$temp."<!-- / webim button -->";
}
@ -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);

View File

@ -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=<strong>Caution!</strong> Please don't change<br/> the code manually because<br/> we don't guarantee that<br/> 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:

View File

@ -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&amp;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;

View File

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

View File

@ -0,0 +1,74 @@
<?php
/*
* This file is part of Web Instant Messenger project.
*
* Copyright (c) 2005-2009 Web Messenger Community
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Evgeny Gryaznov - initial API and implementation
*/
require_once('../libs/common.php');
require_once('../libs/operator.php');
require_once('../libs/groups.php');
$operator = check_login();
function get_group_members($groupid) {
$link = connect();
$query = "select operatorid from chatgroupoperator where groupid = $groupid";
$result = select_multi_assoc($query, $link);
mysql_close($link);
return $result;
}
function update_group_members($groupid,$newvalue) {
$link = connect();
perform_query("delete from chatgroupoperator where groupid = $groupid", $link);
foreach($newvalue as $opid) {
perform_query("insert into chatgroupoperator (groupid, operatorid) values ($groupid,$opid)", $link);
}
mysql_close($link);
}
$groupid = verifyparam( "gid","/^\d{1,9}$/");
$page = array('groupid' => $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');
?>

View File

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

View File

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

View File

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

View File

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

View File

@ -30,6 +30,9 @@ function tpl_content() { global $page, $webimroot, $errors;
<?php
require_once('inc_errors.php');
?>
<?php if( $page['stored'] ) { ?>
<div id="formmessage"><?php echo getlocal("data.saved") ?></div>
<?php } ?>
<form name="agentForm" method="post" action="<?php echo $webimroot ?>/operator/operator.php">
<input type="hidden" name="opid" value="<?php echo $page['opid'] ?>"/>

View File

@ -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;
?>
<?php echo getlocal("page.gen_button.intro") ?>
<br />
<br />
<?php
require_once('inc_errors.php');
?>
<form name="buttonCodeForm" method="get" action="<?php echo $webimroot ?>/operator/getcode.php">
<div class="mform"><div class="formtop"><div class="formtopi"></div></div><div class="forminner">
@ -41,6 +44,15 @@ function tpl_content() { global $page, $webimroot;
</div>
</div>
<?php if($page['showgroups']) { ?>
<div class="field">
<div class="flabel"><?php echo getlocal("page.gen_button.choose_group") ?></div>
<div class="fvaluenodesc">
<select name="group" onchange="this.form.submit();"><?php foreach($page['groups'] as $k) { echo "<option value=\"".$k['groupid']."\"".($k['groupid'] == form_value("group") ? " selected=\"selected\"" : "").">".$k['vclocalname']."</option>"; } ?></select>
</div>
</div>
<?php } ?>
<div class="field">
<div class="flabel"><?php echo getlocal("page.gen_button.choose_style") ?></div>
<div class="fvaluenodesc">

View File

@ -30,10 +30,22 @@ function tpl_content() { global $page, $webimroot, $errors;
<?php
require_once('inc_errors.php');
?>
<?php if( $page['stored'] ) { ?>
<div id="formmessage"><?php echo getlocal("data.saved") ?></div>
<?php } ?>
<form name="groupForm" method="post" action="<?php echo $webimroot ?>/operator/group.php">
<input type="hidden" name="gid" value="<?php echo $page['grid'] ?>"/>
<div>
<?php if($page['tabs']) { ?>
<ul class="tabs">
<?php foreach($page['tabs'] as $k => $v) { if($v) { ?>
<li><a href="<?php echo $v ?>"><?php echo $k ?></a></li>
<?php } else { ?>
<li class="active"><a href="#"><?php echo $k ?></a></li><?php }} ?>
</ul>
<?php } ?>
<div class="mform"><div class="formtop"><div class="formtopi"></div></div><div class="forminner">
<div class="fieldForm">

View File

@ -0,0 +1,71 @@
<?php
/*
* This file is part of Web Instant Messenger project.
*
* Copyright (c) 2005-2009 Web Messenger Community
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Evgeny Gryaznov - initial API and implementation
*/
require_once("inc_menu.php");
$page['title'] = getlocal("page.groupmembers.title");
$page['menuid'] = "groups";
function tpl_content() { global $page, $webimroot, $errors;
?>
<?php echo getlocal("page.groupmembers.intro") ?>
<br />
<br />
<?php
require_once('inc_errors.php');
?>
<?php if( $page['stored'] ) { ?>
<div id="formmessage"><?php echo getlocal("data.saved") ?></div>
<?php } ?>
<form name="membersForm" method="post" action="<?php echo $webimroot ?>/operator/groupmembers.php">
<input type="hidden" name="gid" value="<?php echo $page['groupid'] ?>"/>
<div>
<?php if($page['tabs']) { ?>
<ul class="tabs">
<?php foreach($page['tabs'] as $k => $v) { if($v) { ?>
<li><a href="<?php echo $v ?>"><?php echo $k ?></a></li>
<?php } else { ?>
<li class="active"><a href="#"><?php echo $k ?></a></li><?php }} ?>
</ul>
<?php } ?>
<div class="mform"><div class="formtop"><div class="formtopi"></div></div><div class="forminner">
<p>
<b><?php echo $page['currentgroup'] ?></b>
</p>
<?php foreach( $page['operators'] as $pm ) { ?>
<div class="field">
<div class="fvaluenodesc">
<input type="checkbox" name="op<?php echo $pm['operatorid'] ?>" value="on"<?php echo form_value_mb('op',$pm['operatorid']) ? " checked=\"checked\"" : "" ?>/>
<?php echo htmlspecialchars(topage($pm['vclocalename'])) ?> (<a href="operator.php?op=<?php echo $pm['operatorid'] ?>"
><?php echo htmlspecialchars(topage($pm['vclogin'])) ?></a>)
</div>
</div>
<?php } ?>
<div class="fbutton">
<input type="image" name="save" value="" src='<?php echo $webimroot.getlocal("image.button.save") ?>' alt='<?php echo getlocal("button.save") ?>'/>
</div>
</div><div class="formbottom"><div class="formbottomi"></div></div></div>
</div>
</form>
<?php
} /* content */
require_once('inc_main.php');
?>

View File

@ -59,7 +59,9 @@ if(count($page['groups']) > 0) {
<?php echo $grp['vclocaldescription'] ? htmlspecialchars(topage($grp['vclocaldescription'])) : "&lt;none&gt;" ?>
</td>
<td>
<?php echo htmlspecialchars(topage($grp['inumofagents'])) ?>
<a href="<?php echo $webimroot ?>/operator/groupmembers.php?gid=<?php echo $grp['groupid'] ?>">
<?php echo htmlspecialchars(topage($grp['inumofagents'])) ?>
</a>
</td>
<td>
<a href="<?php echo $webimroot ?>/operator/groups.php?act=del&amp;gid=<?php echo $grp['groupid'] ?>">

View File

@ -25,6 +25,9 @@ function tpl_content() { global $page, $webimroot, $errors;
<?php
require_once('inc_errors.php');
?>
<?php if( $page['stored'] ) { ?>
<div id="formmessage"><?php echo getlocal("data.saved") ?></div>
<?php } ?>
<form name="opgroupsForm" method="post" action="<?php echo $webimroot ?>/operator/opgroups.php">
<input type="hidden" name="op" value="<?php echo $page['op'] ?>"/>

View File

@ -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;
?>
<?php echo getlocal("permissions.intro") ?>
@ -25,6 +25,9 @@ function tpl_content() { global $page, $webimroot;
<?php
require_once('inc_errors.php');
?>
<?php if( $page['stored'] ) { ?>
<div id="formmessage"><?php echo getlocal("data.saved") ?></div>
<?php } ?>
<form name="permissionsForm" method="post" action="<?php echo $webimroot ?>/operator/permissions.php">
<input type="hidden" name="op" value="<?php echo $page['op'] ?>"/>