department -> group, manages groups of agent

git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@431 c66351dc-e62f-0410-b875-e3a5c0b9693f
This commit is contained in:
Evgeny Gryaznov 2009-03-22 21:22:51 +00:00
parent 9d2f6ec2f5
commit 2fb7e37d7b
24 changed files with 397 additions and 232 deletions

View File

@ -14,8 +14,8 @@
["view/permissions.php", 2], ["view/permissions.php", 2],
["view/agent.php", 2], ["view/agent.php", 2],
["view/agents.php", 2], ["view/agents.php", 2],
["view/department.php", 2], ["view/group.php", 2],
["view/departments.php", 2], ["view/groups.php", 2],
["view/gen_button.php", 2], ["view/gen_button.php", 2],
["view/install_err.php", 2], ["view/install_err.php", 2],
["view/install_index.php", 2], ["view/install_index.php", 2],
@ -32,8 +32,8 @@
["operator/permissions.php", 2], ["operator/permissions.php", 2],
["operator/operator.php", 2], ["operator/operator.php", 2],
["operator/operators.php", 2], ["operator/operators.php", 2],
["operator/department.php", 2], ["operator/group.php", 2],
["operator/departments.php", 2], ["operator/groups.php", 2],
["operator/getcode.php", 2], ["operator/getcode.php", 2],
["operator/.*\\.php", 1], ["operator/.*\\.php", 1],

View File

