From: skodak Date: Mon, 27 Jul 2009 19:32:45 +0000 (+0000) Subject: MDL-16089 fixed hardcoded itemid in module files support X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=3c131047f2ad6c92f2bd1882da10c44cccb1a84a;p=moodle.git MDL-16089 fixed hardcoded itemid in module files support --- diff --git a/lib/file/file_browser.php b/lib/file/file_browser.php index 680bf6b784..487fec7f7a 100644 --- a/lib/file/file_browser.php +++ b/lib/file/file_browser.php @@ -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)) { diff --git a/lib/file/file_info_module.php b/lib/file/file_info_module.php index 5de584afc5..d32129dd4f 100644 --- a/lib/file/file_info_module.php +++ b/lib/file/file_info_module.php @@ -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; } }