mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-26 04:50:11 +01:00
added imap restore to inbox feature
This commit is contained in:
parent
37e921898f
commit
c21c27a6dd
@ -12,6 +12,8 @@ class ControllerMessageBulkrestore extends Controller {
|
|||||||
$request = Registry::get('request');
|
$request = Registry::get('request');
|
||||||
$db = Registry::get('db');
|
$db = Registry::get('db');
|
||||||
|
|
||||||
|
$imap_ok = 0;
|
||||||
|
|
||||||
$this->load->model('search/search');
|
$this->load->model('search/search');
|
||||||
$this->load->model('search/message');
|
$this->load->model('search/message');
|
||||||
$this->load->model('message/restore');
|
$this->load->model('message/restore');
|
||||||
@ -19,6 +21,7 @@ class ControllerMessageBulkrestore extends Controller {
|
|||||||
$this->load->model('user/user');
|
$this->load->model('user/user');
|
||||||
$this->load->model('mail/mail');
|
$this->load->model('mail/mail');
|
||||||
|
|
||||||
|
|
||||||
$this->document->title = $this->data['text_message'];
|
$this->document->title = $this->data['text_message'];
|
||||||
|
|
||||||
if(!isset($this->request->post['idlist']) || $this->request->post['idlist'] == '') { die("no idlist parameter given"); }
|
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;
|
$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) {
|
foreach($idlist as $id) {
|
||||||
|
|
||||||
AUDIT(ACTION_RESTORE_MESSAGE, '', '', $id, '');
|
AUDIT(ACTION_RESTORE_MESSAGE, '', '', $id, '');
|
||||||
@ -61,14 +72,26 @@ class ControllerMessageBulkrestore extends Controller {
|
|||||||
$msg = $this->model_search_message->get_raw_message($piler_id);
|
$msg = $this->model_search_message->get_raw_message($piler_id);
|
||||||
$this->model_search_message->remove_journal($msg);
|
$this->model_search_message->remove_journal($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,
|
$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 );
|
"Received: by piler" . EOL . PILER_HEADER_FIELD . $id . EOL . $msg );
|
||||||
|
}
|
||||||
|
|
||||||
if($x == 1) { $this->data['restored']++; }
|
if($x == 1) { $this->data['restored']++; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(ENABLE_IMAP_AUTH == 1) { $this->model_mail_mail->disconnect_imap(); }
|
||||||
|
|
||||||
|
|
||||||
$this->render();
|
$this->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,12 @@ class ControllerMessageRestore extends Controller {
|
|||||||
|
|
||||||
$rcpt = array();
|
$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) {
|
if(Registry::get('auditor_user') == 1) {
|
||||||
$this->data['id'] = @$this->request->post['id'];
|
$this->data['id'] = @$this->request->post['id'];
|
||||||
$rcpt = preg_split("/\s/", $this->request->post['rcpt']);
|
$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']);
|
$msg = $this->model_search_message->get_raw_message($this->data['piler_id']);
|
||||||
$this->model_search_message->remove_journal($msg);
|
$this->model_search_message->remove_journal($msg);
|
||||||
|
|
||||||
|
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,
|
$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 );
|
"Received: by piler" . EOL . PILER_HEADER_FIELD . $this->data['id'] . EOL . $msg );
|
||||||
|
}
|
||||||
|
|
||||||
if($x == 1) { $this->data['data'] = $this->data['text_restored']; }
|
if($x == 1) { $this->data['data'] = $this->data['text_restored']; }
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,23 @@ class ModelMailMail extends Model {
|
|||||||
return $ok;
|
return $ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function connect_imap() {
|
||||||
|
$this->imap = new Zend_Mail_Protocol_Imap(IMAP_HOST, IMAP_PORT, IMAP_SSL);
|
||||||
|
|
||||||
|
if($this->imap) {
|
||||||
|
if($this->imap->login($_SESSION['username'], $_SESSION['password'])) { return 1; }
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function disconnect_imap() {
|
||||||
|
$this->imap->logout;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -178,6 +178,8 @@ class ModelUserAuth extends Model {
|
|||||||
|
|
||||||
$this->add_session_vars($username, $username, array($username));
|
$this->add_session_vars($username, $username, array($username));
|
||||||
|
|
||||||
|
$_SESSION['password'] = $password;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user