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/>.
18 * Displays external information about a course
19 * @package core_course
20 * @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 require_once("../config.php");
25 require_once("lib.php");
27 $id = optional_param('id', false, PARAM_INT
); // Course id
28 $name = optional_param('name', false, PARAM_RAW
); // Course short name
30 if (!$id and !$name) {
31 print_error("unspecifycourseid");
35 if (!$course = $DB->get_record("course", array("shortname"=>$name))) {
36 print_error("invalidshortname");
39 if (!$course = $DB->get_record("course", array("id"=>$id))) {
40 print_error("invalidcourseid");
46 if ($CFG->forcelogin
) {
50 $context = context_course
::instance($course->id
);
51 if (!core_course_category
::can_view_course_info($course) && !is_enrolled($context, null, '', true)) {
52 print_error('cannotviewcategory', '', $CFG->wwwroot
.'/');
55 $PAGE->set_course($course);
56 $PAGE->set_pagelayout('incourse');
57 $PAGE->set_url('/course/info.php', array('id' => $course->id
));
58 $PAGE->set_title(get_string("summaryof", "", $course->fullname
));
59 $PAGE->set_heading(get_string('courseinfo'));
60 $PAGE->navbar
->add(get_string('summary'));
62 echo $OUTPUT->header();
65 if ($texts = enrol_get_course_description_texts($course)) {
66 echo $OUTPUT->box_start('generalbox icons');
68 echo $OUTPUT->box_end();
71 $courserenderer = $PAGE->get_renderer('core', 'course');
72 echo $courserenderer->course_info_box($course);
76 // Trigger event, course information viewed.
77 $eventparams = array('context' => $context, 'objectid' => $course->id
);
78 $event = \core\event\course_information_viewed
::create($eventparams);
81 echo $OUTPUT->footer();