|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00018 00028 defined('MOODLE_INTERNAL') || die(); 00029 00038 class file_info_context_system extends file_info { 00039 public function __construct($browser, $context) { 00040 parent::__construct($browser, $context); 00041 } 00042 00051 public function get_file_info($component, $filearea, $itemid, $filepath, $filename) { 00052 if (empty($component)) { 00053 return $this; 00054 } 00055 00056 // no components supported at this level yet 00057 return null; 00058 } 00059 00064 public function get_visible_name() { 00065 return get_string('arearoot', 'repository'); 00066 } 00067 00072 public function is_writable() { 00073 return false; 00074 } 00075 00080 public function is_directory() { 00081 return true; 00082 } 00083 00088 public function get_children() { 00089 global $DB, $USER; 00090 00091 $children = array(); 00092 00093 if ($child = $this->browser->get_file_info(get_context_instance(CONTEXT_USER, $USER->id))) { 00094 $children[] = $child; 00095 } 00096 00097 $course_cats = $DB->get_records('course_categories', array('parent'=>0), 'sortorder', 'id,visible'); 00098 foreach ($course_cats as $category) { 00099 $context = get_context_instance(CONTEXT_COURSECAT, $category->id); 00100 if (!$category->visible and !has_capability('moodle/category:viewhiddencategories', $context)) { 00101 continue; 00102 } 00103 if ($child = $this->browser->get_file_info($context)) { 00104 $children[] = $child; 00105 } 00106 } 00107 00108 $courses = $DB->get_records('course', array('category'=>0), 'sortorder', 'id,visible'); 00109 foreach ($courses as $course) { 00110 if (!$course->visible and !has_capability('moodle/course:viewhiddencourses', $context)) { 00111 continue; 00112 } 00113 $context = get_context_instance(CONTEXT_COURSE, $course->id); 00114 if ($child = $this->browser->get_file_info($context)) { 00115 $children[] = $child; 00116 } 00117 } 00118 00119 return $children; 00120 } 00121 00126 public function get_parent() { 00127 return null; 00128 } 00129 }