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/>.
19 * Folder module main user interface
23 * @copyright 2009 Petr Skoda {@link http://skodak.org}
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 require('../../config.php');
28 require_once("$CFG->dirroot/mod/folder/locallib.php");
29 require_once("$CFG->dirroot/repository/lib.php");
30 require_once($CFG->libdir
. '/completionlib.php');
32 $id = optional_param('id', 0, PARAM_INT
); // Course module ID
33 $f = optional_param('f', 0, PARAM_INT
); // Folder instance id
35 if ($f) { // Two ways to specify the module
36 $folder = $DB->get_record('folder', array('id'=>$f), '*', MUST_EXIST
);
37 $cm = get_coursemodule_from_instance('folder', $folder->id
, $folder->course
, true, MUST_EXIST
);
40 $cm = get_coursemodule_from_id('folder', $id, 0, true, MUST_EXIST
);
41 $folder = $DB->get_record('folder', array('id'=>$cm->instance
), '*', MUST_EXIST
);
44 $course = $DB->get_record('course', array('id'=>$cm->course
), '*', MUST_EXIST
);
46 require_course_login($course, true, $cm);
47 $context = context_module
::instance($cm->id
);
48 require_capability('mod/folder:view', $context);
49 if ($folder->display
== FOLDER_DISPLAY_INLINE
) {
50 redirect(course_get_url($folder->course
, $cm->sectionnum
));
53 add_to_log($course->id
, 'folder', 'view', 'view.php?id='.$cm->id
, $folder->id
, $cm->id
);
55 // Update 'viewed' state if required by completion system
56 $completion = new completion_info($course);
57 $completion->set_module_viewed($cm);
59 $PAGE->set_url('/mod/folder/view.php', array('id' => $cm->id
));
61 $PAGE->set_title($course->shortname
.': '.$folder->name
);
62 $PAGE->set_heading($course->fullname
);
63 $PAGE->set_activity_record($folder);
66 $output = $PAGE->get_renderer('mod_folder');
68 echo $output->header();
70 echo $output->heading(format_string($folder->name
), 2);
72 echo $output->display_folder($folder);
74 echo $output->footer();