renewregistration.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. ///////////////////////////////////////////////////////////////////////////
  3. // //
  4. // This file is part of Moodle - http://moodle.org/ //
  5. // Moodle - Modular Object-Oriented Dynamic Learning Environment //
  6. // //
  7. // Moodle is free software: you can redistribute it and/or modify //
  8. // it under the terms of the GNU General Public License as published by //
  9. // the Free Software Foundation, either version 3 of the License, or //
  10. // (at your option) any later version. //
  11. // //
  12. // Moodle is distributed in the hope that it will be useful, //
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of //
  14. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
  15. // GNU General Public License for more details. //
  16. // //
  17. // You should have received a copy of the GNU General Public License //
  18. // along with Moodle. If not, see <http://www.gnu.org/licenses/>. //
  19. // //
  20. ///////////////////////////////////////////////////////////////////////////
  21. /*
  22. * @package moodle
  23. * @subpackage registration
  24. * @author Jerome Mouneyrac <jerome@mouneyrac.com>
  25. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL
  26. * @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
  27. *
  28. * The administrator is redirect to this page from the hub to renew a registration
  29. * process because
  30. */
  31. require('../../config.php');
  32. require_once($CFG->libdir . '/adminlib.php');
  33. require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
  34. $url = optional_param('url', '', PARAM_URL);
  35. $hubname = optional_param('hubname', '', PARAM_TEXT);
  36. $token = optional_param('token', '', PARAM_TEXT);
  37. admin_externalpage_setup('registrationhubs');
  38. //check that we are waiting a confirmation from this hub, and check that the token is correct
  39. $registrationmanager = new registration_manager();
  40. $registeredhub = $registrationmanager->get_unconfirmedhub($url);
  41. if (!empty($registeredhub) and $registeredhub->token == $token) {
  42. echo $OUTPUT->header();
  43. echo $OUTPUT->heading(get_string('renewregistration', 'hub'), 3, 'main');
  44. $hublink = html_writer::tag('a', $hubname, array('href' => $url));
  45. $registrationmanager->delete_registeredhub($url);
  46. //Mooch case, need to recreate the siteidentifier
  47. if ($url == HUB_MOODLEORGHUBURL) {
  48. $CFG->siteidentifier = null;
  49. get_site_identifier();
  50. }
  51. $deletedregmsg = get_string('previousregistrationdeleted', 'hub', $hublink);
  52. $button = new single_button(new moodle_url('/admin/registration/index.php'),
  53. get_string('restartregistration', 'hub'));
  54. $button->class = 'restartregbutton';
  55. echo html_writer::tag('div', $deletedregmsg . $OUTPUT->render($button),
  56. array('class' => 'mdl-align'));
  57. echo $OUTPUT->footer();
  58. } else {
  59. throw new moodle_exception('wrongtoken', 'hub',
  60. $CFG->wwwroot . '/' . $CFG->admin . '/registration/index.php');
  61. }