Skip to content

Commit

Permalink
MDL-22950 fixed regression - files in subdirectories not found; big t…
Browse files Browse the repository at this point in the history
…hanks to Dongsheng for spotting this
  • Loading branch information
skodak committed Jul 7, 2010
1 parent c393165 commit d85ab70
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion blocks/html/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function block_html_pluginfile($course, $birecord_or_cm, $context, $filearea, $a
$fs = get_file_storage();

$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()) {
send_file_not_found();
Expand Down
34 changes: 17 additions & 17 deletions pluginfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
}

$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()) {
send_file_not_found();
Expand Down Expand Up @@ -204,7 +204,7 @@

// Get the file and serve if successful
$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()) {
send_file_not_found();
}
Expand Down Expand Up @@ -232,7 +232,7 @@

// Get the file and serve if successful
$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()) {
send_file_not_found();
}
Expand Down Expand Up @@ -279,7 +279,7 @@

// If we get this far we can serve the file
$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()) {
send_file_not_found();
}
Expand All @@ -305,7 +305,7 @@
}

$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()) {
send_file_not_found();
}
Expand Down Expand Up @@ -352,7 +352,7 @@
}

$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()) {
send_file_not_found();
}
Expand Down Expand Up @@ -390,7 +390,7 @@
}

$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()) {
send_file_not_found();
}
Expand All @@ -409,7 +409,7 @@
}

$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()) {
send_file_not_found();
}
Expand All @@ -434,7 +434,7 @@
}

$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()) {
send_file_not_found();
}
Expand All @@ -457,7 +457,7 @@
}

$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()) {
send_file_not_found();
}
Expand All @@ -483,7 +483,7 @@
}

$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()) {
send_file_not_found();
}
Expand Down Expand Up @@ -514,7 +514,7 @@
//TODO: implement group image storage in file pool

$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()) {
send_file_not_found();
}
Expand All @@ -539,7 +539,7 @@
if ($filearea === 'description') {

$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()) {
send_file_not_found();
}
Expand All @@ -558,7 +558,7 @@
require_capability('moodle/backup:downloadfile', $context);

$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()) {
send_file_not_found();
}
Expand All @@ -573,7 +573,7 @@
$sectionid = (int)array_shift($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()) {
send_file_not_found();
}
Expand All @@ -586,7 +586,7 @@
require_capability('moodle/backup:downloadfile', $context);

$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()) {
send_file_not_found();
}
Expand Down Expand Up @@ -621,7 +621,7 @@

// all users may access it
$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()) {
send_file_not_found();
}
Expand Down

0 comments on commit d85ab70

Please sign in to comment.