|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00027 require_once('../../config.php'); 00028 require_once($CFG->dirroot.'/mod/lti/lib.php'); 00029 require_once($CFG->dirroot.'/mod/lti/locallib.php'); 00030 00031 $courseid = required_param('course', PARAM_INT); 00032 $instanceid = required_param('instanceid', PARAM_INT); 00033 00034 $errormsg = optional_param('lti_errormsg', '', PARAM_RAW); 00035 $unsigned = optional_param('unsigned', '0', PARAM_INT); 00036 00037 $launchcontainer = optional_param('launch_container', LTI_LAUNCH_CONTAINER_WINDOW, PARAM_INT); 00038 00039 $course = $DB->get_record('course', array('id' => $courseid)); 00040 00041 require_login($course); 00042 00043 if (!empty($errormsg)) { 00044 $url = new moodle_url('/mod/lti/return.php', array('course' => $courseid)); 00045 $PAGE->set_url($url); 00046 00047 $pagetitle = strip_tags($course->shortname); 00048 $PAGE->set_title($pagetitle); 00049 $PAGE->set_heading($course->fullname); 00050 00051 //Avoid frame-in-frame action 00052 if ($launchcontainer == LTI_LAUNCH_CONTAINER_EMBED || $launchcontainer == LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS) { 00053 $PAGE->set_pagelayout('embedded'); 00054 } else { 00055 $PAGE->set_pagelayout('incourse'); 00056 } 00057 00058 echo $OUTPUT->header(); 00059 00060 echo get_string('lti_launch_error', 'lti'); 00061 00062 echo htmlspecialchars($errormsg); 00063 00064 $canaddtools = has_capability('mod/lti:addcoursetool', get_context_instance(CONTEXT_COURSE, $courseid)); 00065 00066 if ($unsigned == 1 && $canaddtools) { 00067 echo '<br /><br />'; 00068 00069 $links = new stdClass(); 00070 $coursetooleditor = new moodle_url('/mod/lti/instructor_edit_tool_type.php', array('course' => $courseid, 'action' => 'add')); 00071 $links->course_tool_editor = $coursetooleditor->out(false); 00072 00073 $adminrequesturl = new moodle_url('/mod/lti/request_tool.php', array('instanceid' => $instanceid)); 00074 $links->admin_request_url = $adminrequesturl->out(false); 00075 00076 echo get_string('lti_launch_error_unsigned_help', 'lti', $links); 00077 00078 echo get_string('lti_launch_error_tool_request', 'lti', $links); 00079 } 00080 00081 echo $OUTPUT->footer(); 00082 } else { 00083 $courseurl = new moodle_url('/course/view.php', array('id' => $courseid)); 00084 $url = $courseurl->out(); 00085 00086 //Avoid frame-in-frame action 00087 if ($launchcontainer == LTI_LAUNCH_CONTAINER_EMBED || $launchcontainer == LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS) { 00088 //Output a page containing some script to break out of frames and redirect them 00089 00090 echo '<html><body>'; 00091 00092 $script = " 00093 <script type=\"text/javascript\"> 00094 //<![CDATA[ 00095 if(window != top){ 00096 top.location.href = '{$url}'; 00097 } 00098 //]] 00099 </script> 00100 "; 00101 00102 $clickhere = get_string('return_to_course', 'lti', (object)array('link' => $url)); 00103 00104 $noscript = " 00105 <noscript> 00106 {$clickhere} 00107 </noscript> 00108 "; 00109 00110 echo $script; 00111 echo $noscript; 00112 00113 echo '</body></html>'; 00114 } else { 00115 //If no error, take them back to the course 00116 redirect($url); 00117 } 00118 }