New module: Label.
[moodle.git] / mod / label / view.php
CommitLineData
2c5c3e62 1<?PHP // $Id$
2
3 require_once("../../config.php");
4
5 optional_variable($id); // Course Module ID, or
6 optional_variable($l); // Label ID
7
8 if ($id) {
9 if (! $cm = get_record("course_modules", "id", $id)) {
10 error("Course Module ID was incorrect");
11 }
12
13 if (! $course = get_record("course", "id", $cm->course)) {
14 error("Course is misconfigured");
15 }
16
17 if (! $label = get_record("label", "id", $cm->instance)) {
18 error("Course module is incorrect");
19 }
20
21 } else {
22 if (! $label = get_record("label", "id", $l)) {
23 error("Course module is incorrect");
24 }
25 if (! $course = get_record("course", "id", $label->course)) {
26 error("Course is misconfigured");
27 }
28 if (! $cm = get_coursemodule_from_instance("label", $label->id, $course->id)) {
29 error("Course Module ID was incorrect");
30 }
31 }
32
33 require_login($course->id);
34
35 redirect("$CFG->wwwroot/course/view.php?id=$course->id");
36
37?>
38