3 ///////////////////////////////////////////////////////////////////////////
5 // This file is part of Moodle - http://moodle.org/ //
6 // Moodle - Modular Object-Oriented Dynamic Learning Environment //
8 // Moodle is free software: you can redistribute it and/or modify //
9 // it under the terms of the GNU General Public License as published by //
10 // the Free Software Foundation, either version 3 of the License, or //
11 // (at your option) any later version. //
13 // Moodle is distributed in the hope that it will be useful, //
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
16 // GNU General Public License for more details. //
18 // You should have received a copy of the GNU General Public License //
19 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. //
21 ///////////////////////////////////////////////////////////////////////////
25 * @subpackage registration
26 * @author Jerome Mouneyrac <jerome@mouneyrac.com>
27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL
28 * @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
30 * The administrator is redirect to this page from the hub to confirm that the
31 * site has been registered. It is an administration page. The administrator
32 * should be using the same browser during all the registration process.
33 * This page save the token that the hub gave us, in order to call the hub
34 * directory later by web service.
37 require('../../config.php');
38 require_once($CFG->libdir
. '/adminlib.php');
40 $newtoken = optional_param('newtoken', '', PARAM_ALPHANUM
);
41 $url = optional_param('url', '', PARAM_URL
);
42 $hubname = optional_param('hubname', '', PARAM_TEXT
);
43 $token = optional_param('token', '', PARAM_TEXT
);
44 $error = optional_param('error', '', PARAM_ALPHANUM
);
46 admin_externalpage_setup('registrationmoodleorg');
48 if (parse_url($url, PHP_URL_HOST
) !== parse_url(HUB_MOODLEORGHUBURL
, PHP_URL_HOST
)) {
49 // Allow other plugins to confirm registration on custom hubs. Plugins implementing this
50 // callback need to redirect or exit. See https://docs.moodle.org/en/Hub_registration .
51 $callbacks = get_plugins_with_function('hub_registration');
52 foreach ($callbacks as $plugintype => $plugins) {
53 foreach ($plugins as $plugin => $callback) {
57 throw new moodle_exception('errorotherhubsnotsupported', 'hub');
60 if (!empty($error) and $error == 'urlalreadyexist') {
61 throw new moodle_exception('urlalreadyregistered', 'hub',
62 $CFG->wwwroot
. '/' . $CFG->admin
. '/registration/index.php');
65 //check that we are waiting a confirmation from this hub, and check that the token is correct
66 core\hub\registration
::confirm_registration($token, $newtoken, $hubname);
68 echo $OUTPUT->header();
69 echo $OUTPUT->heading(get_string('registrationconfirmed', 'hub'), 3, 'main');
71 // Display notification message.
72 echo $OUTPUT->notification(get_string('registrationconfirmedon', 'hub'), 'notifysuccess');
74 // Display continue button.
75 $returnurl = !empty($SESSION->registrationredirect
) ?
clean_param($SESSION->registrationredirect
, PARAM_LOCALURL
) : null;
76 unset($SESSION->registrationredirect
);
77 $continueurl = new moodle_url($returnurl ?
: '/admin/registration/index.php');
78 $continuebutton = $OUTPUT->render(new single_button($continueurl, get_string('continue')));
79 $continuebutton = html_writer
::tag('div', $continuebutton, array('class' => 'mdl-align'));
82 echo $OUTPUT->footer();