webui search fixes

This commit is contained in:
SJ 2012-02-12 16:16:54 +01:00
parent 2a9376222c
commit cfb7b80120
5 changed files with 70 additions and 45 deletions

View File

@ -154,17 +154,15 @@ create index `user_settings_idx` on `user_settings`(`username`);
drop table if exists `user`; drop table if exists `user`;
create table if not exists `user` ( create table if not exists `user` (
`uid` int unsigned not null primary key, `uid` int unsigned not null primary key,
`gid` int unsigned not null,
`username` char(64) not null unique, `username` char(64) not null unique,
`realname` char(64) default null, `realname` char(64) default null,
`password` char(48) default null, `password` char(48) default null,
`domain` char(64) default null, `domain` char(64) default null,
`dn` char(255) default '*', `dn` char(255) default '*',
`policy_group` int(4) default 0,
`isadmin` tinyint default 0 `isadmin` tinyint default 0
) Engine=InnoDB; ) Engine=InnoDB;
insert into `user` (`uid`, `gid`, `username`, `realname`, `password`, `policy_group`, `isadmin`, `domain`) values (0, 0, 'admin', 'built-in piler admin', '$1$PItc7d$zsUgON3JRrbdGS11t9JQW1', 0, 1, 'local'); insert into `user` (`uid`, `username`, `realname`, `password`, `isadmin`, `domain`) values (0, 'admin', 'built-in piler admin', '$1$PItc7d$zsUgON3JRrbdGS11t9JQW1', 1, 'local');
drop table if exists `email`; drop table if exists `email`;
create table if not exists `email` ( create table if not exists `email` (

View File

@ -49,14 +49,22 @@ class ControllerSearchHelper extends Controller {
$this->data['n'] = -1; $this->data['n'] = -1;
if($this->request->post['searchtype'] == 'advanced') { if($this->request->post['searchtype'] == 'advanced') {
$this->preprocess_post_advanced_request($this->request->post); $this->preprocess_post_advanced_request($this->request->post);
$this->fixup_post_request(); $this->fixup_post_request();
list ($this->data['n'], $this->data['messages']) = $this->model_search_search->search_messages($this->a, ADVANCED_SEARCH, $this->data['page']); list ($this->data['n'], $this->data['messages']) = $this->model_search_search->search_messages($this->a, ADVANCED_SEARCH, $this->data['page']);
} else if($this->request->post['searchtype'] == 'expert'){ }
else if($this->request->post['searchtype'] == 'expert'){
$this->preprocess_post_expert_request($this->request->post); $this->preprocess_post_expert_request($this->request->post);
$this->fixup_post_request(); $this->fixup_post_request();
list ($this->data['n'], $this->data['messages']) = $this->model_search_search->search_messages($this->a, ADVANCED_SEARCH, $this->data['page']); list ($this->data['n'], $this->data['messages']) = $this->model_search_search->search_messages($this->a, ADVANCED_SEARCH, $this->data['page']);
} else { }
else {
$this->fixup_post_simple_request(); $this->fixup_post_simple_request();
list ($this->data['n'], $this->data['messages']) = $this->model_search_search->search_messages($this->request->post, SIMPLE_SEARCH, $this->data['page']); list ($this->data['n'], $this->data['messages']) = $this->model_search_search->search_messages($this->request->post, SIMPLE_SEARCH, $this->data['page']);
} }
@ -86,12 +94,16 @@ class ControllerSearchHelper extends Controller {
private function fixup_post_request() { private function fixup_post_request() {
while(list($k, $v) = each($this->a)) { $this->a['o_from'] = substr($this->a['o_from'], 1, strlen($this->a['o_from']));
if($this->a[$k]) { $this->a[$k] = substr($this->a[$k], 1, strlen($this->a[$k])); } $this->a['f_from'] = substr($this->a['f_from'], 1, strlen($this->a['f_from']));
} $this->a['o_to'] = substr($this->a['o_to'], 1, strlen($this->a['o_to']));
$this->a['f_to'] = substr($this->a['f_to'], 1, strlen($this->a['f_to']));
$this->a['from'] = substr($this->a['from'], 1, strlen($this->a['from']));
$this->a['to'] = substr($this->a['to'], 1, strlen($this->a['to']));
$this->a['from_domain'] = substr($this->a['from_domain'], 1, strlen($this->a['from_domain']));
$this->a['to_domain'] = substr($this->a['to_domain'], 1, strlen($this->a['to_domain']));
$this->a['ref'] = $this->request->post['ref']; $this->a['ref'] = $this->request->post['ref'];
$this->a['sort'] = $this->request->post['sort']; $this->a['sort'] = $this->request->post['sort'];
$this->a['order'] = $this->request->post['order']; $this->a['order'] = $this->request->post['order'];
} }
@ -100,14 +112,14 @@ class ControllerSearchHelper extends Controller {
private function preprocess_post_expert_request($data = array()) { private function preprocess_post_expert_request($data = array()) {
$token = ''; $token = '';
//print_r($data);
$s = preg_replace("/:/", ": ", $data['search']); $s = preg_replace("/:/", ": ", $data['search']);
$s = preg_replace("/,/", " ", $s); $s = preg_replace("/,/", " ", $s);
$s = preg_replace("/\s{1,}/", " ", $s); $s = preg_replace("/\s{1,}/", " ", $s);
$b = explode(" ", $s); $b = explode(" ", $s);
while(list($k, $v) = each($b)) { while(list($k, $v) = each($b)) {
if($v == '') { continue; }
if($v == 'from:') { $token = 'from'; continue; } if($v == 'from:') { $token = 'from'; continue; }
else if($v == 'to:') { $token = 'to'; continue; } else if($v == 'to:') { $token = 'to'; continue; }
else if($v == 'subject:') { $token = 'subject'; continue; } else if($v == 'subject:') { $token = 'subject'; continue; }
@ -145,15 +157,42 @@ class ControllerSearchHelper extends Controller {
} }
else if($token == 'subject') { $this->a['subject'] .= ' ' . $v; } else if($token == 'subject') { $this->a['subject'] .= ' ' . $v; }
else if($token == 'body') { $this->a['body'] .= ' ' . $v; } else if($token == 'body') { $this->a['body'] .= ' ' . $v; }
else if($token == 'date1') { $this->a['date1'] = $v; } else if($token == 'date1') { $this->a['date1'] = ' ' . $v; }
else if($token == 'date2') { $this->a['date2'] = $v; } else if($token == 'date2') { $this->a['date2'] = ' ' . $v; }
else if($token == 'direction') { $this->a['direction'] = $v; } else if($token == 'attachment_type') { $this->a['attachment_type'] .= '|' . $v; }
else if($token == 'size') { $this->a['size'] .= ' ' . $v; }
else if($token == 'attachment_type') { $this->a['attachment_type'] .= ' ' . $v; }
else if($token == 'tag') { $this->a['tag'] .= ' ' . $v; } else if($token == 'tag') { $this->a['tag'] .= ' ' . $v; }
else if($token == 'ref') { $this->a['ref'] = $v; } else if($token == 'ref') { $this->a['ref'] = ' ' . $v; }
else if($token == 'direction') {
if($v == 'inbound') { $this->a['direction'] = 0; }
else if($v == 'outbound') { $this->a['direction'] = 2; }
else if($v == 'internal') { $this->a['direction'] = 1; }
}
else if($token == 'size') {
$o = substr($v, 0, 1);
if($o == '<' || $o == '>') {
$v = substr($v, 1, strlen($v));
$o1 = substr($v, 0, 1);
if($o1 == '=') {
$v = substr($v, 1, strlen($v));
$o .= $o1;
}
}
else { $o = ''; }
$s = explode("k", $v);
if($s[0] != $v) { $v = $s[0] * 1000; }
$s = explode("M", $v);
if($s[0] != $v) { $v = $s[0] * 1000000; }
$this->a['size'] .= ' ' . $o . $v;
}
} }
$this->a['attachment_type'] = substr($this->a['attachment_type'], 1, strlen($this->a['attachment_type']));
} }
@ -173,7 +212,7 @@ class ControllerSearchHelper extends Controller {
if(in_array($v, $_SESSION['emails'])) { $this->a['o_from'] .= "|$v"; } else { $this->a['f_from'] .= "|$v"; } if(in_array($v, $_SESSION['emails'])) { $this->a['o_from'] .= "|$v"; } else { $this->a['f_from'] .= "|$v"; }
} }
else { else {
$this->a['from'] .= "|$v"; $this->a['from'] .= " $v";
} }
} }
@ -185,28 +224,21 @@ class ControllerSearchHelper extends Controller {
if(in_array($v, $_SESSION['emails'])) { $this->a['o_to'] .= "|$v"; } else { $this->a['f_to'] .= "|$v"; } if(in_array($v, $_SESSION['emails'])) { $this->a['o_to'] .= "|$v"; } else { $this->a['f_to'] .= "|$v"; }
} }
else { else {
$this->a['to'] .= "|$v"; $this->a['to'] .= " $v";
} }
} }
if($f == 'subject') { if($f == 'subject') { $this->a['subject'] .= ' ' . $v; }
$this->a['subject'] .= "|$v"; if($f == 'body') { $this->a['body'] .= ' ' . $v; }
}
if($f == 'body') {
$this->a['body'] .= "|$v";
}
if($f == 'tag') {
$this->a['tag'] .= "|$v";
}
} }
} }
if(isset($data['attachment_type'])) { $this->a['attachment_type'] = $data['attachment_type']; }
if(isset($data['direction'])) { $this->a['direction'] = $data['direction']; }
if(isset($data['tag'])) { $this->a['tag'] = $data['tag']; }
if(isset($data['date1'])) { $this->a['date1'] = $data['date1']; }
if(isset($data['date2'])) { $this->a['date2'] = $data['date2']; }
} }

