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 * This file plays the mediafile set in lesson settings. 20 * 21 * If there is a way to use the resource class instead of this code, please change to do so 22 * 23 * 24 * @package mod_lesson 25 * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} 26 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 27 **/ 28 29 require_once('../../config.php'); 30 require_once($CFG->dirroot.'/mod/lesson/locallib.php'); 31 32 $id = required_param('id', PARAM_INT); // Course Module ID 33 $printclose = optional_param('printclose', 0, PARAM_INT); 34 35 $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST); 36 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); 37 $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST), $cm); 38 39 require_login($course, false, $cm); 40 41 // Apply overrides. 42 $lesson->update_effective_access($USER->id); 43 44 $context = $lesson->context; 45 $canmanage = $lesson->can_manage(); 46 47 $url = new moodle_url('/mod/lesson/mediafile.php', array('id'=>$id)); 48 if ($printclose !== '') { 49 $url->param('printclose', $printclose); 50 } 51 $PAGE->set_url($url); 52 $PAGE->set_pagelayout('popup'); 53 $PAGE->set_title($course->shortname); 54 55 $lessonoutput = $PAGE->get_renderer('mod_lesson'); 56 57 // Get the mimetype 58 $mimetype = mimeinfo("type", $lesson->mediafile); 59 60 if ($printclose) { // this is for framesets 61 if ($lesson->mediaclose) { 62 echo $lessonoutput->header($lesson, $cm); 63 echo $OUTPUT->box('<form><div><input type="button" onclick="top.close();" value="'.get_string("closewindow").'" /></div></form>', 'lessonmediafilecontrol'); 64 echo $lessonoutput->footer(); 65 } 66 exit(); 67 } 68 69 // Check access restrictions. 70 if ($timerestriction = $lesson->get_time_restriction_status()) { // Deadline restrictions. 71 echo $lessonoutput->header($lesson, $cm, '', false, null, get_string('notavailable')); 72 echo $lessonoutput->lesson_inaccessible(get_string($timerestriction->reason, 'lesson', userdate($timerestriction->time))); 73 echo $lessonoutput->footer(); 74 exit(); 75 } else if ($passwordrestriction = $lesson->get_password_restriction_status(null)) { // Password protected lesson code. 76 echo $lessonoutput->header($lesson, $cm, '', false, null, get_string('passwordprotectedlesson', 'lesson', format_string($lesson->name))); 77 echo $lessonoutput->login_prompt($lesson, $userpassword !== ''); 78 echo $lessonoutput->footer(); 79 exit(); 80 } else if ($dependenciesrestriction = $lesson->get_dependencies_restriction_status()) { // Check for dependencies. 81 echo $lessonoutput->header($lesson, $cm, '', false, null, get_string('completethefollowingconditions', 'lesson', format_string($lesson->name))); 82 echo $lessonoutput->dependancy_errors($dependenciesrestriction->dependentlesson, $dependenciesrestriction->errors); 83 echo $lessonoutput->footer(); 84 exit(); 85 } 86 87 echo $lessonoutput->header($lesson, $cm); 88 89 // print the embedded media html code 90 echo $OUTPUT->box(lesson_get_media_html($lesson, $context)); 91 92 if ($lesson->mediaclose) { 93 echo '<div class="lessonmediafilecontrol">'; 94 echo $OUTPUT->close_window_button(); 95 echo '</div>'; 96 } 97 98 echo $lessonoutput->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body