2012-05-07 09:38:47 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
class ControllerMessageBulkrestore extends Controller {
|
|
|
|
|
|
|
|
public function index(){
|
|
|
|
|
|
|
|
$this->id = "content";
|
|
|
|
$this->template = "message/bulkrestore.tpl";
|
|
|
|
$this->layout = "common/layout-empty";
|
|
|
|
|
|
|
|
$request = Registry::get('request');
|
|
|
|
$db = Registry::get('db');
|
|
|
|
|
|
|
|
$this->load->model('search/search');
|
|
|
|
$this->load->model('search/message');
|
2012-05-11 23:42:55 +02:00
|
|
|
$this->load->model('message/restore');
|
2012-05-07 09:38:47 +02:00
|
|
|
|
|
|
|
$this->load->model('user/user');
|
|
|
|
$this->load->model('mail/mail');
|
|
|
|
|
|
|
|
$this->document->title = $this->data['text_message'];
|
|
|
|
|
|
|
|
if(!isset($this->request->post['idlist']) || $this->request->post['idlist'] == '') { die("no idlist parameter given"); }
|
|
|
|
|
|
|
|
list($a, $idlist) = $this->model_search_search->check_your_permission_by_id_list(explode(",", $this->request->post['idlist']));
|
|
|
|
|
2012-05-11 23:42:55 +02:00
|
|
|
$download = $this->request->post['download'];
|
|
|
|
|
|
|
|
|
|
|
|
if($download == 1) {
|
|
|
|
$this->model_message_restore->download_files_as_zip($idlist);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2012-05-07 09:38:47 +02:00
|
|
|
|
|
|
|
$this->data['username'] = Registry::get('username');
|
|
|
|
|
|
|
|
$rcpt = array();
|
|
|
|
|
|
|
|
|
2012-05-11 23:42:55 +02:00
|
|
|
/* 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 {
|
|
|
|
array_push($rcpt, $_SESSION['email']);
|
|
|
|
}
|
2012-05-07 09:38:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
$this->data['restored'] = 0;
|
|
|
|
|
|
|
|
foreach($idlist as $id) {
|
|
|
|
|
|
|
|
AUDIT(ACTION_RESTORE_MESSAGE, '', '', $id, '');
|
|
|
|
|
2012-05-07 09:42:28 +02:00
|
|
|
$x = $this->model_mail_mail->send_smtp_email(SMARTHOST, SMARTHOST_PORT, SMTP_DOMAIN, SMTP_FROMADDR, $rcpt,
|
2012-05-07 09:38:47 +02:00
|
|
|
"Received: by piler" . EOL . PILER_HEADER_FIELD . $id . EOL . $this->model_search_message->get_raw_message($id) );
|
|
|
|
|
2012-05-07 09:42:28 +02:00
|
|
|
if($x == 1) { $this->data['restored']++; }
|
2012-05-07 09:38:47 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 23:42:55 +02:00
|
|
|
|
2012-05-07 09:38:47 +02:00
|
|
|
$this->render();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|