From a079c915c6b2293aa0dc02d76c179728651d5339 Mon Sep 17 00:00:00 2001 From: SJ Date: Thu, 20 Dec 2012 14:11:17 +0100 Subject: [PATCH] added a select option to auditors to define the recipients of the message to be restored --- webui/controller/message/bulkrestore.php | 2 +- webui/controller/message/headers.php | 2 ++ webui/controller/message/restore.php | 30 +++++++++------- webui/controller/message/view.php | 5 ++- webui/language/en/messages.php | 2 ++ webui/language/hu/messages.iso-8859-2.php | 2 ++ webui/language/hu/messages.php | 2 ++ webui/language/pt/messages.php | 2 ++ webui/model/search/search.php | 36 +++++++++++++++++++ webui/view/javascript/piler.js | 22 ++++++++++++ .../default/templates/message/headers.tpl | 25 +++++++------ .../default/templates/message/restore.tpl | 2 +- .../theme/default/templates/message/view.tpl | 19 ++++++++-- 13 files changed, 123 insertions(+), 28 deletions(-) diff --git a/webui/controller/message/bulkrestore.php b/webui/controller/message/bulkrestore.php index 9296f370..15a569a6 100644 --- a/webui/controller/message/bulkrestore.php +++ b/webui/controller/message/bulkrestore.php @@ -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); diff --git a/webui/controller/message/headers.php b/webui/controller/message/headers.php index 49ada36a..d3d31d2a 100644 --- a/webui/controller/message/headers.php +++ b/webui/controller/message/headers.php @@ -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']); diff --git a/webui/controller/message/restore.php b/webui/controller/message/restore.php index 13128770..f26b8b42 100644 --- a/webui/controller/message/restore.php +++ b/webui/controller/message/restore.php @@ -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(); } diff --git a/webui/controller/message/view.php b/webui/controller/message/view.php index c1539f26..f206239b 100644 --- a/webui/controller/message/view.php +++ b/webui/controller/message/view.php @@ -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) ) { diff --git a/webui/language/en/messages.php b/webui/language/en/messages.php index 0d0d75f3..4cdb1d39 100644 --- a/webui/language/en/messages.php +++ b/webui/language/en/messages.php @@ -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"; diff --git a/webui/language/hu/messages.iso-8859-2.php b/webui/language/hu/messages.iso-8859-2.php index 3bbe1012..3bf83c2b 100644 --- a/webui/language/hu/messages.iso-8859-2.php +++ b/webui/language/hu/messages.iso-8859-2.php @@ -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"; diff --git a/webui/language/hu/messages.php b/webui/language/hu/messages.php index c2030f67..e4e0b033 100644 --- a/webui/language/hu/messages.php +++ b/webui/language/hu/messages.php @@ -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"; diff --git a/webui/language/pt/messages.php b/webui/language/pt/messages.php index 6d758229..951cac6b 100644 --- a/webui/language/pt/messages.php +++ b/webui/language/pt/messages.php @@ -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"; diff --git a/webui/model/search/search.php b/webui/model/search/search.php index e5a99286..99de1ed3 100644 --- a/webui/model/search/search.php +++ b/webui/model/search/search.php @@ -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 = ''; diff --git a/webui/view/javascript/piler.js b/webui/view/javascript/piler.js index 3c99fa29..928e6ac7 100644 --- a/webui/view/javascript/piler.js +++ b/webui/view/javascript/piler.js @@ -838,3 +838,25 @@ function close_folder(id) { } +function assemble_recipient_list() { + var a = document.getElementById('restorebox'); + var emails = ''; + + for(i=0; i - - - + - - - diff --git a/webui/view/theme/default/templates/message/restore.tpl b/webui/view/theme/default/templates/message/restore.tpl index a7ed1b6d..d3449806 100644 --- a/webui/view/theme/default/templates/message/restore.tpl +++ b/webui/view/theme/default/templates/message/restore.tpl @@ -10,7 +10,7 @@

| | - +

diff --git a/webui/view/theme/default/templates/message/view.tpl b/webui/view/theme/default/templates/message/view.tpl index 59874b2f..801488c4 100644 --- a/webui/view/theme/default/templates/message/view.tpl +++ b/webui/view/theme/default/templates/message/view.tpl @@ -1,8 +1,23 @@ +

| - | - + + | + + | + +