@ -13,8 +13,8 @@
*/ */
$dbtables = array( $dbtables = array(
"chatdepartment" => array( "chatgroup" => array(
"departmentid" => "int NOT NULL auto_increment PRIMARY KEY", "groupid" => "int NOT NULL auto_increment PRIMARY KEY",
"vclocalname" => "varchar(64) NOT NULL", "vclocalname" => "varchar(64) NOT NULL",
"vccommonname" => "varchar(64) NOT NULL", "vccommonname" => "varchar(64) NOT NULL",
"vclocaldescription" => "varchar(1024) NOT NULL", "vclocaldescription" => "varchar(1024) NOT NULL",
@ -43,7 +43,7 @@ $dbtables = array(
"shownmessageid" => "int NOT NULL DEFAULT 0", "shownmessageid" => "int NOT NULL DEFAULT 0",
"userAgent" => "varchar(255)", "userAgent" => "varchar(255)",
"messageCount" => "varchar(16)", "messageCount" => "varchar(16)",
"departmentid" => "int references chatdepartment(departmentid)", "groupid" => "int references chatgroup(groupid)",
), ),
"chatmessage" => array( "chatmessage" => array(
@ -72,8 +72,8 @@ $dbtables = array(
"id" => "INT NOT NULL" "id" => "INT NOT NULL"
), ),
"chatdepartmentoperator" => array( "chatgroupoperator" => array(
"departmentid" => "int NOT NULL references chatdepartment(departmentid)", "groupid" => "int NOT NULL references chatgroup(groupid)",
"operatorid" => "int NOT NULL references chatoperator(operatorid)", "operatorid" => "int NOT NULL references chatoperator(operatorid)",
), ),
@ -96,12 +96,12 @@ $dbtables = array(
$memtables = array(); $memtables = array();
$dbtables_can_update = array( $dbtables_can_update = array(
"chatthread" => array("agentId", "userTyping", "agentTyping", "messageCount", "nextagent", "shownmessageid", "userid", "userAgent", "departmentid"), "chatthread" => array("agentId", "userTyping", "agentTyping", "messageCount", "nextagent", "shownmessageid", "userid", "userAgent", "groupid"),
"chatmessage" => array("agentId"), "chatmessage" => array("agentId"),
"chatoperator" => array("vcavatar", "vcjabbername", "iperm"), "chatoperator" => array("vcavatar", "vcjabbername", "iperm"),
"chatban" => array(), "chatban" => array(),
"chatdepartment" => array(), "chatgroup" => array(),
"chatdepartmentoperator" => array(), "chatgroupoperator" => array(),
); );
function show_install_err($text) { function show_install_err($text) {

View File

@ -118,8 +118,8 @@ if ($act == "silentcreateall") {
runsql("ALTER TABLE chatoperator ADD vcjabbername varchar(255)", $link); runsql("ALTER TABLE chatoperator ADD vcjabbername varchar(255)", $link);
} }
if( in_array("chatthread.departmentid", $absent) ) { if( in_array("chatthread.groupid", $absent) ) {
runsql("ALTER TABLE chatthread ADD departmentid int references chatdepartment(departmentid)", $link); runsql("ALTER TABLE chatthread ADD groupid int references chatgroup(groupid)", $link);
} }
if( in_array("chatthread.userAgent", $absent) ) { if( in_array("chatthread.userAgent", $absent) ) {

View File

@ -5,7 +5,7 @@
[+] right menu, show/hide menu on awaiting users page, nice locale chooser [+] right menu, show/hide menu on awaiting users page, nice locale chooser
[+] main page: warning if database is outdated (after install) [+] main page: warning if database is outdated (after install)
[+] "Updates" tab in settings: news, link to the latest version [+] "Updates" tab in settings: news, link to the latest version
[+] Create/edit/remove departments [+] Create/edit/remove groups
1.5.2 1.5.2
----- -----

View File

@ -519,7 +519,7 @@ $settings = array(
'enableban' => '0', 'enableban' => '0',
'enablessl' => '0', 'enablessl' => '0',
'usercanchangename' => '1', 'usercanchangename' => '1',
'enabledepartments' => '0', 'enablegroups' => '0',
'enablestatistics' => '1', 'enablestatistics' => '1',
); );
$settingsloaded = false; $settingsloaded = false;

View File

@ -220,10 +220,28 @@ function prepare_menu($operator,$hasright=true) {
if($hasright) { if($hasright) {
loadsettings(); loadsettings();
$page['showban'] = $settings['enableban'] == "1"; $page['showban'] = $settings['enableban'] == "1";
$page['showdep'] = $settings['enabledepartments'] == "1"; $page['showgroups'] = $settings['enablegroups'] == "1";
$page['showstat'] = $settings['enablestatistics'] == "1"; $page['showstat'] = $settings['enablestatistics'] == "1";
$page['showadmin'] = is_capable($can_administrate, $operator); $page['showadmin'] = is_capable($can_administrate, $operator);
} }
} }
function get_groups($countagents) {
$link = connect();
$query = "select groupid, vclocalname, vclocaldescription".
($countagents ? ", 0 as inumofagents" : "").
" from chatgroup order by vclocalname";
$result = select_multi_assoc($query, $link);
mysql_close($link);
return $result;
}
function get_operator_groupids($operatorid) {
$link = connect();
$query = "select groupid from chatgroupoperator where operatorid = $operatorid";
$result = select_multi_assoc($query, $link);
mysql_close($link);
return $result;
}
?> ?>

View File

@ -0,0 +1,29 @@
<?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 setup_operator_settings_tabs($opId, $active) {
global $page, $webimroot;
if($opId) {
$page['tabs'] = array(
getlocal("page_agent.tab.main") => $active != 0 ? "$webimroot/operator/operator.php?op=$opId" : "",
getlocal("page_agent.tab.avatar") => $active != 1 ? "$webimroot/operator/avatar.php?op=$opId" : "",
getlocal("page_agent.tab.groups") => $active != 2 ? "$webimroot/operator/opgroups.php?op=$opId" : "",
getlocal("page_agent.tab.permissions") => $active != 3 ? "$webimroot/operator/permissions.php?op=$opId" : ""
);
} else {
$page['tabs'] = array();
}
}
?>

View File

@ -107,14 +107,14 @@ form.field.ban_comment.description=Reason of block
form.field.ban_comment=Comment form.field.ban_comment=Comment
form.field.ban_days.description=Numbers of days this address is blocked form.field.ban_days.description=Numbers of days this address is blocked
form.field.ban_days=Days form.field.ban_days=Days
form.field.depname=Name form.field.groupname=Name
form.field.depname.description=Name to identify the department. form.field.groupname.description=Name to identify the group.
form.field.depdesc=Description form.field.groupdesc=Description
form.field.depdesc.description=Description of the department. form.field.groupdesc.description=Description of the group.
form.field.depcommonname=International name form.field.groupcommonname=International name
form.field.depcommonname.description=Name in English. form.field.groupcommonname.description=Name in English.
form.field.depcommondesc=International description form.field.groupcommondesc=International description
form.field.depcommondesc.description=Description in English. form.field.groupcommondesc.description=Description in English.
form.field.email=Your email form.field.email=Your email
form.field.login.description=Login can consist of small Latin letters and underscore. form.field.login.description=Login can consist of small Latin letters and underscore.
form.field.login=Login form.field.login=Login
@ -177,8 +177,8 @@ mailthread.perform=Send
mailthread.title=Send chat history<br>by mail mailthread.title=Send chat history<br>by mail
menu.agents=Agents list menu.agents=Agents list
menu.blocked=Blocked visitors menu.blocked=Blocked visitors
menu.departments=Departments menu.groups=Groups
menu.departments.content=Group operators together. menu.groups.content=Department or skill based operator groups.
menu.locale=Language menu.locale=Language
menu.locale.content=Change locale. menu.locale.content=Change locale.
menu.main=Main menu.main=Main
@ -186,6 +186,8 @@ menu.operator=You are {0}
menu.translate=Localize menu.translate=Localize
my_settings.error.password_match=Entered passwords do not match my_settings.error.password_match=Entered passwords do not match
no_such_operator=No such operator no_such_operator=No such operator
operator.groups.title=Operator groups
operator.groups.intro=Choose groups according to operator skills.
page.analysis.search.head_host=Visitor's address page.analysis.search.head_host=Visitor's address
page.analysis.search.head_messages=Visitor's messages page.analysis.search.head_messages=Visitor's messages
page.analysis.search.head_name=Name page.analysis.search.head_name=Name
@ -197,15 +199,15 @@ page.chat.old_browser.close=Close...
page.chat.old_browser.list=<p><ul>\n<li>Internet Explorer 5.5+\n<li>Firefox 1.0+\n<li>Opera 8.0+\n<li>Mozilla 1.4+\n<li>Netscape 7.1+\n<li>Safari 1.2+\n</ul></p>\nAlso, we support some old browsers:\n<p><ul>\n<li>Internet Explorer 5.0\n<li>Opera 7.0\n</ul></p> page.chat.old_browser.list=<p><ul>\n<li>Internet Explorer 5.5+\n<li>Firefox 1.0+\n<li>Opera 8.0+\n<li>Mozilla 1.4+\n<li>Netscape 7.1+\n<li>Safari 1.2+\n</ul></p>\nAlso, we support some old browsers:\n<p><ul>\n<li>Internet Explorer 5.0\n<li>Opera 7.0\n</ul></p>
page.chat.old_browser.problem=Your web browser is not fully supported by Web Messenger. \nPlease, use one of the following web browsers: page.chat.old_browser.problem=Your web browser is not fully supported by Web Messenger. \nPlease, use one of the following web browsers:
page.chat.old_browser.title=Please, use newer browser page.chat.old_browser.title=Please, use newer browser
page.department.create_new=Here you can create new department. page.group.create_new=Here you can create new group.
page.department.duplicate_name=Please choose another name, because department with entered name already exists. page.group.duplicate_name=Please choose another name, because group with entered name already exists.
page.department.intro=On this page you can edit department details. page.group.intro=On this page you can edit group details.
page.department.membersnum=Agents page.group.membersnum=Agents
page.department.no_such=No such department page.group.no_such=No such group
page.department.title=Department details page.group.title=Group details
page.departments.title=Departments page.groups.title=Groups
page.departments.intro=This page displays list of departments in your company. Each department can have separate button and canned responses. page.groups.intro=This page displays list of groups in your company. Each group can have separate button and canned responses.
page.departments.new=Create new department... page.groups.new=Create new group...
page.gen_button.choose_image=Choose image page.gen_button.choose_image=Choose image
page.gen_button.choose_locale=Target locale page.gen_button.choose_locale=Target locale
page.gen_button.choose_style=Chat window style page.gen_button.choose_style=Chat window style
@ -243,6 +245,7 @@ page_agent.error.duplicate_login=Please choose another login, because agent with
page_agent.error.wrong_login=Login should contain only latin characters, numbers and underscore symbol. page_agent.error.wrong_login=Login should contain only latin characters, numbers and underscore symbol.
page_agent.intro=This page displays agent details, if you have access rights you can edit them. page_agent.intro=This page displays agent details, if you have access rights you can edit them.
page_agent.tab.avatar=Photo page_agent.tab.avatar=Photo
page_agent.tab.groups=Groups
page_agent.tab.main=General page_agent.tab.main=General
page_agent.tab.permissions=Permissions page_agent.tab.permissions=Permissions
page_agent.title=Operator details page_agent.title=Operator details
@ -310,7 +313,7 @@ report.total=Total:
right.administration=Administration right.administration=Administration
right.main=Main right.main=Main
right.other=Other right.other=Other
settings.chat.title.description=Department of your company for example. settings.chat.title.description=Name of your company for example.
settings.chat.title=Title in the chat window settings.chat.title=Title in the chat window
settings.chatstyle.description=Preview for all pages of each style is available <a href="preview.php">here</a> settings.chatstyle.description=Preview for all pages of each style is available <a href="preview.php">here</a>
settings.chatstyle=Select style for your chat windows settings.chatstyle=Select style for your chat windows
@ -320,8 +323,8 @@ settings.email.description=Enter email to receive system messages
settings.email=Email settings.email=Email
settings.enableban.description=Using it you can block attacks from specific IPs settings.enableban.description=Using it you can block attacks from specific IPs
settings.enableban=Enable feature "Malicious Visitors" settings.enableban=Enable feature "Malicious Visitors"
settings.enabledepartments.description=Use it to have separate queues for different questions. settings.enablegroups.description=Use it to have separate queues for different questions.
settings.enabledepartments=Enable "Departments" settings.enablegroups=Enable "Groups"
settings.enablessl.description=Please, note that your web server should be configured to support https requests. settings.enablessl.description=Please, note that your web server should be configured to support https requests.
settings.enablessl=Allow secure connections (SSL) settings.enablessl=Allow secure connections (SSL)
settings.enablestatistics.description=Adds page with messenger usage reports. settings.enablestatistics.description=Adds page with messenger usage reports.

View File

@ -56,8 +56,8 @@ leftMenu.client_agents
leftMenu.client_gen_button leftMenu.client_gen_button
leftMenu.client_settings leftMenu.client_settings
menu.blocked menu.blocked
menu.departments menu.groups
menu.departments.content menu.groups.content
menu.locale menu.locale
menu.locale.content menu.locale.content
menu.operator menu.operator

View File

@ -167,7 +167,6 @@ mailthread.perform=
mailthread.title=Отправить историю разговора<br>на почтовый ящик mailthread.title=Отправить историю разговора<br>на почтовый ящик
menu.agents=Список агентов menu.agents=Список агентов
menu.blocked=Нежелательные посетители menu.blocked=Нежелательные посетители
menu.departments=Îòäåëû
menu.locale=Язык menu.locale=Язык
menu.locale.content=Сменить язык. menu.locale.content=Сменить язык.
menu.main=Главная menu.main=Главная

View File

@ -14,6 +14,7 @@
require_once('../libs/common.php'); require_once('../libs/common.php');
require_once('../libs/operator.php'); require_once('../libs/operator.php');
require_once('../libs/operator_settings.php');
$operator = check_login(); $operator = check_login();
@ -81,14 +82,10 @@ if( !$op ) {
$page['avatar'] = topage($op['vcavatar']); $page['avatar'] = topage($op['vcavatar']);
} }
$page['tabs'] = array(
getlocal("page_agent.tab.main") => "$webimroot/operator/operator.php?op=$opId",
getlocal("page_agent.tab.avatar") => "",
getlocal("page_agent.tab.permissions") => "$webimroot/operator/permissions.php?op=$opId"
);
$page['currentop'] = topage(get_operator_name($op))." (".$op['vclogin'].")"; $page['currentop'] = topage(get_operator_name($op))." (".$op['vclogin'].")";
prepare_menu($operator); prepare_menu($operator);
setup_operator_settings_tabs($opId,1);
start_html_output(); start_html_output();
require('../view/avatar.php'); require('../view/avatar.php');
?> ?>

View File

@ -1,124 +0,0 @@
<?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');
$operator = check_login();
$page = array('depid' => '');
$errors = array();
$departmentid = '';
function department_by_id($id) {
$link = connect();
$department = select_one_row(
"select * from chatdepartment where departmentid = $id", $link );
mysql_close($link);
return $department;
}
function department_by_name($name) {
$link = connect();
$department = select_one_row(
"select * from chatdepartment where vclocalname = '".mysql_real_escape_string($name)."'", $link );
mysql_close($link);
return $department;
}
function create_department($name,$descr,$commonname,$commondescr) {
$link = connect();
$query = sprintf(
"insert into chatdepartment (vclocalname,vclocaldescription,vccommonname,vccommondescription) values ('%s','%s','%s','%s')",
mysql_real_escape_string($name),
mysql_real_escape_string($descr),
mysql_real_escape_string($commonname),
mysql_real_escape_string($commondescr));
perform_query($query,$link);
$id = mysql_insert_id($link);
$newdep = select_one_row("select * from chatdepartment where departmentid = $id", $link );
mysql_close($link);
return $newdep;
}
function update_department($departmentid,$name,$descr,$commonname,$commondescr) {
$link = connect();
$query = sprintf(
"update chatdepartment set vclocalname = '%s', vclocaldescription = '%s', vccommonname = '%s', vccommondescription = '%s' where departmentid = %s",
mysql_real_escape_string($name),
mysql_real_escape_string($descr),
mysql_real_escape_string($commonname),
mysql_real_escape_string($commondescr),
$departmentid );
perform_query($query,$link);
mysql_close($link);
}
if( isset($_POST['name'])) {
$departmentid = verifyparam( "dep", "/^(\d{1,9})?$/", "");
$name = getparam('name');
$description = getparam('description');
$commonname = getparam('commonname');
$commondescription = getparam('commondescription');
if( !$name )
$errors[] = no_field("form.field.depname");
$existing_department = department_by_name($name);
if( (!$departmentid && $existing_department) ||
( $departmentid && $existing_department && $departmentid != $existing_department['departmentid']) )
$errors[] = getlocal("page.department.duplicate_name");
if( count($errors) == 0 ) {
if (!$departmentid) {
$newdep = create_department($name,$description,$commonname,$commondescription);
header("Location: $webimroot/operator/departments.php");
exit;
} else {
update_department($departmentid,$name,$description,$commonname,$commondescription);
header("Location: $webimroot/operator/departments.php");
exit;
}
} else {
$page['formname'] = topage($name);
$page['formdescription'] = topage($description);
$page['formcommonname'] = topage($commonname);
$page['formcommondescription'] = topage($commondescription);
$page['depid'] = topage($departmentid);
}
} else if( isset($_GET['dep']) ) {
$departmentid = verifyparam( 'dep', "/^\d{1,9}$/");
$department = department_by_id($departmentid);
if( !$department ) {
$errors[] = getlocal("page.department.no_such");
$page['depid'] = topage($departmentid);
} else {
$page['formname'] = topage($department['vclocalname']);
$page['formdescription'] = topage($department['vclocaldescription']);
$page['formcommonname'] = topage($department['vccommonname']);
$page['formcommondescription'] = topage($department['vccommondescription']);
$page['depid'] = topage($department['departmentid']);
}
}
prepare_menu($operator);
start_html_output();
require('../view/department.php');
?>

View File

@ -21,7 +21,7 @@ $operator = check_login();
$page = array('agentId' => ''); $page = array('agentId' => '');
$errors = array(); $errors = array();
$options = array('enableban', 'usercanchangename', 'enablessl', 'enabledepartments', 'enablestatistics'); $options = array('enableban', 'usercanchangename', 'enablessl', 'enablegroups', 'enablestatistics');
loadsettings(); loadsettings();
$params = array(); $params = array();

View File

@ -0,0 +1,124 @@
<?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');
$operator = check_login();
$page = array('depid' => '');
$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(
"select * from chatgroup where vclocalname = '".mysql_real_escape_string($name)."'", $link );
mysql_close($link);
return $group;
}
function create_group($name,$descr,$commonname,$commondescr) {
$link = connect();
$query = sprintf(
"insert into chatgroup (vclocalname,vclocaldescription,vccommonname,vccommondescription) values ('%s','%s','%s','%s')",
mysql_real_escape_string($name),
mysql_real_escape_string($descr),
mysql_real_escape_string($commonname),
mysql_real_escape_string($commondescr));
perform_query($query,$link);
$id = mysql_insert_id($link);
$newdep = select_one_row("select * from chatgroup where groupid = $id", $link );
mysql_close($link);
return $newdep;
}
function update_group($groupid,$name,$descr,$commonname,$commondescr) {
$link = connect();
$query = sprintf(
"update chatgroup set vclocalname = '%s', vclocaldescription = '%s', vccommonname = '%s', vccommondescription = '%s' where groupid = %s",
mysql_real_escape_string($name),
mysql_real_escape_string($descr),
mysql_real_escape_string($commonname),
mysql_real_escape_string($commondescr),
$groupid );
perform_query($query,$link);
mysql_close($link);
}
if( isset($_POST['name'])) {
$groupid = verifyparam( "dep", "/^(\d{1,9})?$/", "");
$name = getparam('name');
$description = getparam('description');
$commonname = getparam('commonname');
$commondescription = getparam('commondescription');
if( !$name )
$errors[] = no_field("form.field.groupname");
$existing_group = group_by_name($name);
if( (!$groupid && $existing_group) ||
( $groupid && $existing_group && $groupid != $existing_group['groupid']) )
$errors[] = getlocal("page.group.duplicate_name");
if( count($errors) == 0 ) {
if (!$groupid) {
$newdep = create_group($name,$description,$commonname,$commondescription);
header("Location: $webimroot/operator/groups.php");
exit;
} else {
update_group($groupid,$name,$description,$commonname,$commondescription);
header("Location: $webimroot/operator/groups.php");
exit;
}
} else {
$page['formname'] = topage($name);
$page['formdescription'] = topage($description);
$page['formcommonname'] = topage($commonname);
$page['formcommondescription'] = topage($commondescription);
$page['depid'] = topage($groupid);
}
} else if( isset($_GET['dep']) ) {
$groupid = verifyparam( 'dep', "/^\d{1,9}$/");
$group = group_by_id($groupid);
if( !$group ) {
$errors[] = getlocal("page.group.no_such");
$page['depid'] = topage($groupid);
} else {
$page['formname'] = topage($group['vclocalname']);
$page['formdescription'] = topage($group['vclocaldescription']);
$page['formcommonname'] = topage($group['vccommonname']);
$page['formcommondescription'] = topage($group['vccommondescription']);
$page['depid'] = topage($group['groupid']);
}
}
prepare_menu($operator);
start_html_output();
require('../view/group.php');
?>

View File

@ -17,32 +17,23 @@ require_once('../libs/operator.php');
$operator = check_login(); $operator = check_login();
function get_departments() {
$link = connect();
$query = "select departmentid, vclocalname, vclocaldescription, 0 as inumofagents ".
"from chatdepartment order by vclocalname";
$result = select_multi_assoc($query, $link);
mysql_close($link);
return $result;
}
if( isset($_GET['act']) && $_GET['act'] == 'del' ) { if( isset($_GET['act']) && $_GET['act'] == 'del' ) {
// TODO check permissions, delete in other places // TODO check permissions, delete in other places
$departmentid = verifyparam( "dep", "/^(\d{1,9})?$/"); $groupid = verifyparam( "dep", "/^(\d{1,9})?$/");
$link = connect(); $link = connect();
perform_query("delete from chatdepartment where departmentid = $departmentid",$link); perform_query("delete from chatgroup where groupid = $groupid",$link);
mysql_close($link); mysql_close($link);
header("Location: $webimroot/operator/departments.php"); header("Location: $webimroot/operator/groups.php");
exit; exit;
} }
$page = array(); $page = array();
$page['departments'] = get_departments(); $page['groups'] = get_groups(true);
prepare_menu($operator); prepare_menu($operator);
start_html_output(); start_html_output();
require('../view/departments.php'); require('../view/groups.php');
?> ?>

View File

@ -14,6 +14,7 @@
require_once('../libs/common.php'); require_once('../libs/common.php');
require_once('../libs/operator.php'); require_once('../libs/operator.php');
require_once('../libs/operator_settings.php');
$operator = check_login(); $operator = check_login();
@ -84,13 +85,8 @@ if( isset($_POST['login']) && isset($_POST['password']) ) {
} }
} }
$page['tabs'] = $opId ? array(
getlocal("page_agent.tab.main") => "",
getlocal("page_agent.tab.avatar") => "$webimroot/operator/avatar.php?op=$opId",
getlocal("page_agent.tab.permissions") => "$webimroot/operator/permissions.php?op=$opId"
) : array();
prepare_menu($operator); prepare_menu($operator);
setup_operator_settings_tabs($opId,0);
start_html_output(); start_html_output();
require('../view/agent.php'); require('../view/agent.php');
?> ?>

View File

@ -0,0 +1,67 @@
<?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/operator_settings.php');
$operator = check_login();
function update_operator_groups($operatorid,$newvalue) {
$link = connect();
perform_query("delete from chatgroupoperator where operatorid = $operatorid", $link);
foreach($newvalue as $groupid) {
perform_query("insert into chatgroupoperator (groupid, operatorid) values ($groupid,$operatorid)", $link);
}
mysql_close($link);
}
$opId = verifyparam( "op","/^\d{1,9}$/");
$page = array('op' => $opId);
$page['groups'] = get_groups(false);
$errors = array();
$op = operator_by_id($opId);
if( !$op ) {
$errors[] = getlocal("no_such_operator");
} else if( isset($_POST['op']) ) {
$new_groups = array();
foreach($page['groups'] as $group) {
if( verifyparam("group".$group['groupid'],"/^on$/", "") == "on") {
$new_groups[] = $group['groupid'];
}
}
update_operator_groups($op['operatorid'],$new_groups);
header("Location: $webimroot/operator/operator.php?op=$opId");
exit;
}
$page['formgroup'] = array();
$page['currentop'] = $opId ? topage(get_operator_name($op))." (".$op['vclogin'].")" : "";
if($opId) {
foreach(get_operator_groupids($opId) as $rel) {
$page['formgroup'][] = $rel['groupid'];
}
}
prepare_menu($operator);
setup_operator_settings_tabs($opId,2);
start_html_output();
require('../view/operator_groups.php');
?>

View File

@ -14,6 +14,7 @@
require_once('../libs/common.php'); require_once('../libs/common.php');
require_once('../libs/operator.php'); require_once('../libs/operator.php');
require_once('../libs/operator_settings.php');
$operator = check_login(); $operator = check_login();
@ -58,12 +59,6 @@ if( !$op ) {
} }
$page['tabs'] = array(
getlocal("page_agent.tab.main") => "$webimroot/operator/operator.php?op=$opId",
getlocal("page_agent.tab.avatar") => "$webimroot/operator/avatar.php?op=$opId",
getlocal("page_agent.tab.permissions") => ""
);
$page['permissionsList'] = get_permission_list(); $page['permissionsList'] = get_permission_list();
$page['formpermissions'] = array(""); $page['formpermissions'] = array("");
$page['currentop'] = topage(get_operator_name($op))." (".$op['vclogin'].")"; $page['currentop'] = topage(get_operator_name($op))." (".$op['vclogin'].")";
@ -75,6 +70,7 @@ foreach($permission_ids as $perm => $id) {
} }
prepare_menu($operator); prepare_menu($operator);
setup_operator_settings_tabs($opId,3);
start_html_output(); start_html_output();
require('../view/permissions.php'); require('../view/permissions.php');
?> ?>

