]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-16089 fixed hardcoded itemid in module files support
authorskodak <skodak>
Mon, 27 Jul 2009 19:32:45 +0000 (19:32 +0000)
committerskodak <skodak>
Mon, 27 Jul 2009 19:32:45 +0000 (19:32 +0000)
lib/file/file_browser.php
lib/file/file_info_module.php

index 680bf6b7841ae96c211c62e1a4e7913d98f6de8d..487fec7f7af4dbe63e486e456b49fd645da6e277 100644 (file)
@@ -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)) {
index 5de584afc5ef4d2fe1c3d8c3a18df38a090821a5..d32129dd4f056fb080a7c62796ef26ef93a71084 100644 (file)
@@ -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;
             }
         }