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
info
mahara-museum
Commits
e128c2ca
Commit
e128c2ca
authored
Jan 09, 2008
by
Richard Mansfield
Committed by
Nigel McNie
Jan 15, 2008
Browse files
Remove duplicated code
parent
4f52fc18
Changes
1
Show whitespace changes
Inline
Side-by-side
htdocs/artefact/file/download.php
View file @
e128c2ca
...
...
@@ -53,26 +53,20 @@ if ($viewid && $fileid) {
if
(
!
(
$file
instanceof
ArtefactTypeFile
))
{
throw
new
NotFoundException
();
}
$path
=
$file
->
get_path
(
array
(
'size'
=>
$size
));
$title
=
$file
->
download_title
();
if
(
$contenttype
=
$file
->
override_content_type
())
{
$options
[
'overridecontenttype'
]
=
$contenttype
;
}
serve_file
(
$path
,
$title
,
$options
);
}
// We just have a file ID
$file
=
artefact_instance_from_id
(
$fileid
);
if
(
!
(
$file
instanceof
ArtefactTypeFile
))
{
else
{
// We just have a file ID
$file
=
artefact_instance_from_id
(
$fileid
);
if
(
!
(
$file
instanceof
ArtefactTypeFile
))
{
throw
new
NotFoundException
();
}
}
// If the file is in the public directory, it's fine to serve
$fileispublic
=
$file
->
get
(
'parent'
)
==
ArtefactTypeFolder
::
admin_public_folder_id
();
$fileispublic
&=
$file
->
get
(
'adminfiles'
);
$fileispublic
&=
record_exists
(
'site_menu'
,
'file'
,
$fileid
,
'public'
,
1
);
// If the file is in the public directory, it's fine to serve
$fileispublic
=
$file
->
get
(
'parent'
)
==
ArtefactTypeFolder
::
admin_public_folder_id
();
$fileispublic
&=
$file
->
get
(
'adminfiles'
);
$fileispublic
&=
record_exists
(
'site_menu'
,
'file'
,
$fileid
,
'public'
,
1
);
if
(
!
$fileispublic
)
{
if
(
!
$fileispublic
)
{
// If the file is in the logged in menu and the user is logged in then
// they can view it
$fileinloggedinmenu
=
$file
->
get
(
'adminfiles'
);
...
...
@@ -88,6 +82,7 @@ if (!$fileispublic) {
throw
new
AccessDeniedException
();
}
}
}
}
$path
=
$file
->
get_path
(
array
(
'size'
=>
$size
));
...
...
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