mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-24 04:40:13 +01:00
Added support for wildcard domains
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
parent
b5a8255be1
commit
bfeef2669e
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,55 +1,56 @@
|
||||
|
||||
<?php if(!isset($x)){ ?>
|
||||
|
||||
<h4><?php print $text_access_settings; ?></h4>
|
||||
<h4><?php print $text_access_settings; ?></h4>
|
||||
<p><em><?php print $text_access_setting_explanation; ?></em></p>
|
||||
|
||||
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<td class="span2"><?php print $text_email_addresses; ?>:</td>
|
||||
<td class="span8">
|
||||
<?php print $emails; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="span2"><?php print $text_email_addresses; ?>:</td>
|
||||
<td class="span8"><?php print $emails; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php if(Registry::get('auditor_user') == 1 && RESTRICTED_AUDITOR == 1) { ?>
|
||||
|
||||
<tr>
|
||||
<td><?php print $text_domains; ?>:</td>
|
||||
<td>
|
||||
<?php print $domains; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><?php print $text_domains; ?>:</td>
|
||||
<td><?php print $domains; ?></td>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<?php if(Registry::get('auditor_user') == 0 || RESTRICTED_AUDITOR == 0) { ?>
|
||||
|
||||
<tr>
|
||||
<td><?php print $text_groups; ?>:</td>
|
||||
<td>
|
||||
<?php print $groups; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><?php print $text_groups; ?>:</td>
|
||||
<td><?php print $groups; ?></td>
|
||||
</tr>
|
||||
|
||||
<?php if($wildcard_domains) { ?>
|
||||
<tr>
|
||||
<td>Wildcard domains:</td>
|
||||
<td><?php print $wildcard_domains; ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<?php if(ENABLE_FOLDER_RESTRICTIONS == 1) { ?>
|
||||
|
||||
<tr>
|
||||
<td><?php print $text_folders; ?>:</td>
|
||||
<td>
|
||||
<?php print $folders; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><?php print $text_folders; ?>:</td>
|
||||
<td><?php print $folders; ?></td>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
<form action="/settings.php" method="post" name="setpagelen" class="form-horizontal">
|
||||
|
||||
<h4><?php print $text_display_settings; ?></h4>
|
||||
|
||||
<h4><?php print $text_display_settings; ?></h4>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="pagelen"><?php print $text_page_length; ?></label>
|
||||
@ -89,7 +90,7 @@
|
||||
<input type="submit" value="<?php print $text_set; ?>" class="btn btn-primary" /> <input type="reset" value="<?php print $text_cancel; ?>" class="btn btn" onclick="Piler.go_to_default_page();" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
<?php if(ENABLE_GOOGLE_AUTHENTICATOR == 1) { ?>
|
||||
|
Loading…
Reference in New Issue
Block a user