From 958423ef353dd19d4fdf681a2a6cc2262967f6be Mon Sep 17 00:00:00 2001 From: Evgeny Gryaznov Date: Sat, 9 Jan 2010 20:58:27 +0000 Subject: [PATCH] two-row tab menu, two column options in "generate code", jabber notification option, adjust db git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@717 c66351dc-e62f-0410-b875-e3a5c0b9693f --- src/messenger/webim/default.css | 10 +++- src/messenger/webim/install/dbinfo.php | 5 +- src/messenger/webim/install/dbperform.php | 4 ++ src/messenger/webim/libs/operator.php | 21 ++++--- .../webim/libs/operator_settings.php | 16 +++--- src/messenger/webim/libs/settings.php | 9 +-- src/messenger/webim/locales/en/properties | 4 ++ src/messenger/webim/operator/operator.php | 16 +++++- src/messenger/webim/view/agent.php | 29 +++++++--- src/messenger/webim/view/avatar.php | 11 +--- src/messenger/webim/view/features.php | 11 +--- src/messenger/webim/view/gen_button.php | 16 ++++-- src/messenger/webim/view/inc_tabbar.php | 56 +++++++++++++++++++ src/messenger/webim/view/operator_groups.php | 11 +--- src/messenger/webim/view/performance.php | 11 +--- src/messenger/webim/view/permissions.php | 11 +--- src/messenger/webim/view/settings.php | 11 +--- src/messenger/webim/view/themes.php | 11 +--- 18 files changed, 160 insertions(+), 103 deletions(-) create mode 100644 src/messenger/webim/view/inc_tabbar.php diff --git a/src/messenger/webim/default.css b/src/messenger/webim/default.css index 4512dd2f..f622ccd2 100644 --- a/src/messenger/webim/default.css +++ b/src/messenger/webim/default.css @@ -250,6 +250,7 @@ img.left { .tabs { float: right; + margin-left: 15px; display: inline; margin-right: 15px; } @@ -324,11 +325,18 @@ div.errinfo { font-weight: bold; } -.field .subfield { +.field .subfield .fieldinrow { padding-left: 30px; background: url(images/subitem.gif) no-repeat 10px 2px; } +.fieldinrow { + min-width: 300px; + display: inline; + float:left; + width: 45%; +} + .fvalue { float: left; } diff --git a/src/messenger/webim/install/dbinfo.php b/src/messenger/webim/install/dbinfo.php index e3fab78c..24463b17 100644 --- a/src/messenger/webim/install/dbinfo.php +++ b/src/messenger/webim/install/dbinfo.php @@ -76,6 +76,7 @@ $dbtables = array( "vcavatar" => "varchar(255)", "vcjabbername" => "varchar(255)", "iperm" => "int DEFAULT 65535", + "inotify" => "int DEFAULT 0", /* 0 - none, 1 - jabber */ "dtmrestore" => "datetime DEFAULT 0", "vcrestoretoken" => "varchar(64)", ), @@ -117,7 +118,7 @@ $memtables = array(); $dbtables_can_update = array( "chatthread" => array("agentId", "userTyping", "agentTyping", "messageCount", "nextagent", "shownmessageid", "userid", "userAgent", "groupid"), "chatmessage" => array("agentId"), - "chatoperator" => array("vcavatar", "vcjabbername", "iperm", "istatus", "vcemail", "dtmrestore", "vcrestoretoken"), + "chatoperator" => array("vcavatar", "vcjabbername", "iperm", "istatus", "vcemail", "dtmrestore", "vcrestoretoken", "inotify"), "chatban" => array(), "chatgroup" => array("vcemail"), "chatgroupoperator" => array(), @@ -161,7 +162,7 @@ function create_table($id,$link) { mysql_query($query,$link) or show_install_err(' Query failed: '.mysql_error()); if( $id == 'chatoperator' ) { - create_operator_("admin", "", "", "Administrator", "Administrator", "", $link); + create_operator_("admin", "", "", "", "Administrator", "Administrator", 0, $link); } else if( $id == 'chatrevision' ) { perform_query("INSERT INTO chatrevision VALUES (1)",$link); } diff --git a/src/messenger/webim/install/dbperform.php b/src/messenger/webim/install/dbperform.php index 9a1ed9dc..c0b7df01 100644 --- a/src/messenger/webim/install/dbperform.php +++ b/src/messenger/webim/install/dbperform.php @@ -121,6 +121,10 @@ if ($act == "silentcreateall") { if( in_array("chatoperator.istatus", $absent) ) { runsql("ALTER TABLE chatoperator ADD istatus int DEFAULT 0", $link); } + + if( in_array("chatoperator.inotify", $absent) ) { + runsql("ALTER TABLE chatoperator ADD inotify int DEFAULT 0", $link); + } if( in_array("chatoperator.vcavatar", $absent) ) { runsql("ALTER TABLE chatoperator ADD vcavatar varchar(255)", $link); diff --git a/src/messenger/webim/libs/operator.php b/src/messenger/webim/libs/operator.php index 0b480378..7c71b660 100644 --- a/src/messenger/webim/libs/operator.php +++ b/src/messenger/webim/libs/operator.php @@ -61,18 +61,19 @@ function operator_by_id($id) { return $operator; } -function update_operator($operatorid,$login,$email,$password,$localename,$commonname) { +function update_operator($operatorid,$login,$email,$jabber,$password,$localename,$commonname,$notify) { $link = connect(); $query = sprintf( "update chatoperator set vclogin = '%s',%s vclocalename = '%s', vccommonname = '%s'". - ", vcemail = '%s', vcjabbername= '%s'". + ", vcemail = '%s', vcjabbername= '%s', inotify = %s". " where operatorid = %s", mysql_real_escape_string($login), ($password ? " vcpassword='".md5($password)."'," : ""), mysql_real_escape_string($localename), mysql_real_escape_string($commonname), mysql_real_escape_string($email), - '', + mysql_real_escape_string($jabber), + $notify, $operatorid ); perform_query($query,$link); @@ -89,15 +90,17 @@ function update_operator_avatar($operatorid,$avatar) { mysql_close($link); } -function create_operator_($login,$email,$password,$localename,$commonname,$avatar,$link) { +function create_operator_($login,$email,$jabber,$password,$localename,$commonname,$notify,$link) { $query = sprintf( - "insert into chatoperator (vclogin,vcpassword,vclocalename,vccommonname,vcavatar,vcemail,vcjabbername) values ('%s','%s','%s','%s','%s','%s','%s')", + "insert into chatoperator (vclogin,vcpassword,vclocalename,vccommonname,vcavatar,vcemail,vcjabbername,inotify) values ('%s','%s','%s','%s','%s','%s','%s',%s)", mysql_real_escape_string($login), md5($password), mysql_real_escape_string($localename), mysql_real_escape_string($commonname), - mysql_real_escape_string($avatar), - mysql_real_escape_string($email), ''); + '' /* no avatar */, + mysql_real_escape_string($email), + mysql_real_escape_string($jabber), + $notify); perform_query($query,$link); $id = mysql_insert_id($link); @@ -105,9 +108,9 @@ function create_operator_($login,$email,$password,$localename,$commonname,$avata return select_one_row("select * from chatoperator where operatorid = $id", $link ); } -function create_operator($login,$email,$password,$localename,$commonname,$avatar) { +function create_operator($login,$email,$jabber,$password,$localename,$commonname,$notify) { $link = connect(); - $newop = create_operator_($login,$email,$password,$localename,$commonname,$avatar,$link); + $newop = create_operator_($login,$email,$jabber,$password,$localename,$commonname,$notify,$link); mysql_close($link); return $newop; } diff --git a/src/messenger/webim/libs/operator_settings.php b/src/messenger/webim/libs/operator_settings.php index f62ddbf7..6308da86 100644 --- a/src/messenger/webim/libs/operator_settings.php +++ b/src/messenger/webim/libs/operator_settings.php @@ -24,19 +24,21 @@ function setup_operator_settings_tabs($opId, $active) { loadsettings(); if($opId) { + $page['tabselected'] = $active; if($settings['enablegroups'] == '1') { $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" : "" + array('title'=> getlocal("page_agent.tab.main"), 'link' => "$webimroot/operator/operator.php?op=$opId"), + array('title'=> getlocal("page_agent.tab.avatar"), 'link' => "$webimroot/operator/avatar.php?op=$opId"), + array('title'=> getlocal("page_agent.tab.groups"), 'link' => "$webimroot/operator/opgroups.php?op=$opId"), + array('title'=> getlocal("page_agent.tab.permissions"), 'link' => "$webimroot/operator/permissions.php?op=$opId"), ); } else { $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.permissions") => $active != 3 ? "$webimroot/operator/permissions.php?op=$opId" : "" + array('title'=> getlocal("page_agent.tab.main"), 'link' => "$webimroot/operator/operator.php?op=$opId"), + array('title'=> getlocal("page_agent.tab.avatar"), 'link' => "$webimroot/operator/avatar.php?op=$opId"), + array('title'=> getlocal("page_agent.tab.permissions"), 'link' => "$webimroot/operator/permissions.php?op=$opId"), ); + if($active == 3) $active--; } } else { $page['tabs'] = array(); diff --git a/src/messenger/webim/libs/settings.php b/src/messenger/webim/libs/settings.php index c8ba97f4..446b3353 100644 --- a/src/messenger/webim/libs/settings.php +++ b/src/messenger/webim/libs/settings.php @@ -35,11 +35,12 @@ function update_settings() { function setup_settings_tabs($active) { global $page, $webimroot; + $page['tabselected'] = $active; $page['tabs'] = array( - getlocal("page_settings.tab.main") => $active != 0 ? "$webimroot/operator/settings.php" : "", - getlocal("page_settings.tab.features") => $active != 1 ? "$webimroot/operator/features.php" : "", - getlocal("page_settings.tab.performance") => $active != 2 ? "$webimroot/operator/performance.php" : "", - getlocal("page_settings.tab.themes") => $active != 3 ? "$webimroot/operator/themes.php" : "", + array('title'=> getlocal("page_settings.tab.main"), 'link' => "$webimroot/operator/settings.php"), + array('title'=> getlocal("page_settings.tab.features"), 'link' => "$webimroot/operator/features.php"), + array('title'=> getlocal("page_settings.tab.performance"), 'link' => "$webimroot/operator/performance.php"), + array('title'=> getlocal("page_settings.tab.themes"), 'link' => "$webimroot/operator/themes.php"), ); } diff --git a/src/messenger/webim/locales/en/properties b/src/messenger/webim/locales/en/properties index 875d8292..4dedc906 100644 --- a/src/messenger/webim/locales/en/properties +++ b/src/messenger/webim/locales/en/properties @@ -146,6 +146,10 @@ form.field.groupdesc.description=Description of the group. form.field.groupdesc=Description form.field.groupname.description=Name to identify the group. form.field.groupname=Name +form.field.jabber.description=For instant notifications +form.field.jabbernotify.description=deliver via Jabber (instant) +form.field.jabbernotify=Notification of new visitor +form.field.jabber=Jabber ID form.field.login.description=Login can consist of small Latin letters and underscore. form.field.login=Login form.field.mail.description=For notifications and password retrieval. diff --git a/src/messenger/webim/operator/operator.php b/src/messenger/webim/operator/operator.php index 7fa71703..07fcfe85 100644 --- a/src/messenger/webim/operator/operator.php +++ b/src/messenger/webim/operator/operator.php @@ -33,10 +33,12 @@ if( isset($_POST['login']) && isset($_POST['password']) ) { $opId = verifyparam( "opid", "/^(\d{1,9})?$/", ""); $login = getparam('login'); $email = getparam('email'); + $jabber = getparam('jabber'); $password = getparam('password'); $passwordConfirm = getparam('passwordConfirm'); $localname = getparam('name'); $commonname = getparam('commonname'); + $jabbernotify = verifyparam("jabbernotify","/^on$/", "") == "on"; if( !$localname ) $errors[] = no_field("form.field.agent_name"); @@ -53,6 +55,12 @@ if( isset($_POST['login']) && isset($_POST['password']) ) { if($email != '' && !is_valid_email($email)) $errors[] = wrong_field("form.field.mail"); + if($jabber != '' && !is_valid_email($jabber)) + $errors[] = wrong_field("form.field.jabber"); + + if($jabbernotify && $jabber == '') + $errors[] = no_field("form.field.jabber"); + if( !$opId && !$password ) $errors[] = no_field("form.field.password"); @@ -72,11 +80,11 @@ if( isset($_POST['login']) && isset($_POST['password']) ) { if( count($errors) == 0 ) { if (!$opId) { - $newop = create_operator($login,$email,$password,$localname,$commonname,""); + $newop = create_operator($login,$email,$jabber,$password,$localname,$commonname,$jabbernotify ? 1 : 0); header("Location: $webimroot/operator/avatar.php?op=".$newop['operatorid']); exit; } else { - update_operator($opId,$login,$email,$password,$localname,$commonname); + update_operator($opId,$login,$email,$jabber,$password,$localname,$commonname,$jabbernotify ? 1 : 0); header("Location: $webimroot/operator/operator.php?op=$opId&stored"); exit; } @@ -84,6 +92,8 @@ if( isset($_POST['login']) && isset($_POST['password']) ) { $page['formlogin'] = topage($login); $page['formname'] = topage($localname); $page['formemail'] = topage($email); + $page['formjabber'] = topage($jabber); + $page['formjabbernotify'] = $jabbernotify; $page['formcommonname'] = topage($commonname); $page['opid'] = topage($opId); } @@ -99,6 +109,8 @@ if( isset($_POST['login']) && isset($_POST['password']) ) { $page['formlogin'] = topage($op['vclogin']); $page['formname'] = topage($op['vclocalename']); $page['formemail'] = topage($op['vcemail']); + $page['formjabber'] = topage($op['vcjabbername']); + $page['formjabbernotify'] = $op['inotify'] != 0; $page['formcommonname'] = topage($op['vccommonname']); $page['opid'] = topage($op['operatorid']); } diff --git a/src/messenger/webim/view/agent.php b/src/messenger/webim/view/agent.php index 3b4dee5e..edaa67a7 100644 --- a/src/messenger/webim/view/agent.php +++ b/src/messenger/webim/view/agent.php @@ -20,6 +20,7 @@ */ require_once("inc_menu.php"); +require_once("inc_tabbar.php"); $page['title'] = getlocal("page_agent.title"); $page['menuid'] = $page['opid'] == $page['currentopid'] ? "profile" : "operators"; @@ -45,15 +46,7 @@ require_once('inc_errors.php');
- -
    - - $v) { if($v) { ?> -
  • - -
  • -
- +
@@ -111,6 +104,24 @@ require_once('inc_errors.php');
+
+
+
+ /> +
+
+
+
+ +
+
+
+ /> +
+
+
+
+
diff --git a/src/messenger/webim/view/avatar.php b/src/messenger/webim/view/avatar.php index f1b2ab3f..cc27ef2b 100644 --- a/src/messenger/webim/view/avatar.php +++ b/src/messenger/webim/view/avatar.php @@ -20,6 +20,7 @@ */ require_once("inc_menu.php"); +require_once("inc_tabbar.php"); $page['title'] = getlocal("page_avatar.title"); $page['menuid'] = $page['opid'] == $page['currentopid'] ? "profile" : "operators"; @@ -36,15 +37,7 @@ require_once('inc_errors.php');
- -
    - - $v) { if($v) { ?> -
  • - -
  • -
- +

diff --git a/src/messenger/webim/view/features.php b/src/messenger/webim/view/features.php index 1dbf9578..6de4407a 100644 --- a/src/messenger/webim/view/features.php +++ b/src/messenger/webim/view/features.php @@ -20,6 +20,7 @@ */ require_once("inc_menu.php"); +require_once("inc_tabbar.php"); $page['title'] = getlocal("settings.title"); $page['menuid'] = "settings"; @@ -73,15 +74,7 @@ require_once('inc_errors.php');

- -
    - - $v) { if($v) { ?> -
  • - -
  • -
- +
diff --git a/src/messenger/webim/view/gen_button.php b/src/messenger/webim/view/gen_button.php index 4f13e237..b1e28050 100644 --- a/src/messenger/webim/view/gen_button.php +++ b/src/messenger/webim/view/gen_button.php @@ -37,22 +37,24 @@ require_once('inc_errors.php');
-
+ +
-
+
+
-
+
@@ -60,14 +62,15 @@ require_once('inc_errors.php');
-
+
+
-
+
onchange="this.form.submit();"/> @@ -76,13 +79,14 @@ require_once('inc_errors.php'); -
+
onchange="this.form.submit();"/>
+
diff --git a/src/messenger/webim/view/inc_tabbar.php b/src/messenger/webim/view/inc_tabbar.php new file mode 100644 index 00000000..92aee26d --- /dev/null +++ b/src/messenger/webim/view/inc_tabbar.php @@ -0,0 +1,56 @@ +".$tabbar[$i]['title']."\n" + : "
  • ".$tabbar[$i]['title']."
  • \n"; + } + + if($len > $maxwidth) { // && $len - $selected > $maxwidth + if($selected < $maxwidth) { + $tabbar = array_splice($tabbar2, 0, $maxwidth); + array_splice($tabbar2, count($tabbar2),0, $tabbar); + } // else 3 rows menu + } + + echo "
      \n"; + $i = 0; + foreach($tabbar2 as $v) { + if($i > 0 && (($len-$i)%$maxwidth) == 0) { + echo "

      \n"; + } + echo $v; + $i++; + } + echo "
    "; + } +} + +?> \ No newline at end of file diff --git a/src/messenger/webim/view/operator_groups.php b/src/messenger/webim/view/operator_groups.php index 79b4ef9e..c99372c7 100644 --- a/src/messenger/webim/view/operator_groups.php +++ b/src/messenger/webim/view/operator_groups.php @@ -20,6 +20,7 @@ */ require_once("inc_menu.php"); +require_once("inc_tabbar.php"); $page['title'] = getlocal("operator.groups.title"); $page['menuid'] = $page['opid'] == $page['currentopid'] ? "profile" : "operators"; @@ -39,15 +40,7 @@ require_once('inc_errors.php');
    - -
      - - $v) { if($v) { ?> -
    • - -
    • -
    - +

    diff --git a/src/messenger/webim/view/performance.php b/src/messenger/webim/view/performance.php index e127eb7b..5252b6eb 100644 --- a/src/messenger/webim/view/performance.php +++ b/src/messenger/webim/view/performance.php @@ -20,6 +20,7 @@ */ require_once("inc_menu.php"); +require_once("inc_tabbar.php"); $page['title'] = getlocal("settings.title"); $page['menuid'] = "settings"; @@ -39,15 +40,7 @@ require_once('inc_errors.php');

    - -
      - - $v) { if($v) { ?> -
    • - -
    • -
    - +
    diff --git a/src/messenger/webim/view/permissions.php b/src/messenger/webim/view/permissions.php index a0fa382c..7705c91f 100644 --- a/src/messenger/webim/view/permissions.php +++ b/src/messenger/webim/view/permissions.php @@ -20,6 +20,7 @@ */ require_once("inc_menu.php"); +require_once("inc_tabbar.php"); $page['title'] = getlocal("permissions.title"); $page['menuid'] = $page['opid'] == $page['currentopid'] ? "profile" : "operators"; @@ -39,15 +40,7 @@ require_once('inc_errors.php');
    - -
      - - $v) { if($v) { ?> -
    • - -
    • -
    - +

    diff --git a/src/messenger/webim/view/settings.php b/src/messenger/webim/view/settings.php index a9cd86ec..2b8eddb4 100644 --- a/src/messenger/webim/view/settings.php +++ b/src/messenger/webim/view/settings.php @@ -20,6 +20,7 @@ */ require_once("inc_menu.php"); +require_once("inc_tabbar.php"); $page['title'] = getlocal("settings.title"); $page['menuid'] = "settings"; @@ -39,15 +40,7 @@ require_once('inc_errors.php');

    - -
      - - $v) { if($v) { ?> -
    • - -
    • -
    - +
    diff --git a/src/messenger/webim/view/themes.php b/src/messenger/webim/view/themes.php index e0fff2e9..bf4bbda6 100644 --- a/src/messenger/webim/view/themes.php +++ b/src/messenger/webim/view/themes.php @@ -20,6 +20,7 @@ */ require_once("inc_menu.php"); +require_once("inc_tabbar.php"); $page['title'] = getlocal("page.preview.title"); $page['menuid'] = "settings"; @@ -32,15 +33,7 @@ function tpl_content() { global $page, $webimroot;
    - -
      - - $v) { if($v) { ?> -
    • - -
    • -
    - +