Moodle 2.0.3 release
[moodle.git] / admin / registration / hubselector.php
blob6bb215f080fcd3e94fe5b879b63d5eb4ab55635a
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 * @package moodle
19 * @subpackage registration
20 * @author Jerome Mouneyrac <jerome@mouneyrac.com>
21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL
22 * @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
24 * Thsi page displays a hub selector or a hub URL + password. Then it will redirect to
25 * the site registration form (with the selected hub as parameter)
28 require('../../config.php');
30 require_once($CFG->libdir.'/adminlib.php');
31 require_once($CFG->dirroot.'/' . $CFG->admin . '/registration/forms.php');
33 admin_externalpage_setup('registrationselector');
35 $hubselectorform = new hub_selector_form();
36 $fromform = $hubselectorform->get_data();
38 //// Redirect to the registration form if an URL has been choosen ////
40 $selectedhuburl = optional_param('publichub', false, PARAM_URL);
41 $unlistedhuburl = optional_param('unlistedurl', false, PARAM_TEXT);
42 $password = optional_param('password', '', PARAM_RAW);
44 if (!empty($unlistedhuburl)) {
45 if (clean_param($unlistedhuburl, PARAM_URL) !== '') {
46 $huburl = $unlistedhuburl;
48 } else if (!empty($selectedhuburl)) {
49 $huburl = $selectedhuburl;
53 //redirect
54 if (!empty($huburl) and confirm_sesskey()) {
55 $hubname = optional_param(clean_param($huburl, PARAM_ALPHANUMEXT), '', PARAM_TEXT);
56 $params = array('sesskey' => sesskey(), 'huburl' => $huburl,
57 'password' => $password, 'hubname' => $hubname);
58 redirect(new moodle_url($CFG->wwwroot."/" . $CFG->admin . "/registration/register.php",
59 $params));
63 //// OUTPUT ////
65 echo $OUTPUT->header();
66 echo $OUTPUT->heading(get_string('registeron', 'hub'), 3, 'main');
67 $hubselectorform->display();
68 echo $OUTPUT->footer();