mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 00:16:46 +02:00
MDL-22950 fixed regression - files in subdirectories not found; big thanks to Dongsheng for spotting this
This commit is contained in:
parent
c393165495
commit
d85ab7051c
2 changed files with 18 additions and 18 deletions
|
@ -38,7 +38,7 @@ function block_html_pluginfile($course, $birecord_or_cm, $context, $filearea, $a
|
||||||
$fs = get_file_storage();
|
$fs = get_file_storage();
|
||||||
|
|
||||||
$filename = array_pop($args);
|
$filename = array_pop($args);
|
||||||
$filepath = '/'.implode('/', $args);
|
$filepath = $args ? '/'.implode('/', $args).'/' : '/';
|
||||||
|
|
||||||
if (!$file = $fs->get_file($context->id, 'block_html', 'content', 0, $filepath, $filename) or $file->is_directory()) {
|
if (!$file = $fs->get_file($context->id, 'block_html', 'content', 0, $filepath, $filename) or $file->is_directory()) {
|
||||||
send_file_not_found();
|
send_file_not_found();
|
||||||
|
|
|
@ -117,7 +117,7 @@ if ($component === 'blog') {
|
||||||
}
|
}
|
||||||
|
|
||||||
$filename = array_pop($args);
|
$filename = array_pop($args);
|
||||||
$filepath = '/'.implode('/', $args);
|
$filepath = $args ? '/'.implode('/', $args).'/' : '/';
|
||||||
|
|
||||||
if (!$file = $fs->get_file($context->id, $component, $filearea, $entryid, $filepath, $filename) or $file->is_directory()) {
|
if (!$file = $fs->get_file($context->id, $component, $filearea, $entryid, $filepath, $filename) or $file->is_directory()) {
|
||||||
send_file_not_found();
|
send_file_not_found();
|
||||||
|
@ -204,7 +204,7 @@ if ($component === 'blog') {
|
||||||
|
|
||||||
// Get the file and serve if successful
|
// Get the file and serve if successful
|
||||||
$filename = array_pop($args);
|
$filename = array_pop($args);
|
||||||
$filepath = '/'.implode('/', $args);
|
$filepath = $args ? '/'.implode('/', $args).'/' : '/';
|
||||||
if (!$file = $fs->get_file($context->id, $component, $filearea, $eventid, $filepath, $filename) or $file->is_directory()) {
|
if (!$file = $fs->get_file($context->id, $component, $filearea, $eventid, $filepath, $filename) or $file->is_directory()) {
|
||||||
send_file_not_found();
|
send_file_not_found();
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ if ($component === 'blog') {
|
||||||
|
|
||||||
// Get the file and serve if successful
|
// Get the file and serve if successful
|
||||||
$filename = array_pop($args);
|
$filename = array_pop($args);
|
||||||
$filepath = '/'.implode('/', $args);
|
$filepath = $args ? '/'.implode('/', $args).'/' : '/';
|
||||||
if (!$file = $fs->get_file($context->id, $component, $filearea, $eventid, $filepath, $filename) or $file->is_directory()) {
|
if (!$file = $fs->get_file($context->id, $component, $filearea, $eventid, $filepath, $filename) or $file->is_directory()) {
|
||||||
send_file_not_found();
|
send_file_not_found();
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ if ($component === 'blog') {
|
||||||
|
|
||||||
// If we get this far we can serve the file
|
// If we get this far we can serve the file
|
||||||
$filename = array_pop($args);
|
$filename = array_pop($args);
|
||||||
$filepath = '/'.implode('/', $args);
|
$filepath = $args ? '/'.implode('/', $args).'/' : '/';
|
||||||
if (!$file = $fs->get_file($context->id, $component, $filearea, $eventid, $filepath, $filename) or $file->is_directory()) {
|
if (!$file = $fs->get_file($context->id, $component, $filearea, $eventid, $filepath, $filename) or $file->is_directory()) {
|
||||||
send_file_not_found();
|
send_file_not_found();
|
||||||
}
|
}
|
||||||
|
@ -305,7 +305,7 @@ if ($component === 'blog') {
|
||||||
}
|
}
|
||||||
|
|
||||||
$filename = array_pop($args);
|
$filename = array_pop($args);
|
||||||
$filepath = '/'.implode('/', $args);
|
$filepath = $args ? '/'.implode('/', $args).'/' : '/';
|
||||||
if (!$file = $fs->get_file($context->id, $component, $filearea, 0, $filepath, $filename) or $file->is_directory()) {
|
if (!$file = $fs->get_file($context->id, $component, $filearea, 0, $filepath, $filename) or $file->is_directory()) {
|
||||||
send_file_not_found();
|
send_file_not_found();
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,7 @@ if ($component === 'blog') {
|
||||||
}
|
}
|
||||||
|
|
||||||
$filename = array_pop($args);
|
$filename = array_pop($args);
|
||||||
$filepath = '/'.implode('/', $args);
|
$filepath = $args ? '/'.implode('/', $args).'/' : '/';
|
||||||
if (!$file = $fs->get_file($context->id, $component, $filearea, 0, $filepath, $filename) or $file->is_directory()) {
|
if (!$file = $fs->get_file($context->id, $component, $filearea, 0, $filepath, $filename) or $file->is_directory()) {
|
||||||
send_file_not_found();
|
send_file_not_found();
|
||||||
}
|
}
|
||||||
|
@ -390,7 +390,7 @@ if ($component === 'blog') {
|
||||||
}
|
}
|
||||||
|
|
||||||
$filename = array_pop($args);
|
$filename = array_pop($args);
|
||||||
$filepath = '/'.implode('/', $args);
|
$filepath = $args ? '/'.implode('/', $args).'/' : '/';
|
||||||
if (!$file = $fs->get_file($context->id, 'user', 'profile', 0, $filepath, $filename) or $file->is_directory()) {
|
if (!$file = $fs->get_file($context->id, 'user', 'profile', 0, $filepath, $filename) or $file->is_directory()) {
|
||||||
send_file_not_found();
|
send_file_not_found();
|
||||||
}
|
}
|
||||||
|
@ -409,7 +409,7 @@ if ($component === 'blog') {
|
||||||
}
|
}
|
||||||
|
|
||||||
$filename = array_pop($args);
|
$filename = array_pop($args);
|
||||||
$filepath = '/'.implode('/', $args);
|
$filepath = $args ? '/'.implode('/', $args).'/' : '/';
|
||||||
if (!$file = $fs->get_file($context->id, 'user', 'backup', 0, $filepath, $filename) or $file->is_directory()) {
|
if (!$file = $fs->get_file($context->id, 'user', 'backup', 0, $filepath, $filename) or $file->is_directory()) {
|
||||||
send_file_not_found();
|
send_file_not_found();
|
||||||
}
|
}
|
||||||
|
@ -434,7 +434,7 @@ if ($component === 'blog') {
|
||||||
}
|
}
|
||||||
|
|
||||||
$filename = array_pop($args);
|
$filename = array_pop($args);
|
||||||
$filepath = '/'.implode('/', $args);
|
$filepath = $args ? '/'.implode('/', $args).'/' : '/';
|
||||||
if (!$file = $fs->get_file($context->id, 'coursecat', 'description', 0, $filepath, $filename) or $file->is_directory()) {
|
if (!$file = $fs->get_file($context->id, 'coursecat', 'description', 0, $filepath, $filename) or $file->is_directory()) {
|
||||||
send_file_not_found();
|
send_file_not_found();
|
||||||
}
|
}
|
||||||
|
@ -457,7 +457,7 @@ if ($component === 'blog') {
|
||||||
}
|
}
|
||||||
|
|
||||||
$filename = array_pop($args);
|
$filename = array_pop($args);
|
||||||
$filepath = '/'.implode('/', $args);
|
$filepath = $args ? '/'.implode('/', $args).'/' : '/';
|
||||||
if (!$file = $fs->get_file($context->id, 'course', 'summary', 0, $filepath, $filename) or $file->is_directory()) {
|
if (!$file = $fs->get_file($context->id, 'course', 'summary', 0, $filepath, $filename) or $file->is_directory()) {
|
||||||
send_file_not_found();
|
send_file_not_found();
|
||||||
}
|
}
|
||||||
|
@ -483,7 +483,7 @@ if ($component === 'blog') {
|
||||||
}
|
}
|
||||||
|
|
||||||
$filename = array_pop($args);
|
$filename = array_pop($args);
|
||||||
$filepath = '/'.implode('/', $args);
|
$filepath = $args ? '/'.implode('/', $args).'/' : '/';
|
||||||
if (!$file = $fs->get_file($context->id, 'course', 'section', $sectionid, $filepath, $filename) or $file->is_directory()) {
|
if (!$file = $fs->get_file($context->id, 'course', 'section', $sectionid, $filepath, $filename) or $file->is_directory()) {
|
||||||
send_file_not_found();
|
send_file_not_found();
|
||||||
}
|
}
|
||||||
|
@ -514,7 +514,7 @@ if ($component === 'blog') {
|
||||||
//TODO: implement group image storage in file pool
|
//TODO: implement group image storage in file pool
|
||||||
|
|
||||||
$filename = array_pop($args);
|
$filename = array_pop($args);
|
||||||
$filepath = '/'.implode('/', $args);
|
$filepath = $args ? '/'.implode('/', $args).'/' : '/';
|
||||||
if (!$file = $fs->get_file($context->id, 'group', 'description', $group->id, $filepath, $filename) or $file->is_directory()) {
|
if (!$file = $fs->get_file($context->id, 'group', 'description', $group->id, $filepath, $filename) or $file->is_directory()) {
|
||||||
send_file_not_found();
|
send_file_not_found();
|
||||||
}
|
}
|
||||||
|
@ -539,7 +539,7 @@ if ($component === 'blog') {
|
||||||
if ($filearea === 'description') {
|
if ($filearea === 'description') {
|
||||||
|
|
||||||
$filename = array_pop($args);
|
$filename = array_pop($args);
|
||||||
$filepath = '/'.implode('/', $args);
|
$filepath = $args ? '/'.implode('/', $args).'/' : '/';
|
||||||
if (!$file = $fs->get_file($context->id, 'grouping', 'description', $groupingid->id, $filepath, $filename) or $file->is_directory()) {
|
if (!$file = $fs->get_file($context->id, 'grouping', 'description', $groupingid->id, $filepath, $filename) or $file->is_directory()) {
|
||||||
send_file_not_found();
|
send_file_not_found();
|
||||||
}
|
}
|
||||||
|
@ -558,7 +558,7 @@ if ($component === 'blog') {
|
||||||
require_capability('moodle/backup:downloadfile', $context);
|
require_capability('moodle/backup:downloadfile', $context);
|
||||||
|
|
||||||
$filename = array_pop($args);
|
$filename = array_pop($args);
|
||||||
$filepath = '/'.implode('/', $args);
|
$filepath = $args ? '/'.implode('/', $args).'/' : '/';
|
||||||
if (!$file = $fs->get_file($context->id, 'backup', 'course', 0, $filepath, $filename) or $file->is_directory()) {
|
if (!$file = $fs->get_file($context->id, 'backup', 'course', 0, $filepath, $filename) or $file->is_directory()) {
|
||||||
send_file_not_found();
|
send_file_not_found();
|
||||||
}
|
}
|
||||||
|
@ -573,7 +573,7 @@ if ($component === 'blog') {
|
||||||
$sectionid = (int)array_shift($args);
|
$sectionid = (int)array_shift($args);
|
||||||
|
|
||||||
$filename = array_pop($args);
|
$filename = array_pop($args);
|
||||||
$filepath = '/'.implode('/', $args);
|
$filepath = $args ? '/'.implode('/', $args).'/' : '/';
|
||||||
if (!$file = $fs->get_file($context->id, 'backup', 'section', $sectionid, $filepath, $filename) or $file->is_directory()) {
|
if (!$file = $fs->get_file($context->id, 'backup', 'section', $sectionid, $filepath, $filename) or $file->is_directory()) {
|
||||||
send_file_not_found();
|
send_file_not_found();
|
||||||
}
|
}
|
||||||
|
@ -586,7 +586,7 @@ if ($component === 'blog') {
|
||||||
require_capability('moodle/backup:downloadfile', $context);
|
require_capability('moodle/backup:downloadfile', $context);
|
||||||
|
|
||||||
$filename = array_pop($args);
|
$filename = array_pop($args);
|
||||||
$filepath = '/'.implode('/', $args);
|
$filepath = $args ? '/'.implode('/', $args).'/' : '/';
|
||||||
if (!$file = $fs->get_file($context->id, 'backup', 'activity', 0, $filepath, $filename) or $file->is_directory()) {
|
if (!$file = $fs->get_file($context->id, 'backup', 'activity', 0, $filepath, $filename) or $file->is_directory()) {
|
||||||
send_file_not_found();
|
send_file_not_found();
|
||||||
}
|
}
|
||||||
|
@ -621,7 +621,7 @@ if ($component === 'blog') {
|
||||||
|
|
||||||
// all users may access it
|
// all users may access it
|
||||||
$filename = array_pop($args);
|
$filename = array_pop($args);
|
||||||
$filepath = '/'.implode('/', $args);
|
$filepath = $args ? '/'.implode('/', $args).'/' : '/';
|
||||||
if (!$file = $fs->get_file($context->id, 'mod_'.$modname, 'intro', 0, $filepath, $filename) or $file->is_directory()) {
|
if (!$file = $fs->get_file($context->id, 'mod_'.$modname, 'intro', 0, $filepath, $filename) or $file->is_directory()) {
|
||||||
send_file_not_found();
|
send_file_not_found();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue