FIX Fixing plain email blank file field value (#940)

* Fixing plain email blank file field value
This commit is contained in:
3Dgoo 2020-07-01 06:30:31 +09:30 committed by GitHub
parent 8c2d9a9438
commit 6ca8ce2596
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -25,6 +25,7 @@ use SilverStripe\UserForms\Form\UserForm;
use SilverStripe\UserForms\Model\EditableFormField; use SilverStripe\UserForms\Model\EditableFormField;
use SilverStripe\UserForms\Model\EditableFormField\EditableFileField; use SilverStripe\UserForms\Model\EditableFormField\EditableFileField;
use SilverStripe\UserForms\Model\Submission\SubmittedForm; use SilverStripe\UserForms\Model\Submission\SubmittedForm;
use SilverStripe\UserForms\Model\Submission\SubmittedFileField;
use SilverStripe\UserForms\Model\UserDefinedForm; use SilverStripe\UserForms\Model\UserDefinedForm;
use SilverStripe\View\ArrayData; use SilverStripe\View\ArrayData;
use SilverStripe\View\Requirements; use SilverStripe\View\Requirements;
@ -416,9 +417,13 @@ JS
$body = strip_tags($recipient->getEmailBodyContent()) . "\n"; $body = strip_tags($recipient->getEmailBodyContent()) . "\n";
if (isset($emailData['Fields']) && !$emailData['HideFormData']) { if (isset($emailData['Fields']) && !$emailData['HideFormData']) {
foreach ($emailData['Fields'] as $field) { foreach ($emailData['Fields'] as $field) {
if ($field instanceof SubmittedFileField) {
$body .= $field->Title . ': ' . $field->ExportValue ." \n";
} else {
$body .= $field->Title . ': ' . $field->Value . " \n"; $body .= $field->Title . ': ' . $field->Value . " \n";
} }
} }
}
$email->setBody($body); $email->setBody($body);
$email->sendPlain(); $email->sendPlain();

View File

@ -61,7 +61,8 @@ class SubmittedFileField extends SubmittedFormField
*/ */
public function getLink() public function getLink()
{ {
if ($file = $this->UploadedFile()) { $file = $this->UploadedFile();
if ($file && $file->exists()) {
if (trim($file->getFilename(), '/') != trim(ASSETS_DIR, '/')) { if (trim($file->getFilename(), '/') != trim(ASSETS_DIR, '/')) {
return $this->UploadedFile()->AbsoluteLink(); return $this->UploadedFile()->AbsoluteLink();
} }