From 9a054da64bb2863a89faf9c29c37957a36cbaa03 Mon Sep 17 00:00:00 2001 From: Evgeny Gryaznov Date: Sat, 16 Jan 2010 00:42:28 +0000 Subject: [PATCH] send new visitor notification git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@725 c66351dc-e62f-0410-b875-e3a5c0b9693f --- src/messenger/webim/client.php | 2 ++ src/messenger/webim/libs/chat.php | 27 +++++++++++++++++++++++ src/messenger/webim/libs/notify.php | 5 +++++ src/messenger/webim/locales/en/properties | 2 ++ 4 files changed, 36 insertions(+) diff --git a/src/messenger/webim/client.php b/src/messenger/webim/client.php index 67eb1c2f..63234b25 100644 --- a/src/messenger/webim/client.php +++ b/src/messenger/webim/client.php @@ -25,6 +25,7 @@ require_once('libs/operator.php'); require_once('libs/groups.php'); require_once('libs/expand.php'); require_once('libs/captcha.php'); +require_once('libs/notify.php'); loadsettings(); if($settings['enablessl'] == "1" && $settings['forcessl'] == "1") { @@ -129,6 +130,7 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) { $postedid = post_message_($thread['threadid'],$kind_user,$firstmessage,$link,$visitor['name']); commit_thread( $thread['threadid'], array('shownmessageid' => $postedid), $link); } + notify_operators($thread, $firstmessage, $link); mysql_close($link); } $threadid = $thread['threadid']; diff --git a/src/messenger/webim/libs/chat.php b/src/messenger/webim/libs/chat.php index 969dc981..56e6536b 100644 --- a/src/messenger/webim/libs/chat.php +++ b/src/messenger/webim/libs/chat.php @@ -643,6 +643,33 @@ function check_for_reassign($thread,$operator) { } } +function notify_operators($thread,$firstmessage,$link) { + global $settings; + if($settings['enablejabber'] == 1) { + $groupid = $thread['groupid']; + $query = "select chatoperator.operatorid as opid, inotify, vcjabbername, vcemail, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time from chatoperator"; + if($groupid) { + $query .= ", chatgroupoperator where groupid = $groupid and chatoperator.operatorid = chatgroupoperator.operatorid and istatus = 0"; + } else { + $query .= " where istatus = 0"; + } + $query .= " and inotify = 1"; + $result = select_multi_assoc($query, $link); + $text = getstring2_("notify.new.text", array( + get_app_location(true, $settings['enablessl'] == '1' && $settings['forcessl'] == '1')."/operator/agent.php?thread=".$thread['threadid'], + $thread['userName'] + ), $thread['locale']); + if($firstmessage) { + $text .= "\n$firstmessage"; + } + foreach($result as $op) { + if($op['time'] < $settings['online_timeout'] && is_valid_email($op['vcjabbername'])) { + webim_xmpp($op['vcjabbername'], getstring2("notify.new.subject", array($thread['userName'])), $text, $link); + } + } + } +} + function check_connections_from_remote($remote,$link) { global $settings, $state_closed, $state_left; if($settings['max_connections_from_one_host'] == 0) { diff --git a/src/messenger/webim/libs/notify.php b/src/messenger/webim/libs/notify.php index 5367af80..00539820 100644 --- a/src/messenger/webim/libs/notify.php +++ b/src/messenger/webim/libs/notify.php @@ -49,4 +49,9 @@ function webim_mail($toaddr, $reply_to, $subject, $body, $link) { @mail($toaddr, $real_subject, wordwrap(myiconv($webim_encoding, $mail_encoding, $body),70), $headers); } +function webim_xmpp($toaddr, $subject, $text, $link) { + global $current_locale; + log_notification($current_locale, "xmpp", $toaddr, $subject, $text, null, $link); +} + ?> \ No newline at end of file diff --git a/src/messenger/webim/locales/en/properties b/src/messenger/webim/locales/en/properties index 9e9a3b18..93ca2042 100644 --- a/src/messenger/webim/locales/en/properties +++ b/src/messenger/webim/locales/en/properties @@ -248,6 +248,8 @@ notifications.kind.xmpp=XMPP/Jabber notifications.kind=Kind of notification notifications.locale.all=-all- notifications.locale=Language +notify.new.subject="{0}" +notify.new.text={1}: {0} operator.group.no_description=<no description> operator.groups.intro=Choose groups according to operator skills. operator.groups.title=Operator groups