From 7f7cf6b60e32e9abc595620e2c769eeef600d1a9 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Tue, 19 Jul 2011 13:28:13 +0000 Subject: [PATCH] try to reopen mail, when saving as draft; make sure we are connected, before trying to reopen a drafted Message (while/after saving) --- felamimail/inc/class.bocompose.inc.php | 8 ++++++-- felamimail/inc/class.uicompose.inc.php | 14 ++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/felamimail/inc/class.bocompose.inc.php b/felamimail/inc/class.bocompose.inc.php index 70d1a11b91..7bd04c91d0 100644 --- a/felamimail/inc/class.bocompose.inc.php +++ b/felamimail/inc/class.bocompose.inc.php @@ -856,7 +856,7 @@ $bofelamimail->closeConnection(); } - function saveAsDraft($_formData) + function saveAsDraft($_formData, &$savingDestination='') { $bofelamimail =& $this->bofelamimail; //CreateObject('felamimail.bofelamimail',$this->displayCharset); $mail = new egw_mailer(); @@ -891,11 +891,15 @@ // if the current folder is in draft or template folder save it there // if it is called from printview then save it with the draft folder $savingDestination = ($this->preferences->ic_server[0]->draftfolder ? $this->preferences->ic_server[0]->draftfolder : $this->preferencesArray['draftFolder']); - if (empty($this->sessionData['messageFolder']) && !empty($this->sessionData['mailbox'])) $this->sessionData['messageFolder'] = $this->sessionData['mailbox']; + if (empty($this->sessionData['messageFolder']) && !empty($this->sessionData['mailbox'])) + { + $this->sessionData['messageFolder'] = $this->sessionData['mailbox']; + } if ($bofelamimail->isDraftFolder($this->sessionData['messageFolder']) || $bofelamimail->isTemplateFolder($this->sessionData['messageFolder'])) { $savingDestination = $this->sessionData['messageFolder']; + //error_log(__METHOD__.__LINE__.' SavingDestination:'.$savingDestination); } if ( !empty($_formData['printit']) && $_formData['printit'] == 0 ) $savingDestination = ($this->preferences->ic_server[0]->draftfolder ? $this->preferences->ic_server[0]->draftfolder : $this->preferencesArray['draftFolder']); diff --git a/felamimail/inc/class.uicompose.inc.php b/felamimail/inc/class.uicompose.inc.php index 9081aadbe4..4626adbe28 100644 --- a/felamimail/inc/class.uicompose.inc.php +++ b/felamimail/inc/class.uicompose.inc.php @@ -57,8 +57,9 @@ $this->bocompose = CreateObject('felamimail.bocompose',$this->composeID,$this->displayCharset); } $this->t = CreateObject('phpgwapi.Template',EGW_APP_TPL); - $this->bofelamimail = CreateObject('felamimail.bofelamimail',$this->displayCharset); - $this->mailPreferences =& $this->bofelamimail->mailPreferences;// ExecMethod('felamimail.bopreferences.getPreferences'); + + $this->bofelamimail =& $this->bocompose->bofelamimail; + $this->mailPreferences =& $this->bofelamimail->mailPreferences; $this->t->set_unknowns('remove'); $this->rowColor[0] = $GLOBALS['egw_info']["theme"]["bg01"]; @@ -129,9 +130,9 @@ $folder = ($this->mailPreferences->ic_server[0]->draftfolder ? $this->mailPreferences->ic_server[0]->draftfolder : $this->mailPreferences->preferences['draftFolder']); $this->bofelamimail->reopen($folder); $status = $this->bofelamimail->getFolderStatus($folder); - //error_log(__METHOD__.__LINE__.array2string($status)); + //error_log(__METHOD__.__LINE__.array2string(array('Folder'=>$folder,'Status'=>$status))); $uidNext = $status['uidnext']; // we may need that, if the server does not return messageUIDs of saved/appended messages - $messageUid = $this->bocompose->saveAsDraft($formData); + $messageUid = $this->bocompose->saveAsDraft($formData,$folder); // folder may change if (!$messageUid) { print ""; //try to reopen the mail from session data @@ -142,10 +143,11 @@ unset($_POST['composeid']); unset($_GET['composeid']); $uicompose = CreateObject('felamimail.uicompose'); + if (!$uicompose->bofelamimail->icServer->_connected) $uicompose->bofelamimail->openConnection($uicompose->bofelamimail->profileID); $messageUid = ($messageUid===true ? $uidNext : $messageUid); - if ($this->bofelamimail->getMessageHeader($messageUid)) + if ($uicompose->bofelamimail->getMessageHeader($messageUid)) { - //error_log(__METHOD__.__LINE__.' (re)open drafted message with new UID: '.$messageUid.' in folder:'.$folder); + //error_log(__METHOD__.__LINE__.' (re)open drafted message with new UID: '.$messageUid.' in folder:'.$folder); $uicompose->bocompose->getDraftData($uicompose->bofelamimail->icServer, $folder, $messageUid); $uicompose->compose(); return;