Modified threads search. Added the ability to select search type.

This commit is contained in:
Dmitriy Simushev 2012-02-12 16:19:06 +00:00
parent 82e40ddd84
commit c490ea8523
6 changed files with 50 additions and 8 deletions

View File

@ -599,7 +599,7 @@ table.awaiting td.visitor {
float:left;
display: inline;
margin:7px 20px 5px 0px;
width:75%;
width:60%;
padding-right:5px;
}

View File

@ -350,7 +350,7 @@ page_agents.login=Login
page_agents.new_agent=Add operator...
page_agents.status=Last active
page_agents.title=Operators
page_analysis.full.text.search=User name or message text search:
page_analysis.full.text.search=User name, operator name or message text search:
page_analysis.search.title=Chat history
page_avatar.intro=You can upload your photo only as JPG, GIF, PNG or TIF image files.
page_avatar.title=Upload photo
@ -373,7 +373,13 @@ page_login.login=Login:
page_login.password=Password:
page_login.remember=Remember
page_login.title=Login
page_search.intro=Search the chat history for a specified user or a specified phrase in messages.
page_search.intro=Search the chat history for a specified user, an operator or a specified phrase in messages.
page_search.type.all=everywhere
page_search.search.type.in_system_messages=Search in system messages
page_search.type.message=in messages
page_search.type.operator=by operator
page_search.type.title=Search:
page_search.type.visitor=by visitor
page_settings.intro=Specify options affecting chat window and common system behavior.
page_settings.tab.features=Optional Services
page_settings.tab.main=General

View File

@ -348,7 +348,7 @@ page_agents.login=
page_agents.new_agent=Добавить оператора...
page_agents.status=Последний раз
page_agents.title=Операторы
page_analysis.full.text.search=Поиск по имени посетителя или по тексту сообщения:
page_analysis.full.text.search=Поиск по имени посетителя, имени оператора или по тексту сообщения:
page_analysis.search.title=История диалогов
page_avatar.intro=Вы можете загрузить фотографию расширения JPG, GIF, PNG или TIF.
page_avatar.title=Загрузка фотографии
@ -371,7 +371,13 @@ page_login.operator.disabled=
page_login.password=Пароль:
page_login.remember=Запомнить
page_login.title=Вход в систему
page_search.intro=На данной странице можно осуществить поиск диалогов по имени пользователя или фразе, встречающейся в сообщении.
page_search.intro=На данной странице можно осуществить поиск диалогов по имени пользователя, имени оператора или фразе, встречающейся в сообщении.
page_search.type.all=везде
page_search.search.type.in_system_messages=Искать в системных сообщениях
page_search.type.message=в сообщениях
page_search.type.operator=по оператору
page_search.type.title=Искать:
page_search.type.visitor=по посетителю
page_settings.intro=Здесь вы можете задать опции влияющие на отображение чат окна и общее поведение системы.
page_settings.tab.features=Расширения
page_settings.tab.main=Общее

View File

