Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
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.
8
//
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.
13
//
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/>.
16
 
17
/**
18
 * Handle the return from the Tool Provider after registering a tool proxy.
19
 *
20
 * @package mod_lti
21
 * @copyright  2015 Ryan Wyllie
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
require_once('../../config.php');
26
require_once($CFG->dirroot.'/mod/lti/lib.php');
27
require_once($CFG->dirroot.'/mod/lti/locallib.php');
28
 
29
$status = optional_param('status', '', PARAM_TEXT);
30
$msg = optional_param('lti_msg', '', PARAM_TEXT);
31
$err = optional_param('lti_errormsg', '', PARAM_TEXT);
32
$id = optional_param('id', 0, PARAM_INT);
33
 
34
// No guest autologin.
35
require_sesskey();
36
require_login(0, false);
37
 
38
$systemcontext = context_system::instance();
39
require_capability('moodle/site:config', $systemcontext);
40
 
41
$pageurl = new moodle_url('/mod/lti/externalregistrationreturn.php');
42
$PAGE->set_context($systemcontext);
43
$PAGE->set_url($pageurl);
44
$PAGE->set_pagelayout('maintenance');
45
$output = $PAGE->get_renderer('mod_lti');
46
echo $output->header();
47
 
48
// Check status and lti_errormsg.
49
if ($status !== 'success' && empty($err)) {
50
    // We have a failed status and an empty lti_errormsg. Check if we can use lti_msg.
51
    if (!empty($msg)) {
52
        // The lti_msg attribute is set, use this as the error message.
53
        $err = $msg;
54
    } else {
55
        // Otherwise, use our generic error message.
56
        $err = get_string('failedtocreatetooltype', 'mod_lti');
57
    }
58
}
59
$params = array('message' => s($msg), 'error' => s($err), 'id' => $id, 'status' => s($status));
60
 
61
$page = new \mod_lti\output\external_registration_return_page();
62
echo $output->render($page);
63
 
64
$PAGE->requires->js_call_amd('mod_lti/external_registration_return', 'init', $params);
65
echo $output->footer();