mirrored from git://git.moodle.org/moodle.git
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
/
return.php
81 lines (61 loc) · 2.42 KB
/
return.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
//This page is used to handle the return back to Moodle from the tool provider
require_once('../../config.php');
require_once($CFG->dirroot.'/mod/lti/lib.php');
$courseid = required_param('course', PARAM_INT);
$errormsg = optional_param('lti_errormsg', '', PARAM_RAW);
$unsigned = optional_param('unsigned', '0', PARAM_INT);
$launchcontainer = optional_param('launch_container', LTI_LAUNCH_CONTAINER_WINDOW, PARAM_INT);
$course = $DB->get_record('course', array('id' => $courseid));
require_login($course);
if(!empty($errormsg)){
$url = new moodle_url('/mod/lti/return.php', array('course' => $courseid));
$PAGE->set_url($url);
$pagetitle = strip_tags($course->shortname);
$PAGE->set_title($pagetitle);
$PAGE->set_heading($course->fullname);
//Avoid frame-in-frame action
if($launchcontainer == LTI_LAUNCH_CONTAINER_EMBED || $launchcontainer == LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS) {
$PAGE->set_pagelayout('embedded');
} else {
$PAGE->set_pagelayout('incourse');
}
echo $OUTPUT->header();
echo get_string('lti_launch_error', 'lti');
//TODO: Add some help around this error message.
echo htmlspecialchars($errormsg);
if($unsigned == 1){
echo '<br /><br />';
echo get_string('lti_launch_error_unsigned_help', 'lti');
}
echo $OUTPUT->footer();
} else {
$courseurl = new moodle_url('/course/view.php', array('id' => $courseid));
$url = $courseurl->out();
//Avoid frame-in-frame action
if($launchcontainer == LTI_LAUNCH_CONTAINER_EMBED || $launchcontainer == LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS) {
//Output a page containing some script to break out of frames and redirect them
echo '<html><body>';
$script = <<<SCRIPT
<script type='text/javascript'>
//<![CDATA[
if(window != top){
top.location.href = '{$url}';
}
//]]
</script>
SCRIPT;
$clickhere = get_string('return_to_course', 'lti', (object)array('link' => $url));
$noscript = <<<NOSCRIPT
<noscript>
{$clickhere}
</noscript>
NOSCRIPT;
echo $script;
echo $noscript;
echo '</body></html>';
} else {
//If no error, take them back to the course
redirect($url);
}
}