diff --git a/src/messenger/webim/default.css b/src/messenger/webim/default.css index ef4f651f..38feb8e7 100644 --- a/src/messenger/webim/default.css +++ b/src/messenger/webim/default.css @@ -299,6 +299,10 @@ img.left { margin-bottom:8px; } +.packedFormField select { + min-width: 130px; +} + div.errinfo { color: #c13030; } @@ -475,6 +479,16 @@ table.list td a.man { padding-left: 15px; } +table.list td a.mail { + background: url(images/mail.png) no-repeat left center; + padding-left: 24px; +} + +table.list td a.xmpp { + background: url(images/xmpp.png) no-repeat left center; + padding-left: 24px; +} + table.list tbody tr:hover td, table.list tbody tr:hover td a, table.statistics tbody tr:hover td { color: #1D485E; } diff --git a/src/messenger/webim/images/mail.png b/src/messenger/webim/images/mail.png new file mode 100755 index 00000000..e3117de7 Binary files /dev/null and b/src/messenger/webim/images/mail.png differ diff --git a/src/messenger/webim/images/xmpp.png b/src/messenger/webim/images/xmpp.png new file mode 100755 index 00000000..6c9d44d5 Binary files /dev/null and b/src/messenger/webim/images/xmpp.png differ diff --git a/src/messenger/webim/install/dbinfo.php b/src/messenger/webim/install/dbinfo.php index 24463b17..79b4a10e 100644 --- a/src/messenger/webim/install/dbinfo.php +++ b/src/messenger/webim/install/dbinfo.php @@ -110,7 +110,18 @@ $dbtables = array( "locale" => "varchar(8)", "groupid" => "int references chatgroup(groupid)", "vcvalue" => "varchar(1024) NOT NULL", - ) + ), + + "chatnotification" => array( + "id" => "INT NOT NULL auto_increment PRIMARY KEY", + "locale" => "varchar(8)", + "vckind" => "varchar(16)", + "vcto" => "varchar(256)", + "dtmcreated" => "datetime DEFAULT 0", + "vcsubject" => "varchar(256)", + "tmessage" => "text NOT NULL", + "refoperator" => "int NOT NULL references chatoperator(operatorid)", + ), ); $memtables = array(); @@ -123,6 +134,7 @@ $dbtables_can_update = array( "chatgroup" => array("vcemail"), "chatgroupoperator" => array(), "chatresponses" => array(), + "chatnotification" => array(), ); function show_install_err($text) { diff --git a/src/messenger/webim/leavemessage.php b/src/messenger/webim/leavemessage.php index 7116258e..1e335ade 100644 --- a/src/messenger/webim/leavemessage.php +++ b/src/messenger/webim/leavemessage.php @@ -24,6 +24,7 @@ require_once('libs/chat.php'); require_once('libs/expand.php'); require_once('libs/groups.php'); require_once('libs/captcha.php'); +require_once('libs/notify.php'); $errors = array(); $page = array(); @@ -110,7 +111,9 @@ $body = getstring2_("leavemail.body", array($visitor_name,$email,$message,$info $inbox_mail = $settings['email']; if($inbox_mail) { - webim_mail($inbox_mail, $email, $subject, $body); + $link = connect(); + webim_mail($inbox_mail, $email, $subject, $body, $link); + mysql_close($link); } setup_logo(); diff --git a/src/messenger/webim/libs/common.php b/src/messenger/webim/libs/common.php index 1d70ec04..acb7f288 100644 --- a/src/messenger/webim/libs/common.php +++ b/src/messenger/webim/libs/common.php @@ -338,14 +338,6 @@ function perform_query($query,$link) { or die(' Query failed: '.mysql_error()/*.": ".$query*/); } -function rows_count($link,$table,$whereclause="") { - $result = mysql_query("SELECT count(*) FROM $table $whereclause",$link) - or die(' Count query failed: '.mysql_error()); - $line = mysql_fetch_array($result, MYSQL_NUM); - mysql_free_result($result); - return $line[0]; -} - function select_one_row($query,$link) { $result = mysql_query($query,$link) or die(' Query failed: ' . mysql_error().": ".$query); @@ -366,6 +358,20 @@ function select_multi_assoc($query, $link) { return $result; } +function db_build_select($fields, $table, $conditions, $orderandgroup) { + $condition = count($conditions) > 0 ? " where ".implode(" and ", $conditions) : ""; + if($orderandgroup) $orderandgroup = " ".$orderandgroup; + return "select $fields from $table$condition$orderandgroup"; +} + +function db_rows_count($table,$conditions,$countfields, $link) { + $result = mysql_query(db_build_select("count(".($countfields ? $countfields : "*").")", $table, $conditions, ""),$link) + or die(' Count query failed: '.mysql_error()); + $line = mysql_fetch_array($result, MYSQL_NUM); + mysql_free_result($result); + return $line[0]; +} + function start_xml_output() { header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); @@ -543,21 +549,6 @@ function date_to_text($unixtime) { return strftime($date_format." ".getlocal("time.timeformat"), $unixtime); } -function webim_mail($toaddr, $reply_to, $subject, $body) { - global $webim_encoding, $webim_mailbox, $mail_encoding; - - $headers = "From: $webim_mailbox\r\n" - ."Reply-To: ".myiconv($webim_encoding, $mail_encoding, $reply_to)."\r\n" - ."Content-Type: text/plain; charset=$mail_encoding\r\n" - .'X-Mailer: PHP/'.phpversion(); - - $real_subject = "=?".$mail_encoding."?B?".base64_encode(myiconv($webim_encoding,$mail_encoding,$subject))."?="; - - $body = preg_replace("/\n/","\r\n", $body); - - @mail($toaddr, $real_subject, wordwrap(myiconv($webim_encoding, $mail_encoding, $body),70), $headers); -} - $dbversion = '1.6.3'; $featuresversion = '1.6.4'; diff --git a/src/messenger/webim/libs/notify.php b/src/messenger/webim/libs/notify.php new file mode 100644 index 00000000..5367af80 --- /dev/null +++ b/src/messenger/webim/libs/notify.php @@ -0,0 +1,52 @@ + \ No newline at end of file diff --git a/src/messenger/webim/libs/operator.php b/src/messenger/webim/libs/operator.php index 7c71b660..ff0957f9 100644 --- a/src/messenger/webim/libs/operator.php +++ b/src/messenger/webim/libs/operator.php @@ -223,20 +223,30 @@ function setup_redirect_links($threadid,$token) { loadsettings(); $link = connect(); - $operatorscount = rows_count($link, "chatoperator"); - $groupscount = $settings['enablegroups'] == "1" ? rows_count($link, "chatgroup") : 0; - - prepare_pagination(max($operatorscount,$groupscount),8); - $limit = $page['pagination']['limit']; - - $query = "select operatorid, vclogin, vclocalename, vccommonname, istatus, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time ". - "from chatoperator order by vclogin $limit"; - $operators = select_multi_assoc($query, $link); + $operatorscount = db_rows_count("chatoperator", array(), "", $link); + $groupscount = 0; if($settings['enablegroups'] == "1") { - $groups = get_groups($link, true); + $groups = array(); + foreach(get_groups($link, true) as $group) { + if($group['inumofagents'] == 0) { + continue; + } + $groups[] = $group; + } + $groupscount = count($groups); } + prepare_pagination(max($operatorscount,$groupscount),8); + $p = $page['pagination']; + $limit = $p['limit']; + + $operators = select_multi_assoc(db_build_select( + "operatorid, vclogin, vclocalename, vccommonname, istatus, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time", + "chatoperator", array(), "order by vclogin $limit"), $link); + + $groups = array_slice($groups, $p['start'], $p['end']-$p['start']); + mysql_close($link); $agent_list = ""; @@ -260,9 +270,6 @@ function setup_redirect_links($threadid,$token) { if($settings['enablegroups'] == "1") { $params = array('thread' => $threadid, 'token' => $token); foreach($groups as $group) { - if($group['inumofagents'] == 0) { - continue; - } $params['nextGroup'] = $group['groupid']; $status = $group['ilastseen'] !== NULL && $group['ilastseen'] < $settings['online_timeout'] ? getlocal("char.redirect.operator.online_suff") diff --git a/src/messenger/webim/libs/pagination.php b/src/messenger/webim/libs/pagination.php index 8e907a16..cc73554a 100644 --- a/src/messenger/webim/libs/pagination.php +++ b/src/messenger/webim/libs/pagination.php @@ -72,6 +72,19 @@ function setup_pagination($items,$default_items_per_page=15) { } } +function select_with_pagintation($fields, $table, $conditions, $order, $countfields, $link) { + global $page; + $count = db_rows_count($table, $conditions, $countfields, $link); + prepare_pagination($count); + if($count) { + $p = $page['pagination']; + $limit = $p['limit']; + $page['pagination.items'] = select_multi_assoc(db_build_select($fields, $table, $conditions, $order)." ".$limit, $link); + } else { + $page['pagination.items'] = false; + } +} + function setup_empty_pagination() { global $page; $page['pagination.items'] = false; diff --git a/src/messenger/webim/locales/en/properties b/src/messenger/webim/locales/en/properties index 9edb6a53..1bcbf983 100644 --- a/src/messenger/webim/locales/en/properties +++ b/src/messenger/webim/locales/en/properties @@ -221,6 +221,7 @@ menu.groups=Groups menu.locale.content=Change locale. menu.locale=Language menu.main=Main +menu.notifications=Notifications menu.operator=You are {0} menu.profile.content=You can change your personal information on this page. menu.profile=Profile @@ -229,6 +230,16 @@ menu.updates.content=Check for news and updates. menu.updates=Updates my_settings.error.password_match=Entered passwords do not match no_such_operator=No such operator +notifications.locale=Language +notifications.locale.all=-all- +notifications.kind=Kind of notification +notifications.kind.all=-all- +notifications.kind.mail=E-Mail +notifications.kind.xmpp=XMPP/Jabber +notifications.head.to=To +notifications.head.subj=Subject +notifications.head.msg=Text +notifications.head.time=Time operator.group.no_description=<no description> operator.groups.intro=Choose groups according to operator skills. operator.groups.title=Operator groups @@ -272,6 +283,8 @@ page.groups.isaway=Away page.groups.isonline=Online page.groups.new=Create new group... page.groups.title=Groups +page.notifications.title=Notifications Log +page.notifications.intro=The list displays all notifications sent by messenger, including instant text messages and E-Mails. page.preview.agentchat=Chat window (operator-mode) page.preview.agentrochat=View Chat window (operator in readonly mode) page.preview.chatsimple=Simple chat window, refresh to post messages (IE 5, Opera 7) diff --git a/src/messenger/webim/locales/ru/properties b/src/messenger/webim/locales/ru/properties index 261560f1..26716391 100644 --- a/src/messenger/webim/locales/ru/properties +++ b/src/messenger/webim/locales/ru/properties @@ -482,3 +482,4 @@ updates.intro= updates.latest=Последняя версия: updates.news=Новости: updates.title=Обновления +menu.notifications=Уведомления diff --git a/src/messenger/webim/mail.php b/src/messenger/webim/mail.php index 131bcbda..8baa6c34 100644 --- a/src/messenger/webim/mail.php +++ b/src/messenger/webim/mail.php @@ -22,6 +22,7 @@ require_once('libs/common.php'); require_once('libs/chat.php'); require_once('libs/expand.php'); +require_once('libs/notify.php'); $errors = array(); $page = array(); @@ -63,7 +64,9 @@ foreach( $output as $msg ) { $subject = getstring("mail.user.history.subject"); $body = getstring2("mail.user.history.body", array($thread['userName'],$history) ); -webim_mail($email, $webim_mailbox, $subject, $body); +$link = connect(); +webim_mail($email, $webim_mailbox, $subject, $body, $link); +mysql_close($link); setup_logo(); expand("styles", getchatstyle(), "mailsent.tpl"); diff --git a/src/messenger/webim/operator/history.php b/src/messenger/webim/operator/history.php index b660c72d..c18f6a01 100644 --- a/src/messenger/webim/operator/history.php +++ b/src/messenger/webim/operator/history.php @@ -42,31 +42,25 @@ if($query !== false) { while ($group = mysql_fetch_array($result, MYSQL_ASSOC)) { $groupName[$group['groupid']] = $group['vclocalname']; } - $page['groupName'] = $groupName; mysql_free_result($result); - - $result = mysql_query( - "select DISTINCT unix_timestamp(chatthread.dtmcreated) as created, ". + $page['groupName'] = $groupName; + + $escapedQuery = mysql_real_escape_string($query,$link); + select_with_pagintation("DISTINCT unix_timestamp(chatthread.dtmcreated) as created, ". "unix_timestamp(chatthread.dtmmodified) as modified, chatthread.threadid, ". "chatthread.remote, chatthread.agentName, chatthread.userName, groupid, ". - "messageCount as size ". - "from chatthread, chatmessage ". - "where chatmessage.threadid = chatthread.threadid and ". - "((chatthread.userName LIKE '%%$query%%') or ". - " (chatmessage.tmessage LIKE '%%$query%%'))". - "order by created DESC", $link) - or die(' Query failed: ' .mysql_error().": ".$query); - - $foundThreads = array(); - while ($thread = mysql_fetch_array($result, MYSQL_ASSOC)) { - $foundThreads[] = $thread; - } - - mysql_free_result($result); + "messageCount as size", + "chatthread, chatmessage", + array( + "chatmessage.threadid = chatthread.threadid", + "((chatthread.userName LIKE '%%$escapedQuery%%') or (chatmessage.tmessage LIKE '%%$escapedQuery%%'))" + ), + "order by created DESC", + "DISTINCT chatthread.dtmcreated", $link); + mysql_close($link); $page['formq'] = topage($query); - setup_pagination($foundThreads); } else { setup_empty_pagination(); } diff --git a/src/messenger/webim/operator/notifications.php b/src/messenger/webim/operator/notifications.php new file mode 100644 index 00000000..d137a3aa --- /dev/null +++ b/src/messenger/webim/operator/notifications.php @@ -0,0 +1,82 @@ + '', 'name' => getlocal("notifications.locale.all"))); +foreach($all_locales as $id) { + $locales_with_label[] = array('id' => $id, 'name' => getlocal_($id,"names")); +} +$page['locales'] = $locales_with_label; + +$lang = verifyparam("lang", "/^([\w-]{2,5})?$/", ""); +if( $lang && !in_array($lang,$all_locales) ) { + $lang = ""; +} + +# kind + +$kind = verifyparam("kind", "/^(mail|xmpp)?$/", ""); +$page['allkinds'] = array('', 'mail', 'xmpp'); + +# fetch + +$conditions = array(); +if($kind) { + $conditions[] = "vckind = '$kind'"; +} +if($lang) { + $conditions[] = "locale = '$lang'"; +} + +$link = connect(); +select_with_pagintation( + "id, locale, vckind, vcto, unix_timestamp(dtmcreated) as created, vcsubject, tmessage, refoperator", "chatnotification", + $conditions, + "order by created desc", "", $link); + +mysql_close($link); + +$page['formlang'] = $lang; +$page['formkind'] = $kind; + +prepare_menu($operator); +start_html_output(); + +require('../view/notifications.php'); +exit; +?> \ No newline at end of file diff --git a/src/messenger/webim/operator/restore.php b/src/messenger/webim/operator/restore.php index 6ff4dcd4..008db4cb 100644 --- a/src/messenger/webim/operator/restore.php +++ b/src/messenger/webim/operator/restore.php @@ -22,6 +22,7 @@ require_once('../libs/common.php'); require_once('../libs/operator.php'); require_once('../libs/settings.php'); +require_once('../libs/notify.php'); $errors = array(); $page = array('version' => $version); @@ -46,11 +47,10 @@ if (isset($_POST['loginoremail'])) { $link = connect(); $query = "update chatoperator set dtmrestore = CURRENT_TIMESTAMP, vcrestoretoken = '$token' where operatorid = ".$torestore['operatorid']; perform_query($query, $link); + + $href = get_app_location(true,false)."/operator/resetpwd.php?id=".$torestore['operatorid']."&token=$token"; + webim_mail($email, $email, getstring("restore.mailsubj"), getstring2("restore.mailtext",array(get_operator_name($torestore), $href)), $link); mysql_close($link); - - $link = get_app_location(true,false)."/operator/resetpwd.php?id=".$torestore['operatorid']."&token=$token"; - - webim_mail($email, $email, getstring("restore.mailsubj"), getstring2("restore.mailtext",array(get_operator_name($torestore), $link))); $page['isdone'] = true; require('../view/restore.php'); diff --git a/src/messenger/webim/view/agents.php b/src/messenger/webim/view/agents.php index d3cd5685..fab61b90 100644 --- a/src/messenger/webim/view/agents.php +++ b/src/messenger/webim/view/agents.php @@ -75,7 +75,7 @@ require_once('inc_errors.php');
+ + | + + | + + | + + | +
---|---|---|---|
+ + + + | ++ + | ++ + | ++ + | +
+ + | +