|
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 require_once("$CFG->dirroot/mod/folder/locallib.php"); 00029 require_once("$CFG->dirroot/repository/lib.php"); 00030 require_once($CFG->libdir . '/completionlib.php'); 00031 00032 $id = optional_param('id', 0, PARAM_INT); // Course module ID 00033 $f = optional_param('f', 0, PARAM_INT); // Folder instance id 00034 00035 if ($f) { // Two ways to specify the module 00036 $folder = $DB->get_record('folder', array('id'=>$f), '*', MUST_EXIST); 00037 $cm = get_coursemodule_from_instance('folder', $folder->id, $folder->course, false, MUST_EXIST); 00038 00039 } else { 00040 $cm = get_coursemodule_from_id('folder', $id, 0, false, MUST_EXIST); 00041 $folder = $DB->get_record('folder', array('id'=>$cm->instance), '*', MUST_EXIST); 00042 } 00043 00044 $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); 00045 00046 require_course_login($course, true, $cm); 00047 $context = get_context_instance(CONTEXT_MODULE, $cm->id); 00048 require_capability('mod/folder:view', $context); 00049 00050 add_to_log($course->id, 'folder', 'view', 'view.php?id='.$cm->id, $folder->id, $cm->id); 00051 00052 // Update 'viewed' state if required by completion system 00053 $completion = new completion_info($course); 00054 $completion->set_module_viewed($cm); 00055 00056 $PAGE->set_url('/mod/folder/view.php', array('id' => $cm->id)); 00057 00058 $PAGE->set_title($course->shortname.': '.$folder->name); 00059 $PAGE->set_heading($course->fullname); 00060 $PAGE->set_activity_record($folder); 00061 00062 00063 $output = $PAGE->get_renderer('mod_folder'); 00064 00065 echo $output->header(); 00066 00067 echo $output->heading(format_string($folder->name), 2); 00068 00069 if (trim(strip_tags($folder->intro))) { 00070 echo $output->box_start('mod_introbox', 'pageintro'); 00071 echo format_module_intro('folder', $folder, $cm->id); 00072 echo $output->box_end(); 00073 } 00074 00075 echo $output->box_start('generalbox foldertree'); 00076 echo $output->folder_tree($folder, $cm, $course); 00077 echo $output->box_end(); 00078 00079 if (has_capability('mod/folder:managefiles', $context)) { 00080 echo $output->container_start('mdl-align'); 00081 echo $output->single_button(new moodle_url('/mod/folder/edit.php', array('id'=>$id)), get_string('edit')); 00082 echo $output->container_end(); 00083 } 00084 00085 echo $output->footer();