[redirect, predefined answers] store nextagent id in Db, show next agent in agent field, predefined answers started, messages

git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@132 c66351dc-e62f-0410-b875-e3a5c0b9693f
This commit is contained in:
Evgeny Gryaznov 2008-10-02 09:43:58 +00:00
parent 9befc1c180
commit 78e48df62d
4 changed files with 52 additions and 10 deletions

View File

@ -270,7 +270,7 @@ function setup_chatview_for_operator($thread,$operator) {
$page = array();
$page['agent'] = true;
$page['user'] = false;
$page['canpost'] = true;
$page['canpost'] = $thread['agentId'] == $operator['operatorid'];
$page['ct.chatThreadId'] = $thread['threadid'];
$page['ct.token'] = $thread['ltoken'];
$page['ct.user.name'] = topage(get_user_name($thread['userName'],$thread['remote']));
@ -282,6 +282,10 @@ function setup_chatview_for_operator($thread,$operator) {
$page['isOpera95'] = is_agent_opera95();
$page['neediframesrc'] = needsFramesrc();
$page['predefinedList'] = explode("\n", getlocal_('chat.predefined_answers', $thread['locale']));
$params = "thread=".$thread['threadid']."&token=".$thread['ltoken'];
$page['selfLink'] = "$webimroot/operator/agent.php?".$params;
$page['namePostfix'] = "";
}
@ -323,6 +327,7 @@ function ping_thread($thread, $isuser,$istyping) {
$message_to_post = getstring_("chat.status.operator.dead", $thread['locale']);
post_message_($thread['threadid'],$kind_conn,$message_to_post,$link,null,$lastping+$connection_timeout);
$params['istate'] = $state_waiting;
$params['nextagent'] = 0;
commit_thread($thread['threadid'], $params, $link);
mysql_close($link);
return;
@ -373,7 +378,7 @@ function close_thread($thread,$isuser) {
function thread_by_id_($id,$link) {
return select_one_row("select threadid,userName,agentName,agentId,lrevision,istate,ltoken,userTyping,agentTyping".
",remote,referer,locale,unix_timestamp(lastpinguser) as lpuser,unix_timestamp(lastpingagent) as lpagent, unix_timestamp(CURRENT_TIMESTAMP) as current".
",remote,referer,locale,unix_timestamp(lastpinguser) as lpuser,unix_timestamp(lastpingagent) as lpagent, unix_timestamp(CURRENT_TIMESTAMP) as current,nextagent".
" from chatthread where threadid = ". $id, $link );
}
@ -411,6 +416,7 @@ function do_take_thread($threadid,$operatorId,$operatorName) {
$link = connect();
commit_thread( $threadid,
array("istate" => $state_chatting,
"nextagent" => 0,
"agentId" => $operatorId,
"agentName" => "'".mysql_real_escape_string($operatorName)."'"), $link);
mysql_close($link);
@ -429,7 +435,7 @@ function reopen_thread($threadid) {
if( $thread['istate'] != $state_chatting && $thread['istate'] != $state_queue && $thread['istate'] != $state_loading ) {
$link = connect();
commit_thread( $threadid,
array("istate" => $state_waiting ), $link);
array("istate" => $state_waiting, "nextagent" => 0), $link);
mysql_close($link);
}
@ -449,7 +455,7 @@ function take_thread($thread,$operator) {
if( $state == $state_queue || $state == $state_waiting || $state == $state_loading) {
do_take_thread($threadid, $operator['operatorid'], $operatorName);
if( $state == $state_waiting ) {
if( $state == $state_waiting && $thread['nextagent'] != 0 ) {
if( $operatorName != $thread['agentName'] ) {
$message_to_post = getstring2_("chat.status.operator.changed", array($operatorName, $thread['agentName']), $thread['locale']);
} else {
@ -476,7 +482,8 @@ function check_for_reassign($thread,$operator) {
global $state_waiting, $home_locale, $kind_events;
$operatorName = ($thread['locale'] == $home_locale) ? $operator['vclocalename'] : $operator['vccommonname'];
if( $thread['istate'] == $state_waiting &&
( $thread['agentId'] == $operator['operatorid'] )) {
( $thread['nextagent'] == $operator['operatorid']
|| $thread['agentId'] == $operator['operatorid'] )) {
do_take_thread($thread['threadid'], $operator['operatorid'], $operatorName);
if( $operatorName != $thread['agentName'] ) {
$message_to_post = getstring2_("chat.status.operator.changed", array($operatorName, $thread['agentName']), $thread['locale']);

View File

@ -22,7 +22,9 @@ chat.window.poweredby=Powered by:
chat.window.poweredreftext=webim.ru
chat.window.send_message=Send message
chat.window.send_message_short=Send ({0})
chat.window.predefined.select_answer=Choose answer...
chat.window.toolbar.mail_history=Send chat history by e-mail
chat.window.toolbar.redirect_user=Redirect visitor to another operator
chat.window.toolbar.refresh=Refresh
chat.client.name=You are
chat.client.changename=Change name
@ -30,6 +32,7 @@ chat.status.operator.left=Operator {0} left the chat
chat.status.user.left=Visitor {0} left the chat
chat.status.user.dead=Visitor closed chat window
chat.status.operator.dead=Operator has connection issues, we temporarily moved you to foreground queue. Sorry for keeping you waiting.
chat.status.operator.redirect=Operator {0} redirected you to another operator, please, wait a little
chat.status.operator.joined=Operator {0} joined the chat
chat.status.user.changedname=Visitor changed the name {0} to {1}
chat.status.user.reopenedthread=Visitor joined chat again
@ -43,6 +46,7 @@ page.chat.old_browser.title=Please, use newer browser
page.chat.old_browser.close=Close...
page.chat.old_browser.content=Your web browser is not fully supported by Web Messenger. \nPlease, use one of the following web browsers: \n<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>
chat.wait=Thank you for contacting us. An operator will be with you shortly...
chat.predefined_answers=Hello, how may I help you?\nHello! Welcome to our support. How may I help you?
mailthread.title=Send chat history<br>by mail
mailthread.enter_email=Enter your e-mail:
mailthread.perform=Send
@ -56,6 +60,13 @@ chat.thread.state_wait_for_another_agent=Waiting for operator
chat.thread.state_chatting_with_agent=In chat
chat.thread.state_closed=Closed
chat.thread.state_loading=Loading
chat.redirect.title=Redirect to<br>another operator
chat.redirect.choose_operator=Choose an operator:
chat.redirect.back=Back...
chat.redirected.title=The visitor redirected to another operator
chat.redirected.content=The visitor placed in priorty queue of the operator {0}.
chat.redirected.closewindow=Click to close the window
chat.redirected.close=Close...
clients.title=List of awaiting visitors
clients.no_clients=The list of awaiting visitors is empty
clients.intro=The page displays list of awaiting visitors.
@ -135,6 +146,10 @@ image.button.search=/locales/en/images/search.gif
admin.content.client_settings=Specify options affecting chat window and common system behavior
app.title=Web Instant Messenger
chat.came.from=Vistor came from page {0}
confirm.take.head=Change operator
confirm.take.message=Visitor <span style="color:blue;">{0}</span> is already served by <span style="color:green;">{1}</span>.<br/> Are your really sure you wan't to start chatting the visitor?
confirm.take.no=No, close the window
confirm.take.yes=Yes, I'm sure
content.history=Search the dialogs history
content.logoff=Log out of the system.
errors.wrong_field=Please fill "{0}" correctly.

View File

@ -22,7 +22,9 @@ chat.window.poweredby=
chat.window.poweredreftext=webim.ru
chat.window.send_message=Отправить сообщение
chat.window.send_message_short=Отправить ({0})
chat.window.predefined.select_answer=Выберите ответ...
chat.window.toolbar.mail_history=Отправить историю диалога по электронной почте
chat.window.toolbar.redirect_user=Перенаправить посетителя другому оператору
chat.window.toolbar.refresh=Обновить содержимое диалога
chat.client.name=Вы
chat.client.changename=Изменить имя
@ -30,6 +32,7 @@ chat.status.operator.left=
chat.status.user.left=Посетитель {0} покинул диалог
chat.status.user.dead=Посетитель закрыл окно диалога
chat.status.operator.dead=У оператора возникли проблемы со связью, мы временно перевели Вас в приоритетную очередь. Приносим извинения за Ваше ожидание.
chat.status.operator.redirect=Оператор {0} переключил Вас на другого оператора, пожалуйста, подождите немного
chat.status.operator.joined=Оператор {0} включился в разговор
chat.status.user.changedname=Посетитель сменил имя {0} на {1}
chat.status.user.reopenedthread=Посетитель заново вошел в диалог
@ -43,6 +46,7 @@ page.chat.old_browser.title=
page.chat.old_browser.close=Закрыть...
page.chat.old_browser.content=К сожалению, для работы этой страницы необходим более новый браузер. Для лучшего просмотра используйте:\n<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>\nТакже поддерживаются некоторые старые браузеры:\n<p><ul>\n<li>Internet Explorer 5.0\n<li>Opera 7.0\n</ul></p>
chat.wait=Пожалуйста, подождите немного, к Вам присоединится оператор..
chat.predefined_answers=Здравствуйте! Чем я могу Вам помочь?\nПодождите секунду, я переключу Вас на другого оператора.\nВы не могли бы уточнить, что Вы имеете ввиду..\nУдачи, до свиданья!
mailthread.title=Отправить историю разговора<br>на почтовый ящик
mailthread.enter_email=Введите Ваш E-mail:
mailthread.perform=Отправить
@ -56,6 +60,13 @@ chat.thread.state_wait_for_another_agent=
chat.thread.state_chatting_with_agent=В диалоге
chat.thread.state_closed=Закрыто
chat.thread.state_loading=Загружается
chat.redirect.title=Перенаправить<br>другому оператору
chat.redirect.choose_operator=Выберите оператора:
chat.redirect.back=Назад...
chat.redirected.title=Посетитель переведен другому оператору
chat.redirected.content=Посетитель помещен в привелегированную очередь оператора {0}.
chat.redirected.closewindow=Нажмите на эту ссылку чтобы закрыть окно
chat.redirected.close=Закрыть...
clients.title=Список ожидающих посетителей
clients.no_clients=В этой очереди ожидающих посетителей нет
clients.intro=На этой странице можно просмотреть список ожидающих ответа посетителей.
@ -135,6 +146,10 @@ image.button.search=/locales/ru/images/search.gif
admin.content.client_settings=Вы можете задать опции влияющие на отображение чат окна и общее поведение системы
app.title=Веб Мессенджер
chat.came.from=Посетитель пришел со страницы {0}
confirm.take.head=Сменить оператора
confirm.take.message=С посетителем <span style="color:blue;">{0}</span> уже общается <span style="color:green;">{1}</span>.<br/>Вы уверены что хотите сменить его?
confirm.take.no=Нет, закрыть окно
confirm.take.yes=Да, я уверен
content.history=Поиск по истории диалогов
content.logoff=Покинуть систему.
errors.wrong_field=Неправильно заполнено поле "{0}"

View File

@ -39,17 +39,22 @@ $threadstate_key = array(
$state_loading => "chat.thread.state_loading"
);
function thread_to_xml($thread) {
global $threadstate_to_string, $threadstate_key, $webim_encoding;
function thread_to_xml($thread,$link) {
global $threadstate_to_string, $threadstate_key, $webim_encoding, $operator;
$state = $threadstate_to_string[$thread['istate']];
$result = "<thread id=\"".$thread['threadid']."\" stateid=\"$state\"";
if( $state == "closed" )
return $result."/>";
$state = getstring($threadstate_key[$thread['istate']]);
$threadoperator = ($thread['agentName'] ? $thread['agentName'] : "-");
$nextagent = $thread['nextagent'] != 0 ? operator_by_id_($thread['nextagent'],$link) : null;
$threadoperator = $nextagent ? get_operator_name($nextagent)
: ($thread['agentName'] ? $thread['agentName'] : "-");
$result .= " canopen=\"true\"";
if( $thread['agentId'] != $operator['operatorid'] && $thread['nextagent'] != $operator['operatorid']) {
$result .= " canview=\"true\"";
}
$result .= " state=\"$state\" typing=\"".$thread['userTyping']."\">";
$result .= "<name>".htmlspecialchars(htmlspecialchars(get_user_name($thread['userName'],$thread['remote'])))."</name>";
@ -69,11 +74,11 @@ function print_pending_threads($since) {
$revision = $since;
$output = array();
$query = "select threadid, userName, agentName, unix_timestamp(dtmcreated), userTyping, ".
"unix_timestamp(dtmmodified), lrevision, istate, remote ".
"unix_timestamp(dtmmodified), lrevision, istate, remote, nextagent, agentId ".
"from chatthread where lrevision > $since ORDER BY threadid";
$rows = select_multi_assoc($query, $link);
foreach ($rows as $row) {
$thread = thread_to_xml($row);
$thread = thread_to_xml($row,$link);
$output[] = $thread;
if( $row['lrevision'] > $revision )
$revision = $row['lrevision'];