2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 * Handle the return from the Tool Provider after registering a tool proxy.
21 * @copyright 2014 Vital Source Technologies http://vitalsource.com
22 * @author Stephen Vickers
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 require_once('../../config.php');
27 require_once($CFG->dirroot
.'/mod/lti/locallib.php');
29 $top = optional_param('top', 0, PARAM_INT
);
30 $msg = optional_param('lti_msg', '', PARAM_TEXT
);
31 $err = optional_param('lti_errormsg', '', PARAM_TEXT
);
32 $id = optional_param('id', 0, PARAM_INT
);
34 // No guest autologin.
36 require_login(0, false);
38 $systemcontext = context_system
::instance();
39 require_capability('moodle/site:config', $systemcontext);
44 $params['sesskey'] = sesskey();
47 $params['lti_msg'] = $msg;
50 $params['lti_errormsg'] = $err;
55 $redirect = new moodle_url('/mod/lti/registrationreturn.php', $params);
56 $redirect = $redirect->out(false);
58 $clickhere = get_string('click_to_continue', 'lti', (object)array('link' => $redirect));
62 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8" />
63 <script type
="text/javascript">
65 top
.location
.href
= '{$redirect}';
77 // We always send the headers because they set the encoding.
78 send_headers('text/html; charset=utf-8', false);
81 } else if (!empty($msg) && !empty($err)) {
84 $params['sesskey'] = sesskey();
87 $params['lti_errormsg'] = $err;
92 $redirect = new moodle_url('/mod/lti/registrationreturn.php', $params);
93 $redirect = $redirect->out(false);
94 redirect($redirect, $err);
98 $redirect = new moodle_url('/mod/lti/toolproxies.php');
100 $toolproxy = $DB->get_record('lti_tool_proxies', array('id' => $id));
101 switch($toolproxy->state
) {
102 case LTI_TOOL_PROXY_STATE_ACCEPTED
:
103 $redirect->param('tab', 'tp_accepted');
105 case LTI_TOOL_PROXY_STATE_REJECTED
:
106 $redirect->param('tab', 'tp_rejected');
108 case LTI_TOOL_PROXY_STATE_PENDING
:
109 // Change the status to configured.
110 $toolproxy->state
= LTI_TOOL_PROXY_STATE_CONFIGURED
;
111 lti_update_tool_proxy($toolproxy);
115 $redirect = $redirect->out();
120 redirect($redirect, $msg);