mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-08 00:51:59 +01:00
added a select option to auditors to define the recipients of the message to be restored
This commit is contained in:
parent
cc55883b35
commit
a079c915c6
@ -46,7 +46,7 @@ class ControllerMessageBulkrestore extends Controller {
|
||||
|
||||
$rcpt = array();
|
||||
|
||||
/* send the email to all the recipients of the original email if we are admin or auditor users */
|
||||
/* send the email to all the recipients of the original email if you are an auditor user */
|
||||
|
||||
if(Registry::get('auditor_user') == 1) {
|
||||
$rcpt = $this->model_search_search->get_message_recipients($id);
|
||||
|
@ -33,6 +33,8 @@ class ControllerMessageHeaders extends Controller {
|
||||
|
||||
AUDIT(ACTION_VIEW_HEADER, '', '', $this->data['id'], '');
|
||||
|
||||
if(Registry::get('auditor_user') == 1) { $this->data['rcpt'] = $this->model_search_search->get_message_addresses_in_my_domain($this->data['id']); }
|
||||
|
||||
$this->data['piler_id'] = $this->model_search_message->get_piler_id_by_id($this->data['id']);
|
||||
|
||||
$this->data['data'] = $this->model_search_message->get_message_headers($this->data['piler_id']);
|
||||
|
@ -22,6 +22,14 @@ class ControllerMessageRestore extends Controller {
|
||||
|
||||
$this->data['id'] = @$this->request->get['id'];
|
||||
|
||||
$rcpt = array();
|
||||
|
||||
if(Registry::get('auditor_user') == 1) {
|
||||
$this->data['id'] = @$this->request->post['id'];
|
||||
$rcpt = preg_split("/\s/", $this->request->post['rcpt']);
|
||||
}
|
||||
|
||||
|
||||
if(!verify_piler_id($this->data['id'])) {
|
||||
AUDIT(ACTION_UNKNOWN, '', '', $this->data['id'], 'unknown piler id: ' . $this->data['id']);
|
||||
die("invalid id: " . $this->data['id']);
|
||||
@ -37,26 +45,24 @@ class ControllerMessageRestore extends Controller {
|
||||
|
||||
$this->data['username'] = Registry::get('username');
|
||||
|
||||
$rcpt = array();
|
||||
|
||||
|
||||
/* send the email to all the recipients of the original email if we are admin or auditor users */
|
||||
|
||||
if(Registry::get('admin_user') == 1 || Registry::get('auditor_user') == 1) {
|
||||
$rcpt = $this->model_search_search->get_message_recipients($this->data['id']);
|
||||
|
||||
}
|
||||
else {
|
||||
if(Registry::get('auditor_user') == 0) {
|
||||
array_push($rcpt, $_SESSION['email']);
|
||||
}
|
||||
|
||||
$this->data['piler_id'] = $this->model_search_message->get_piler_id_by_id($this->data['id']);
|
||||
$this->data['data'] = $this->data['text_failed_to_restore'];
|
||||
|
||||
$x = $this->model_mail_mail->send_smtp_email(SMARTHOST, SMARTHOST_PORT, SMTP_DOMAIN, SMTP_FROMADDR, $rcpt,
|
||||
"Received: by piler" . EOL . PILER_HEADER_FIELD . $this->data['id'] . EOL . $this->model_search_message->get_raw_message($this->data['piler_id']) );
|
||||
if(count($rcpt) > 0) {
|
||||
|
||||
if($x == 1) { $this->data['data'] = $this->data['text_restored']; }
|
||||
else { $this->data['data'] = $this->data['text_failed_to_restore']; }
|
||||
$this->data['piler_id'] = $this->model_search_message->get_piler_id_by_id($this->data['id']);
|
||||
|
||||
$x = $this->model_mail_mail->send_smtp_email(SMARTHOST, SMARTHOST_PORT, SMTP_DOMAIN, SMTP_FROMADDR, $rcpt,
|
||||
"Received: by piler" . EOL . PILER_HEADER_FIELD . $this->data['id'] . EOL . $this->model_search_message->get_raw_message($this->data['piler_id']) );
|
||||
|
||||
if($x == 1) { $this->data['data'] = $this->data['text_restored']; }
|
||||
}
|
||||
|
||||
$this->render();
|
||||
}
|
||||
|
@ -21,8 +21,9 @@ class ControllerMessageView extends Controller {
|
||||
$this->document->title = $this->data['text_message'];
|
||||
|
||||
$this->data['id'] = '';
|
||||
$this->data['rcpt'] = array();
|
||||
|
||||
if(isset($_SERVER['REQUEST_URI'])) { $this->data['id'] = preg_replace("/\/message.php\//", "", $_SERVER['REQUEST_URI']); }
|
||||
if(isset($_SERVER['REQUEST_URI'])) { $a = preg_split("/\//", $_SERVER['REQUEST_URI']); $this->data['id'] = $a[count($a)-1]; }
|
||||
|
||||
if($this->request->server['REQUEST_METHOD'] == 'POST') {
|
||||
$this->data['id'] = $this->request->post['id'];
|
||||
@ -44,6 +45,8 @@ class ControllerMessageView extends Controller {
|
||||
|
||||
$this->data['username'] = Registry::get('username');
|
||||
|
||||
if(Registry::get('auditor_user') == 1) { $this->data['rcpt'] = $this->model_search_search->get_message_addresses_in_my_domain($this->data['id']); }
|
||||
|
||||
/* fix username if we are admin */
|
||||
|
||||
if(isset($this->request->get['user']) && strlen($this->request->get['user']) > 1 && (Registry::get('admin_user') == 1 || $this->model_user_user->isUserInMyDomain($this->request->get['user']) == 1) ) {
|
||||
|
@ -240,6 +240,7 @@ $_['text_remove_this_policy'] = "Remove this policy";
|
||||
$_['text_remove_this_group'] = "Remove this group";
|
||||
$_['text_remove_this_user'] = "Remove this user";
|
||||
$_['text_reset_counters'] = "Reset counters";
|
||||
$_['text_restore'] = "Restore";
|
||||
$_['text_restored'] = "Restored";
|
||||
$_['text_restore_message'] = "restore message";
|
||||
$_['text_restore_to_mailbox'] = "Restore message to mailbox";
|
||||
@ -265,6 +266,7 @@ $_['text_search_group_to_add'] = "Search group to add";
|
||||
$_['text_search_terms'] = "Search terms";
|
||||
$_['text_select_action'] = "Select action";
|
||||
$_['text_select_all'] = "Select all";
|
||||
$_['text_select_recipients'] = "Select recipients";
|
||||
$_['text_sender'] = "Sender";
|
||||
$_['text_sending_domains'] = "sending domains";
|
||||
$_['text_server_name'] = "Server name";
|
||||
|
@ -241,6 +241,7 @@ $_['text_remove_this_group'] = "Csoport t
|
||||
$_['text_remove_this_policy'] = "Házirend törlése";
|
||||
$_['text_remove_this_user'] = "Felhasználó törlése";
|
||||
$_['text_reset_counters'] = "Számlálók nullázása";
|
||||
$_['text_restore'] = "Visszaállít";
|
||||
$_['text_restored'] = "Visszaállítva";
|
||||
$_['text_restore_message'] = "levél visszaállítása";
|
||||
$_['text_restore_to_mailbox'] = "Levél visszaállítása postafiókba";
|
||||
@ -266,6 +267,7 @@ $_['text_search_group_to_add'] = "
|
||||
$_['text_search_terms'] = "Keresési feltételek";
|
||||
$_['text_select_action'] = "Művelet választás";
|
||||
$_['text_select_all'] = "Mindegyik kijelölése";
|
||||
$_['text_select_recipients'] = "Címzettek kijelölése";
|
||||
$_['text_sender'] = "Feladó";
|
||||
$_['text_sending_domains'] = "küldő domain";
|
||||
$_['text_server_name'] = "Szerver név";
|
||||
|
@ -241,6 +241,7 @@ $_['text_remove_this_group'] = "Csoport törlése";
|
||||
$_['text_remove_this_policy'] = "Házirend törlése";
|
||||
$_['text_remove_this_user'] = "Felhasználó törlése";
|
||||
$_['text_reset_counters'] = "Számlálók nullázása";
|
||||
$_['text_restore'] = "Visszaállít";
|
||||
$_['text_restored'] = "Visszaállítva";
|
||||
$_['text_restore_message'] = "levél visszaállítása";
|
||||
$_['text_restore_to_mailbox'] = "Levél visszaállítása postafiókba";
|
||||
@ -266,6 +267,7 @@ $_['text_search_group_to_add'] = "írja be a csoport nevének elejét";
|
||||
$_['text_search_terms'] = "Keresési feltételek";
|
||||
$_['text_select_action'] = "Művelet választás";
|
||||
$_['text_select_all'] = "Mindegyik kijelölése";
|
||||
$_['text_select_recipients'] = "Címzettek kijelölése";
|
||||
$_['text_sender'] = "Feladó";
|
||||
$_['text_sending_domains'] = "küldő domain";
|
||||
$_['text_server_name'] = "Szerver név";
|
||||
|
@ -241,6 +241,7 @@ $_['text_remove_this_group'] = "Remover este grupo";
|
||||
$_['text_remove_this_user'] = "Remover este usuário";
|
||||
$_['text_reset_counters'] = "Zerar contadores";
|
||||
|
||||
$_['text_restore'] = "reenviar";
|
||||
$_['text_restore_message'] = "reenviar mensagem";
|
||||
$_['text_restore_to_mailbox'] = "Reenviar mensagem";
|
||||
$_['text_restored'] = "Reenviado.";
|
||||
@ -265,6 +266,7 @@ $_['text_search_group_to_add'] = "Pesquisar grupos para adicionar";
|
||||
$_['text_search_terms'] = "Pesquisar strings";
|
||||
$_['text_select_action'] = "Selecionar ação";
|
||||
$_['text_select_all'] = "Selcionar todos";
|
||||
$_['text_select_recipients'] = "Selcionar recipiente";
|
||||
$_['text_sender'] = "Remetente";
|
||||
$_['text_sending_domains'] = "envio de domínios";
|
||||
$_['text_server_name'] = "Nome do servidor";
|
||||
|
@ -529,6 +529,42 @@ class ModelSearchSearch extends Model {
|
||||
}
|
||||
|
||||
|
||||
public function get_message_addresses_in_my_domain($id = '') {
|
||||
$addr = array();
|
||||
$domains = array();
|
||||
|
||||
if(Registry::get('auditor_user') == 0) { return $addr; }
|
||||
|
||||
$query = $this->db->query("SELECT `domain` FROM " . TABLE_DOMAIN);
|
||||
foreach($query->rows as $q) {
|
||||
array_push($domains, $q['domain']);
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT `from`, `to` FROM " . VIEW_MESSAGES . " WHERE id=?", array($id));
|
||||
|
||||
if(isset($query->row)) {
|
||||
foreach ($domains as $domain) {
|
||||
if(preg_match("/\@$domain$/", $query->row['from'])) { array_push($addr, $query->row['from']); }
|
||||
}
|
||||
}
|
||||
|
||||
foreach($query->rows as $q) {
|
||||
$mydomain = 0;
|
||||
|
||||
foreach ($domains as $domain) {
|
||||
if(preg_match("/\@$domain$/", $q['to'])) { $mydomain = 1; break; }
|
||||
}
|
||||
|
||||
if($mydomain == 1) {
|
||||
array_push($addr, $q['to']);
|
||||
}
|
||||
}
|
||||
|
||||
return $addr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function get_all_your_address() {
|
||||
$s = '';
|
||||
|
||||
|
@ -838,3 +838,25 @@ function close_folder(id) {
|
||||
}
|
||||
|
||||
|
||||
function assemble_recipient_list() {
|
||||
var a = document.getElementById('restorebox');
|
||||
var emails = '';
|
||||
|
||||
for(i=0; i<a.childNodes.length; i++) {
|
||||
|
||||
if(a.childNodes[i].id && a.childNodes[i].id.substring(0, 5) == "rcpt_") {
|
||||
var e = document.getElementById(a.childNodes[i].id);
|
||||
if(e && e.checked == 1) {
|
||||
|
||||
email = a.childNodes[i].id.substring(5,1000);
|
||||
|
||||
if(emails) { emails += ' ' + email; } else { emails = email; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return encodeURI(emails);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,21 +1,24 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="/view/theme/default/stylesheet/style-<?php print THEME; ?>.css" />
|
||||
</head>
|
||||
<div id="restorebox" style="position: absolute; top: 20px; left: 15%; border: 3px solid red; display: none; background: orange; color: #000000; font-weight: bold; padding: 15px; z-index: 1;">
|
||||
<?php if(Registry::get('auditor_user') == 1 && count($rcpt) > 0) { ?>
|
||||
<?php foreach($rcpt as $r) { ?>
|
||||
<input type="checkbox" id="rcpt_<?php print $r; ?>" name="rcpt_<?php print $r; ?>" value="1" style="margin:0;"/> <?php print $r; ?><br />
|
||||
<?php } ?>
|
||||
<br />
|
||||
<input type="button" id="restore_button" name="restore_button" value="<?php print $text_restore; ?>" class="restore_to_mailbox_button" onclick="javascript: var p = assemble_recipient_list(); if(p == '') { show_message('messagebox1', '<?php print $text_select_recipients; ?>', 1); return false; } send_ajax_post_request('<?php print SITE_URL; ?>index.php?route=message/restore', 'id=<?php print $id; ?>&rcpt=' + p); var a=document.getElementById('restorebox'); a.style.display = 'none'; show_message('messagebox1', '<?php print $text_restored; ?>', 1); " />
|
||||
<input type="button" value="<?php print $text_cancel; ?>" class="restore_to_mailbox_button" onclick="script:var a=document.getElementById('restorebox'); a.style.display = 'none';" />
|
||||
<?php } ?>
|
||||
|
||||
<body style="background: white;">
|
||||
|
||||
<div id="messagepopup">
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<a class="messagelink" href="index.php?route=message/download&id=<?php print $id; ?>"><?php print $text_download_message; ?></a> |
|
||||
<?php if(Registry::get('auditor_user') == 1) { ?>
|
||||
<a class="messagelink" href="#" onclick="script:var a=document.getElementById('restorebox'); a.style.display = ''; return false;"><?php print $text_restore_to_mailbox; ?></a> |
|
||||
<?php } else { ?>
|
||||
<a class="messagelink" href="#" onclick="script:load_url_with_get('<?php print SITE_URL; ?>index.php?route=message/restore&id=<?php print $id; ?>', 'mailpreviewframe'); return false;"><?php print $text_restore_to_mailbox; ?></a> |
|
||||
<?php } ?>
|
||||
<a class="messagelink" href="#" onclick="script:load_url_with_get('<?php print SITE_URL; ?>message.php/<?php print $id; ?>', 'mailpreviewframe'); return false;"><?php print $text_view_message; ?></a>
|
||||
</p>
|
||||
|
||||
<pre><?php print $data; ?></pre>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -10,7 +10,7 @@
|
||||
<p>
|
||||
<a class="messagelink" href="index.php?route=message/download&id=<?php print $id; ?>"><?php print $text_download_message; ?></a> |
|
||||
<a class="messagelink" href="#" onclick="script:load_url_with_get('<?php print SITE_URL; ?>message.php/<?php print $id; ?>', 'mailpreviewframe'); return false;"><?php print $text_view_message; ?></a> |
|
||||
<a class="messagelink" href="#" onclick="script:load_url_with_get('<?php print SITE_URL; ?>/index.php?route=message/headers&id=<?php print $id; ?>', 'mailpreviewframe'); return false;"><?php print $text_view_headers; ?></a>
|
||||
<a class="messagelink" href="#" onclick="script:load_url_with_get('<?php print SITE_URL; ?>index.php?route=message/headers&id=<?php print $id; ?>', 'mailpreviewframe'); return false;"><?php print $text_view_headers; ?></a>
|
||||
</p>
|
||||
|
||||
<p><?php print $data; ?></p>
|
||||
|
@ -1,8 +1,23 @@
|
||||
<div id="restorebox" style="position: absolute; top: 20px; left: 15%; border: 3px solid red; display: none; background: orange; color: #000000; font-weight: bold; padding: 15px; z-index: 1;">
|
||||
<?php if(Registry::get('auditor_user') == 1 && count($rcpt) > 0) { ?>
|
||||
<?php foreach($rcpt as $r) { ?>
|
||||
<input type="checkbox" id="rcpt_<?php print $r; ?>" name="rcpt_<?php print $r; ?>" value="1" style="margin:0;"/> <?php print $r; ?><br />
|
||||
<?php } ?>
|
||||
<br />
|
||||
<input type="button" id="restore_button" name="restore_button" value="<?php print $text_restore; ?>" class="restore_to_mailbox_button" onclick="javascript: var p = assemble_recipient_list(); if(p == '') { show_message('messagebox1', '<?php print $text_select_recipients; ?>', 1); return false; } send_ajax_post_request('<?php print SITE_URL; ?>index.php?route=message/restore', 'id=<?php print $id; ?>&rcpt=' + p); var a=document.getElementById('restorebox'); a.style.display = 'none'; show_message('messagebox1', '<?php print $text_restored; ?>', 1); " />
|
||||
<input type="button" value="<?php print $text_cancel; ?>" class="restore_to_mailbox_button" onclick="script:var a=document.getElementById('restorebox'); a.style.display = 'none';" />
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<a class="messagelink" href="index.php?route=message/download&id=<?php print $id; ?>"><?php print $text_download_message; ?></a> |
|
||||
<a class="messagelink" href="#" onclick="script:load_url_with_get('<?php print SITE_URL; ?>/index.php?route=message/restore&id=<?php print $id; ?>', 'mailpreviewframe'); return false;"><?php print $text_restore_to_mailbox; ?></a> |
|
||||
<a class="messagelink" href="#" onclick="script:load_url_with_get('<?php print SITE_URL; ?>/index.php?route=message/headers&id=<?php print $id; ?>', 'mailpreviewframe'); return false;"><?php print $text_view_headers; ?></a>
|
||||
<?php if(Registry::get('auditor_user') == 1) { ?>
|
||||
<a class="messagelink" href="#" onclick="script:var a=document.getElementById('restorebox'); a.style.display = ''; return false;"><?php print $text_restore_to_mailbox; ?></a> |
|
||||
<?php } else { ?>
|
||||
<a class="messagelink" href="#" onclick="script:load_url_with_get('<?php print SITE_URL; ?>index.php?route=message/restore&id=<?php print $id; ?>', 'mailpreviewframe'); return false;"><?php print $text_restore_to_mailbox; ?></a> |
|
||||
<?php } ?>
|
||||
<a class="messagelink" href="#" onclick="script:load_url_with_get('<?php print SITE_URL; ?>index.php?route=message/headers&id=<?php print $id; ?>', 'mailpreviewframe'); return false;"><?php print $text_view_headers; ?></a>
|
||||
</p>
|
||||
|
||||
<strong><?php if($message['subject'] == "" || $message['subject'] == "Subject:") { print "<" . $text_no_subject . ">"; } else { print $message['subject']; } ?></strong><br />
|
||||
|
Loading…
Reference in New Issue
Block a user