mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-08 02:21:59 +01:00
added option to search by numeric internal id
This commit is contained in:
parent
5161103a44
commit
dc0419d05a
@ -18,6 +18,7 @@ class ControllerSearchHelper extends Controller {
|
||||
'ref' => '',
|
||||
'folders' => '',
|
||||
'extra_folders' => '',
|
||||
'id' => '',
|
||||
'any' => ''
|
||||
);
|
||||
|
||||
@ -48,7 +49,7 @@ class ControllerSearchHelper extends Controller {
|
||||
|
||||
if($this->request->post['searchtype'] == 'expert'){
|
||||
|
||||
if(isset($this->request->post['search']) && preg_match("/(from|to|subject|body|direction|size|date1|date2|attachment|tag|note)\:/", $this->request->post['search'])) {
|
||||
if(isset($this->request->post['search']) && preg_match("/(from|to|subject|body|direction|size|date1|date2|attachment|tag|note|id)\:/", $this->request->post['search'])) {
|
||||
$this->preprocess_post_expert_request($this->request->post);
|
||||
}
|
||||
else {
|
||||
@ -94,6 +95,7 @@ class ControllerSearchHelper extends Controller {
|
||||
if(!isset($this->request->post['tag'])) { $this->request->post['tag'] = ''; }
|
||||
if(!isset($this->request->post['note'])) { $this->request->post['note'] = ''; }
|
||||
if(!isset($this->request->post['any'])) { $this->request->post['any'] = ''; }
|
||||
if(!isset($this->request->post['id'])) { $this->request->post['id'] = ''; }
|
||||
if(!isset($this->request->post['attachment_type'])) { $this->request->post['attachment_type'] = ''; }
|
||||
if(!isset($this->request->post['date1'])) { $this->request->post['date1'] = ''; }
|
||||
if(!isset($this->request->post['date2'])) { $this->request->post['date2'] = ''; }
|
||||
@ -163,6 +165,7 @@ class ControllerSearchHelper extends Controller {
|
||||
else if($v == 'tag:') { $token = 'tag'; continue; }
|
||||
else if($v == 'note:') { $token = 'note'; continue; }
|
||||
else if($v == 'ref:') { $token = 'ref'; continue; }
|
||||
else if($v == 'id:') { $token = 'id'; continue; }
|
||||
else {
|
||||
if(preg_match("/\d{4}\-\d{1,2}\-\d{1,2}/", $v) || preg_match("/\d{1,2}\/\d{1,2}\/\d{4}/", $v)) {
|
||||
$ndate++;
|
||||
@ -189,6 +192,7 @@ class ControllerSearchHelper extends Controller {
|
||||
else if($token == 'tag') { $this->a['tag'] .= ' ' . $v; }
|
||||
else if($token == 'note') { $this->a['note'] .= ' ' . $v; }
|
||||
else if($token == 'ref') { $this->a['ref'] = ' ' . $v; }
|
||||
else if($token == 'id') { $this->a['id'] .= ' ' . $v; }
|
||||
|
||||
else if($token == 'direction') {
|
||||
if($v == 'inbound') { $this->a['direction'] = "0"; }
|
||||
|
@ -245,6 +245,7 @@ class ModelSearchSearch extends Model {
|
||||
$direction = $attachment = $size = $folders = '';
|
||||
$tag_id_list = '';
|
||||
$a = "";
|
||||
$id = "";
|
||||
|
||||
|
||||
$match = $this->assemble_email_address_condition($data['from'], $data['to']);
|
||||
@ -291,6 +292,12 @@ class ModelSearchSearch extends Model {
|
||||
else if(isset($data['has_attachment']) && $data['has_attachment'] == 1) { $attachment = "attachments > 0 AND "; }
|
||||
|
||||
|
||||
if(isset($data['id'])) {
|
||||
$data['id'] = preg_replace("/ /", "," , substr($data['id'], 1, strlen($data['id'])));
|
||||
$id = " id IN (" . $data['id'] . ") AND ";
|
||||
}
|
||||
|
||||
|
||||
if(ENABLE_FOLDER_RESTRICTIONS == 1) {
|
||||
$s = explode(" ", $data['folders']);
|
||||
while(list($k,$v) = each($s)) {
|
||||
@ -318,10 +325,10 @@ class ModelSearchSearch extends Model {
|
||||
}
|
||||
else if(ENABLE_FOLDER_RESTRICTIONS == 1 && isset($data['extra_folders']) && $data['extra_folders']) {
|
||||
$ids_in_extra_folders = $this->get_sphinx_id_list_by_extra_folders($data['extra_folders']);
|
||||
$query = $this->sphx->query("SELECT id FROM " . SPHINX_MAIN_INDEX . " WHERE $a $date $attachment $direction $size MATCH('$match') AND id IN ($ids_in_extra_folders) $sortorder LIMIT 0," . MAX_SEARCH_HITS . " OPTION max_matches=" . MAX_SEARCH_HITS);
|
||||
$query = $this->sphx->query("SELECT id FROM " . SPHINX_MAIN_INDEX . " WHERE $a $id $date $attachment $direction $size MATCH('$match') AND id IN ($ids_in_extra_folders) $sortorder LIMIT 0," . MAX_SEARCH_HITS . " OPTION max_matches=" . MAX_SEARCH_HITS);
|
||||
}
|
||||
else {
|
||||
$query = $this->sphx->query("SELECT id FROM " . SPHINX_MAIN_INDEX . " WHERE $a $date $attachment $direction $size $folders MATCH('$match') $sortorder LIMIT 0," . MAX_SEARCH_HITS . " OPTION max_matches=" . MAX_SEARCH_HITS);
|
||||
$query = $this->sphx->query("SELECT id FROM " . SPHINX_MAIN_INDEX . " WHERE $a $id $date $attachment $direction $size $folders MATCH('$match') $sortorder LIMIT 0," . MAX_SEARCH_HITS . " OPTION max_matches=" . MAX_SEARCH_HITS);
|
||||
}
|
||||
|
||||
if(ENABLE_SYSLOG == 1) { syslog(LOG_INFO, sprintf("sphinx query: '%s' in %.2f s, %d hits", $query->query, $query->exec_time, $query->num_rows)); }
|
||||
|
Loading…
Reference in New Issue
Block a user