mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-25 07:10:12 +01:00
Added support for wildcard domains
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
parent
b5a8255be1
commit
bfeef2669e
@ -53,6 +53,11 @@ class ControllerUserSettings extends Controller {
|
|||||||
if($auditgroups) { $this->data['groups'] = $auditgroups; } else { $this->data['groups'] = $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']; }
|
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'])) {
|
if(isset($this->request->post['pagelen']) && isset($this->request->post['theme'])) {
|
||||||
$this->model_user_prefs->set_user_preferences(Registry::get('username'), $this->request->post);
|
$this->model_user_prefs->set_user_preferences(Registry::get('username'), $this->request->post);
|
||||||
|
|
||||||
|
@ -81,8 +81,14 @@ class ModelSearchSearch extends Model {
|
|||||||
|
|
||||||
if(ENABLE_FOLDER_RESTRICTIONS == 1) { return ""; }
|
if(ENABLE_FOLDER_RESTRICTIONS == 1) { return ""; }
|
||||||
|
|
||||||
$all_your_addresses = $this->get_all_your_address();
|
$all_your_addresses = $this->get_all_your_address("emails");
|
||||||
return sprintf(" (%s %s | %s %s) ", FROM_TOKEN, $all_your_addresses, TO_TOKEN, $all_your_addresses);
|
$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 = '';
|
$s = '';
|
||||||
|
|
||||||
$session = Registry::get('session');
|
$session = Registry::get('session');
|
||||||
|
|
||||||
$emails = $session->get("emails");
|
$emails = $session->get($session_var);
|
||||||
|
|
||||||
while(list($k, $v) = each($emails)) {
|
while(list($k, $v) = each($emails)) {
|
||||||
if($s) { $s .= '| ' . $this->fix_email_address_for_sphinx($v); }
|
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 = '') {
|
public function check_your_permission_by_id($id = '') {
|
||||||
$q = '';
|
$q = '';
|
||||||
$arr = $a = array();
|
$arr = $a = array();
|
||||||
@ -717,7 +742,8 @@ class ModelSearchSearch extends Model {
|
|||||||
if(Registry::get('auditor_user') == 1 && RESTRICTED_AUDITOR == 1) {
|
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);
|
$query = $this->db->query("SELECT id FROM " . VIEW_MESSAGES . " WHERE id=? AND ( `fromdomain` IN ($q) OR `todomain` IN ($q) )", $arr);
|
||||||
} else {
|
} 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; }
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,7 @@
|
|||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="span2"><?php print $text_email_addresses; ?>:</td>
|
<td class="span2"><?php print $text_email_addresses; ?>:</td>
|
||||||
<td class="span8">
|
<td class="span8"><?php print $emails; ?>
|
||||||
<?php print $emails; ?>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@ -16,9 +15,7 @@
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php print $text_domains; ?>:</td>
|
<td><?php print $text_domains; ?>:</td>
|
||||||
<td>
|
<td><?php print $domains; ?></td>
|
||||||
<?php print $domains; ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
@ -27,20 +24,24 @@
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php print $text_groups; ?>:</td>
|
<td><?php print $text_groups; ?>:</td>
|
||||||
<td>
|
<td><?php print $groups; ?></td>
|
||||||
<?php print $groups; ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<?php if($wildcard_domains) { ?>
|
||||||
|
<tr>
|
||||||
|
<td>Wildcard domains:</td>
|
||||||
|
<td><?php print $wildcard_domains; ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<?php if(ENABLE_FOLDER_RESTRICTIONS == 1) { ?>
|
<?php if(ENABLE_FOLDER_RESTRICTIONS == 1) { ?>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php print $text_folders; ?>:</td>
|
<td><?php print $text_folders; ?>:</td>
|
||||||
<td>
|
<td><?php print $folders; ?></td>
|
||||||
<?php print $folders; ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user