Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
a0564ca5
Commit
a0564ca5
authored
Jun 02, 2009
by
Richard Mansfield
Browse files
Check that files uploaded during block configuration are the right type for the block
parent
6a6e4caf
Changes
3
Hide whitespace changes
Inline
Side-by-side
htdocs/artefact/file/form/elements/filebrowser.php
View file @
a0564ca5
...
...
@@ -486,6 +486,22 @@ function pieform_element_filebrowser_upload(Pieform $form, $element, $data) {
}
// Upload succeeded
if
(
isset
(
$element
[
'filters'
]))
{
$artefacttypes
=
$element
[
'filters'
][
'artefacttype'
];
$filetypes
=
$element
[
'filters'
][
'filetype'
];
if
(
!
empty
(
$artefacttypes
)
||
!
empty
(
$filetypes
))
{
// Need to check the artefacttype or filetype (mimetype) of the uploaded file.
$file
=
artefact_instance_from_id
(
$newid
);
if
(
is_array
(
$artefacttypes
)
&&
!
in_array
(
$file
->
get
(
'artefacttype'
),
$artefacttypes
)
||
is_array
(
$filetypes
)
&&
!
in_array
(
$file
->
get
(
'filetype'
),
$filetypes
))
{
$result
[
'error'
]
=
true
;
$result
[
'message'
]
=
get_string
(
'wrongfiletypeforblock'
,
'artefact.file'
);
return
$result
;
}
}
}
if
(
$parentfoldername
)
{
if
(
$data
->
title
==
$originalname
)
{
$result
[
'message'
]
=
get_string
(
'uploadoffiletofoldercomplete'
,
'artefact.file'
,
...
...
htdocs/artefact/file/js/filebrowser.js
View file @
a0564ca5
...
...
@@ -378,6 +378,9 @@ function FileBrowser(idprefix, folderid, config, globalconfig) {
}
this
.
add_to_selected_list
=
function
(
id
,
highlight
)
{
if
(
!
self
.
filedata
[
id
])
{
return
;
}
var
tbody
=
getFirstElementByTagAndClassName
(
'
tbody
'
,
null
,
self
.
id
+
'
_selectlist
'
);
var
rows
=
getElementsByTagAndClassName
(
'
tr
'
,
null
,
tbody
);
if
(
rows
.
length
==
0
)
{
...
...
htdocs/artefact/file/lang/en.utf8/artefact.file.php
View file @
a0564ca5
...
...
@@ -200,6 +200,6 @@ $string['Title'] = 'Title';
$string
[
'imagetitle'
]
=
'Image Title'
;
$string
[
'usenodefault'
]
=
'Use no default'
;
$string
[
'usingnodefaultprofileicon'
]
=
'Now using no default profile icon'
;
$string
[
'wrongfiletypeforblock'
]
=
'The file you uploaded was not the correct type for this block.'
;
?>
Write
Preview
Supports
Markdown
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