View File

@ -162,7 +162,7 @@ class ModelSearchSearch extends Model {
if($data['body']) { if($match) { $match .= " & "; } $match .= "(@body " . $data['body'] . ") "; } if($data['body']) { if($match) { $match .= " & "; } $match .= "(@body " . $data['body'] . ") "; }
if($data['subject']) { if($match) { $match .= " & "; } $match .= "(@subject " . $data['subject'] . ") "; } if($data['subject']) { if($match) { $match .= " & "; } $match .= "(@subject " . $data['subject'] . ") "; }
if($data['attachment_type']) { if($match) { $match .= " & "; } $match .= "(@attachment_types " . $data['attachment_type'] . ") "; } if($data['attachment_type'] && $data['attachment_type'] != "any") { if($match) { $match .= " & "; } $match .= "(@attachment_types " . $data['attachment_type'] . ") "; }
return $match; return $match;
} }
@ -249,7 +249,7 @@ class ModelSearchSearch extends Model {
$ids = array(); $ids = array();
$direction = $size = ''; $direction = $size = '';
$tag_id_list = ''; $tag_id_list = '';
$a = "";
if($data['sort'] == 'from' || $data['sort'] == 'subj') { $sortorder = ''; } if($data['sort'] == 'from' || $data['sort'] == 'subj') { $sortorder = ''; }
@ -264,6 +264,7 @@ class ModelSearchSearch extends Model {
if(preg_match("/^(\>|\<)\={0,}\d{1,}$/", $data['size'])) { $size = "size " . $data['size'] . " AND "; } if(preg_match("/^(\>|\<)\={0,}\d{1,}$/", $data['size'])) { $size = "size " . $data['size'] . " AND "; }
} }
if(isset($data['attachment_type']) && $data['attachment_type'] == 'any') { $a = "attachments > 0 AND "; }
if($data['tag']) { if($data['tag']) {
$data['tag'] = $this->fixup_sphinx_operators($data['tag']); $data['tag'] = $this->fixup_sphinx_operators($data['tag']);
@ -277,7 +278,7 @@ class ModelSearchSearch extends Model {
$query = $this->sphx->query("SELECT id FROM " . SPHINX_MAIN_INDEX . " WHERE id IN (" . substr($tag_id_list, 1, strlen($tag_id_list)) . ") $sortorder LIMIT 0," . MAX_SEARCH_HITS); $query = $this->sphx->query("SELECT id FROM " . SPHINX_MAIN_INDEX . " WHERE id IN (" . substr($tag_id_list, 1, strlen($tag_id_list)) . ") $sortorder LIMIT 0," . MAX_SEARCH_HITS);
} }
else { else {
$query = $this->sphx->query("SELECT id FROM " . SPHINX_MAIN_INDEX . " WHERE $date $direction $size MATCH('$conditions') $sortorder LIMIT 0," . MAX_SEARCH_HITS); $query = $this->sphx->query("SELECT id FROM " . SPHINX_MAIN_INDEX . " WHERE $a $date $direction $size MATCH('$conditions') $sortorder LIMIT 0," . MAX_SEARCH_HITS);
} }
//print $query->query; print "<p>" . $query->exec_time . "</p>\n"; //print $query->query; print "<p>" . $query->exec_time . "</p>\n";

View File

@ -265,11 +265,11 @@ function format_qshape($desc = '', $filename = '') {
} }
function nice_size($size = 0) { function nice_size($size = 0, $space = '') {
if($size < 1000) return "1k"; if($size < 1000) return "1k";
if($size < 100000) return round($size/1000) . "k"; if($size < 100000) return round($size/1000) . $space . "k";
return sprintf("%.1f", $size/1000000) . "M"; return sprintf("%.1f", $size/1000000) . $space . "M";
} }

View File

@ -20,12 +20,6 @@
</div> </div>
</div> </div>
<div id="ss1" style="border: 0px solid blue;">
<div class="row">
<div class="fcell">eg. from: enron.com, subject: lunch, body: invite, date1: 2001-01-01, date2: 2001-12-31</div>
</div>
</div>
<div class="row"> <div class="row">
<div class="cell1s">&nbsp;</div> <div class="cell1s">&nbsp;</div>
<div class="cell2"> <div class="cell2">