Fix attached files in mail - Refs # 8154

1.10.x
José Loguercio 9 years ago
parent 94b01481b5
commit 4292a69177
  1. 19
      main/inc/lib/api.lib.php
  2. 9
      main/inc/lib/message.lib.php
  3. 6
      main/inc/lib/notification.lib.php

@ -7846,8 +7846,8 @@ function api_create_protected_dir($name, $parentDirectory)
* @param string sender e-mail
* @param array extra headers in form $headers = array($name => $value) to allow parsing
* @param array data file (path and filename)
* @param array data to attach a file (optional)
* @param bool True for attaching a embedded file inside content html (optional)
* @param array Additional parameters
* @return returns true if mail was sent
* @see class.phpmailer.php
*/
@ -7968,7 +7968,22 @@ function api_mail_html(
// Attachment ...
if (!empty($data_file)) {
$mail->AddAttachment($data_file['path'], $data_file['filename']);
$o = 0;
foreach ($data_file as $file_attach) {
if (!empty($file_attach['path']) && !empty($file_attach['filename'])) {
$mail->AddAttachment($file_attach['path'], $file_attach['filename']);
}
$o++;
}
} elseif (is_array($_FILES)) {
$data_file = $_FILES;
$o = 0;
foreach ($data_file as $file_attach) {
if (!empty($file_attach['tmp_name']) && !empty($file_attach['name'])) {
$mail->AddAttachment($file_attach['tmp_name'], $file_attach['name']);
}
$o++;
}
}
// Only valid addresses are accepted.

@ -362,6 +362,12 @@ class MessageManager
// Load user settings.
$notification = new Notification();
$sender_info = api_get_user_info($user_sender_id);
// add file attachment additional attributes
foreach ($file_attachments as $file_attach) {
$file_attachments['path'] = $file_attach['tmp_name'];
$file_attachments['filename'] = $file_attach['name'];
}
if (empty($group_id)) {
$type = Notification::NOTIFICATION_TYPE_MESSAGE;
@ -373,7 +379,8 @@ class MessageManager
array($receiver_user_id),
$subject,
$content,
$sender_info
$sender_info,
$file_attachments
);
} else {
$usergroup = new UserGroup();

@ -227,7 +227,8 @@ class Notification extends Model
$user_list,
$title,
$content,
$senderInfo = array()
$senderInfo = array(),
$attachments = array()
) {
$this->type = intval($type);
$content = $this->formatContent($content, $senderInfo);
@ -307,7 +308,8 @@ class Notification extends Model
Security::filter_terms($content),
$this->adminName,
$this->adminEmail,
$extraHeaders
$extraHeaders,
$attachments
);
}
$sendDate = api_get_utc_datetime();

Loading…
Cancel
Save