added imap restore to inbox feature

This commit is contained in:
SJ
2013-04-02 22:22:30 +02:00
parent 37e921898f
commit c21c27a6dd
4 changed files with 63 additions and 3 deletions

View File

@ -12,6 +12,8 @@ class ControllerMessageBulkrestore extends Controller {
$request = Registry::get('request');
$db = Registry::get('db');
$imap_ok = 0;
$this->load->model('search/search');
$this->load->model('search/message');
$this->load->model('message/restore');
@ -19,6 +21,7 @@ class ControllerMessageBulkrestore extends Controller {
$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"); }
@ -40,6 +43,14 @@ class ControllerMessageBulkrestore extends Controller {
$this->data['restored'] = 0;
if(ENABLE_IMAP_AUTH == 1) {
require_once 'Zend/Mail/Protocol/Imap.php';
require_once 'Zend/Mail/Storage/Imap.php';
$imap_ok = $this->model_mail_mail->connect_imap();
}
foreach($idlist as $id) {
AUDIT(ACTION_RESTORE_MESSAGE, '', '', $id, '');
@ -61,14 +72,26 @@ class ControllerMessageBulkrestore extends Controller {
$msg = $this->model_search_message->get_raw_message($piler_id);
$this->model_search_message->remove_journal($msg);
$x = $this->model_mail_mail->send_smtp_email(SMARTHOST, SMARTHOST_PORT, SMTP_DOMAIN, SMTP_FROMADDR, $rcpt,
"Received: by piler" . EOL . PILER_HEADER_FIELD . $id . EOL . $msg );
if(ENABLE_IMAP_AUTH == 1) {
if($imap_ok) {
$x = $this->imap->append('INBOX', $msg);
}
else { $x = 0; }
}
else {
$x = $this->model_mail_mail->send_smtp_email(SMARTHOST, SMARTHOST_PORT, SMTP_DOMAIN, SMTP_FROMADDR, $rcpt,
"Received: by piler" . EOL . PILER_HEADER_FIELD . $id . EOL . $msg );
}
if($x == 1) { $this->data['restored']++; }
}
}
if(ENABLE_IMAP_AUTH == 1) { $this->model_mail_mail->disconnect_imap(); }
$this->render();
}

View File

@ -24,6 +24,12 @@ class ControllerMessageRestore extends Controller {
$rcpt = array();
if(ENABLE_IMAP_AUTH == 1) {
require_once 'Zend/Mail/Protocol/Imap.php';
require_once 'Zend/Mail/Storage/Imap.php';
}
if(Registry::get('auditor_user') == 1) {
$this->data['id'] = @$this->request->post['id'];
$rcpt = preg_split("/\s/", $this->request->post['rcpt']);
@ -61,8 +67,20 @@ class ControllerMessageRestore extends Controller {
$msg = $this->model_search_message->get_raw_message($this->data['piler_id']);
$this->model_search_message->remove_journal($msg);
$x = $this->model_mail_mail->send_smtp_email(SMARTHOST, SMARTHOST_PORT, SMTP_DOMAIN, SMTP_FROMADDR, $rcpt,
if(ENABLE_IMAP_AUTH == 1) {
if($this->model_mail_mail->connect_imap()) {
$x = $this->imap->append('INBOX', $msg);
$this->model_mail_mail->disconnect_imap();
}
else {
$x = 0;
}
}
else {
$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 . $msg );
}
if($x == 1) { $this->data['data'] = $this->data['text_restored']; }
}