Commit | Line | Data |
---|---|---|
aa6c1ced | 1 | <?php |
768e3613 SB |
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. | |
13 | // | |
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/>. | |
16 | ||
17 | /** | |
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 | |
22 | */ | |
52a554db | 23 | |
24 | require_once("../config.php"); | |
25 | require_once("lib.php"); | |
26 | ||
d5f8920f | 27 | $id = optional_param('id', false, PARAM_INT); // Course id |
28 | $name = optional_param('name', false, PARAM_RAW); // Course short name | |
52a554db | 29 | |
30 | if (!$id and !$name) { | |
ba6018a9 | 31 | print_error("unspecifycourseid"); |
52a554db | 32 | } |
33 | ||
34 | if ($name) { | |
e4907498 | 35 | if (!$course = $DB->get_record("course", array("shortname"=>$name))) { |
ba6018a9 | 36 | print_error("invalidshortname"); |
52a554db | 37 | } |
38 | } else { | |
6bb08163 | 39 | if (!$course = $DB->get_record("course", array("id"=>$id))) { |
ba6018a9 | 40 | print_error("invalidcourseid"); |
52a554db | 41 | } |
42 | } | |
43 | ||
44 | $site = get_site(); | |
45 | ||
4f006bc1 | 46 | if ($CFG->forcelogin) { |
47 | require_login(); | |
48 | } | |
49 | ||
9a5e297b | 50 | $context = context_course::instance($course->id); |
beff3806 MG |
51 | if (!core_course_category::can_view_course_info($course) && !is_enrolled($context, null, '', true)) { |
52 | print_error('cannotviewcategory', '', $CFG->wwwroot .'/'); | |
98b369f8 | 53 | } |
54 | ||
ddbf9b6b | 55 | $PAGE->set_course($course); |
369484bf | 56 | $PAGE->set_pagelayout('incourse'); |
a6855934 | 57 | $PAGE->set_url('/course/info.php', array('id' => $course->id)); |
0a122046 | 58 | $PAGE->set_title(get_string("summaryof", "", $course->fullname)); |
bba67fcb | 59 | $PAGE->set_heading(get_string('courseinfo')); |
aebd86db | 60 | $PAGE->navbar->add(get_string('summary')); |
aebd86db | 61 | |
0a122046 | 62 | echo $OUTPUT->header(); |
52a554db | 63 | |
bf423bb1 PS |
64 | // print enrol info |
65 | if ($texts = enrol_get_course_description_texts($course)) { | |
98b369f8 | 66 | echo $OUTPUT->box_start('generalbox icons'); |
bf423bb1 | 67 | echo implode($texts); |
98b369f8 | 68 | echo $OUTPUT->box_end(); |
bf423bb1 | 69 | } |
52a554db | 70 | |
cb76fec0 PS |
71 | $courserenderer = $PAGE->get_renderer('core', 'course'); |
72 | echo $courserenderer->course_info_box($course); | |
52a554db | 73 | |
74 | echo "<br />"; | |
75 | ||
768e3613 SB |
76 | // Trigger event, course information viewed. |
77 | $eventparams = array('context' => $context, 'objectid' => $course->id); | |
78 | $event = \core\event\course_information_viewed::create($eventparams); | |
79 | $event->trigger(); | |
80 | ||
d60c1124 | 81 | echo $OUTPUT->footer(); |
52a554db | 82 | |
aa6c1ced | 83 |