View File

@ -72,11 +72,11 @@ require_once('inc_errors.php');
</div> </div>
<div class="field"> <div class="field">
<div class="flabel"><?php echo getlocal('settings.enabledepartments') ?></div> <div class="flabel"><?php echo getlocal('settings.enablegroups') ?></div>
<div class="fvalue"> <div class="fvalue">
<input type="checkbox" name="enabledepartments" value="on"<?php echo form_value_cb('enabledepartments') ? " checked=\"checked\"" : "" ?>/> <input type="checkbox" name="enablegroups" value="on"<?php echo form_value_cb('enablegroups') ? " checked=\"checked\"" : "" ?>/>
</div> </div>
<div class="fdescr"> &mdash; <?php echo getlocal('settings.enabledepartments.description') ?></div> <div class="fdescr"> &mdash; <?php echo getlocal('settings.enablegroups.description') ?></div>
<br clear="left"/> <br clear="left"/>
</div> </div>

View File

@ -13,17 +13,17 @@
*/ */
require_once("inc_menu.php"); require_once("inc_menu.php");
$page['title'] = getlocal("page.department.title"); $page['title'] = getlocal("page.group.title");
$page['menuid'] = "departments"; $page['menuid'] = "groups";
function tpl_content() { global $page, $webimroot, $errors; function tpl_content() { global $page, $webimroot, $errors;
?> ?>
<?php if( $page['depid'] ) { ?> <?php if( $page['depid'] ) { ?>
<?php echo getlocal("page.department.intro") ?> <?php echo getlocal("page.group.intro") ?>
<?php } ?> <?php } ?>
<?php if( !$page['depid'] ) { ?> <?php if( !$page['depid'] ) { ?>
<?php echo getlocal("page.department.create_new") ?> <?php echo getlocal("page.group.create_new") ?>
<?php } ?> <?php } ?>
<br /> <br />
<br /> <br />
@ -31,45 +31,45 @@ function tpl_content() { global $page, $webimroot, $errors;
require_once('inc_errors.php'); require_once('inc_errors.php');
?> ?>
<form name="departmentForm" method="post" action="<?php echo $webimroot ?>/operator/department.php"> <form name="groupForm" method="post" action="<?php echo $webimroot ?>/operator/group.php">
<input type="hidden" name="dep" value="<?php echo $page['depid'] ?>"/> <input type="hidden" name="dep" value="<?php echo $page['depid'] ?>"/>
<div> <div>
<div class="mform"><div class="formtop"><div class="formtopi"></div></div><div class="forminner"> <div class="mform"><div class="formtop"><div class="formtopi"></div></div><div class="forminner">
<div class="fieldForm"> <div class="fieldForm">
<div class="field"> <div class="field">
<div class="flabel"><?php echo getlocal('form.field.depname') ?><span class="required">*</span></div> <div class="flabel"><?php echo getlocal('form.field.groupname') ?><span class="required">*</span></div>
<div class="fvalue"> <div class="fvalue">
<input type="text" name="name" size="40" value="<?php echo form_value('name') ?>" class="formauth"/> <input type="text" name="name" size="40" value="<?php echo form_value('name') ?>" class="formauth"/>
</div> </div>
<div class="fdescr"> &mdash; <?php echo getlocal('form.field.depname.description') ?></div> <div class="fdescr"> &mdash; <?php echo getlocal('form.field.groupname.description') ?></div>
<br clear="left"/> <br clear="left"/>
</div> </div>
<div class="field"> <div class="field">
<div class="flabel"><?php echo getlocal('form.field.depdesc') ?></div> <div class="flabel"><?php echo getlocal('form.field.groupdesc') ?></div>
<div class="fvalue"> <div class="fvalue">
<input type="text" name="description" size="40" value="<?php echo form_value('description') ?>" class="formauth"/> <input type="text" name="description" size="40" value="<?php echo form_value('description') ?>" class="formauth"/>
</div> </div>
<div class="fdescr"> &mdash; <?php echo getlocal('form.field.depdesc.description') ?></div> <div class="fdescr"> &mdash; <?php echo getlocal('form.field.groupdesc.description') ?></div>
<br clear="left"/> <br clear="left"/>
</div> </div>
<div class="field"> <div class="field">
<div class="flabel"><?php echo getlocal('form.field.depcommonname') ?></div> <div class="flabel"><?php echo getlocal('form.field.groupcommonname') ?></div>
<div class="fvalue"> <div class="fvalue">
<input type="text" name="commonname" size="40" value="<?php echo form_value('commonname') ?>" class="formauth"/> <input type="text" name="commonname" size="40" value="<?php echo form_value('commonname') ?>" class="formauth"/>
</div> </div>
<div class="fdescr"> &mdash; <?php echo getlocal('form.field.depcommonname.description') ?></div> <div class="fdescr"> &mdash; <?php echo getlocal('form.field.groupcommonname.description') ?></div>
<br clear="left"/> <br clear="left"/>
</div> </div>
<div class="field"> <div class="field">
<div class="flabel"><?php echo getlocal('form.field.depcommondesc') ?></div> <div class="flabel"><?php echo getlocal('form.field.groupcommondesc') ?></div>
<div class="fvalue"> <div class="fvalue">
<input type="text" name="commondescription" size="40" value="<?php echo form_value('commondescription') ?>" class="formauth"/> <input type="text" name="commondescription" size="40" value="<?php echo form_value('commondescription') ?>" class="formauth"/>
</div> </div>
<div class="fdescr"> &mdash; <?php echo getlocal('form.field.depcommondesc.description') ?></div> <div class="fdescr"> &mdash; <?php echo getlocal('form.field.groupcommondesc.description') ?></div>
<br clear="left"/> <br clear="left"/>
</div> </div>

View File

@ -13,20 +13,20 @@
*/ */
require_once("inc_menu.php"); require_once("inc_menu.php");
$page['title'] = getlocal("page.departments.title"); $page['title'] = getlocal("page.groups.title");
$page['menuid'] = "departments"; $page['menuid'] = "groups";
function tpl_content() { global $page, $webimroot; function tpl_content() { global $page, $webimroot;
?> ?>
<?php echo getlocal("page.departments.intro") ?> <?php echo getlocal("page.groups.intro") ?>
<br /> <br />
<br /> <br />
<div class="tabletool"> <div class="tabletool">
<img src='<?php echo $webimroot ?>/images/buttons/createdep.gif' border="0" alt="" /> <img src='<?php echo $webimroot ?>/images/buttons/createdep.gif' border="0" alt="" />
<a href='<?php echo $webimroot ?>/operator/department.php' title="<?php echo getlocal("page.departments.new") ?>"> <a href='<?php echo $webimroot ?>/operator/group.php' title="<?php echo getlocal("page.groups.new") ?>">
<?php echo getlocal("page.departments.new") ?> <?php echo getlocal("page.groups.new") ?>
</a> </a>
</div> </div>
<br clear="all"/> <br clear="all"/>
@ -36,22 +36,22 @@ function tpl_content() { global $page, $webimroot;
<thead> <thead>
<tr class="header"> <tr class="header">
<th> <th>
<?php echo getlocal("form.field.depname") ?> <?php echo getlocal("form.field.groupname") ?>
</th><th> </th><th>
<?php echo getlocal("form.field.depdesc") ?> <?php echo getlocal("form.field.groupdesc") ?>
</th><th> </th><th>
<?php echo getlocal("page.department.membersnum") ?> <?php echo getlocal("page.group.membersnum") ?>
</th><th> </th><th>
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
if(count($page['departments']) > 0) { if(count($page['groups']) > 0) {
foreach( $page['departments'] as $dep ) { ?> foreach( $page['groups'] as $dep ) { ?>
<tr> <tr>
<td class="notlast"> <td class="notlast">
<a href="<?php echo $webimroot ?>/operator/department.php?dep=<?php echo $dep['departmentid'] ?>" class="man"> <a href="<?php echo $webimroot ?>/operator/group.php?dep=<?php echo $dep['groupid'] ?>" class="man">
<?php echo htmlspecialchars(topage($dep['vclocalname'])) ?> <?php echo htmlspecialchars(topage($dep['vclocalname'])) ?>
</a> </a>
</td> </td>
@ -62,7 +62,7 @@ if(count($page['departments']) > 0) {
<?php echo htmlspecialchars(topage($dep['inumofagents'])) ?> <?php echo htmlspecialchars(topage($dep['inumofagents'])) ?>
</td> </td>
<td> <td>
<a href="<?php echo $webimroot ?>/operator/departments.php?act=del&amp;dep=<?php echo $dep['departmentid'] ?>"> <a href="<?php echo $webimroot ?>/operator/groups.php?act=del&amp;dep=<?php echo $dep['groupid'] ?>">
remove remove
</a> </a>
</td> </td>

View File

@ -28,8 +28,8 @@ function tpl_menu() { global $page, $webimroot, $errors;
<h2><?php echo getlocal('right.administration') ?></h2> <h2><?php echo getlocal('right.administration') ?></h2>
<ul class="submenu"> <ul class="submenu">
<li<?php menuli("operators")?>><a href='<?php echo $webimroot ?>/operator/operators.php'><?php echo getlocal('leftMenu.client_agents') ?></a></li> <li<?php menuli("operators")?>><a href='<?php echo $webimroot ?>/operator/operators.php'><?php echo getlocal('leftMenu.client_agents') ?></a></li>
<?php if(isset($page['showdep']) && $page['showdep']) { ?> <?php if(isset($page['showgroups']) && $page['showgroups']) { ?>
<li<?php menuli("departments")?>><a href='<?php echo $webimroot ?>/operator/departments.php'><?php echo getlocal('menu.departments') ?></a></li> <li<?php menuli("groups")?>><a href='<?php echo $webimroot ?>/operator/groups.php'><?php echo getlocal('menu.groups') ?></a></li>
<?php } ?> <?php } ?>
<li<?php menuli("getcode")?>><a href='<?php echo $webimroot ?>/operator/getcode.php'><?php echo getlocal('leftMenu.client_gen_button') ?></a></li> <li<?php menuli("getcode")?>><a href='<?php echo $webimroot ?>/operator/getcode.php'><?php echo getlocal('leftMenu.client_gen_button') ?></a></li>
<li<?php menuli("settings")?>><a href='<?php echo $webimroot ?>/operator/settings.php'><?php echo getlocal('leftMenu.client_settings') ?></a></li> <li<?php menuli("settings")?>><a href='<?php echo $webimroot ?>/operator/settings.php'><?php echo getlocal('leftMenu.client_settings') ?></a></li>

View File

@ -89,12 +89,12 @@ if( $page['showadmin'] ) { ?>
</td> </td>
<?php menuseparator(); ?> <?php menuseparator(); ?>
<?php if($page['showdep']) { ?> <?php if($page['showgroups']) { ?>
<td class="dashitem"> <td class="dashitem">
<img src="/webim/images/dash/dep.gif" alt=""/> <img src="/webim/images/dash/dep.gif" alt=""/>
<a href='<?php echo $webimroot ?>/operator/departments.php'> <a href='<?php echo $webimroot ?>/operator/groups.php'>
<?php echo getlocal('menu.departments') ?></a> <?php echo getlocal('menu.groups') ?></a>
<?php echo getlocal('menu.departments.content') ?> <?php echo getlocal('menu.groups.content') ?>
</td> </td>
<?php menuseparator(); ?> <?php menuseparator(); ?>
<?php } ?> <?php } ?>

View File

@ -0,0 +1,69 @@
<?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("operator.groups.title");
$page['menuid'] = "operators";
function tpl_content() { global $page, $webimroot, $errors;
?>
<?php echo getlocal("operator.groups.intro") ?>
<br />
<br />
<?php
require_once('inc_errors.php');
?>
<form name="opgroupsForm" method="post" action="<?php echo $webimroot ?>/operator/opgroups.php">
<input type="hidden" name="op" value="<?php echo $page['op'] ?>"/>
<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['currentop'] ?></b>
</p>
<?php foreach( $page['groups'] as $pm ) { ?>
<div class="field">
<div class="flabel"><?php echo $pm['vclocalname'] ?></div>
<div class="fvalue">
<input type="checkbox" name="group<?php echo $pm['groupid'] ?>" value="on"<?php echo form_value_mb('group',$pm['groupid']) ? " checked=\"checked\"" : "" ?>/>
</div>
<div class="fdescr"> &mdash; <?php echo $pm['vclocaldescription'] ?></div>
<br clear="left"/>
</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');
?>