Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/lesson/mediafile.php
Go to the documentation of this file.
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 
00030 require_once('../../config.php');
00031 require_once($CFG->dirroot.'/mod/lesson/locallib.php');
00032 
00033 $id = required_param('id', PARAM_INT);    // Course Module ID
00034 $printclose = optional_param('printclose', 0, PARAM_INT);
00035 
00036 $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST);;
00037 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
00038 $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST));
00039 
00040 require_login($course, false, $cm);
00041 
00042 $context = get_context_instance(CONTEXT_MODULE, $cm->id);
00043 $canmanage = has_capability('mod/lesson:manage', $context);
00044 
00045 $url = new moodle_url('/mod/lesson/mediafile.php', array('id'=>$id));
00046 if ($printclose !== '') {
00047     $url->param('printclose', $printclose);
00048 }
00049 $PAGE->set_url($url);
00050 $PAGE->set_pagelayout('popup');
00051 $PAGE->set_title($course->shortname);
00052 
00053 $lessonoutput = $PAGE->get_renderer('mod_lesson');
00054 
00055 // Get the mimetype
00056 $mimetype = mimeinfo("type", $lesson->mediafile);
00057 
00058 if ($printclose) {  // this is for framesets
00059     if ($lesson->mediaclose) {
00060         echo $lessonoutput->header($lesson, $cm);
00061         echo $OUTPUT->box('<form><div><input type="button" onclick="top.close();" value="'.get_string("closewindow").'" /></div></form>', 'lessonmediafilecontrol');
00062         echo $lessonoutput->footer();
00063     }
00064     exit();
00065 }
00066 
00067 echo $lessonoutput->header($lesson, $cm);
00068 
00069 //TODO: this is copied from view.php - the access should be the same!
00075 if (!$canmanage) {
00076     if (!$lesson->is_accessible()) {  // Deadline restrictions
00077         echo $lessonoutput->header($lesson, $cm);
00078         if ($lesson->deadline != 0 && time() > $lesson->deadline) {
00079             echo $lessonoutput->lesson_inaccessible(get_string('lessonclosed', 'lesson', userdate($lesson->deadline)));
00080         } else {
00081             echo $lessonoutput->lesson_inaccessible(get_string('lessonopen', 'lesson', userdate($lesson->available)));
00082         }
00083         echo $lessonoutput->footer();
00084         exit();
00085     } else if ($lesson->usepassword && empty($USER->lessonloggedin[$lesson->id])) { // Password protected lesson code
00086         $correctpass = false;
00087         if (!empty($userpassword) && (($lesson->password == md5(trim($userpassword))) || ($lesson->password == trim($userpassword)))) {
00088             // with or without md5 for backward compatibility (MDL-11090)
00089             $USER->lessonloggedin[$lesson->id] = true;
00090             if ($lesson->highscores) {
00091                 // Logged in - redirect so we go through all of these checks before starting the lesson.
00092                 redirect("$CFG->wwwroot/mod/lesson/view.php?id=$cm->id");
00093             }
00094         } else {
00095             echo $lessonoutput->header($lesson, $cm);
00096             echo $lessonoutput->login_prompt($lesson, $userpassword !== '');
00097             echo $lessonoutput->footer();
00098             exit();
00099         }
00100     }
00101 }
00102 
00103 // print the embedded media html code
00104 echo $OUTPUT->box(lesson_get_media_html($lesson, $context));
00105 
00106 if ($lesson->mediaclose) {
00107    echo '<div class="lessonmediafilecontrol">';
00108    echo $OUTPUT->close_window_button();
00109    echo '</div>';
00110 }
00111 
00112 echo $lessonoutput->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations