diff --git a/module/schools/src/InputFilter/Lab.php b/module/schools/src/InputFilter/Lab.php index 467adad02be8c32d81ba67f15b1308b1779341f7..0f1b290720a6233835ebc373d03cd3dda1e2eafd 100644 --- a/module/schools/src/InputFilter/Lab.php +++ b/module/schools/src/InputFilter/Lab.php @@ -66,7 +66,23 @@ class Lab 'randomize' => true, ])); $attachment->getValidatorChain() - ->attach(new Validator\File\UploadFile()); + ->attach(new Validator\File\UploadFile()) + ->attach(new Validator\File\MimeType([ + 'application/zip', + 'application/x-rar-compressed', + 'application/octet-stream', + 'application/pdf', + 'image/png', + 'image/jpeg', + 'image/gif', + 'image/bmp', + 'image/vnd.microsoft.icon', + 'image/tiff', + 'image/tiff', + 'image/svg+xml', + 'image/svg+xml', + 'image/vnd.adobe.photoshop', + ])); $use_ext_program= new Input('use_ext_program'); $use_ext_program->setRequired(false); diff --git a/module/schools/src/Service/LabService.php b/module/schools/src/Service/LabService.php index 56d6ac32250259084a20543bc5fc391eb9cf708b..81b80e453b0fde4fc53b16027315f3d022b93fce 100644 --- a/module/schools/src/Service/LabService.php +++ b/module/schools/src/Service/LabService.php @@ -142,7 +142,9 @@ class LabService implements LabServiceInterface mkdir($fullPath, 0700, true); } // remove previous - unlink($this->filesPath . '/' . $lab->attachment); + if ($lab->attachment) { + unlink($this->filesPath . '/' . $lab->attachment); + } // move new file rename($attachment['tmp_name'], $fullPath . '/' . $attachment['name']); $lab->attachment = $schoolPath . '/' . $attachment['name']; diff --git a/public/js/utils.js b/public/js/utils.js index 1ce3beed38928b26171b9df3d9e5870c86d0831a..656f8bbf5431063052e9b921b90d36d715bcaa33 100644 --- a/public/js/utils.js +++ b/public/js/utils.js @@ -23,15 +23,21 @@ render: function (form, messages) { var renderMessages = function (element, messages) { var key, - ul; + ul, + inputGrp; element.parents('.form-group').addClass('has-error'); + inputGrp = element.parents('.input-group'); ul = $('