mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
Merge branch 'MDL-44257-master' of git://github.com/lameze/moodle
This commit is contained in:
commit
c4006c851a
3 changed files with 19 additions and 4 deletions
|
@ -5888,7 +5888,16 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml = '',
|
|||
} else {
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
$mimetype = mimeinfo('type', $attachname);
|
||||
$mail->addAttachment($CFG->dataroot .'/'. $attachment, $attachname, 'base64', $mimetype);
|
||||
|
||||
$attachmentpath = $attachment;
|
||||
|
||||
// If the attachment is a full path to a file in the tempdir, use it as is,
|
||||
// otherwise assume it is a relative path from the dataroot (for backwards compatibility reasons).
|
||||
if (strpos($attachmentpath, $CFG->tempdir) !== 0) {
|
||||
$attachmentpath = $CFG->dataroot . '/' . $attachmentpath;
|
||||
}
|
||||
|
||||
$mail->addAttachment($attachmentpath, $attachname, 'base64', $mimetype);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -760,6 +760,11 @@ class core_messagelib_testcase extends advanced_testcase {
|
|||
$email = reset($emails);
|
||||
$this->assertTrue(strpos($email->body, 'Content-Disposition: attachment;') !== false);
|
||||
$this->assertTrue(strpos($email->body, 'emailtest.txt') !== false);
|
||||
|
||||
// Check if the stored file still exists after remove the temporary attachment.
|
||||
$storedfileexists = $fs->file_exists($filerecord['contextid'], $filerecord['component'], $filerecord['filearea'],
|
||||
$filerecord['itemid'], $filerecord['filepath'], $filerecord['filename']);
|
||||
$this->assertTrue($storedfileexists);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue