Merge branch 'MDL-45296' of git://github.com/stronk7/moodle
[moodle.git] / admin / registration / renewregistration.php
blobdd1546387cf23a9b13ce5c08ba8fed045b43ccaa
1 <?php
3 ///////////////////////////////////////////////////////////////////////////
4 // //
5 // This file is part of Moodle - http://moodle.org/ //
6 // Moodle - Modular Object-Oriented Dynamic Learning Environment //
7 // //
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. //
12 // //
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. //
17 // //
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/>. //
20 // //
21 ///////////////////////////////////////////////////////////////////////////
24 * @package moodle
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 renew a registration
31 * process because
34 require('../../config.php');
35 require_once($CFG->libdir . '/adminlib.php');
36 require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
38 $url = optional_param('url', '', PARAM_URL);
39 $hubname = optional_param('hubname', '', PARAM_TEXT);
40 $token = optional_param('token', '', PARAM_TEXT);
42 admin_externalpage_setup('registrationhubs');
44 //check that we are waiting a confirmation from this hub, and check that the token is correct
45 $registrationmanager = new registration_manager();
46 $registeredhub = $registrationmanager->get_unconfirmedhub($url);
47 if (!empty($registeredhub) and $registeredhub->token == $token) {
49 echo $OUTPUT->header();
50 echo $OUTPUT->heading(get_string('renewregistration', 'hub'), 3, 'main');
51 $hublink = html_writer::tag('a', $hubname, array('href' => $url));
53 $registrationmanager->delete_registeredhub($url);
55 //Mooch case, need to recreate the siteidentifier
56 if ($url == HUB_MOODLEORGHUBURL) {
57 $CFG->siteidentifier = null;
58 get_site_identifier();
61 $deletedregmsg = get_string('previousregistrationdeleted', 'hub', $hublink);
63 $button = new single_button(new moodle_url('/admin/registration/index.php'),
64 get_string('restartregistration', 'hub'));
65 $button->class = 'restartregbutton';
67 echo html_writer::tag('div', $deletedregmsg . $OUTPUT->render($button),
68 array('class' => 'mdl-align'));
70 echo $OUTPUT->footer();
71 } else {
72 throw new moodle_exception('wrongtoken', 'hub',
73 $CFG->wwwroot . '/' . $CFG->admin . '/registration/index.php');