mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-03 12:39:25 +01:00
Drag & drop support for mail into filemanager
This commit is contained in:
parent
8af4ca6049
commit
9481dab570
@ -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))
|
||||
|
@ -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,16 +2558,21 @@ 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);
|
||||
}
|
||||
}
|
||||
if($close)
|
||||
{
|
||||
egw_framework::window_close(($err?$err:null));
|
||||
}
|
||||
else
|
||||
{
|
||||
return $succeeded;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save an attachment in the vfs
|
||||
|
Loading…
Reference in New Issue
Block a user