diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index 5622156dec..d34cf09f19 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -1336,9 +1336,9 @@ class mail_compose switch($from) { case 'composefromdraft': - $content['mode'] = 'composefromdraft'; case 'composeasnew': $content = $this->getDraftData($icServer, $folder, $msgUID, $part_id); + if ($from =='composefromdraft') $content['mode'] = 'composefromdraft'; $content['processedmail_id'] = $mail_id; $_focusElement = 'body'; @@ -2998,7 +2998,14 @@ class mail_compose { try { - $mail_bo->deleteMessages($lastDrafted['uid'],$lastDrafted['folder'],'remove_immediately'); + if ($this->sessionData['lastDrafted'] != $this->sessionData['uid'] || !($_formData['mode']=='composefromdraft' && + ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )&&$this->sessionData['attachments'])) + { + //error_log(__METHOD__.__LINE__."#".$lastDrafted['uid'].'#'.$lastDrafted['folder'].array2string($_formData)); + //error_log(__METHOD__.__LINE__."#".array2string($_formData)); + //error_log(__METHOD__.__LINE__."#".array2string($this->sessionData)); + $mail_bo->deleteMessages($lastDrafted['uid'],$lastDrafted['folder'],'remove_immediately'); + } } catch (egw_exception $e) { @@ -3018,10 +3025,14 @@ class mail_compose // unless your templatefolder is a subfolder of your draftfolder, and the message is in there if ($mail_bo->isDraftFolder($this->sessionData['messageFolder']) && !$mail_bo->isTemplateFolder($this->sessionData['messageFolder'])) { - //error_log(__METHOD__.__LINE__."#".$this->sessionData['uid'].'#'.$this->sessionData['messageFolder']); try // message may be deleted already, as it maybe done by autosave { - if ($_formData['mode']=='composefromdraft') $mail_bo->deleteMessages(array($this->sessionData['uid']),$this->sessionData['messageFolder']); + if ($_formData['mode']=='composefromdraft' && + !(($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on') && $this->sessionData['attachments'])) + { + //error_log(__METHOD__.__LINE__."#".$this->sessionData['uid'].'#'.$this->sessionData['messageFolder']); + $mail_bo->deleteMessages(array($this->sessionData['uid']),$this->sessionData['messageFolder']); + } } catch (egw_exception $e) { diff --git a/mail/inc/class.mail_integration.inc.php b/mail/inc/class.mail_integration.inc.php index bb9dd89f99..4cf63c1203 100644 --- a/mail/inc/class.mail_integration.inc.php +++ b/mail/inc/class.mail_integration.inc.php @@ -77,7 +77,7 @@ class mail_integration { $_date = egw_time::server2user($time->now,'ts'); } $GLOBALS['egw_info']['flags']['currentapp'] = $app; - + //error_log(__METHOD__.__LINE__.': RowID:'.$_GET['rowid'].': emailAddress:'. array2string($_to_emailAddress).' && '.$app); // Integrate not yet saved mail if (empty($_GET['rowid']) && $_to_emailAddress && $app) { @@ -90,9 +90,10 @@ class mail_integration { if (!isset($_icServerID)) $_icServerID =& egw_cache::getSession($sessionLocation,'activeProfileID'); $mo = mail_bo::getInstance(true,$_icServerID); $mo->openConnection(); - + $messageUID = $messagePartId = $messageFolder = null; foreach ($_attachments as $attachment) { + //error_log(__METHOD__.__LINE__.array2string($attachment)); if (trim(strtoupper($attachment['type'])) == 'MESSAGE/RFC822' && !empty($attachment['uid']) && !empty($attachment['folder'])) { $mo->reopen(($attachment['folder']?$attachment['folder']:$mailbox)); @@ -120,8 +121,11 @@ class mail_integration { if (!empty($attachment['folder'])) { $is_winmail = $_GET['is_winmail'] ? $_GET['is_winmail'] : 0; + $messageFolder = $attachment['folder']; + $messageUid = $attachment['uid']; + $messagePartId = $attachment['partID']; $mo->reopen($attachment['folder']); - $attachmentData = $mo->getAttachment($attachment['uid'],$attachment['partID'],$is_winmail); + $attachmentData = $mo->getAttachment($attachment['uid'],$attachment['partID'],$is_winmail,false,false,$attachment['folder']); $attachment['file'] =tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_"); $tmpfile = fopen($attachment['file'],'w'); fwrite($tmpfile,$attachmentData['attachment']); @@ -142,6 +146,19 @@ class mail_integration { ); } } + if ($messageFolder && $messageUid && $messagePartId && $mo->isDraftFolder($messageFolder) && !$mo->isTemplateFolder($messageFolder)) + { + //error_log(__METHOD__.__LINE__."#".$messageUid.'#'.$messageFolder); + try // message may be deleted already, as it maybe done by autosave + { + $mo->deleteMessages(array($messageUid),$messageFolder); + } + catch (egw_exception $e) + { + //error_log(__METHOD__.__LINE__." ". str_replace('"',"'",$e->getMessage())); + unset($e); + } + } $mo->closeConnection(); } // this one adds the mail itself (as message/rfc822 (.eml) file) to the app as additional attachment