From 535d0db435ac570c12d18e6566c1d6da57a93d0c Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Tue, 12 Jan 2016 15:11:41 +0000 Subject: [PATCH] fix problem on single file download to vfs --- mail/inc/class.mail_ui.inc.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index 3530849669..8b88a89161 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -2528,7 +2528,8 @@ class mail_ui //Examine the first attachment to see if attachment //is winmail.dat embedded attachments. - $p = $getParams($ids[0]); + $isMultipleDownload=is_array($ids); + $p = $getParams((is_array($ids)?$ids[0]:$ids)); if ($p['is_winmail']) { if ($p['icServer'] && $p['icServer'] != $this->mail_bo->profileID) @@ -2541,10 +2542,12 @@ class mail_ui // for each file. $attachments = $this->mail_bo->getTnefAttachments($p['uid'],$p['part']); } - + foreach((array)$ids as $id) { $params = $getParams($id); + // when downloading a single file, name is not set + if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload) $params['name'] = $_GET['name']; if ($params['icServer'] && $params['icServer'] != $this->mail_bo->profileID) { //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); @@ -2552,7 +2555,6 @@ class mail_ui } //error_log(__METHOD__.__LINE__.array2string($hA)); $this->mail_bo->reopen($params['mailbox']); - if ($params['is_winmail']) { // Try to find the right content for file id @@ -2567,7 +2569,8 @@ class mail_ui } $file = $params['name']; - while(egw_vfs::file_exists($path.($file ? '/'.$file : ''))) + // when $isMultipleDownload the path holds no filename + while(egw_vfs::file_exists($path.($file && $isMultipleDownload ? '/'.$file : ''))) { $dupe_count[$params['name']]++; $file = pathinfo($params['name'], PATHINFO_FILENAME) . @@ -2576,7 +2579,8 @@ class mail_ui } $params['name'] = $file; //error_log(__METHOD__.__LINE__.array2string($attachment)); - if (!($fp = egw_vfs::fopen($file=$path.($params['name'] ? '/'.$params['name'] : ''),'wb')) || + // when $isMultipleDownload the path holds no filename + if (!($fp = egw_vfs::fopen($file=$path.($params['name'] && $isMultipleDownload ? '/'.$params['name'] : ''),'wb')) || !fwrite($fp,$attachment['attachment'])) { $err .= lang('Error saving %1!',$file);