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 |
* unilabel module.
|
|
|
19 |
*
|
|
|
20 |
* @package mod_unilabel
|
|
|
21 |
* @author Andreas Grabs <info@grabs-edv.de>
|
|
|
22 |
* @copyright 2018 onwards Grabs EDV {@link https://www.grabs-edv.de}
|
|
|
23 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
24 |
*/
|
|
|
25 |
|
|
|
26 |
require_once('../../config.php');
|
|
|
27 |
|
|
|
28 |
$id = optional_param('id', 0, PARAM_INT); // Course Module ID.
|
|
|
29 |
$l = optional_param('l', 0, PARAM_INT); // The unilabel ID.
|
|
|
30 |
|
|
|
31 |
if ($id) {
|
|
|
32 |
$PAGE->set_url('/mod/unilabel/index.php', ['id' => $id]);
|
|
|
33 |
if (!$cm = get_coursemodule_from_id('unilabel', $id, 0, true)) {
|
|
|
34 |
throw new \moodle_exception('invalidcoursemodule');
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
if (!$course = $DB->get_record('course', ['id' => $cm->course])) {
|
|
|
38 |
throw new \moodle_exception('coursemisconf');
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
if (!$unilabel = $DB->get_record('unilabel', ['id' => $cm->instance])) {
|
|
|
42 |
throw new \moodle_exception('invalidcoursemodule');
|
|
|
43 |
}
|
|
|
44 |
} else {
|
|
|
45 |
$PAGE->set_url('/mod/unilabel/index.php', ['l' => $l]);
|
|
|
46 |
if (!$unilabel = $DB->get_record('unilabel', ['id' => $l])) {
|
|
|
47 |
throw new \moodle_exception('invalidcoursemodule');
|
|
|
48 |
}
|
|
|
49 |
if (!$course = $DB->get_record('course', ['id' => $unilabel->course])) {
|
|
|
50 |
throw new \moodle_exception('coursemisconf');
|
|
|
51 |
}
|
|
|
52 |
if (!$cm = get_coursemodule_from_instance('unilabel', $unilabel->id, $course->id, true)) {
|
|
|
53 |
throw new \moodle_exception('invalidcoursemodule');
|
|
|
54 |
}
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
require_login($course, true, $cm);
|
|
|
58 |
|
|
|
59 |
$url = new \moodle_url('/course/view.php', ['id' => $course->id, 'section' => $cm->sectionnum], 'module-' . $id);
|
|
|
60 |
redirect($url);
|