From 222a3aa3558e4baace3db74903209198af6be18a Mon Sep 17 00:00:00 2001 From: SJ Date: Tue, 28 Aug 2012 22:00:45 +0200 Subject: [PATCH] improved the expert search --- util/db-mysql.sql | 23 +++++++++++++++-------- util/db-upgrade-0.20-vs-0.21.sql | 6 +++++- webui/controller/search/helper.php | 4 +++- webui/model/search/search.php | 5 +++++ 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/util/db-mysql.sql b/util/db-mysql.sql index 1f783520..08d8b48e 100644 --- a/util/db-mysql.sql +++ b/util/db-mysql.sql @@ -62,14 +62,6 @@ create index metadata_idx5 on metadata(`deleted`); create index metadata_idx6 on metadata(`arrived`); create index metadata_idx7 on metadata(`retained`); -drop table if exists `folder`; -create table if not exists `folder` ( - `id` int not null auto_increment, - `parent_id` int default 0, - `name` char(64) not null unique, - primary key (`id`) -) Engine=InnoDB; - drop table if exists `rcpt`; create table if not exists `rcpt` ( @@ -246,6 +238,21 @@ create table if not exists `group_email` ( ) ENGINE=InnoDB; +create table if not exists `folder` ( + `id` int not null auto_increment, + `parent_id` int default 0, + `name` char(64) not null unique, + primary key (`id`) +) Engine=InnoDB; + + +create table if not exists `notes` ( + `id` bigint unsigned not null, + `note` text default null, + key `notes_idx` (`id`) +) ENGINE=InnoDB; + + create table if not exists `remote` ( `remotedomain` char(64) not null primary key, `remotehost` char(64) not null, diff --git a/util/db-upgrade-0.20-vs-0.21.sql b/util/db-upgrade-0.20-vs-0.21.sql index 4f7257c3..6b20f6f2 100644 --- a/util/db-upgrade-0.20-vs-0.21.sql +++ b/util/db-upgrade-0.20-vs-0.21.sql @@ -1,6 +1,5 @@ alter table `sph_index` add column `folder` int default 0; -drop table if exists `folder`; create table if not exists `folder` ( `id` int not null auto_increment, `parent_id` int default 0, @@ -8,4 +7,9 @@ create table if not exists `folder` ( primary key (`id`) ) Engine=InnoDB; +create table if not exists `notes` ( + `id` bigint unsigned not null, + `note` text default null, + key `notes_idx` (`id`) +) ENGINE=InnoDB; diff --git a/webui/controller/search/helper.php b/webui/controller/search/helper.php index 1d2edbc4..3d13335b 100644 --- a/webui/controller/search/helper.php +++ b/webui/controller/search/helper.php @@ -20,7 +20,8 @@ class ControllerSearchHelper extends Controller { 'size' => '', 'attachment_type' => '', 'tag' => '', - 'ref' => '' + 'ref' => '', + 'any' => '' ); @@ -137,6 +138,7 @@ class ControllerSearchHelper extends Controller { else if($v == 'size') { $token = 'size'; continue; } else if($v == 'tag:') { $token = 'tag'; continue; } else if($v == 'ref:') { $token = 'ref'; continue; } + else { $this->a['any'] .= ' ' . $v; } if($token == 'from') { $v = fix_email_address($v); diff --git a/webui/model/search/search.php b/webui/model/search/search.php index 78463104..0aea8170 100644 --- a/webui/model/search/search.php +++ b/webui/model/search/search.php @@ -103,6 +103,9 @@ class ModelSearchSearch extends Model { $data['body'] = $this->fixup_sphinx_operators($data['body']); $data['subject'] = $this->fixup_sphinx_operators($data['subject']); + $data['any'] = $this->fixup_sphinx_operators($data['any']); + $data['any'] = $this->fix_email_address_for_sphinx($data['any']); + if(Registry::get('auditor_user') == 1) { if($data['f_from']) { $f1 .= "|" . $data['f_from']; $n_fc++; } @@ -167,6 +170,8 @@ class ModelSearchSearch extends Model { if($data['subject']) { if($match) { $match .= " & "; } $match .= "(@subject " . $data['subject'] . ") "; } if($data['attachment_type'] && $data['attachment_type'] != "any") { if($match) { $match .= " & "; } $match .= "(@attachment_types " . $data['attachment_type'] . ") "; } + if($data['any']) { if($match) { $match .= " & "; } $match .= "(" . $data['any'] . ") "; } + return $match; }