diff --git a/src/webim/libs/chat.php b/src/webim/libs/chat.php index 67a373d9..0cff2d02 100644 --- a/src/webim/libs/chat.php +++ b/src/webim/libs/chat.php @@ -98,7 +98,7 @@ function message_to_text($msg) { } function get_messages($threadid,$meth,$isuser,&$lastid) { - global $kind_for_agent; + global $kind_for_agent, $webim_encoding; $link = connect(); $query = sprintf( @@ -110,7 +110,13 @@ function get_messages($threadid,$meth,$isuser,&$lastid) { $result = mysql_query($query,$link) or die(' Query failed: ' .mysql_error().": ".$query); while ($msg = mysql_fetch_array($result, MYSQL_ASSOC)) { - $message = ($meth == 'text') ? message_to_text($msg) : message_to_html($msg); + $message = ""; + if ($meth == 'xml') { + $message = "".myiconv($webim_encoding,"utf-8",escape_with_cdata(message_to_html($msg)))."\n"; + } else { + $message = (($meth == 'text') ? message_to_text($msg) : message_to_html($msg)); + } + $messages[] = $message; if( $msg['messageid'] > $lastid ) { $lastid = $msg['messageid']; @@ -122,18 +128,21 @@ function get_messages($threadid,$meth,$isuser,&$lastid) { return $messages; } -function print_thread_mesages($threadid, $token, $lastid, $isuser,$format) { - global $webim_encoding, $webimroot; - $output = get_messages($threadid,"html",$isuser,$lastid); +function print_thread_messages($threadid, $token, $lastid, $isuser,$format) { + global $webim_encoding, $webimroot; if( $format == "xml" ) { + $output = get_messages($threadid,"xml",$isuser,$lastid); + start_xml_output(); print(""); foreach( $output as $msg ) { - print "".myiconv($webim_encoding,"utf-8",escape_with_cdata($msg))."\n"; + print $msg; } print(""); } else if( $format == "html" ) { + $output = get_messages($threadid,"html",$isuser,$lastid); + start_html_output(); $url = "$webimroot/thread.php?act=refresh&thread=$threadid&token=$token&html=on&user=".($isuser?"true":"false"); @@ -177,9 +186,11 @@ function setup_chatview_for_user($thread,$level) { $page['ct.company.name'] = $company_name; $page['ct.company.chatLogoURL'] = $company_logo_link; + $page['send_shortcut'] = "Ctrl-Enter"; $params = "thread=".$thread['threadid']."&token=".$thread['ltoken']; $page['selfLink'] = "$webimroot/client.php?".$params."&level=".$level; + } function setup_chatview_for_operator($thread,$operator) { @@ -194,6 +205,7 @@ function setup_chatview_for_operator($thread,$operator) { $page['ct.company.name'] = $company_name; $page['ct.company.chatLogoURL'] = $company_logo_link; + $page['send_shortcut'] = "Ctrl-Enter"; // TODO $page['namePostfix'] = ""; @@ -316,6 +328,7 @@ function rename_user($thread, $newname) { } } + function close_thread($thread,$isuser) { global $state_closed, $kind_events; @@ -420,6 +433,7 @@ function check_for_reassign($thread,$operator) { ( $thread['agentId'] == $operator['operatorid'] )) { do_take_thread($thread['threadid'], $operator['operatorid'], $operatorName); $message_to_post = getstring2_("chat.status.operator.changed", array($operatorName,$thread['agentName']), $thread['locale']); + post_message($thread['threadid'],$kind_events,$message_to_post); } } diff --git a/src/webim/libs/common.php b/src/webim/libs/common.php index dada55bd..ac1d9a53 100644 --- a/src/webim/libs/common.php +++ b/src/webim/libs/common.php @@ -249,12 +249,13 @@ function no_field($key) { return getstring2("errors.required",array(getstring($key))); } + function wrong_field($key) { return getstring2("errors.wrong_field",array(getstring($key))); } function get_popup($href,$message,$title,$wndName,$options) { - return "$message"; + return "$message"; } function get_image($href,$width,$height) { @@ -356,4 +357,6 @@ function set_form_date($time,$prefix) { $page["form${prefix}month"] = date("m.y", $time); } + + ?> \ No newline at end of file diff --git a/src/webim/libs/config.php b/src/webim/libs/config.php index d4ee5b59..1de4d70c 100644 --- a/src/webim/libs/config.php +++ b/src/webim/libs/config.php @@ -96,5 +96,4 @@ $remote_visitor = 'visitor_from_request'; $online_timeout = 30; - ?> diff --git a/src/webim/libs/operator.php b/src/webim/libs/operator.php index 59c75062..e56a6a64 100644 --- a/src/webim/libs/operator.php +++ b/src/webim/libs/operator.php @@ -51,7 +51,8 @@ function get_operators() { function update_operator($operatorid,$login,$password,$localename,$commonname) { $link = connect(); $query = sprintf( - "update chatoperator set vclogin = '%s',%s vclocalename = '%s',vccommonname = '%s' where operatorid = %s", + "update chatoperator set vclogin = '%s',%s vclocalename = '%s', vccommonname = '%s'". + " where operatorid = %s", mysql_real_escape_string($login), ($password ? " vcpassword='".md5($password)."'," : ""), mysql_real_escape_string($localename), @@ -64,11 +65,11 @@ function update_operator($operatorid,$login,$password,$localename,$commonname) { function create_operator_($login,$password,$localename,$commonname,$link) { $query = sprintf( - "insert into chatoperator (vclogin,vcpassword,vclocalename,vccommonname) values ('%s','%s','%s','%s')", + "insert into chatoperator (vclogin,vcpassword,vclocalename,vccommonname".") values ('%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($commonname)); perform_query($query,$link); $id = mysql_insert_id($link); diff --git a/src/webim/locales/en/properties b/src/webim/locales/en/properties index fd448ddc..50d62b2f 100644 --- a/src/webim/locales/en/properties +++ b/src/webim/locales/en/properties @@ -18,7 +18,7 @@ chat.window.chatting_with=You chat with: chat.window.poweredby=Powered by: chat.window.poweredreftext=webim.ru chat.window.send_message=Send message -chat.window.send_message_short=Send (Ctrl-Enter) +chat.window.send_message_short=Send ({0}) chat.window.toolbar.mail_history=Send chat history by e-mail chat.window.toolbar.refresh=Refresh chat.client.name=Your name: @@ -52,7 +52,7 @@ chat.thread.state_wait_for_another_agent=Waiting for operator chat.thread.state_chatting_with_agent=In chat chat.thread.state_closed=Closed clients.title=List of awaiting visitors -clients.no_clients=The of awaiting visitors is empty +clients.no_clients=The list of awaiting visitors is empty clients.intro=The page displays list of awaiting visitors. clients.how_to=To answer the visitor click on his/her name in the list. clients.queue.prio=Priority visitors queue diff --git a/src/webim/locales/ru/properties b/src/webim/locales/ru/properties index 9c677a86..78f9ad59 100644 --- a/src/webim/locales/ru/properties +++ b/src/webim/locales/ru/properties @@ -18,7 +18,7 @@ chat.window.chatting_with= chat.window.poweredby=Предоставлено: chat.window.poweredreftext=webim.ru chat.window.send_message=Отправить сообщение -chat.window.send_message_short=Отправить (Ctrl-Enter) +chat.window.send_message_short=Отправить ({0}) chat.window.toolbar.mail_history=Отправить историю диалога по электронной почте chat.window.toolbar.refresh=Обновить содержимое диалога chat.client.name=Ваше имя: diff --git a/src/webim/operator/users.php b/src/webim/operator/users.php index 55aed786..34af522a 100644 --- a/src/webim/operator/users.php +++ b/src/webim/operator/users.php @@ -15,6 +15,8 @@ require('../libs/common.php'); require('../libs/operator.php'); + + $operator = check_login(); notify_operator_alive($operator['operatorid']); diff --git a/src/webim/thread.php b/src/webim/thread.php index ca20e37a..082c062b 100644 --- a/src/webim/thread.php +++ b/src/webim/thread.php @@ -16,12 +16,16 @@ require('libs/common.php'); require('libs/chat.php'); require('libs/operator.php'); -$act = verifyparam( "act", "/^(refresh|post|rename|close|ping)$/"); + + +$act = verifyparam( "act", "/^(refresh|post|rename|close|ping".")$/"); $token = verifyparam( "token", "/^\d{1,9}$/"); $threadid = verifyparam( "thread", "/^\d{1,9}$/"); $isuser = verifyparam( "user", "/^true$/", "false") == 'true'; $outformat = (verifyparam( "html", "/^on$/", "off") == 'on') ? "html" : "xml"; + + $thread = thread_by_id($threadid); if( !$thread || !isset($thread['ltoken']) || $token != $thread['ltoken'] ) { die("wrong thread"); @@ -39,7 +43,7 @@ if( !$isuser && $act != "rename" ) { if( $act == "refresh" ) { $lastid = verifyparam( "lastid", "/^\d{1,9}$/", -1); - print_thread_mesages($threadid, $token, $lastid, $isuser,$outformat); + print_thread_messages($threadid, $token, $lastid, $isuser,$outformat); exit; } else if( $act == "post" ) { @@ -48,9 +52,9 @@ if( $act == "refresh" ) { $kind = $isuser ? $kind_user : $kind_agent; $from = $isuser ? $thread['userName'] : $thread['agentName']; - + post_message($threadid,$kind,$message,$from, $isuser ? null : $operator['operatorid'] ); - print_thread_mesages($threadid, $token, $lastid, $isuser, $outformat); + print_thread_messages($threadid, $token, $lastid, $isuser, $outformat); exit; } else if( $act == "rename" ) { diff --git a/src/webim/view/agent.php b/src/webim/view/agent.php index c0e4d056..b8b5be52 100644 --- a/src/webim/view/agent.php +++ b/src/webim/view/agent.php @@ -93,11 +93,10 @@ - + + - - diff --git a/src/webim/view/chat_ajaxed.php b/src/webim/view/chat_ajaxed.php index 5d53e4b7..dd0b82c2 100644 --- a/src/webim/view/chat_ajaxed.php +++ b/src/webim/view/chat_ajaxed.php @@ -42,17 +42,19 @@ var threadParams = { servl:"/thread.php",wroot:" - + - + + +
');return false;" href="_blank">
@@ -192,7 +194,7 @@ var threadParams = { servl:"/thread.php",wroot:" - - - +
+ @@ -201,17 +203,20 @@ var threadParams = { servl:"/thread.php",wroot:"
" title="" target="_blank"> + " title="" target="_blank"> + diff --git a/src/webim/view/chat_leavemsg.php b/src/webim/view/chat_leavemsg.php index 4230958f..c0b71228 100644 --- a/src/webim/view/chat_leavemsg.php +++ b/src/webim/view/chat_leavemsg.php @@ -100,7 +100,7 @@
+ + ">
- ">
+ ">
">
- - + +
+ @@ -112,7 +112,10 @@
">
+ + " title="" target="_blank"> diff --git a/src/webim/view/chat_simple.php b/src/webim/view/chat_simple.php index 549aa500..5050598e 100644 --- a/src/webim/view/chat_simple.php +++ b/src/webim/view/chat_simple.php @@ -189,12 +189,12 @@
">
- + - +
">">
- ">
+ ">
">">