3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
20 * Utility class for browsing of system files.
23 * @subpackage filebrowser
24 * @copyright 2008 Petr Skoda (http://skodak.org)
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28 defined('MOODLE_INTERNAL') ||
die();
31 * Represents the system context in the tree navigated by @see{file_browser}.
34 * @subpackage filebrowser
35 * @copyright 2008 Petr Skoda (http://skodak.org)
36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38 class file_info_context_system
extends file_info
{
39 public function __construct($browser, $context) {
40 parent
::__construct($browser, $context);
44 * Return information about this specific part of context level
51 public function get_file_info($component, $filearea, $itemid, $filepath, $filename) {
52 if (empty($component)) {
56 // no components supported at this level yet
61 * Returns localised visible name.
64 public function get_visible_name() {
65 return get_string('arearoot', 'repository');
69 * Can I add new files or directories?
72 public function is_writable() {
80 public function is_directory() {
85 * Returns list of children.
86 * @return array of file_info instances
88 public function get_children() {
93 if ($child = $this->browser
->get_file_info(get_context_instance(CONTEXT_USER
, $USER->id
))) {
97 $course_cats = $DB->get_records('course_categories', array('parent'=>0), 'sortorder', 'id,visible');
98 foreach ($course_cats as $category) {
99 $context = get_context_instance(CONTEXT_COURSECAT
, $category->id
);
100 if (!$category->visible
and !has_capability('moodle/category:viewhiddencategories', $context)) {
103 if ($child = $this->browser
->get_file_info($context)) {
104 $children[] = $child;
108 $courses = $DB->get_records('course', array('category'=>0), 'sortorder', 'id,visible');
109 foreach ($courses as $course) {
110 if (!$course->visible
and !has_capability('moodle/course:viewhiddencourses', $context)) {
113 $context = get_context_instance(CONTEXT_COURSE
, $course->id
);
114 if ($child = $this->browser
->get_file_info($context)) {
115 $children[] = $child;
123 * Returns parent file_info instance
124 * @return file_info or null for root
126 public function get_parent() {