From f9965f4d1029862bb2a45c3155375bf084371c83 Mon Sep 17 00:00:00 2001 From: Evgeny Gryaznov Date: Sun, 10 Jan 2010 13:39:49 +0000 Subject: [PATCH] add "Notifications Log" page, record sent mails, fast history search, fix redirection to groups git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@720 c66351dc-e62f-0410-b875-e3a5c0b9693f --- src/messenger/webim/default.css | 14 ++ src/messenger/webim/images/mail.png | Bin 0 -> 3077 bytes src/messenger/webim/images/xmpp.png | Bin 0 -> 3184 bytes src/messenger/webim/install/dbinfo.php | 14 +- src/messenger/webim/leavemessage.php | 5 +- src/messenger/webim/libs/common.php | 37 ++--- src/messenger/webim/libs/notify.php | 52 +++++++ src/messenger/webim/libs/operator.php | 33 +++-- src/messenger/webim/libs/pagination.php | 13 ++ src/messenger/webim/locales/en/properties | 13 ++ src/messenger/webim/locales/ru/properties | 1 + src/messenger/webim/mail.php | 5 +- src/messenger/webim/operator/history.php | 32 ++--- .../webim/operator/notifications.php | 82 +++++++++++ src/messenger/webim/operator/restore.php | 8 +- src/messenger/webim/view/agents.php | 2 +- src/messenger/webim/view/inc_menu.php | 1 + src/messenger/webim/view/notifications.php | 136 ++++++++++++++++++ 18 files changed, 385 insertions(+), 63 deletions(-) create mode 100755 src/messenger/webim/images/mail.png create mode 100755 src/messenger/webim/images/xmpp.png create mode 100644 src/messenger/webim/libs/notify.php create mode 100644 src/messenger/webim/operator/notifications.php create mode 100644 src/messenger/webim/view/notifications.php 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 0000000000000000000000000000000000000000..e3117de7c4466fadcc22e35b95a45fee89ad383a GIT binary patch literal 3077 zcmV+g4EpnlP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5Ry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KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=00004XF*Lt006O$eEU(80000WV@Og>004R=004l4008;_004mL004C` z008P>0026e000+nl3&F}0003XNklYU6o_Aa&b>k@ zMVgu;Wu+EqmSv^tK?A7OcV~jDmGY#8MzhcJ(D@TO?Tu(O`|%l+3OWb2|EuKue#FI% z%SJ967ktWzqW3k5`;=16&#-Vn8sK# z7{2m2a5!rF6!RI{*Dj%ADuMPrL963o8ahHKOhaeS_5mp7Gtqg{by-_oh$m=uJhqK_ z1d2ckK0+`JJ%R%Xejr%SWx2h3k0;pKT27q&Qo`Nl%Hp)3S}D)`62-s&#;*YY(l2`p TJ)Te{00000NkvXXu0mjfu>7^Z literal 0 HcmV?d00001 diff --git a/src/messenger/webim/images/xmpp.png b/src/messenger/webim/images/xmpp.png new file mode 100755 index 0000000000000000000000000000000000000000..6c9d44d526b96aad49176f18c84d43174f93eb17 GIT binary patch literal 3184 zcmV-$43G1PP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v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cv2emFyRr%LtPuTu1KI57)1L5Xey4&WPcy>Wi}A1dYmnW$Qm!*t(q{yPAZ W&+|YdcsmvV0000 "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'); / - + diff --git a/src/messenger/webim/view/inc_menu.php b/src/messenger/webim/view/inc_menu.php index bca6663c..4956c2c7 100644 --- a/src/messenger/webim/view/inc_menu.php +++ b/src/messenger/webim/view/inc_menu.php @@ -56,6 +56,7 @@ function tpl_menu() { global $page, $webimroot, $errors; > > > + > >'> diff --git a/src/messenger/webim/view/notifications.php b/src/messenger/webim/view/notifications.php new file mode 100644 index 00000000..7ad88dba --- /dev/null +++ b/src/messenger/webim/view/notifications.php @@ -0,0 +1,136 @@ + $len) + return substr($text,0,$len).".."; + return $text; +} + +function tpl_header() { global $page, $webimroot; +?> + + + + +
+
+ + +
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+ + + + + + + + + +
+ +
+"; + echo generate_pagination($page['pagination']); + } +} +?> + + \ No newline at end of file