[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 18 /** 19 * Utility class for browsing of system files. 20 * 21 * @package core_files 22 * @copyright 2008 Petr Skoda (http://skodak.org) 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 defined('MOODLE_INTERNAL') || die(); 27 28 /** 29 * Represents the system context in the tree navigated by {@link file_browser}. 30 * 31 * @package core_files 32 * @copyright 2008 Petr Skoda (http://skodak.org) 33 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 34 */ 35 class file_info_context_system extends file_info { 36 37 /** 38 * Constructor 39 * 40 * @param file_browser $browser file_browser instance 41 * @param stdClass $context context object 42 */ 43 public function __construct($browser, $context) { 44 parent::__construct($browser, $context); 45 } 46 47 /** 48 * Return information about this specific part of context level 49 * 50 * @param string $component component 51 * @param string $filearea file area 52 * @param int $itemid item ID 53 * @param string $filepath file path 54 * @param string $filename file name 55 */ 56 public function get_file_info($component, $filearea, $itemid, $filepath, $filename) { 57 if (empty($component)) { 58 return $this; 59 } 60 61 // no components supported at this level yet 62 return null; 63 } 64 65 /** 66 * Returns localised visible name. 67 * 68 * @return string 69 */ 70 public function get_visible_name() { 71 return get_string('arearoot', 'repository'); 72 } 73 74 /** 75 * Whether or not new files or directories can be added 76 * 77 * @return bool 78 */ 79 public function is_writable() { 80 return false; 81 } 82 83 /** 84 * Whether or not this is a directory 85 * 86 * @return bool 87 */ 88 public function is_directory() { 89 return true; 90 } 91 92 /** 93 * Returns list of children. 94 * 95 * @return array of file_info instances 96 */ 97 public function get_children() { 98 global $DB, $USER; 99 100 $children = array(); 101 102 $course_cats = $DB->get_records('course_categories', array('parent'=>0), 'sortorder', 'id,visible'); 103 foreach ($course_cats as $category) { 104 $context = context_coursecat::instance($category->id); 105 if (!$category->visible and !has_capability('moodle/category:viewhiddencategories', $context)) { 106 continue; 107 } 108 if ($child = $this->browser->get_file_info($context)) { 109 $children[] = $child; 110 } 111 } 112 113 $courses = $DB->get_records('course', array('category'=>0), 'sortorder', 'id,visible'); 114 foreach ($courses as $course) { 115 if (!$course->visible and !has_capability('moodle/course:viewhiddencourses', $context)) { 116 continue; 117 } 118 $context = context_course::instance($course->id); 119 if ($child = $this->browser->get_file_info($context)) { 120 $children[] = $child; 121 } 122 } 123 124 return $children; 125 } 126 127 /** 128 * Returns parent file_info instance 129 * 130 * @return file_info|null file_info instance or null for root 131 */ 132 public function get_parent() { 133 return null; 134 } 135 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |