1 |
efrain |
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.
|
|
|
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 |
*/
|
|
|
23 |
|
|
|
24 |
require_once("../config.php");
|
|
|
25 |
require_once("lib.php");
|
|
|
26 |
|
|
|
27 |
$id = optional_param('id', false, PARAM_INT); // Course id
|
|
|
28 |
$name = optional_param('name', false, PARAM_RAW); // Course short name
|
|
|
29 |
|
|
|
30 |
if (!$id and !$name) {
|
|
|
31 |
throw new \moodle_exception("unspecifycourseid");
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
if ($name) {
|
|
|
35 |
if (!$course = $DB->get_record("course", array("shortname"=>$name))) {
|
|
|
36 |
throw new \moodle_exception("invalidshortname");
|
|
|
37 |
}
|
|
|
38 |
} else {
|
|
|
39 |
if (!$course = $DB->get_record("course", array("id"=>$id))) {
|
|
|
40 |
throw new \moodle_exception("invalidcourseid");
|
|
|
41 |
}
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
$site = get_site();
|
|
|
45 |
|
|
|
46 |
if ($CFG->forcelogin) {
|
|
|
47 |
require_login();
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
$context = context_course::instance($course->id);
|
|
|
51 |
if (!core_course_category::can_view_course_info($course) && !is_enrolled($context, null, '', true)) {
|
|
|
52 |
throw new \moodle_exception('cannotviewcategory', '', $CFG->wwwroot .'/');
|
|
|
53 |
}
|
|
|
54 |
|
|
|
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'));
|
|
|
61 |
|
|
|
62 |
echo $OUTPUT->header();
|
|
|
63 |
|
|
|
64 |
// print enrol info
|
|
|
65 |
if ($texts = enrol_get_course_description_texts($course)) {
|
|
|
66 |
echo $OUTPUT->box_start('generalbox icons');
|
|
|
67 |
echo implode($texts);
|
|
|
68 |
echo $OUTPUT->box_end();
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
$courserenderer = $PAGE->get_renderer('core', 'course');
|
|
|
72 |
echo $courserenderer->course_info_box($course);
|
|
|
73 |
|
|
|
74 |
echo "<br />";
|
|
|
75 |
|
|
|
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 |
|
|
|
81 |
echo $OUTPUT->footer();
|
|
|
82 |
|
|
|
83 |
|