course-completion MDL-23249 Fixed up notices and deprecated functions
[moodle.git] / files / index.php
CommitLineData
be19e367 1<?php
2
3// This file is part of Moodle - http://moodle.org/
4//
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.
9//
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.
14//
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/>.
17
18/**
fb2fb46e 19 * Moodle file tree viewer based on YUI2 Treeview
be19e367 20 *
64f93798 21 * @package core
be19e367 22 * @subpackage file
fb2fb46e 23 * @copyright 2010 Dongsheng Cai <dongsheng@moodle.com>
be19e367 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 */
26
27require('../config.php');
be19e367 28
be19e367 29$contextid = optional_param('contextid', SYSCONTEXTID, PARAM_INT);
64f93798 30$component = optional_param('component', '', PARAM_ALPHAEXT);
be19e367 31$filearea = optional_param('filearea', '', PARAM_ALPHAEXT);
32$itemid = optional_param('itemid', -1, PARAM_INT);
33$filepath = optional_param('filepath', '', PARAM_PATH);
34$filename = optional_param('filename', '', PARAM_FILE);
35
64f93798 36$PAGE->set_url('/files/index.php', array('contextid'=>$contextid, 'component'=>$component, 'filearea'=>$filearea, 'itemid'=>$itemid, 'filepath'=>$filepath, 'filename'=>$filename));
1904e9b3 37
64f93798
PS
38if ($component === '') {
39 $component = null;
be19e367 40}
f9903ed0 41
be19e367 42if ($filearea === '') {
43 $filearea = null;
44}
ad4e0fcc 45
be19e367 46if ($itemid < 0) {
47 $itemid = null;
48}
f9903ed0 49
be19e367 50if ($filepath === '') {
51 $filepath = null;
52}
fdfc6269 53
be19e367 54if ($filename === '') {
55 $filename = null;
56}
f9903ed0 57
64f93798
PS
58list($context, $course, $cm) = get_context_info_array($contextid);
59
60require_login($course, false, $cm);
61require_capability('moodle/course:managefiles', $context);
62
be19e367 63$browser = get_file_browser();
1a11dfd1 64
64f93798 65$file_info = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename);
1a11dfd1 66
fb2fb46e 67$strfiles = get_string("files");
64f93798
PS
68
69$PAGE->navbar->add($strfiles);
70$PAGE->set_title("$SITE->shortname: $strfiles");
71$PAGE->set_heading($SITE->fullname);
72
fb2fb46e
DC
73if ($context->contextlevel == CONTEXT_MODULE) {
74 $PAGE->set_pagelayout('incourse');
75} else if ($context->contextlevel == CONTEXT_COURSE) {
76 $PAGE->set_pagelayout('course');
77} else {
78 $PAGE->set_pagelayout('admin');
f9903ed0 79}
80
64f93798
PS
81$output = $PAGE->get_renderer('core', 'files');
82
83echo $output->header();
84echo $output->box_start();
85
86if ($file_info) {
87 $options = array();
88 //$options['visible_areas'] = array('backup'=>array('section', 'course'), 'course'=>array('legacy'), 'user'=>array('backup'));
89 echo $output->files_tree_viewer($file_info, $options);
90} else {
91 notify(get_string('nofilesavailable', 'repository'));
92}
93
94echo $output->box_end();
6b091c94 95
64f93798 96echo $output->footer();
70cedbfd 97