Commit | Line | Data |
---|---|---|
0e16b939 | 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 | /** | |
19 | * Folder module main user interface | |
20 | * | |
21 | * @package mod-folder | |
22 | * @copyright 2009 Petr Skoda (http://skodak.org) | |
23 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | |
24 | */ | |
25 | ||
26 | require('../../config.php'); | |
27 | require_once("$CFG->dirroot/mod/folder/locallib.php"); | |
33c36cf1 | 28 | require_once($CFG->libdir . '/completionlib.php'); |
0e16b939 | 29 | |
30 | $id = optional_param('id', 0, PARAM_INT); // Course module ID | |
31 | $f = optional_param('f', 0, PARAM_INT); // Folder instance id | |
32 | ||
33 | if ($f) { // Two ways to specify the module | |
34 | $folder = $DB->get_record('folder', array('id'=>$f), '*', MUST_EXIST); | |
35 | $cm = get_coursemodule_from_instance('folder', $folder->id, $folder->course, false, MUST_EXIST); | |
36 | ||
37 | } else { | |
38 | $cm = get_coursemodule_from_id('folder', $id, 0, false, MUST_EXIST); | |
39 | $folder = $DB->get_record('folder', array('id'=>$cm->instance), '*', MUST_EXIST); | |
40 | } | |
41 | ||
42 | $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); | |
43 | ||
44 | require_course_login($course, true, $cm); | |
45 | $context = get_context_instance(CONTEXT_MODULE, $cm->id); | |
46 | ||
47 | add_to_log($course->id, 'folder', 'view', 'view.php?id='.$cm->id, $folder->id, $cm->id); | |
48 | ||
c15a60e6 SM |
49 | // Update 'viewed' state if required by completion system |
50 | $completion = new completion_info($course); | |
51 | $completion->set_module_viewed($cm); | |
52 | ||
a6855934 | 53 | $PAGE->set_url('/mod/folder/view.php', array('id' => $cm->id)); |
0e16b939 | 54 | |
55 | $PAGE->set_title($course->shortname.': '.$folder->name); | |
56 | $PAGE->set_heading($course->fullname); | |
57 | $PAGE->set_activity_record($folder); | |
5647cde8 | 58 | echo $OUTPUT->header(); |
0e16b939 | 59 | |
60 | echo $OUTPUT->heading(format_string($folder->name), 2); | |
61 | ||
62 | if (trim(strip_tags($folder->intro))) { | |
63 | echo $OUTPUT->box_start('mod_introbox', 'pageintro'); | |
64 | echo format_module_intro('folder', $folder, $cm->id); | |
65 | echo $OUTPUT->box_end(); | |
66 | } | |
67 | ||
68 | echo $OUTPUT->box_start('generalbox foldertree'); | |
fb2fb46e | 69 | echo $OUTPUT->area_file_tree_viewer($context->id, 'folder_content', 0); |
0e16b939 | 70 | echo $OUTPUT->box_end(); |
c84cea17 | 71 | |
3ebb42ae DC |
72 | if (has_capability('moodle/course:managefiles', $context)) { |
73 | echo $OUTPUT->container_start('mdl-align'); | |
74 | echo $OUTPUT->single_button(new moodle_url('/mod/folder/edit.php', array('id'=>$id)), get_string('edit')); | |
75 | echo $OUTPUT->container_end(); | |
76 | } | |
c84cea17 | 77 | |
0e16b939 | 78 | echo $OUTPUT->footer(); |