2 // This file is part of Moodle - http://moodle.org/
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.
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/>.
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 * The user selects if he wants to publish the course on Moodle.org hub or
25 * on a specific hub. The site must be registered on a hub to be able to
26 * publish a course on it.
29 require('../../config.php');
31 $courseid = required_param('id', PARAM_INT
); // Course id.
32 $publicationid = optional_param('publicationid', 0, PARAM_INT
); // Id of course publication to unpublish.
34 require_login($courseid);
35 $shortname = format_string($COURSE->shortname
);
37 $PAGE->set_url('/course/publish/index.php', array('id' => $courseid));
38 $PAGE->set_pagelayout('incourse');
39 $PAGE->set_title(get_string('publish', 'core_hub') . ': ' . $COURSE->fullname
);
40 $PAGE->set_heading($COURSE->fullname
);
42 require_capability('moodle/course:publish', context_course
::instance($courseid));
44 // If the site is not registered display an error page.
45 if (!\core\hub\registration
::is_registered()) {
46 echo $OUTPUT->header();
47 echo $OUTPUT->heading(get_string('publishcourseon', 'hub', 'Moodle.net'), 3, 'main');
48 echo $OUTPUT->box(get_string('notregisteredonhub', 'hub'));
49 if (has_capability('moodle/site:config', context_system
::instance())) {
50 echo $OUTPUT->single_button(new moodle_url('/admin/registration/index.php'), get_string('register', 'admin'));
52 echo $OUTPUT->footer();
56 // When hub listing status is requested update statuses of all published courses.
57 $updatestatusid = optional_param('updatestatusid', false, PARAM_INT
);
58 if (!empty($updatestatusid) && confirm_sesskey()) {
59 if (core\hub\publication
::get_publication($updatestatusid, $courseid)) {
60 core\hub\publication
::request_status_update();
65 $renderer = $PAGE->get_renderer('core', 'course');
68 if ($publication = \core\hub\publication
::get_publication($publicationid, $courseid)) {
69 $confirm = optional_param('confirm', 0, PARAM_BOOL
);
70 if ($confirm && confirm_sesskey()) {
71 \core\hub\publication
::unpublish($publication);
73 // Display confirmation page for unpublishing.
74 $publication = \core\hub\publication
::get_publication($publicationid, $courseid, MUST_EXIST
);
75 $publication->courseshortname
= format_string($COURSE->shortname
);
76 echo $OUTPUT->header();
77 echo $OUTPUT->heading(get_string('unpublishcourse', 'hub', $shortname), 3, 'main');
78 echo $renderer->confirmunpublishing($publication);
79 echo $OUTPUT->footer();
84 // List current publications and "Publish" buttons.
85 echo $OUTPUT->header();
87 echo $OUTPUT->heading(get_string('publishcourse', 'hub', $shortname), 3, 'main');
88 echo $renderer->publicationselector($courseid);
90 $publications = \core\hub\publication
::get_course_publications($courseid);
91 if (!empty($publications)) {
92 echo $OUTPUT->heading(get_string('publishedon', 'hub'), 3, 'main');
93 echo $renderer->registeredonhublisting($courseid, $publications);
96 echo $OUTPUT->footer();