|
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 00027 require('../config.php'); 00028 00029 $contextid = optional_param('contextid', SYSCONTEXTID, PARAM_INT); 00030 $filepath = optional_param('filepath', '', PARAM_PATH); 00031 $filename = optional_param('filename', '', PARAM_FILE); 00032 // hard-coded to course legacy area 00033 $component = 'course'; 00034 $filearea = 'legacy'; 00035 $itemid = 0; 00036 00037 $PAGE->set_url('/files/index.php', array('contextid'=>$contextid, 'filepath'=>$filepath, 'filename'=>$filename)); 00038 00039 if ($filepath === '') { 00040 $filepath = null; 00041 } 00042 00043 if ($filename === '') { 00044 $filename = null; 00045 } 00046 00047 list($context, $course, $cm) = get_context_info_array($contextid); 00048 $PAGE->set_context($context); 00049 00050 require_login($course, false, $cm); 00051 require_capability('moodle/course:managefiles', $context); 00052 00053 $browser = get_file_browser(); 00054 00055 $file_info = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename); 00056 00057 $strfiles = get_string("files"); 00058 if ($node = $PAGE->settingsnav->find('coursefiles', navigation_node::TYPE_SETTING)) { 00059 $node->make_active(); 00060 } else { 00061 $PAGE->navbar->add($strfiles); 00062 } 00063 00064 $PAGE->set_title("$course->shortname: $strfiles"); 00065 $PAGE->set_heading($course->fullname); 00066 $PAGE->set_pagelayout('course'); 00067 00068 $output = $PAGE->get_renderer('core', 'files'); 00069 00070 echo $output->header(); 00071 echo $output->box_start(); 00072 00073 if ($file_info) { 00074 $options = array(); 00075 $options['context'] = $context; 00076 //$options['visible_areas'] = array('backup'=>array('section', 'course'), 'course'=>array('legacy'), 'user'=>array('backup')); 00077 echo $output->files_tree_viewer($file_info, $options); 00078 } else { 00079 echo $output->notification(get_string('nofilesavailable', 'repository')); 00080 } 00081 00082 echo $output->box_end(); 00083 echo $output->footer();