@ -35,6 +35,9 @@ setlocale(LC_TIME, getstring("time.locale"));
$page = array();
$query = isset($_GET['q']) ? myiconv(getoutputenc(), $webim_encoding, $_GET['q']) : false;
$searchType = verifyparam('type', '/^(all|message|operator|visitor)$/', 'all');
$searchInSystemMessages = (verifyparam('insystemmessages', '/^on$/', 'off') == 'on') || !$query;
if ($query !== false) {
$link = connect();
@ -48,6 +51,18 @@ if ($query !== false) {
$page['groupName'] = $groupName;
$escapedQuery = db_escape_string($query, $link);
$searchConditions = array();
if ($searchType == 'message' || $searchType == 'all') {
$searchConditions[] = "(${mysqlprefix}chatmessage.tmessage LIKE '%%$escapedQuery%%'" .
($searchInSystemMessages?'':" AND (${mysqlprefix}chatmessage.ikind = $kind_user OR ${mysqlprefix}chatmessage.ikind = $kind_agent)") .
")";
}
if ($searchType == 'operator' || $searchType == 'all') {
$searchConditions[] = "(${mysqlprefix}chatthread.agentName LIKE '%%$escapedQuery%%')";
}
if ($searchType == 'visitor' || $searchType == 'all') {
$searchConditions[] = "(${mysqlprefix}chatthread.userName LIKE '%%$escapedQuery%%')";
}
select_with_pagintation("DISTINCT unix_timestamp(${mysqlprefix}chatthread.dtmcreated) as created, " .
"unix_timestamp(${mysqlprefix}chatthread.dtmmodified) as modified, ${mysqlprefix}chatthread.threadid, " .
"${mysqlprefix}chatthread.remote, ${mysqlprefix}chatthread.agentName, ${mysqlprefix}chatthread.userName, groupid, " .
@ -55,7 +70,7 @@ if ($query !== false) {
"${mysqlprefix}chatthread, ${mysqlprefix}chatmessage",
array(
"${mysqlprefix}chatmessage.threadid = ${mysqlprefix}chatthread.threadid",
"((${mysqlprefix}chatthread.userName LIKE '%%$escapedQuery%%') or (${mysqlprefix}chatmessage.tmessage LIKE '%%$escapedQuery%%'))"
"(" . implode(' or ', $searchConditions) . ")"
),
"order by created DESC",
"DISTINCT ${mysqlprefix}chatthread.dtmcreated", $link);
@ -67,6 +82,9 @@ if ($query !== false) {
setup_empty_pagination();
}
$page['formtype'] = $searchType;
$page['forminsystemmessages'] = $searchInSystemMessages;
prepare_menu($operator);
start_html_output();
require('../view/thread_search.php');

View File

@ -138,7 +138,7 @@ require_once('inc_errors.php');
<?php if( $page['reportByAgent'] ) { ?>
<?php foreach( $page['reportByAgent'] as $row ) { ?>
<tr>
<td><a href="<?php echo $webimroot ?>/operator/history.php?q=<?php echo topage(htmlspecialchars($row['name'])) ?>"><?php echo topage(htmlspecialchars($row['name'])) ?></a></td>
<td><a href="<?php echo $webimroot ?>/operator/history.php?q=<?php echo topage(htmlspecialchars($row['name'])) ?>&type=operator"><?php echo topage(htmlspecialchars($row['name'])) ?></a></td>
<td><?php echo $row['threads'] ?></td>
<td><?php echo $row['msgs'] ?></td>
<td><?php echo $row['avglen'] ?></td>

View File

@ -38,10 +38,22 @@ function tpl_content() { global $page, $webimroot;
<div class="flabel"><?php echo getlocal("page_analysis.full.text.search") ?></div>
<div class="fvaluenodesc">
<div id="searchtext">
<input type="text" name="q" size="80" value="<?php echo form_value('q') ?>" class="formauth"/>
<input type="text" name="q" size="60" value="<?php echo form_value('q') ?>" class="formauth"/>
</div>
<div class="searchctrl">
<?php echo getlocal("page_search.type.title") ?>
<select name="type" onchange="if (this.value == 'all' || this.value == 'message') {document.getElementById('inSystemMessages').style.display='inline'} else {document.getElementById('inSystemMessages').style.display='none'}; ">
<option value="all" <?php echo (form_value('type') == 'all')?'selected="selected"':'' ?>><?php echo getlocal("page_search.type.all") ?></option>
<option value="message" <?php echo (form_value('type') == 'message')?'selected="selected"':'' ?>><?php echo getlocal("page_search.type.message") ?></option>
<option value="operator" <?php echo (form_value('type') == 'operator')?'selected="selected"':'' ?>><?php echo getlocal("page_search.type.operator") ?></option>
<option value="visitor" <?php echo (form_value('type') == 'visitor')?'selected="selected"':'' ?>><?php echo getlocal("page_search.type.visitor") ?></option>
</select>
</div>
<div id="searchbutton">
<input type="image" name="search" src='<?php echo $webimroot.getlocal("image.button.search") ?>' alt='<?php echo getlocal("button.search") ?>'/>
</div><br />
<div class="searchctrl" id="inSystemMessages"<?php echo ((form_value('type') != 'all' && form_value('type') != 'message')?' style="display: none;"':'')?>>
<input type="checkbox" name="insystemmessages" <?php echo (form_value('insystemmessages')?'checked="checked"':'') ?>/> <?php echo getlocal("page_search.search.type.in_system_messages") ?>
</div>
</div>
<br clear="all"/>