[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/admin/registration/ -> confirmregistration.php (source)

   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  require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
  40  
  41  $newtoken = optional_param('newtoken', '', PARAM_ALPHANUM);
  42  $url = optional_param('url', '', PARAM_URL);
  43  $hubname = optional_param('hubname', '', PARAM_TEXT);
  44  $token = optional_param('token', '', PARAM_TEXT);
  45  $error = optional_param('error', '', PARAM_ALPHANUM);
  46  
  47  admin_externalpage_setup('registrationhubs');
  48  
  49  if (!empty($error) and $error == 'urlalreadyexist') {
  50      throw new moodle_exception('urlalreadyregistered', 'hub',
  51              $CFG->wwwroot . '/' . $CFG->admin . '/registration/index.php');
  52  }
  53  
  54  //check that we are waiting a confirmation from this hub, and check that the token is correct
  55  $registrationmanager = new registration_manager();
  56  $registeredhub = $registrationmanager->get_unconfirmedhub($url);
  57  if (!empty($registeredhub) and $registeredhub->token == $token) {
  58  
  59      echo $OUTPUT->header();
  60      echo $OUTPUT->heading(get_string('registrationconfirmed', 'hub'), 3, 'main');
  61  
  62      $registeredhub->token = $newtoken;
  63      $registeredhub->confirmed = 1;
  64      $registeredhub->hubname = $hubname;
  65      $registrationmanager->update_registeredhub($registeredhub);
  66  
  67      // Display notification message.
  68      echo $OUTPUT->notification(get_string('registrationconfirmedon', 'hub'), 'notifysuccess');
  69  
  70      //display continue button
  71      $registrationpage = new moodle_url('/admin/registration/index.php');
  72      $continuebutton = $OUTPUT->render(new single_button($registrationpage, get_string('continue', 'hub')));
  73      $continuebutton = html_writer::tag('div', $continuebutton, array('class' => 'mdl-align'));
  74      echo $continuebutton;
  75  
  76      if (!extension_loaded('xmlrpc')) {
  77          //display notice about xmlrpc
  78          $xmlrpcnotification = $OUTPUT->doc_link('admin/environment/php_extension/xmlrpc', '');
  79          $xmlrpcnotification .= get_string('xmlrpcdisabledregistration', 'hub');
  80          echo $OUTPUT->notification($xmlrpcnotification);
  81      }
  82  
  83      echo $OUTPUT->footer();
  84  } else {
  85      throw new moodle_exception('wrongtoken', 'hub',
  86              $CFG->wwwroot . '/' . $CFG->admin . '/registration/index.php');
  87  }
  88  
  89  


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1