auditor can restore emails only to mydomain addresses

This commit is contained in:
SJ 2012-08-12 15:09:13 +02:00
parent acee4749e0
commit 1744ff986d
2 changed files with 16 additions and 2 deletions

View File

@ -42,7 +42,7 @@ class ControllerMessageRestore extends Controller {
/* 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 we are admin or auditor users */
if(Registry::get('admin_user') == 1 || Registry::get('auditor_user') == 1) { if(Registry::get('auditor_user') == 1) {
$rcpt = $this->model_search_search->get_message_recipients($this->data['id']); $rcpt = $this->model_search_search->get_message_recipients($this->data['id']);
} }
else { else {

View File

@ -405,13 +405,27 @@ class ModelSearchSearch extends Model {
public function get_message_recipients($id = '') { public function get_message_recipients($id = '') {
$rcpt = array(); $rcpt = array();
$domains = array();
if(Registry::get('auditor_user') == 0) { return $rcpt; } if(Registry::get('auditor_user') == 0) { return $rcpt; }
$query = $this->db->query("SELECT `domain` FROM " . TABLE_DOMAIN);
foreach($query->rows as $q) {
array_push($domains, $q['domain']);
}
$query = $this->db->query("SELECT `to` FROM " . VIEW_MESSAGES . " WHERE piler_id=?", array($id)); $query = $this->db->query("SELECT `to` FROM " . VIEW_MESSAGES . " WHERE piler_id=?", array($id));
foreach($query->rows as $q) { foreach($query->rows as $q) {
array_push($rcpt, $q['to']); $mydomain = 0;
foreach ($domains as $domain) {
if(preg_match("/\@$domain$/", $q['to'])) { $mydomain = 1; break; }
}
if($mydomain == 1) {
array_push($rcpt, $q['to']);
}
} }
return $rcpt; return $rcpt;