mirror of
https://bitbucket.org/jsuto/piler.git
synced 2025-06-12 23:47:02 +02:00
major rewrite of the web interface
This commit is contained in:
24
webui/controller/search/folder.php
Normal file
24
webui/controller/search/folder.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ControllerSearchFolder extends Controller {
|
||||
|
||||
protected function index() {
|
||||
|
||||
$this->id = "folder";
|
||||
$this->template = "search/folder.tpl";
|
||||
|
||||
$request = Registry::get('request');
|
||||
$db = Registry::get('db');
|
||||
|
||||
$this->load->model('folder/folder');
|
||||
|
||||
$this->data['folders'] = $this->model_folder_folder->get_folders_for_user();
|
||||
|
||||
$this->render();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -4,14 +4,8 @@
|
||||
class ControllerSearchHelper extends Controller {
|
||||
private $error = array();
|
||||
private $a = array(
|
||||
'o_from' => '',
|
||||
'f_from' => '',
|
||||
'o_to' => '',
|
||||
'f_to' => '',
|
||||
'from' => '',
|
||||
'to' => '',
|
||||
'from_domain' => '',
|
||||
'to_domain' => '',
|
||||
'subject' => '',
|
||||
'body' => '',
|
||||
'date1' => '',
|
||||
@ -20,7 +14,9 @@ class ControllerSearchHelper extends Controller {
|
||||
'size' => '',
|
||||
'attachment_type' => '',
|
||||
'tag' => '',
|
||||
'note' => '',
|
||||
'ref' => '',
|
||||
'folders' => '',
|
||||
'any' => ''
|
||||
);
|
||||
|
||||
@ -49,27 +45,26 @@ class ControllerSearchHelper extends Controller {
|
||||
|
||||
$this->data['n'] = -1;
|
||||
|
||||
if($this->request->post['searchtype'] == 'advanced') {
|
||||
if($this->request->post['searchtype'] == 'expert'){
|
||||
|
||||
if(isset($this->request->post['search']) && preg_match("/(from|to|subject|body|direction|size|date1|date2|attachment|tagnote)\:/", $this->request->post['search'])) {
|
||||
$this->preprocess_post_expert_request($this->request->post);
|
||||
}
|
||||
else {
|
||||
$this->naive_preprocess_post_expert_request($this->request->post);
|
||||
}
|
||||
|
||||
$this->preprocess_post_advanced_request($this->request->post);
|
||||
$this->fixup_post_request();
|
||||
|
||||
list ($this->data['n'], $this->data['all_ids'], $this->data['messages']) = $this->model_search_search->search_messages($this->a, ADVANCED_SEARCH, $this->data['page']);
|
||||
}
|
||||
|
||||
else if($this->request->post['searchtype'] == 'expert'){
|
||||
|
||||
$this->preprocess_post_expert_request($this->request->post);
|
||||
$this->fixup_post_request();
|
||||
|
||||
list ($this->data['n'], $this->data['all_ids'], $this->data['messages']) = $this->model_search_search->search_messages($this->a, ADVANCED_SEARCH, $this->data['page']);
|
||||
list ($this->data['n'], $this->data['all_ids'], $this->data['messages']) = $this->model_search_search->search_messages($this->a, $this->data['page']);
|
||||
}
|
||||
|
||||
else {
|
||||
$this->fixup_post_simple_request();
|
||||
list ($this->data['n'], $this->data['all_ids'], $this->data['messages']) = $this->model_search_search->search_messages($this->request->post, SIMPLE_SEARCH, $this->data['page']);
|
||||
list ($this->data['n'], $this->data['all_ids'], $this->data['messages']) = $this->model_search_search->search_messages($this->request->post, $this->data['page']);
|
||||
}
|
||||
|
||||
|
||||
if($this->a['ref']) { $this->data['_ref'] = $this->a['ref']; }
|
||||
if(isset($this->request->post['ref']) && $this->request->post['ref']) { $this->data['_ref'] = $this->request->post['ref']; }
|
||||
|
||||
@ -97,24 +92,43 @@ class ControllerSearchHelper extends Controller {
|
||||
|
||||
|
||||
private function fixup_post_request() {
|
||||
$this->a['o_from'] = substr($this->a['o_from'], 1, strlen($this->a['o_from']));
|
||||
$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']));
|
||||
|
||||
if(isset($this->request->post['ref'])) { $this->a['ref'] = $this->request->post['ref']; }
|
||||
if(isset($this->request->post['folders'])) { $this->a['folders'] = $this->request->post['folders']; }
|
||||
|
||||
$this->a['sort'] = $this->request->post['sort'];
|
||||
$this->a['order'] = $this->request->post['order'];
|
||||
}
|
||||
|
||||
|
||||
private function naive_preprocess_post_expert_request($data = array()) {
|
||||
$ndate = 0;
|
||||
|
||||
if(!isset($data['search'])) { return; }
|
||||
|
||||
$b = preg_split("/\s/", $data['search']);
|
||||
|
||||
while(list($k, $v) = each($b)) {
|
||||
if($v == '') { continue; }
|
||||
|
||||
if(preg_match("/\d{4}\-\d{1,2}\-\d{1,2}/", $v)) {
|
||||
$ndate++;
|
||||
$this->a["date$ndate"] = $v;
|
||||
}
|
||||
else if(strchr($v, '@')) {
|
||||
$this->a['from'] .= " $v";
|
||||
}
|
||||
else { $this->a['any'] .= ' ' . $v; }
|
||||
}
|
||||
|
||||
if($this->a['date1'] && $this->a['date2'] == '') { $this->a['date2'] = $this->a['date1']; }
|
||||
|
||||
if($this->a['any'] == ' ' . $this->data['text_enter_search_terms']) { $this->a['any'] = ''; }
|
||||
}
|
||||
|
||||
|
||||
private function preprocess_post_expert_request($data = array()) {
|
||||
$token = '';
|
||||
$ndate = 0;
|
||||
|
||||
if(!isset($data['search'])) { return; }
|
||||
|
||||
@ -137,41 +151,37 @@ class ControllerSearchHelper extends Controller {
|
||||
else if($v == 'attachment:' || $v == 'a:') { $token = 'attachment_type'; continue; }
|
||||
else if($v == 'size') { $token = 'size'; continue; }
|
||||
else if($v == 'tag:') { $token = 'tag'; continue; }
|
||||
else if($v == 'note:') { $token = 'note'; continue; }
|
||||
else if($v == 'ref:') { $token = 'ref'; continue; }
|
||||
else { $this->a['any'] .= ' ' . $v; }
|
||||
else {
|
||||
if(preg_match("/\d{4}\-\d{1,2}\-\d{1,2}/", $v)) {
|
||||
$ndate++;
|
||||
$this->a["date$ndate"] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($token == 'from') {
|
||||
$v = fix_email_address($v);
|
||||
|
||||
if(substr($v, 0, 1) == '@') { $this->a['from_domain'] .= "|$v"; }
|
||||
else if(strstr($v, '@')) {
|
||||
if(in_array($v, $_SESSION['emails'])) { $this->a['o_from'] .= "|$v"; } else { $this->a['f_from'] .= "|$v"; }
|
||||
}
|
||||
else {
|
||||
$this->a['from'] .= " $v";
|
||||
}
|
||||
if($v == 'OR') { continue; }
|
||||
$this->a['from'] .= " $v";
|
||||
}
|
||||
|
||||
else if($token == 'to') {
|
||||
$v = fix_email_address($v);
|
||||
|
||||
if(substr($v, 0, 1) == '@') { $this->a['to_domain'] .= "|$v"; }
|
||||
else if(strstr($v, '@')) {
|
||||
if(in_array($v, $_SESSION['emails'])) { $this->a['o_to'] .= "|$v"; } else { $this->a['f_to'] .= "|$v"; }
|
||||
}
|
||||
else {
|
||||
$this->a['to'] .= " $v";
|
||||
}
|
||||
if($v == 'OR') { continue; }
|
||||
$this->a['to'] .= " $v";
|
||||
}
|
||||
|
||||
else if($token == 'subject') { $this->a['subject'] .= ' ' . $v; }
|
||||
else if($token == 'body') { $this->a['body'] .= ' ' . $v; }
|
||||
else if($token == 'date1') { $this->a['date1'] = ' ' . $v; }
|
||||
else if($token == 'date2') { $this->a['date2'] = ' ' . $v; }
|
||||
else if($token == 'attachment_type') { $this->a['attachment_type'] .= '|' . $v; }
|
||||
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 == 'direction') {
|
||||
if($v == 'inbound') { $this->a['direction'] = 0; }
|
||||
if($v == 'inbound') { $this->a['direction'] = "0"; }
|
||||
else if($v == 'outbound') { $this->a['direction'] = 2; }
|
||||
else if($v == 'internal') { $this->a['direction'] = 1; }
|
||||
}
|
||||
@ -205,52 +215,6 @@ class ControllerSearchHelper extends Controller {
|
||||
}
|
||||
|
||||
|
||||
private function preprocess_post_advanced_request($data = array()) {
|
||||
|
||||
if(isset($data['f'])) {
|
||||
foreach($data['f'] as $f) {
|
||||
$v = array_shift($data['v']);
|
||||
|
||||
if($v == '') { continue; }
|
||||
|
||||
if($f == 'from') {
|
||||
$v = fix_email_address($v);
|
||||
|
||||
if(substr($v, 0, 1) == '@') { $this->a['from_domain'] .= "|$v"; }
|
||||
else if(strstr($v, '@')) {
|
||||
if(in_array($v, $_SESSION['emails'])) { $this->a['o_from'] .= "|$v"; } else { $this->a['f_from'] .= "|$v"; }
|
||||
}
|
||||
else {
|
||||
$this->a['from'] .= " $v";
|
||||
}
|
||||
}
|
||||
|
||||
if($f == 'to') {
|
||||
$v = fix_email_address($v);
|
||||
|
||||
if(substr($v, 0, 1) == '@') { $this->a['to_domain'] .= "|$v"; }
|
||||
else if(strstr($v, '@')) {
|
||||
if(in_array($v, $_SESSION['emails'])) { $this->a['o_to'] .= "|$v"; } else { $this->a['f_to'] .= "|$v"; }
|
||||
}
|
||||
else {
|
||||
$this->a['to'] .= " $v";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($f == 'subject') { $this->a['subject'] .= ' ' . $v; }
|
||||
if($f == 'body') { $this->a['body'] .= ' ' . $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']; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
17
webui/controller/search/popup.php
Normal file
17
webui/controller/search/popup.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ControllerSearchPopup extends Controller {
|
||||
|
||||
protected function index() {
|
||||
|
||||
$this->id = "popup";
|
||||
$this->template = "search/popup.tpl";
|
||||
|
||||
$this->render();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -7,31 +7,16 @@ class ControllerSearchSearch extends Controller {
|
||||
|
||||
$this->id = "content";
|
||||
$this->template = "search/search.tpl";
|
||||
$this->layout = "common/layout-search";
|
||||
$this->layout = "common/layout-new";
|
||||
|
||||
$request = Registry::get('request');
|
||||
$db = Registry::get('db');
|
||||
|
||||
$this->load->model('search/search');
|
||||
|
||||
$this->document->title = $this->data['text_simple_search'];
|
||||
$this->document->title = $this->data['text_search'];
|
||||
|
||||
$this->data['searchtype'] = 'simple';
|
||||
|
||||
if(isset($this->request->get['type'])) {
|
||||
if($this->request->get['type'] == 'advanced') {
|
||||
$this->template = "search/advanced.tpl";
|
||||
$this->data['searchtype'] = 'advanced';
|
||||
$this->document->title = $this->data['text_advanced_search'];
|
||||
}
|
||||
|
||||
if($this->request->get['type'] == 'expert') {
|
||||
$this->template = "search/expert.tpl";
|
||||
$this->data['searchtype'] = 'expert';
|
||||
$this->document->title = $this->data['text_expert_search'];
|
||||
}
|
||||
|
||||
}
|
||||
$this->data['searchtype'] = 'expert';
|
||||
|
||||
if(isset($this->request->post['searchterm'])) {
|
||||
$this->fixup_post_request();
|
||||
@ -63,30 +48,6 @@ class ControllerSearchSearch extends Controller {
|
||||
if(isset($a['sort'])) { $this->data['sort'] = $a['sort']; }
|
||||
if(isset($a['order'])) { $this->data['order'] = $a['order']; }
|
||||
|
||||
if(isset($a['f'])) {
|
||||
foreach($a['f'] as $f) {
|
||||
$val = array_shift($a['v']);
|
||||
|
||||
if($val == '') { continue; }
|
||||
|
||||
if($i == 0) {
|
||||
$this->data['key0'] = 0;
|
||||
|
||||
if($f == 'from') { $this->data['key0'] = 0; }
|
||||
else if($f == 'to') { $this->data['key0'] = 1; }
|
||||
else if($f == 'subject') { $this->data['key0'] = 2; }
|
||||
else if($f == 'body') { $this->data['key0'] = 3; }
|
||||
|
||||
$this->data['val0'] = $val;
|
||||
}
|
||||
else {
|
||||
array_push($this->data['blocks'], array('key' => $f, 'val' => $val));
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($a['date1'])) { $this->data['date1'] = $a['date1']; }
|
||||
if(isset($a['date2'])) { $this->data['date2'] = $a['date2']; }
|
||||
|
||||
|
@ -19,11 +19,12 @@ class ControllerSearchTag extends Controller {
|
||||
|
||||
if(isset($this->request->post['tag']) && isset($this->request->post['idlist'])) {
|
||||
$idlist = explode(",", $this->request->post['idlist']);
|
||||
|
||||
if(count($idlist) > 0) {
|
||||
|
||||
$q = '';
|
||||
|
||||
list($ids, $a) = $this->model_search_search->check_your_permission_by_id_list($idlist);
|
||||
$ids = $this->model_search_search->check_your_permission_by_id_list($idlist);
|
||||
|
||||
for($i=0; $i<count($ids); $i++) { $q .= ",?"; }
|
||||
$q = preg_replace("/^\,/", "", $q);
|
||||
@ -31,10 +32,6 @@ class ControllerSearchTag extends Controller {
|
||||
$this->model_search_message->bulk_add_message_tag($ids, $_SESSION['uid'], $this->request->post['tag'], $q);
|
||||
}
|
||||
}
|
||||
|
||||
/*$this->data['message'] = 'I tagged this!';
|
||||
|
||||
$this->render();*/
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user