mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-25 18:50:12 +01:00
gui: folder search improvements
Change-Id: Ia098c7c2efcb9011e706012ee074e0c354bebded Signed-off-by: SJ <sj@acts.hu>
This commit is contained in:
parent
3107683386
commit
857f5e549d
@ -14,10 +14,7 @@ class ControllerSearchFolder extends Controller {
|
|||||||
|
|
||||||
$this->load->model('folder/folder');
|
$this->load->model('folder/folder');
|
||||||
|
|
||||||
$this->data['extra_folders'] = $this->model_folder_folder->get_folders_for_user();
|
$this->data['folders'] = $session->get("folders");
|
||||||
array_unshift($this->data['extra_folders'], array('id' => 0, 'name' => '---'));
|
|
||||||
|
|
||||||
$this->data['folders_by_hier'] = $this->model_folder_folder->get_all_folder_ids_hier($session->get("uid"));
|
|
||||||
|
|
||||||
$this->render();
|
$this->render();
|
||||||
}
|
}
|
||||||
|
@ -81,8 +81,6 @@ class ModelSearchSearch extends Model {
|
|||||||
else { return ""; }
|
else { return ""; }
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ENABLE_FOLDER_RESTRICTIONS == 1) { return ""; }
|
|
||||||
|
|
||||||
$all_your_addresses = $this->get_all_your_address();
|
$all_your_addresses = $this->get_all_your_address();
|
||||||
return " (@from $all_your_addresses | @to $all_your_addresses) ";
|
return " (@from $all_your_addresses | @to $all_your_addresses) ";
|
||||||
}
|
}
|
||||||
@ -90,9 +88,9 @@ class ModelSearchSearch extends Model {
|
|||||||
|
|
||||||
private function get_results($data = array(), $sort = 'sent', $order = 'DESC', $sortorder = '', $page = 0) {
|
private function get_results($data = array(), $sort = 'sent', $order = 'DESC', $sortorder = '', $page = 0) {
|
||||||
$ids = array();
|
$ids = array();
|
||||||
$__folders = array();
|
$folders = $search_folders = array();
|
||||||
$match = '';
|
$match = '';
|
||||||
$direction = $attachment = $size = $folders = '';
|
$direction = $attachment = $size = '';
|
||||||
$tag_id_list = '';
|
$tag_id_list = '';
|
||||||
$a = "";
|
$a = "";
|
||||||
$id = "";
|
$id = "";
|
||||||
@ -190,19 +188,14 @@ class ModelSearchSearch extends Model {
|
|||||||
|
|
||||||
|
|
||||||
if(ENABLE_FOLDER_RESTRICTIONS == 1) {
|
if(ENABLE_FOLDER_RESTRICTIONS == 1) {
|
||||||
|
$folders = $session->get("folders");
|
||||||
|
|
||||||
$s = explode(" ", $data['folders']);
|
$s = explode(" ", $data['folders']);
|
||||||
while(list($k,$v) = each($s)) {
|
while(list($k,$v) = each($s)) {
|
||||||
if(in_array($v, $session->get("folders"))) {
|
if(in_array($v, $folders)) {
|
||||||
array_push($__folders, $v);
|
array_push($search_folders, $v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($__folders) > 0) {
|
|
||||||
$folders = "folder IN (" . implode(",", $__folders) . ") AND ";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$folders = "folder IN (" . implode(",", $session->get("folders")) . ") AND ";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -216,16 +209,8 @@ class ModelSearchSearch extends Model {
|
|||||||
$total_found = $query->total_found;
|
$total_found = $query->total_found;
|
||||||
$num_rows = $query->num_rows;
|
$num_rows = $query->num_rows;
|
||||||
}
|
}
|
||||||
else if(isset($data['folder']) && $data['folder']) {
|
else if(ENABLE_FOLDER_RESTRICTIONS == 1 && count($search_folders) > 0) {
|
||||||
$folder_id = -1;
|
$q2 = "?" . str_repeat(",?", count($search_folders)-1);
|
||||||
|
|
||||||
$folders = $session->get("folders");
|
|
||||||
|
|
||||||
$data['folder'] = trim($data['folder']);
|
|
||||||
|
|
||||||
if(isset($folders[$data['folder']])) {
|
|
||||||
$folder_id = $folders[$data['folder']];
|
|
||||||
}
|
|
||||||
|
|
||||||
if($data['match']) {
|
if($data['match']) {
|
||||||
|
|
||||||
@ -243,13 +228,15 @@ class ModelSearchSearch extends Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// run a final query to filter which messages are in this folder
|
// run a final query to filter which messages are in this folder
|
||||||
$q = "?" . str_repeat(",?", count($f_bag)-1);
|
$q1 = "?" . str_repeat(",?", count($f_bag)-1);
|
||||||
array_push($f_bag, $folder_id);
|
$f_bag = array_merge($f_bag, $search_folders);
|
||||||
|
|
||||||
$query = $this->db->query("SELECT id FROM " . TABLE_FOLDER_MESSAGE . " WHERE message_id in ($q) AND folder_id=?", $f_bag);
|
$query = $this->db->query("SELECT id FROM " . TABLE_FOLDER_MESSAGE . " WHERE message_id IN ($q1) AND folder_id IN ($q2)", $f_bag);
|
||||||
|
|
||||||
|
if(LOG_LEVEL >= NORMAL) { syslog(LOG_INFO, sprintf("sql query: '%s' in %.2f s, %d hits", $query->query, $query->exec_time, $query->num_rows)); }
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$query = $this->sphx->query("SELECT message_id FROM " . SPHINX_FOLDER_INDEX . " WHERE folder_id=$folder_id $sortorder LIMIT $offset,$pagelen OPTION max_matches=" . MAX_SEARCH_HITS);
|
$query = $this->sphx->query("SELECT message_id FROM " . SPHINX_FOLDER_INDEX . " WHERE folder_id IN ($q2) $sortorder LIMIT $offset,$pagelen OPTION max_matches=" . MAX_SEARCH_HITS, $search_folders);
|
||||||
}
|
}
|
||||||
|
|
||||||
$total_found = $query->total_found;
|
$total_found = $query->total_found;
|
||||||
@ -262,13 +249,8 @@ class ModelSearchSearch extends Model {
|
|||||||
list ($total_found, $num_rows, $id_list) = $this->get_sphinx_id_list($data['note'], SPHINX_NOTE_INDEX, 'note', $page);
|
list ($total_found, $num_rows, $id_list) = $this->get_sphinx_id_list($data['note'], SPHINX_NOTE_INDEX, 'note', $page);
|
||||||
$query = $this->sphx->query("SELECT id FROM " . SPHINX_MAIN_INDEX . " WHERE $folders id IN ($id_list) $sortorder LIMIT 0,$pagelen OPTION max_matches=" . MAX_SEARCH_HITS);
|
$query = $this->sphx->query("SELECT id FROM " . SPHINX_MAIN_INDEX . " WHERE $folders id IN ($id_list) $sortorder LIMIT 0,$pagelen OPTION max_matches=" . MAX_SEARCH_HITS);
|
||||||
}
|
}
|
||||||
else if(ENABLE_FOLDER_RESTRICTIONS == 1 && isset($data['extra_folders']) && strlen($data['extra_folders']) > 0) {
|
|
||||||
$query = $this->sphx->query("SELECT id FROM " . SPHINX_MAIN_INDEX . " WHERE $a $id $date $attachment $direction $size folder IN (" . preg_replace("/ /", ",", $data['extra_folders']) . ") AND MATCH('$match') $sortorder LIMIT $offset,$pagelen OPTION max_matches=" . MAX_SEARCH_HITS);
|
|
||||||
$total_found = $query->total_found;
|
|
||||||
$num_rows = $query->num_rows;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
$query = $this->sphx->query("SELECT id FROM " . SPHINX_MAIN_INDEX . " WHERE $a $id $date $attachment $direction $size $folders MATCH('$match') $sortorder LIMIT $offset,$pagelen 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') $sortorder LIMIT $offset,$pagelen OPTION max_matches=" . MAX_SEARCH_HITS);
|
||||||
$total_found = $query->total_found;
|
$total_found = $query->total_found;
|
||||||
$num_rows = $query->num_rows;
|
$num_rows = $query->num_rows;
|
||||||
}
|
}
|
||||||
@ -333,14 +315,6 @@ class ModelSearchSearch extends Model {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ENABLE_FOLDER_RESTRICTIONS == 1) {
|
|
||||||
$query = $this->sphx->query("SELECT id, folder FROM " . SPHINX_MAIN_INDEX . " WHERE id IN (" . implode(",", $ids) . ")");
|
|
||||||
$ids = array();
|
|
||||||
foreach($query->rows as $q) {
|
|
||||||
if(isset($q['folder']) && in_array($q['folder'], $session->get("folders"))) { array_push($ids, $q['id']); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$total_found = count($ids);
|
$total_found = count($ids);
|
||||||
|
|
||||||
if($total_found >= $pagelen) {
|
if($total_found >= $pagelen) {
|
||||||
@ -761,19 +735,13 @@ class ModelSearchSearch extends Model {
|
|||||||
|
|
||||||
$arr = array_merge($arr, $a, $a);
|
$arr = array_merge($arr, $a, $a);
|
||||||
|
|
||||||
if(ENABLE_FOLDER_RESTRICTIONS == 1) {
|
if(Registry::get('auditor_user') == 1 && RESTRICTED_AUDITOR == 1) {
|
||||||
$query = $this->sphx->query("SELECT folder FROM " . SPHINX_MAIN_INDEX . " WHERE id=" . (int)$id);
|
$query = $this->db->query("SELECT id FROM " . VIEW_MESSAGES . " WHERE id=? AND ( `fromdomain` IN ($q) OR `todomain` IN ($q) )", $arr);
|
||||||
if(isset($query->row['folder']) && in_array($query->row['folder'], $session->get("folders"))) { return 1; }
|
} else {
|
||||||
|
$query = $this->db->query("SELECT id FROM " . VIEW_MESSAGES . " WHERE id=? AND ( `from` IN ($q) OR `to` IN ($q) )", $arr);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if(Registry::get('auditor_user') == 1 && RESTRICTED_AUDITOR == 1) {
|
|
||||||
$query = $this->db->query("SELECT id FROM " . VIEW_MESSAGES . " WHERE id=? AND ( `fromdomain` IN ($q) OR `todomain` IN ($q) )", $arr);
|
|
||||||
} else {
|
|
||||||
$query = $this->db->query("SELECT id FROM " . VIEW_MESSAGES . " WHERE id=? AND ( `from` IN ($q) OR `to` IN ($q) )", $arr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($query->row['id'])) { return 1; }
|
if(isset($query->row['id'])) { return 1; }
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -832,34 +800,26 @@ class ModelSearchSearch extends Model {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
if(ENABLE_FOLDER_RESTRICTIONS == 1) {
|
$arr = array_merge($arr, $a, $a);
|
||||||
$query = $this->sphx->query("SELECT id, folder FROM " . SPHINX_MAIN_INDEX . " WHERE id IN (" . implode(",", $id) . ")");
|
if(Registry::get('auditor_user') == 1 && RESTRICTED_AUDITOR == 1) {
|
||||||
}
|
$query = $this->db->query("SELECT id FROM `" . VIEW_MESSAGES . "` WHERE `id` IN ($q2) AND ( `fromdomain` IN ($q) OR `todomain` IN ($q) )", $arr);
|
||||||
else {
|
} else {
|
||||||
$arr = array_merge($arr, $a, $a);
|
|
||||||
if(Registry::get('auditor_user') == 1 && RESTRICTED_AUDITOR == 1) {
|
|
||||||
$query = $this->db->query("SELECT id FROM `" . VIEW_MESSAGES . "` WHERE `id` IN ($q2) AND ( `fromdomain` IN ($q) OR `todomain` IN ($q) )", $arr);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
$query = $this->db->query("SELECT id FROM " . TABLE_PRIVATE . " WHERE `id` IN ($q2)", $id);
|
$query = $this->db->query("SELECT id FROM " . TABLE_PRIVATE . " WHERE `id` IN ($q2)", $id);
|
||||||
if($query->num_rows > 0) {
|
if($query->num_rows > 0) {
|
||||||
foreach ($query->rows as $r) {
|
foreach ($query->rows as $r) {
|
||||||
array_push($parr, $r['id']);
|
array_push($parr, $r['id']);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = $this->db->query("SELECT id FROM `" . VIEW_MESSAGES . "` WHERE `id` IN ($q2) AND ( `from` IN ($q) OR `to` IN ($q) )", $arr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$query = $this->db->query("SELECT id FROM `" . VIEW_MESSAGES . "` WHERE `id` IN ($q2) AND ( `from` IN ($q) OR `to` IN ($q) )", $arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($query->num_rows > 0) {
|
if($query->num_rows > 0) {
|
||||||
foreach ($query->rows as $q) {
|
foreach ($query->rows as $q) {
|
||||||
if(ENABLE_FOLDER_RESTRICTIONS == 1) {
|
if(!in_array($q['id'], $result) && !in_array($q['id'], $parr)) {
|
||||||
if(in_array($q['folder'], $session->get("folders"))) { array_push($result, $q['id']); }
|
|
||||||
}
|
|
||||||
else if(!in_array($q['id'], $result) && !in_array($q['id'], $parr)) {
|
|
||||||
array_push($result, $q['id']);
|
array_push($result, $q['id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1669,7 +1669,7 @@ html,body{height:auto !important;height:100%;min-height:100%;}
|
|||||||
#searchcontainer #button_audit{width:100%;}
|
#searchcontainer #button_audit{width:100%;}
|
||||||
#searchcontainer #button_search,#searchcontainer #button_options{width:30%;}
|
#searchcontainer #button_search,#searchcontainer #button_options{width:30%;}
|
||||||
#mainscreen{position:absolute;top:120px;right:20px;bottom:20px;left:20px;min-width:320px;z-index:0;}
|
#mainscreen{position:absolute;top:120px;right:20px;bottom:20px;left:20px;min-width:320px;z-index:0;}
|
||||||
#mailleftcontainer{position:absolute;top:0;left:0;bottom:0;width:195px;}
|
#mailleftcontainer{position:absolute;top:0;left:0;bottom:0;width:195px;border:1px solid #999999;}
|
||||||
#mailboxlist-container{position:absolute;top:0;left:0;width:100%;bottom:0;border:1px solid #999999;border-top:none;background-color:#f9f9f9;overflow:auto;}
|
#mailboxlist-container{position:absolute;top:0;left:0;width:100%;bottom:0;border:1px solid #999999;border-top:none;background-color:#f9f9f9;overflow:auto;}
|
||||||
.boxlistcontent{position:absolute;top:0px;bottom:34px;left:0;right:0;width:100%;overflow-y:auto;overflow-x:hidden;height:auto;}
|
.boxlistcontent{position:absolute;top:0px;bottom:34px;left:0;right:0;width:100%;overflow-y:auto;overflow-x:hidden;height:auto;}
|
||||||
.boxfooter{position:absolute;bottom:0px;left:0px;right:0px;overflow:hidden;height:33px;border-top:1px solid #ccc;background-color:#f6f6f6;min-width:320px;}
|
.boxfooter{position:absolute;bottom:0px;left:0px;right:0px;overflow:hidden;height:33px;border-top:1px solid #ccc;background-color:#f6f6f6;min-width:320px;}
|
||||||
|
@ -2,44 +2,10 @@
|
|||||||
|
|
||||||
<div id="folders">
|
<div id="folders">
|
||||||
|
|
||||||
<?php foreach ($extra_folders as $folder) { ?>
|
<?php while(list($k,$v) = each($folders)) { ?>
|
||||||
<div>
|
<div>
|
||||||
<label class="folderlabel"><input type="checkbox" id="extra_folder_<?php print $folder['id']; ?>" name="extra_folder_<?php print $folder['id']; ?>" style="margin:0;" class="foldercheckbox" /> <?php print $folder['name']; ?></label>
|
<label class="folderlabel"><input type="checkbox" id="folder_<?php print $v; ?>" name="folder_<?php print $v; ?>" style="margin:0;" class="foldercheckbox" /> <?php print $k; ?></label>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
function display_folders($arr = array(), &$i) {
|
|
||||||
|
|
||||||
?>
|
|
||||||
<blockquote id="fldr_<?php print $i; ?>" class="folder">
|
|
||||||
<?php
|
|
||||||
$i++;
|
|
||||||
|
|
||||||
foreach($arr as $a) {
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php if(count($a['children']) > 0) { ?>
|
|
||||||
<a id="fldr_collapse_<?php print $i; ?>" href="#" onclick="Piler.close_folder(<?php print $i; ?>); return false;"><img src="<?php print ICON_MINUS; ?>" alt="" /></a>
|
|
||||||
<a id="fldr_open_<?php print $i; ?>" href="#" onclick="Piler.open_folder(<?php print $i; ?>); return false;" style="display:none;"><img src="<?php print ICON_PLUS; ?>" alt="" /></a>
|
|
||||||
<?php } else { ?> <img src="<?php print ICON_EMPTY; ?>" width="12" height="12" alt="" /> <?php } ?>
|
|
||||||
<input type="checkbox" id="folder_<?php print $a['id']; ?>" name="folder_<?php print $a['id']; ?>" /> <?php print $a['name']; ?><br />
|
|
||||||
|
|
||||||
<?php
|
|
||||||
if(count($a['children'])) { display_folders($a['children'], $i); }
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
</blockquote>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
$i = 0;
|
|
||||||
//display_folders($folders_by_hier, $i);
|
|
||||||
?>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user