MDL-17827 workshop: initial check in of the files
[moodle.git] / mod / workshop / view.php
CommitLineData
4eab2e7f
DM
1<?php
2
3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
18
19/**
20 * Prints a particular instance of workshop
21 *
22 * You can have a rather longer description of the file as well,
23 * if you like, and it can span multiple lines.
24 *
25 * @package mod-workshop
26 * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28 */
29
30/// (Replace workshop with the name of your module and remove this line)
31
32require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
33require_once(dirname(__FILE__).'/lib.php');
34
35$id = optional_param('id', 0, PARAM_INT); // course_module ID, or
36$a = optional_param('a', 0, PARAM_INT); // workshop instance ID
37
38if ($id) {
39 if (! $cm = get_coursemodule_from_id('workshop', $id)) {
40 error('Course Module ID was incorrect');
41 }
42
43 if (! $course = $DB->get_record('course', array('id' => $cm->course))) {
44 error('Course is misconfigured');
45 }
46
47 if (! $workshop = $DB->get_record('workshop', array('id' => $cm->instance))) {
48 error('Course module is incorrect');
49 }
50
51} else if ($a) {
52 if (! $workshop = $DB->get_record('workshop', array('id' => $a))) {
53 error('Course module is incorrect');
54 }
55 if (! $course = $DB->get_record('course', array('id' => $workshop->course))) {
56 error('Course is misconfigured');
57 }
58 if (! $cm = get_coursemodule_from_instance('workshop', $workshop->id, $course->id)) {
59 error('Course Module ID was incorrect');
60 }
61
62} else {
63 error('You must specify a course_module ID or an instance ID');
64}
65
66require_login($course, true, $cm);
67
68add_to_log($course->id, "workshop", "view", "view.php?id=$cm->id", "$workshop->id");
69
70/// Print the page header
71$strworkshops = get_string('modulenameplural', 'workshop');
72$strworkshop = get_string('modulename', 'workshop');
73
74$navlinks = array();
75$navlinks[] = array('name' => $strworkshops, 'link' => "index.php?id=$course->id", 'type' => 'activity');
76$navlinks[] = array('name' => format_string($workshop->name), 'link' => '', 'type' => 'activityinstance');
77
78$navigation = build_navigation($navlinks);
79
80print_header_simple(format_string($workshop->name), '', $navigation, '', '', true,
81 update_module_button($cm->id, $course->id, $strworkshop), navmenu($course, $cm));
82
83/// Print the main part of the page
84
85echo "<a href=\"editgradingform.php?id={$cm->id}\">Edit grading form</a>";
86
87/// Finish the page
88print_footer($course);