diff --git a/filemanager/inc/class.filemanager_ui.inc.php b/filemanager/inc/class.filemanager_ui.inc.php index 98847e67ad..26640c907e 100644 --- a/filemanager/inc/class.filemanager_ui.inc.php +++ b/filemanager/inc/class.filemanager_ui.inc.php @@ -183,6 +183,11 @@ class filemanager_ui 'type' => 'drag', 'onExecute' => 'javaScript:app.filemanager.drag' ), + 'file_drop_mail' => array( + 'type' => 'drop', + 'acceptedTypes' => 'mail', + 'onExecute' => 'javaScript:app.filemanager.drop' + ), 'file_drop_move' => array( 'icon' => 'stylite/move', 'acceptedTypes' => 'file', @@ -513,7 +518,19 @@ class filemanager_ui case 'copy': foreach($selected as $path) { - if (!egw_vfs::is_dir($path)) + if (strpos($path, 'mail::') === 0 && $path = substr($path, 6)) + { + // Support for dropping mail in filemanager - Pass mail back to mail app + if(ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false)) + { + ++$files; + } + else + { + ++$errs; + } + } + elseif (!egw_vfs::is_dir($path)) { $to = egw_vfs::concat($dir,egw_vfs::basename($path)); if ($path != $to && egw_vfs::copy($path,$to)) diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index 60826bb4a6..24f19b6359 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -1391,7 +1391,7 @@ class mail_ui 'toolbarDefault' => true ), 'drag_mail' => array( - 'dragType' => array('mail','file'), + 'dragType' => array('mail'), 'type' => 'drag', 'onExecute' => 'javaScript:app.mail.mail_dragStart', ) @@ -2517,16 +2517,19 @@ class mail_ui * * @param string|array $ids use splitRowID, to separate values * @param string $path path in vfs (no egw_vfs::PREFIX!), only directory for multiple id's ($ids is an array) - * @return string javascript eg. to close the selector window + * @param boolean $close Return javascript to close the window + * @return string|boolean javascript eg. to close the selector window if $close is true, or success/fail if $close is false */ - function vfsSaveMessage($ids,$path) + function vfsSaveMessage($ids,$path, $close = true) { - error_log(__METHOD__.' IDs:'.array2string($ids).' SaveToPath:'.$path); + //error_log(__METHOD__.' IDs:'.array2string($ids).' SaveToPath:'.$path); if (is_array($ids) && !egw_vfs::is_writable($path) || !is_array($ids) && !egw_vfs::is_writable(dirname($path))) { return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); window.close();'; } + translation::add_app('mail'); + foreach((array)$ids as $id) { $hA = self::splitRowID($id); @@ -2534,7 +2537,16 @@ class mail_ui $mailbox = $hA['folder']; $message = $this->mail_bo->getMessageRawBody($uid, $partID='', $mailbox); $err=null; - if (!($fp = egw_vfs::fopen($file=$path,'wb')) || !fwrite($fp,$message)) + if(egw_vfs::is_dir($path)) + { + $headers = $this->mail_bo->getMessageHeader($uid,$partID,true,false,$mailbox); + $file = $path . '/'.preg_replace('/[\f\n\t\v\\:*#?<>\|]/',"_",$headers['SUBJECT']).'.eml'; + } + else + { + $file = $path; + } + if (!($fp = egw_vfs::fopen($file,'wb')) || !fwrite($fp,$message)) { $err .= lang('Error saving %1!',$file); $succeeded = false; @@ -2546,15 +2558,20 @@ class mail_ui if ($fp) fclose($fp); if ($succeeded) { - translation::add_app('mail'); - $headers = $this->mail_bo->getMessageHeader($uid,$partID,true,false,$mailbox); unset($headers['SUBJECT']);//already in filename $infoSection = mail_bo::createHeaderInfoSection($headers, 'SUPPRESS', false); $props = array(array('name' => 'comment','val' => $infoSection)); egw_vfs::proppatch($file,$props); } } - egw_framework::window_close(($err?$err:null)); + if($close) + { + egw_framework::window_close(($err?$err:null)); + } + else + { + return $succeeded; + } } /**