Merge branch 'MDL-40047-master' of git://github.com/ankitagarwal/moodle
[moodle.git] / course / publish / hubselector.php
blob095e33be0e7c2ec79dc996b919ac8ffb7257bc2e
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 course
19 * @subpackage publish
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 * On this page the user selects where he wants to publish the course
27 require('../../config.php');
29 require_once($CFG->dirroot.'/' . $CFG->admin . '/registration/lib.php');
30 require_once($CFG->dirroot.'/course/publish/forms.php');
32 $id = required_param('id', PARAM_INT);
33 $course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
34 require_login($course);
36 $PAGE->set_url('/course/publish/hubselector.php', array('id' => $course->id));
37 $PAGE->set_pagelayout('course');
38 $PAGE->set_title(get_string('course') . ': ' . $course->fullname);
39 $PAGE->set_heading($course->fullname);
41 $registrationmanager = new registration_manager();
42 $registeredhubs = $registrationmanager->get_registered_on_hubs();
43 if (empty($registeredhubs)) {
44 echo $OUTPUT->header();
45 echo $OUTPUT->heading(get_string('publishon', 'hub'), 3, 'main');
46 echo $OUTPUT->box(get_string('notregisteredonhub', 'hub'));
47 echo $OUTPUT->footer();
48 die();
52 $share = optional_param('share', false, PARAM_BOOL);
53 $advertise = optional_param('advertise', false, PARAM_BOOL);
54 $hubselectorform = new hub_publish_selector_form('',
55 array('id' => $id, 'share' => $share, 'advertise' => $advertise));
56 $fromform = $hubselectorform->get_data();
58 //// Redirect to the registration form if an URL has been chosen ////
59 $huburl = optional_param('huburl', false, PARAM_URL);
61 //redirect
62 if (!empty($huburl) and confirm_sesskey()) {
63 $hubname = optional_param(clean_param($huburl, PARAM_ALPHANUMEXT), '', PARAM_TEXT);
64 $params = array('sesskey' => sesskey(), 'id' => $id,
65 'huburl' => $huburl, 'hubname' => $hubname, 'share' => $share, 'advertise' => $advertise);
66 redirect(new moodle_url($CFG->wwwroot."/course/publish/metadata.php",
67 $params));
71 //// OUTPUT ////
74 echo $OUTPUT->header();
75 echo $OUTPUT->heading(get_string('publishon', 'hub'), 3, 'main');
76 $hubselectorform->display();
77 echo $OUTPUT->footer();