mirror of
https://github.com/moodle/moodle.git
synced 2025-05-14 12:16:31 +02:00
MDL-16089 fixed hardcoded itemid in module files support
This commit is contained in:
parent
ce13edc4c6
commit
3c131047f2
@ -453,19 +453,14 @@ class file_browser {
|
||||
if (!isset($areas[$modname.'_intro'])
|
||||
and plugin_supports('mod', $modname, FEATURE_MOD_INTRO, true)
|
||||
and has_capability('moodle/course:managefiles', $context)) {
|
||||
$areas[$modname.'_intro'] = get_string('moduleintro');
|
||||
$areas = array_merge(array($modname.'_intro'=>get_string('moduleintro')), $areas);
|
||||
}
|
||||
if (empty($areas)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (is_null($filearea) or is_null($itemid)) {
|
||||
return new file_info_module($this, $course, $cm, $context, $areas);
|
||||
|
||||
} else if (!isset($areas[$filearea])) {
|
||||
return null;
|
||||
|
||||
} else if ($filearea === $modname.'_intro') {
|
||||
if ($filearea === $modname.'_intro') {
|
||||
// always only itemid 0
|
||||
if (!has_capability('moodle/course:managefiles', $context)) {
|
||||
return null;
|
||||
}
|
||||
@ -484,6 +479,13 @@ class file_browser {
|
||||
}
|
||||
return new file_info_stored($this, $context, $storedfile, $urlbase, $areas[$filearea], false, true, true, false);
|
||||
|
||||
} else if (is_null($filearea)) {
|
||||
// modules have to decide if they want to use itemids
|
||||
return new file_info_module($this, $course, $cm, $context, $areas);
|
||||
|
||||
} else if (!array_key_exists($filearea, $areas)) {
|
||||
return null;
|
||||
|
||||
} else {
|
||||
$fileinfofunction = $modname.'_get_file_info';
|
||||
if (function_exists($fileinfofunction)) {
|
||||
|
@ -86,7 +86,7 @@ class file_info_module extends file_info {
|
||||
public function get_children() {
|
||||
$children = array();
|
||||
foreach ($this->areas as $area=>$desctiption) {
|
||||
if ($child = $this->browser->get_file_info($this->context, $area, 0)) {
|
||||
if ($child = $this->browser->get_file_info($this->context, $area, null)) {
|
||||
$children[] = $child;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user