Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
   1  <?php
   2  
   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  ///////////////////////////////////////////////////////////////////////////
  22  
  23  /**
  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
  29   *
  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.
  35   */
  36  
  37  require('../../config.php');
  38  require_once($CFG->libdir . '/adminlib.php');
  39  
  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);
  45  
  46  admin_externalpage_setup('registrationmoodleorg');
  47  
  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) {
  54              $callback('confirm');
  55          }
  56      }
  57      throw new moodle_exception('errorotherhubsnotsupported', 'hub');
  58  }
  59  
  60  if (!empty($error) and $error == 'urlalreadyexist') {
  61      throw new moodle_exception('urlalreadyregistered', 'hub',
  62              $CFG->wwwroot . '/' . $CFG->admin . '/registration/index.php');
  63  }
  64  
  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);
  67  
  68  echo $OUTPUT->header();
  69  echo $OUTPUT->heading(get_string('registrationconfirmed', 'hub'), 3, 'main');
  70  
  71  // Display notification message.
  72  echo $OUTPUT->notification(get_string('registrationconfirmedon', 'hub'), 'notifysuccess');
  73  
  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'));
  80  echo $continuebutton;
  81  
  82  echo $OUTPUT->footer();
  83  
  84