departments: create/edit/remove

git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@413 c66351dc-e62f-0410-b875-e3a5c0b9693f
This commit is contained in:
Evgeny Gryaznov 2009-03-16 21:49:45 +00:00
parent e1eb49e76f
commit 90e4bea7b2
15 changed files with 407 additions and 8 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 728 B

View File

@ -15,8 +15,10 @@
$dbtables = array( $dbtables = array(
"chatdepartment" => array( "chatdepartment" => array(
"departmentid" => "int NOT NULL auto_increment PRIMARY KEY", "departmentid" => "int NOT NULL auto_increment PRIMARY KEY",
"vcname" => "varchar(64) NOT NULL", "vclocalname" => "varchar(64) NOT NULL",
"vcdescription" => "varchar(1024) NOT NULL", "vccommonname" => "varchar(64) NOT NULL",
"vclocaldescription" => "varchar(1024) NOT NULL",
"vccommondescription" => "varchar(1024) NOT NULL",
), ),
"chatthread" => array( "chatthread" => array(

View File

@ -17,7 +17,7 @@ session_start();
require_once(dirname(__FILE__).'/converter.php'); require_once(dirname(__FILE__).'/converter.php');
require_once(dirname(__FILE__).'/config.php'); require_once(dirname(__FILE__).'/config.php');
$version = '1.5.2'; $version = '1.6.0 alpha 1';
function myiconv($in_enc, $out_enc, $string) { function myiconv($in_enc, $out_enc, $string) {
global $_utf8win1251, $_win1251utf8; global $_utf8win1251, $_win1251utf8;
@ -498,7 +498,7 @@ function webim_mail($toaddr, $reply_to, $subject, $body) {
mail($toaddr, $real_subject, wordwrap(myiconv($webim_encoding, $mail_encoding, $body),70), $headers); mail($toaddr, $real_subject, wordwrap(myiconv($webim_encoding, $mail_encoding, $body),70), $headers);
} }
$dbversion = '1.5.2'; $dbversion = '1.6.0.1';
$settings = array( $settings = array(
'dbversion' => 0, 'dbversion' => 0,
@ -519,6 +519,7 @@ $settings = array(
'enableban' => '0', 'enableban' => '0',
'enablessl' => '0', 'enablessl' => '0',
'usercanchangename' => '1', 'usercanchangename' => '1',
'enabledepartments' => '0',
); );
$settingsloaded = false; $settingsloaded = false;
$settings_in_db = array(); $settings_in_db = array();

View File

@ -220,6 +220,7 @@ 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['showadmin'] = is_capable($can_administrate, $operator); $page['showadmin'] = is_capable($can_administrate, $operator);
} }
} }

View File

@ -107,6 +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.depname.description=Name to identify the department.
form.field.depdesc=Description
form.field.depdesc.description=Description of the department.
form.field.depcommonname=International name
form.field.depcommonname.description=Name in English.
form.field.depcommondesc=International description
form.field.depcommondesc.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
@ -170,6 +178,7 @@ 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.departments=Departments
menu.departments.content=Group operators together.
menu.locale=Language menu.locale=Language
menu.locale.content=Change locale. menu.locale.content=Change locale.
menu.main=Main menu.main=Main
@ -188,6 +197,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.department.duplicate_name=Please choose another name, because department with entered name already exists.
page.department.intro=On this page you can edit department details.
page.department.membersnum=Agents
page.department.no_such=No such department
page.department.title=Department details
page.departments.title=Departments
page.departments.intro=This page displays list of departments in your company. Each department can have separate button and canned responses.
page.departments.new=Create new department...
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
@ -290,6 +308,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.enabledepartments=Enable "Departments"
settings.enablessl.description=Please, note that your web server should be<br/> configured to support https requests. settings.enablessl.description=Please, note that your web server should be<br/> configured to support https requests.
settings.enablessl=Allow secure connections (SSL) settings.enablessl=Allow secure connections (SSL)
settings.geolink.description=Each IP becomes a link opening in new window. {ip} is substituted with a real ip. settings.geolink.description=Each IP becomes a link opening in new window. {ip} is substituted with a real ip.

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

@ -0,0 +1,48 @@
<?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();
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' ) {
// TODO check permissions, delete in other places
$departmentid = verifyparam( "dep", "/^(\d{1,9})?$/");
$link = connect();
perform_query("delete from chatdepartment where departmentid = $departmentid",$link);
mysql_close($link);
header("Location: $webimroot/operator/departments.php");
exit;
}
$page = array();
$page['departments'] = get_departments();
prepare_menu($operator);
start_html_output();
require('../view/departments.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'); $options = array('enableban', 'usercanchangename', 'enablessl', 'enabledepartments');
loadsettings(); loadsettings();
$params = array(); $params = array();

View File

@ -0,0 +1,94 @@
<?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.department.title");
$page['menuid'] = "departments";
function tpl_content() { global $page, $webimroot, $errors;
?>
<?php if( $page['depid'] ) { ?>
<?php echo getlocal("page.department.intro") ?>
<?php } ?>
<?php if( !$page['depid'] ) { ?>
<?php echo getlocal("page.department.create_new") ?>
<?php } ?>
<br />
<br />
<?php
require_once('inc_errors.php');
?>
<form name="departmentForm" method="post" action="<?php echo $webimroot ?>/operator/department.php">
<input type="hidden" name="dep" value="<?php echo $page['depid'] ?>"/>
<div>
<div class="mform"><div class="formtop"><div class="formtopi"></div></div><div class="forminner">
<div class="fieldForm">
<div class="field">
<div class="flabel"><?php echo getlocal('form.field.depname') ?><span class="required">*</span></div>
<div class="fvalue">
<input type="text" name="name" size="40" value="<?php echo form_value('name') ?>" class="formauth"/>
</div>
<div class="fdescr"> &mdash; <?php echo getlocal('form.field.depname.description') ?></div>
<br clear="left"/>
</div>
<div class="field">
<div class="flabel"><?php echo getlocal('form.field.depdesc') ?></div>
<div class="fvalue">
<input type="text" name="description" size="40" value="<?php echo form_value('description') ?>" class="formauth"/>
</div>
<div class="fdescr"> &mdash; <?php echo getlocal('form.field.depdesc.description') ?></div>
<br clear="left"/>
</div>
<div class="field">
<div class="flabel"><?php echo getlocal('form.field.depcommonname') ?></div>
<div class="fvalue">
<input type="text" name="commonname" size="40" value="<?php echo form_value('commonname') ?>" class="formauth"/>
</div>
<div class="fdescr"> &mdash; <?php echo getlocal('form.field.depcommonname.description') ?></div>
<br clear="left"/>
</div>
<div class="field">
<div class="flabel"><?php echo getlocal('form.field.depcommondesc') ?></div>
<div class="fvalue">
<input type="text" name="commondescription" size="40" value="<?php echo form_value('commondescription') ?>" class="formauth"/>
</div>
<div class="fdescr"> &mdash; <?php echo getlocal('form.field.depcommondesc.description') ?></div>
<br clear="left"/>
</div>
<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><div class="formbottom"><div class="formbottomi"></div></div></div>
</div>
<div class="asterisk">
<?php echo getlocal("common.asterisk_explanation") ?>
</div>
</form>
<?php
} /* content */
require_once('inc_main.php');
?>

View File

@ -0,0 +1,89 @@
<?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.departments.title");
$page['menuid'] = "departments";
function tpl_content() { global $page, $webimroot;
?>
<?php echo getlocal("page.departments.intro") ?>
<br />
<br />
<div class="tabletool">
<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") ?>">
<?php echo getlocal("page.departments.new") ?>
</a>
</div>
<br clear="all"/>
<table class="list">
<thead>
<tr class="header">
<th>
<?php echo getlocal("form.field.depname") ?>
</th><th>
<?php echo getlocal("form.field.depdesc") ?>
</th><th>
<?php echo getlocal("page.department.membersnum") ?>
</th><th>
</th>
</tr>
</thead>
<tbody>
<?php
if(count($page['departments']) > 0) {
foreach( $page['departments'] as $dep ) { ?>
<tr>
<td class="notlast">
<a href="<?php echo $webimroot ?>/operator/department.php?dep=<?php echo $dep['departmentid'] ?>" class="man">
<?php echo htmlspecialchars(topage($dep['vclocalname'])) ?>
</a>
</td>
<td class="notlast">
<?php echo $dep['vclocaldescription'] ? htmlspecialchars(topage($dep['vclocaldescription'])) : "&lt;none&gt;" ?>
</td>
<td>
<?php echo htmlspecialchars(topage($dep['inumofagents'])) ?>
</td>
<td>
<a href="<?php echo $webimroot ?>/operator/departments.php?act=del&amp;dep=<?php echo $dep['departmentid'] ?>">
remove
</a>
</td>
</tr>
<?php
}
} else {
?>
<tr>
<td colspan="4">
<?php echo getlocal("tag.pagination.no_items.elements") ?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
} /* content */
require_once('inc_main.php');
?>

View File

@ -71,6 +71,15 @@ require_once('inc_errors.php');
<br clear="left"/> <br clear="left"/>
</div> </div>
<div class="field">
<div class="flabel"><?php echo getlocal('settings.enabledepartments') ?></div>
<div class="fvalue">
<input type="checkbox" name="enabledepartments" value="on"<?php echo form_value_cb('enabledepartments') ? " checked=\"checked\"" : "" ?>/>
</div>
<div class="fdescr"> &mdash; <?php echo getlocal('settings.enabledepartments.description') ?></div>
<br clear="left"/>
</div>
<div class="fbutton"> <div class="fbutton">
<input type="image" name="save" value="" src='<?php echo $webimroot.getlocal("image.button.save") ?>' alt='<?php echo getlocal("button.save") ?>'/> <input type="image" name="save" value="" src='<?php echo $webimroot.getlocal("image.button.save") ?>' alt='<?php echo getlocal("button.save") ?>'/>
</div> </div>

View File

@ -64,7 +64,7 @@
<div class="empty_inner" style="">&#160;</div> <div class="empty_inner" style="">&#160;</div>
</div> </div>
<div id="footer"> <div id="footer">
<p id="legal"><a href="http://openwebim.org/" class="flink">Open Web Messenger</a> 1.5.2 | (c) 2009 openwebim.org</p> <p id="legal"><a href="http://openwebim.org/" class="flink">Open Web Messenger</a> <?php echo $version ?> | (c) 2009 openwebim.org</p>
</div> </div>
</body> </body>
</html> </html>

View File

@ -25,7 +25,9 @@ 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>
<li<?php menuli("departments")?>><a href="#"><?php echo getlocal('menu.departments') ?></a></li> <?php if(isset($page['showdep']) && $page['showdep']) { ?>
<li<?php menuli("departments")?>><a href='<?php echo $webimroot ?>/operator/departments.php'><?php echo getlocal('menu.departments') ?></a></li>
<?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>
<li<?php menuli("translate")?>><a href='<?php echo $webimroot ?>/operator/translate.php'><?php echo getlocal('menu.translate') ?></a></li> <li<?php menuli("translate")?>><a href='<?php echo $webimroot ?>/operator/translate.php'><?php echo getlocal('menu.translate') ?></a></li>

View File

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