folder fixes

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO 2020-12-21 21:52:16 +01:00
parent 1288c9fed3
commit fbbdce7f99
6 changed files with 22 additions and 16 deletions

View File

@ -375,6 +375,8 @@ include("system/helper/detectmobilebrowser.php");
// make sure auditors are restricted in a saas environment
if($config['ENABLE_SAAS'] == 1) { $config['RESTRICTED_AUDITOR'] = 1; }
if($session->get("username") == 'auditor@local' || isset($_SERVER['argv'][2]) ) { $config['RESTRICTED_AUDITOR'] = 0; }
// disable folders for normal users with no folder restrictions set
if($config['ENABLE_FOLDER_RESTRICTIONS'] == 1 && $session->get("admin_user") == 0 && (!$session->get("folders") || count($session->get("folders")) <= 1)) { $config['ENABLE_FOLDER_RESTRICTIONS'] = 0; }

View File

@ -15,7 +15,6 @@ class ControllerSearchFolder extends Controller {
$this->load->model('folder/folder');
$this->data['extra_folders'] = $this->model_folder_folder->get_folders_for_user();
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"));

View File

@ -57,17 +57,20 @@ class ModelFolderFolder extends Model {
public function get_folders_for_user() {
$session = Registry::get('session');
$folders = $session->get("folders");
$q = str_repeat("?,", count($session->get("folders")));
$q = str_repeat("?,", count($folders));
$q = preg_replace("/\,$/", "", $q);
if(isAuditorUser() == 1) {
$query = $this->db->query("SELECT `id`, `name` FROM `" . TABLE_FOLDER);
} else {
$query = $this->db->query("SELECT `id`, `name` FROM `" . TABLE_FOLDER . "` WHERE id IN ($q)", $session->get("folders"));
}
$query = $this->db->query("SELECT `id`, `name` FROM `" . TABLE_FOLDER . "` WHERE id IN ($q)", $folders);
if(isset($query->rows)) { return $query->rows; }
if(isset($query->rows)) {
$arr = $query->rows;
if(in_array(0, $folders, TRUE)) {
array_unshift($arr, array('id' => 0, 'name' => '---'));
}
return $arr;
}
return array();
}
@ -95,11 +98,12 @@ class ModelFolderFolder extends Model {
public function get_folder_id_array_for_user($uid = 0, $is_admin = 0) {
$arr = array();
$add_folder0 = ($is_admin == 0);
if($is_admin == 2) {
$query = $this->db->query("SELECT id FROM `" . TABLE_FOLDER);
} else {
$query = $this->db->query("SELECT id FROM `" . TABLE_FOLDER_USER . "` WHERE uid=?", array($uid));
if($is_admin == 2 && (!isset($query->rows) || count($query->rows) == 0)) {
$query = $this->db->query("SELECT id FROM `" . TABLE_FOLDER);
$add_folder0 = 1;
}
if(isset($query->rows)) {
@ -109,6 +113,10 @@ class ModelFolderFolder extends Model {
}
}
if($add_folder0 == 1) {
array_unshift($arr, 0);
}
return $arr;
}

View File

@ -79,8 +79,6 @@ class ModelSearchSearch extends Model {
else { return ""; }
}
if(ENABLE_FOLDER_RESTRICTIONS == 1) { return ""; }
$all_your_addresses = $this->get_all_your_address("emails");
$all_your_wildcard_domains = $this->get_all_your_address("wildcard_domains");
@ -219,7 +217,7 @@ class ModelSearchSearch extends Model {
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);
}
else if(ENABLE_FOLDER_RESTRICTIONS == 1 && isset($data['extra_folders']) && strlen($data['extra_folders']) > 0) {
else if(ENABLE_FOLDER_RESTRICTIONS == 1 && isset($data['extra_folders'])) {
$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;

View File

@ -55,7 +55,6 @@
<div id="folderbox" class="input-prepend input-append">
<span class="add-on"><i class="icon-folder-open-alt icon-large"></i>&nbsp;<?php print $text_folder; ?>:</span>
<select name="folder_id" id="folder_id" class="span2">
<option value="0" <?php if($folder_id == 0) { ?>selected="selected"<?php } ?>>---</option>
<?php foreach ($folders as $folder) { ?>
<option value="<?php print $folder['id']; ?>" <?php if($folder_id == $folder['id']) { ?>selected="selected"<?php } ?>><?php print $folder['name']; ?></option>
<?php } ?>

View File

@ -4,7 +4,7 @@
<?php foreach ($extra_folders as $folder) { ?>
<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="extra_folder_<?php print $folder['id']; ?>" name="extra_folder_<?php print $folder['id']; ?>" style="margin:0;" class="foldercheckbox" checked="checked" /> <?php print $folder['name']; ?></label>
</div>
<?php } ?>