From 90e4bea7b2da7a01a029fbdba857ae5950ccce23 Mon Sep 17 00:00:00 2001
From: Evgeny Gryaznov
Date: Mon, 16 Mar 2009 21:49:45 +0000
Subject: [PATCH] departments: create/edit/remove
git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@413 c66351dc-e62f-0410-b875-e3a5c0b9693f
---
.../webim/images/buttons/createdep.gif | Bin 0 -> 1212 bytes
src/messenger/webim/images/dash/dep.gif | Bin 0 -> 728 bytes
src/messenger/webim/install/dbinfo.php | 6 +-
src/messenger/webim/libs/common.php | 5 +-
src/messenger/webim/libs/operator.php | 1 +
src/messenger/webim/locales/en/properties | 20 +++
src/messenger/webim/operator/department.php | 124 ++++++++++++++++++
src/messenger/webim/operator/departments.php | 48 +++++++
src/messenger/webim/operator/features.php | 2 +-
src/messenger/webim/view/department.php | 94 +++++++++++++
src/messenger/webim/view/departments.php | 89 +++++++++++++
src/messenger/webim/view/features.php | 9 ++
src/messenger/webim/view/inc_main.php | 2 +-
src/messenger/webim/view/inc_menu.php | 4 +-
src/messenger/webim/view/menu.php | 11 +-
15 files changed, 407 insertions(+), 8 deletions(-)
create mode 100644 src/messenger/webim/images/buttons/createdep.gif
create mode 100644 src/messenger/webim/images/dash/dep.gif
create mode 100644 src/messenger/webim/operator/department.php
create mode 100644 src/messenger/webim/operator/departments.php
create mode 100644 src/messenger/webim/view/department.php
create mode 100644 src/messenger/webim/view/departments.php
diff --git a/src/messenger/webim/images/buttons/createdep.gif b/src/messenger/webim/images/buttons/createdep.gif
new file mode 100644
index 0000000000000000000000000000000000000000..138e2000544175b26fff904bbb225d28288c66e2
GIT binary patch
literal 1212
zcmd7ReN)m00KoB|-~*ny>GIZAZK3njbGG4WcdlB)EL*eNk)mRvVhY35O?-X|flv`d
zK|n-NK~YeA!pD3>oky
z&ctv1mYV$9=&Hww#VrwXBaJ_m)}YGdPU1zn0@I5jv973hzOqi4P9H#bo9Pw(vE60{
zX96cs{;_#v5@`#@SDH5dGS*I|O7ujDzJxuNT+$ZVw@_WoPncX43sqS(#XU+#G;1uW
zayWrAfgf8IHfnN)mUyhuBm<yk!$m1)G
zS=?Wl%|*mkWbI@sL;AqFXKbIP@Re!lWk~iow#UqP^I=bFpiZrc)$1}!bCPVXbnoqI
zi7ecDpsyT>r?jIp%26fFu|?d340?DzJFaplp4*$3$%xTxbnG8n6$`AqYBW)Rp?0C3
z9U4gOkt0v*)a%k|YukW@^I~sPFqK&~nrPiOY#ms}R)k0I|11>5kfl+1^@tWFxowst
zP-bLR#BCou?VV?~&JfoR4Q0JCrCs+17P&+TvPqL8))h>wifM}21{I-qzUs-o^7rar
zx=b{lgi7s-<}1^gBk}Yh^yqSfeyb;k9jRETes}VBZZ(?H5v8SKyT;W7iYS(~Tb=*+2#
zEfkrW5~8(uTRfh-^4H7as3(>ah9pxb=QI+di$W;
zK&s}8Yvzn(*JZd~aP24RO&9n!$@_vI>z=FxwVB4j1mT
zHVp~!{W8qa4P!%|a{zyizr?u&G1}Oel40lW)Wv+_=;VjMWM6Lk)n!-_6swjxfsh!Km+Fl8s`+Sw+;<-c2$4E`
zpNfU^<+#&cvO)}6#{t&(7ejKv0PI|Ky;x8{*wH%RI5hzrgoe!2eFIwdCI2{{YwHOB
zqQDSHI}S|BggY9c2q+kWXC*ji(?q47iGd+-KUbKjnRxLKp#s^HSYhs=*)}%=uHIOr
zfIa*`6fiI2Zm^xb$;EWOp2fZqK(bYo*%=P~P2Ya^Dj4jX?&EL!S#+AmtpL+8=G1Aq
ZjNo(%Msg25JHXx1U10ZlAmG52{{Z-iAVvTH
literal 0
HcmV?d00001
diff --git a/src/messenger/webim/images/dash/dep.gif b/src/messenger/webim/images/dash/dep.gif
new file mode 100644
index 0000000000000000000000000000000000000000..d43fe879b3f2aaf840e6889fdd8950120f84c713
GIT binary patch
literal 728
zcmZ{h+e=dc0EbUC%}8s@)R`F#OPx-c+Z5;A?VO#t8Rey{piE6Fvzt^7A1da-3p!V!
zm6u9oYIsRk>fF3LwVE1%k_0h(NK&8bA*hVtm;C|#-ahyqKKLc+weiv%F2N;M37l8DltT1p2j0NIyN%GaWf3#6kH_k2r#F`Ac+wQuV{2cW0poa9|IHyNZ2Se
zMxi7DAM3H)fNnKxB8*93iooXvyw$=Mg9!~LXjq~#szJ99gJRSRFd%}11j9!$9}Y3@
zMZyw=X&SCLI7E0B4TlE(F{q4yRfvWtjBKD1P8#DRrnPWtU?b5>!WsjY7G-=)YB4Us
z{YWg<0U-WA-a2a&K^O?ZKjq&i#8wy$1|7S!EbA~+X{rjpAr9GF9U?vyURB4WNM)+v
zCfN~bc75HspddkLs31sDaH6eB=^yWJw_QGy+iS`Z?RGllM^mpQpW@8UWh7N*Qho~y
zClf^%(k@;Pa0gt^nXYT{s}zK@blSR-HT>5
z6Pxa3@m)4fm9s+>RZf~+v&&1A?{=l-ZWA#~QMjtNb*AQ^e46v1)YDii%$+UKQ>Ohv
zk=|?WnZDI`esQePJWg}_e2dOJP{dpF^!7+?Nq)M=@3oIQOp=#9Ve9%}^_Fm@JY9K7
z-;RaO%;6u;S;0)~>2{sU-m^4ZnBia_*vzW%FmBntZ^X#*;xNKn+zH3a*
R_+_q6oYm;=`fgDXvcKw9YJC6z
literal 0
HcmV?d00001
diff --git a/src/messenger/webim/install/dbinfo.php b/src/messenger/webim/install/dbinfo.php
index f60ce81a..3b093c0a 100644
--- a/src/messenger/webim/install/dbinfo.php
+++ b/src/messenger/webim/install/dbinfo.php
@@ -15,8 +15,10 @@
$dbtables = array(
"chatdepartment" => array(
"departmentid" => "int NOT NULL auto_increment PRIMARY KEY",
- "vcname" => "varchar(64) NOT NULL",
- "vcdescription" => "varchar(1024) NOT NULL",
+ "vclocalname" => "varchar(64) NOT NULL",
+ "vccommonname" => "varchar(64) NOT NULL",
+ "vclocaldescription" => "varchar(1024) NOT NULL",
+ "vccommondescription" => "varchar(1024) NOT NULL",
),
"chatthread" => array(
diff --git a/src/messenger/webim/libs/common.php b/src/messenger/webim/libs/common.php
index 82721129..50e0f581 100644
--- a/src/messenger/webim/libs/common.php
+++ b/src/messenger/webim/libs/common.php
@@ -17,7 +17,7 @@ session_start();
require_once(dirname(__FILE__).'/converter.php');
require_once(dirname(__FILE__).'/config.php');
-$version = '1.5.2';
+$version = '1.6.0 alpha 1';
function myiconv($in_enc, $out_enc, $string) {
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);
}
-$dbversion = '1.5.2';
+$dbversion = '1.6.0.1';
$settings = array(
'dbversion' => 0,
@@ -519,6 +519,7 @@ $settings = array(
'enableban' => '0',
'enablessl' => '0',
'usercanchangename' => '1',
+ 'enabledepartments' => '0',
);
$settingsloaded = false;
$settings_in_db = array();
diff --git a/src/messenger/webim/libs/operator.php b/src/messenger/webim/libs/operator.php
index ee986de1..f38a7d4e 100644
--- a/src/messenger/webim/libs/operator.php
+++ b/src/messenger/webim/libs/operator.php
@@ -220,6 +220,7 @@ function prepare_menu($operator,$hasright=true) {
if($hasright) {
loadsettings();
$page['showban'] = $settings['enableban'] == "1";
+ $page['showdep'] = $settings['enabledepartments'] == "1";
$page['showadmin'] = is_capable($can_administrate, $operator);
}
}
diff --git a/src/messenger/webim/locales/en/properties b/src/messenger/webim/locales/en/properties
index 02f4567f..8e908fa9 100644
--- a/src/messenger/webim/locales/en/properties
+++ b/src/messenger/webim/locales/en/properties
@@ -107,6 +107,14 @@ form.field.ban_comment.description=Reason of block
form.field.ban_comment=Comment
form.field.ban_days.description=Numbers of days this address is blocked
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.login.description=Login can consist of small Latin letters and underscore.
form.field.login=Login
@@ -170,6 +178,7 @@ mailthread.title=Send chat history
by mail
menu.agents=Agents list
menu.blocked=Blocked visitors
menu.departments=Departments
+menu.departments.content=Group operators together.
menu.locale=Language
menu.locale.content=Change locale.
menu.main=Main
@@ -188,6 +197,15 @@ page.chat.old_browser.close=Close...
page.chat.old_browser.list=\n- Internet Explorer 5.5+\n
- Firefox 1.0+\n
- Opera 8.0+\n
- Mozilla 1.4+\n
- Netscape 7.1+\n
- Safari 1.2+\n
\nAlso, we support some old browsers:\n\n- Internet Explorer 5.0\n
- Opera 7.0\n
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.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_locale=Target locale
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.enableban.description=Using it you can block attacks from specific IPs
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
configured to support https requests.
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.
diff --git a/src/messenger/webim/operator/department.php b/src/messenger/webim/operator/department.php
new file mode 100644
index 00000000..c6f59d68
--- /dev/null
+++ b/src/messenger/webim/operator/department.php
@@ -0,0 +1,124 @@
+ '');
+$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');
+?>
\ No newline at end of file
diff --git a/src/messenger/webim/operator/departments.php b/src/messenger/webim/operator/departments.php
new file mode 100644
index 00000000..2ce94547
--- /dev/null
+++ b/src/messenger/webim/operator/departments.php
@@ -0,0 +1,48 @@
+
\ No newline at end of file
diff --git a/src/messenger/webim/operator/features.php b/src/messenger/webim/operator/features.php
index 23d04154..a79caad6 100644
--- a/src/messenger/webim/operator/features.php
+++ b/src/messenger/webim/operator/features.php
@@ -21,7 +21,7 @@ $operator = check_login();
$page = array('agentId' => '');
$errors = array();
-$options = array('enableban', 'usercanchangename', 'enablessl');
+$options = array('enableban', 'usercanchangename', 'enablessl', 'enabledepartments');
loadsettings();
$params = array();
diff --git a/src/messenger/webim/view/department.php b/src/messenger/webim/view/department.php
new file mode 100644
index 00000000..9b5add18
--- /dev/null
+++ b/src/messenger/webim/view/department.php
@@ -0,0 +1,94 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/messenger/webim/view/departments.php b/src/messenger/webim/view/departments.php
new file mode 100644
index 00000000..2e2b0724
--- /dev/null
+++ b/src/messenger/webim/view/departments.php
@@ -0,0 +1,89 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0) {
+ foreach( $page['departments'] as $dep ) { ?>
+
+
+
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+ remove
+
+ |
+
+
+
+
+
+ |
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/messenger/webim/view/features.php b/src/messenger/webim/view/features.php
index 824dc0ff..05e83bc6 100644
--- a/src/messenger/webim/view/features.php
+++ b/src/messenger/webim/view/features.php
@@ -71,6 +71,15 @@ require_once('inc_errors.php');
+
+
diff --git a/src/messenger/webim/view/inc_main.php b/src/messenger/webim/view/inc_main.php
index 977175c2..d6ece1ed 100644
--- a/src/messenger/webim/view/inc_main.php
+++ b/src/messenger/webim/view/inc_main.php
@@ -64,7 +64,7 @@