mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-07 23:01:58 +01:00
Choose imap folder based on if gui user is in To: or From:
Change-Id: I584ff43f9ce5b3f4822b59a5e9ca2cbef3ba4ff3 Signed-off-by: SJ <sj@acts.hu>
This commit is contained in:
parent
a59e322c2c
commit
f7c6abfbe3
@ -107,7 +107,8 @@ $config['STRIP_DOMAIN_NAME_FROM_USERNAME'] = 0;
|
||||
|
||||
$config['ENABLE_IMAP_AUTH'] = 0;
|
||||
$config['RESTORE_OVER_IMAP'] = 0;
|
||||
$config['IMAP_RESTORE_FOLDER'] = 'INBOX';
|
||||
$config['IMAP_RESTORE_FOLDER_INBOX'] = 'INBOX';
|
||||
$config['IMAP_RESTORE_FOLDER_SENT'] = 'Sent';
|
||||
$config['IMAP_HOST'] = 'mail.yourdomain.com';
|
||||
$config['IMAP_PORT'] = 993;
|
||||
$config['IMAP_SSL'] = true;
|
||||
|
@ -50,6 +50,8 @@ class ControllerMessageBulkrestore extends Controller {
|
||||
require_once 'Zend/Mail/Protocol/Imap.php';
|
||||
require_once 'Zend/Mail/Storage/Imap.php';
|
||||
|
||||
$emails = $session->get("emails");
|
||||
|
||||
$imap_ok = $this->model_mail_mail->connect_imap();
|
||||
|
||||
if(!$imap_ok) {
|
||||
@ -86,8 +88,15 @@ class ControllerMessageBulkrestore extends Controller {
|
||||
|
||||
if(RESTORE_OVER_IMAP == 1) {
|
||||
if($imap_ok) {
|
||||
$x = $this->imap->append(IMAP_RESTORE_FOLDER, $msg);
|
||||
syslog(LOG_INFO, "imap append $id/$piler_id, rc=$x");
|
||||
$imap_folder = IMAP_RESTORE_FOLDER_INBOX;
|
||||
|
||||
$meta = $this->model_search_message->get_metadata_by_id($id);
|
||||
if(in_array($meta['from'], $emails)) {
|
||||
$imap_folder = IMAP_RESTORE_FOLDER_SENT;
|
||||
}
|
||||
|
||||
$x = $this->imap->append($imap_folder, $msg);
|
||||
syslog(LOG_INFO, "imap append $id/$piler_id, to " . $imap_folder . ", rc=$x");
|
||||
}
|
||||
else { $x = 0; }
|
||||
}
|
||||
|
@ -67,8 +67,8 @@ class ControllerMessageRestore extends Controller {
|
||||
$this->data['data'] = $this->data['text_failed_to_restore'];
|
||||
|
||||
if(count($rcpt) > 0) {
|
||||
|
||||
$this->data['piler_id'] = $this->model_search_message->get_piler_id_by_id($this->data['id']);
|
||||
$this->data['meta'] = $this->model_search_message->get_metadata_by_id($this->data['id']);
|
||||
$this->data['piler_id'] = $this->data['meta']['piler_id'];
|
||||
|
||||
$msg = $this->model_search_message->get_raw_message($this->data['piler_id']);
|
||||
|
||||
@ -76,8 +76,16 @@ class ControllerMessageRestore extends Controller {
|
||||
|
||||
if(RESTORE_OVER_IMAP == 1) {
|
||||
if($this->model_mail_mail->connect_imap()) {
|
||||
$x = $this->imap->append(IMAP_RESTORE_FOLDER, $msg);
|
||||
syslog(LOG_INFO, "imap append " . $this->data['id'] . "/" . $this->data['piler_id'] . ", rc=$x");
|
||||
|
||||
$imap_folder = IMAP_RESTORE_FOLDER_INBOX;
|
||||
|
||||
$emails = $session->get("emails");
|
||||
if(in_array($this->data['meta']['from'], $emails)) {
|
||||
$imap_folder = IMAP_RESTORE_FOLDER_SENT;
|
||||
}
|
||||
|
||||
$x = $this->imap->append($imap_folder, $msg);
|
||||
syslog(LOG_INFO, "imap append " . $this->data['id'] . "/" . $this->data['piler_id'] . " to " . $imap_folder . ", rc=$x");
|
||||
$this->model_mail_mail->disconnect_imap();
|
||||
}
|
||||
else {
|
||||
|
@ -445,6 +445,13 @@ class ModelSearchMessage extends Model {
|
||||
}
|
||||
|
||||
|
||||
public function get_metadata_by_id($id = 0) {
|
||||
$query = $this->db->query("SELECT * FROM `" . TABLE_META . "` WHERE id=?", array($id));
|
||||
if(isset($query->row['piler_id'])) { return $query->row; }
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
public function fix_subject($s = '') {
|
||||
if($s == '') { $s = 'nosubject'; }
|
||||
return preg_replace("/^\-{1,}/", "", preg_replace("/\W{1,}/", "-", $s));
|
||||
|
Loading…
Reference in New Issue
Block a user