diff --git a/webui/controller/user/settings.php b/webui/controller/user/settings.php index e0fe061c..a5ec49cc 100644 --- a/webui/controller/user/settings.php +++ b/webui/controller/user/settings.php @@ -26,14 +26,14 @@ class ControllerUserSettings extends Controller { $this->data['ga'] = $this->model_user_prefs->get_ga_settings($session->get('username')); $this->document->title = $this->data['text_settings']; - + $d = $r = ''; $auditemails = $auditdomains = $auditgroups = $auditfolders = ''; $auditemails = implode(", ", $session->get("emails")); - + $_auditdomains = $session->get("auditdomains"); - + foreach($_auditdomains as $d) { $auditdomains .= ', ' . $d; } @@ -42,17 +42,22 @@ class ControllerUserSettings extends Controller { $auditgroups = preg_replace("/\n/", ", ", $this->model_group_group->get_groups_by_email($session->get("emails"))); $folders = $session->get("folders"); - + foreach ($folders as $r) { $auditfolders .= ', ' . $r; } - $auditfolders = preg_replace("/^,\s/", "", $auditfolders); - + $auditfolders = preg_replace("/^,\s/", "", $auditfolders); + if($auditemails) { $this->data['emails'] = $auditemails; } else { $this->data['emails'] = $this->data['text_none_found']; } if($auditdomains) { $this->data['domains'] = $auditdomains; } else { $this->data['domains'] = $this->data['text_none_found']; } if($auditgroups) { $this->data['groups'] = $auditgroups; } else { $this->data['groups'] = $this->data['text_none_found']; } if($auditfolders) { $this->data['folders'] = $auditfolders; } else { $this->data['folders'] = $this->data['text_none_found']; } + $this->data['wildcard_domains'] = $session->get("wildcard_domains"); + if($this->data['wildcard_domains']) { + $this->data['wildcard_domains'] = implode(", ", $this->data['wildcard_domains']); + } + if(isset($this->request->post['pagelen']) && isset($this->request->post['theme'])) { $this->model_user_prefs->set_user_preferences(Registry::get('username'), $this->request->post); diff --git a/webui/model/search/search.php b/webui/model/search/search.php index 06cf54e2..cc6a5db9 100644 --- a/webui/model/search/search.php +++ b/webui/model/search/search.php @@ -81,8 +81,14 @@ class ModelSearchSearch extends Model { if(ENABLE_FOLDER_RESTRICTIONS == 1) { return ""; } - $all_your_addresses = $this->get_all_your_address(); - return sprintf(" (%s %s | %s %s) ", FROM_TOKEN, $all_your_addresses, TO_TOKEN, $all_your_addresses); + $all_your_addresses = $this->get_all_your_address("emails"); + $all_your_wildcard_domains = $this->get_all_your_address("wildcard_domains"); + + if($all_your_wildcard_domains) { + return sprintf(" ( (%s %s) | (%s %s) | (%s %s) | (%s %s) ) ", FROM_TOKEN, $all_your_addresses, TO_TOKEN, $all_your_addresses, FROMDOMAIN_TOKEN, $all_your_wildcard_domains, TODOMAIN_TOKEN, $all_your_wildcard_domains); + } else { + return sprintf(" ( (%s %s) | (%s %s) ) ", FROM_TOKEN, $all_your_addresses, TO_TOKEN, $all_your_addresses); + } } @@ -645,12 +651,12 @@ class ModelSearchSearch extends Model { } - private function get_all_your_address() { + private function get_all_your_address($session_var) { $s = ''; $session = Registry::get('session'); - $emails = $session->get("emails"); + $emails = $session->get($session_var); while(list($k, $v) = each($emails)) { if($s) { $s .= '| ' . $this->fix_email_address_for_sphinx($v); } @@ -661,6 +667,25 @@ class ModelSearchSearch extends Model { } + private function get_wildcard_domains($arr=[]) { + $query_suffix = ''; + $results = $arr; + + $session = Registry::get('session'); + + $wildcard_domains = $session->get('wildcard_domains'); + + if($wildcard_domains) { + $q = str_repeat('?,', count($wildcard_domains)); + $q = trim($q, ','); + $results = array_merge($results, $wildcard_domains, $wildcard_domains); + $query_suffix = "OR fromdomain IN ($q) OR todomain IN ($q)"; + } + + return [$results, $query_suffix]; + } + + public function check_your_permission_by_id($id = '') { $q = ''; $arr = $a = array(); @@ -717,7 +742,8 @@ class ModelSearchSearch extends Model { 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); + [$arr, $query_suffix] = $this->get_wildcard_domains($arr); + $query = $this->db->query("SELECT id FROM " . VIEW_MESSAGES . " WHERE id=? AND ( `from` IN ($q) OR `to` IN ($q) $query_suffix )", $arr); } if(isset($query->row['id'])) { return 1; } @@ -796,7 +822,9 @@ class ModelSearchSearch extends Model { } } - $query = $this->db->query("SELECT id FROM `" . VIEW_MESSAGES . "` WHERE `id` IN ($q2) AND ( `from` IN ($q) OR `to` IN ($q) )", $arr); + [$arr, $query_suffix] = $this->get_wildcard_domains($arr); + + $query = $this->db->query("SELECT id FROM `" . VIEW_MESSAGES . "` WHERE `id` IN ($q2) AND ( `from` IN ($q) OR `to` IN ($q) $query_suffix)", $arr); } } diff --git a/webui/view/theme/default/templates/user/settings.tpl b/webui/view/theme/default/templates/user/settings.tpl index d36c1d80..f90f1a72 100644 --- a/webui/view/theme/default/templates/user/settings.tpl +++ b/webui/view/theme/default/templates/user/settings.tpl @@ -1,55 +1,56 @@ -

+

- + - - - - - + + + + + - - - - - + + + + + - + - - - - - + + + + + + + + + + + + + - + - - - - - + + + + + - +
: - -
: +
: - -
:
: - -
:
Wildcard domains:
: - -
:
- +
- -

+ +

@@ -89,7 +90,7 @@
- +