Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gredu_labs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Σταύρος Παπαδάκης
gredu_labs
Commits
de9df588
Commit
de9df588
authored
Mar 04, 2016
by
Vassilis Kanellopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix #15; mime type validation when uploading file
parent
e5a7c0d5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
4 deletions
+28
-4
module/schools/src/InputFilter/Lab.php
module/schools/src/InputFilter/Lab.php
+17
-1
module/schools/src/Service/LabService.php
module/schools/src/Service/LabService.php
+3
-1
public/js/utils.js
public/js/utils.js
+8
-2
No files found.
module/schools/src/InputFilter/Lab.php
View file @
de9df588
...
...
@@ -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
);
...
...
module/schools/src/Service/LabService.php
View file @
de9df588
...
...
@@ -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'
];
...
...
public/js/utils.js
View file @
de9df588
...
...
@@ -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
=
$
(
'
<ul class="help-block has-error">
'
);
for
(
key
in
messages
)
{
if
(
messages
.
hasOwnProperty
(
key
))
{
ul
.
append
(
$
(
'
<li>
'
).
text
(
messages
[
key
]));
}
}
element
.
after
(
ul
);
if
(
inputGrp
.
length
>
0
)
{
inputGrp
.
after
(
ul
);
}
else
{
element
.
after
(
ul
);
}
};
var
prop
;
this
.
clear
(
form
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment