forked from extern/egroupware
Handle multiple attachments with the same name when linking attachments from an email into an entry for another application
This commit is contained in:
parent
bfee0a1bce
commit
9cb46a4d79
@ -5763,6 +5763,9 @@ class emailadmin_imapbase
|
||||
//_debug_array($attachments);
|
||||
if (is_array($attachments))
|
||||
{
|
||||
// For dealing with multiple files of the same name
|
||||
$dupe_count = $file_list = array();
|
||||
|
||||
foreach ($attachments as $num => $attachment)
|
||||
{
|
||||
if ($attachment['mimeType'] == 'MESSAGE/RFC822')
|
||||
@ -5809,11 +5812,19 @@ class emailadmin_imapbase
|
||||
//if ($attachments[$num]['charset']===false) $attachments[$num]['charset'] = translation::detect_encoding($attachments[$num]['attachment']);
|
||||
translation::convert($attachments[$num]['attachment'],$attachments[$num]['charset']);
|
||||
}
|
||||
if(in_array($attachments[$num]['name'], $file_list))
|
||||
{
|
||||
$dupe_count[$attachments[$num]['name']]++;
|
||||
$attachments[$num]['name'] = pathinfo($attachments[$num]['name'], PATHINFO_FILENAME) .
|
||||
' ('.($dupe_count[$attachments[$num]['name']] + 1).')' . '.' .
|
||||
pathinfo($attachments[$num]['name'], PATHINFO_EXTENSION);
|
||||
}
|
||||
$attachments[$num]['type'] = $attachments[$num]['mimeType'];
|
||||
$attachments[$num]['tmp_name'] = tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_");
|
||||
$tmpfile = fopen($attachments[$num]['tmp_name'],'w');
|
||||
fwrite($tmpfile,$attachments[$num]['attachment']);
|
||||
fclose($tmpfile);
|
||||
$file_list[] = $attachments[$num]['name'];
|
||||
unset($attachments[$num]['attachment']);
|
||||
}
|
||||
}
|
||||
|
@ -76,6 +76,10 @@ class mail_integration {
|
||||
$time = time();
|
||||
$_date = egw_time::server2user($time->now,'ts');
|
||||
}
|
||||
|
||||
// For dealing with multiple files of the same name
|
||||
$dupe_count = $file_list = array();
|
||||
|
||||
$GLOBALS['egw_info']['flags']['currentapp'] = $app;
|
||||
//error_log(__METHOD__.__LINE__.': RowID:'.$_GET['rowid'].': emailAddress:'. array2string($_to_emailAddress).' && '.$app);
|
||||
// Integrate not yet saved mail
|
||||
@ -137,6 +141,13 @@ class mail_integration {
|
||||
{
|
||||
$attachment['file'] = $GLOBALS['egw_info']['server']['temp_dir'].SEP.basename($attachment['file']);
|
||||
}
|
||||
if(in_array($attachment['name'], $file_list))
|
||||
{
|
||||
$dupe_count[$attachment['name']]++;
|
||||
$attachment['name'] = pathinfo($attachment['name'], PATHINFO_FILENAME) .
|
||||
' ('.($dupe_count[$attachment['name']] + 1).')' . '.' .
|
||||
pathinfo($attachment['name'], PATHINFO_EXTENSION);
|
||||
}
|
||||
$attachments[] = array(
|
||||
'name' => $attachment['name'],
|
||||
'mimeType' => $attachment['type'],
|
||||
@ -144,6 +155,7 @@ class mail_integration {
|
||||
'tmp_name' => $attachment['file'],
|
||||
'size' => $attachment['size'],
|
||||
);
|
||||
$file_list[] = $attachment['name'];
|
||||
}
|
||||
}
|
||||
if ($messageFolder && $messageUid && $messagePartId && $mo->isDraftFolder($messageFolder) && !$mo->isTemplateFolder($messageFolder))
|
||||
|
Loading…
Reference in New Issue
Block a user