[ Index ]

PHP Cross Reference of moodle-2.8

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 <[email protected]>
  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      $hublink = html_writer::tag('a', $hubname, array('href' => $url));
  62  
  63      $registeredhub->token = $newtoken;
  64      $registeredhub->confirmed = 1;
  65      $registeredhub->hubname = $hubname;
  66      $registrationmanager->update_registeredhub($registeredhub);
  67  
  68      //display notficiation message
  69      $notificationmessage = $OUTPUT->notification(
  70              get_string('registrationconfirmedon', 'hub', $hublink), 'notifysuccess');
  71      echo $notificationmessage;
  72  
  73      //display continue button
  74      $registrationpage = new moodle_url('/admin/registration/index.php');
  75      $continuebutton = $OUTPUT->render(new single_button($registrationpage, get_string('continue', 'hub')));
  76      $continuebutton = html_writer::tag('div', $continuebutton, array('class' => 'mdl-align'));
  77      echo $continuebutton;
  78  
  79      if (!extension_loaded('xmlrpc')) {
  80          //display notice about xmlrpc
  81          $xmlrpcnotification = $OUTPUT->doc_link('admin/environment/php_extension/xmlrpc', '');
  82          $xmlrpcnotification .= get_string('xmlrpcdisabledregistration', 'hub');
  83          echo $OUTPUT->notification($xmlrpcnotification);
  84      }
  85  
  86      echo $OUTPUT->footer();
  87  } else {
  88      throw new moodle_exception('wrongtoken', 'hub',
  89              $CFG->wwwroot . '/' . $CFG->admin . '/registration/index.php');
  90  }
  91  
  92  


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1