}
$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();
// 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();
}
// 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();
}
// 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();
}
}
$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();
}
}
$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();
}
}
$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();
}
}
$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();
}
}
$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();
}
}
$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();
}
}
$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();
}
//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();
}
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();
}
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();
}
$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();
}
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();
}
// 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();
}