From abee24ed0c0b7b30a1a962a57426d4b55bbbf4f0 Mon Sep 17 00:00:00 2001 From: Jean-Fabien Barrios Date: Wed, 22 Sep 2010 02:20:28 +0000 Subject: [PATCH] ENHANCEMENT: Don't return a blank url when no file is specified --- code/submissions/SubmittedFileField.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/code/submissions/SubmittedFileField.php b/code/submissions/SubmittedFileField.php index ca577f7..dbec4e2 100755 --- a/code/submissions/SubmittedFileField.php +++ b/code/submissions/SubmittedFileField.php @@ -17,7 +17,8 @@ class SubmittedFileField extends SubmittedFormField { * @return String */ function getFormattedValue() { - return ''. _t('SubmittedFileField.DOWNLOADFILE', 'Download File') .''; + $link = $this->getLink(); + return (!empty($link)) ? ''. _t('SubmittedFileField.DOWNLOADFILE', 'Download File') .'' : ''; } /** @@ -26,6 +27,10 @@ class SubmittedFileField extends SubmittedFormField { * @return String */ function getLink() { - return ($this->UploadedFile()) ? $this->UploadedFile()->URL : ""; + if ($this->UploadedFile()){ + // Test if there is a filename, not only a filepath to the assets folder + return ($this->UploadedFile()->getFilename() != ASSETS_DIR.'/') ? $this->UploadedFile()->URL : ''; + } + return ''; } } \ No newline at end of file