Skip to content

Commit

Permalink
Fix SubmissionFile::validate error display
Browse files Browse the repository at this point in the history
  • Loading branch information
Antti-Jussi Nygård authored and Antti-Jussi Nygård committed Feb 22, 2024
1 parent 376418e commit 77a29e2
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions AllowedUploadsPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ function checkUploadWizard($hookName, $params) {
$errors =& $params[0];
$request = Application::get()->getRequest();
$context = $request->getContext();

$fileName = $props['name'][$locale];
$tmp = explode('.',$fileName);
$extension = strtolower(end($tmp));
Expand All @@ -126,7 +125,7 @@ function checkUploadWizard($hookName, $params) {
if ($allowedExtensions){
$allowedExtensionsArray = array_filter(array_map('trim', explode(';', $allowedExtensions )), 'strlen');
if (!in_array($extension, $allowedExtensionsArray)){
$errors['allowedExtensions'][$locale] = __('plugins.generic.allowedUploads.error', array('allowedExtensions' => $allowedExtensions));
$errors[] = __('plugins.generic.allowedUploads.error', array('allowedExtensions' => $allowedExtensions));
}
}

Expand All @@ -141,7 +140,6 @@ function checkUpload($hookName, $params) {
$form = $params[0];
$request = Application::get()->getRequest();
$context = $request->getContext();

$userVars = $request->getUserVars();
$fileName = $userVars['name'];
$tmp = explode('.',$fileName);
Expand All @@ -154,7 +152,7 @@ function checkUpload($hookName, $params) {
$allowedExtensionsArray = array_filter(array_map('trim', explode(';', $allowedExtensions )), 'strlen');

if (!in_array($extension, $allowedExtensionsArray)){
$form->addError('fileType', __('plugins.generic.allowedUploads.error', array('allowedExtensions' => $allowedExtensions)));
$form->addError('allowedFileType', __('plugins.generic.allowedUploads.error', ['allowedExtensions' => $allowedExtensions]));
}

}
Expand Down

0 comments on commit 77a29e2

Please sign in to comment.