Merge branch 'install_20_STABLE' of git://github.com/amosbot/moodle into MOODLE_20_STABLE
[moodle.git] / mod / workshop / index.php
blob7a7ea2774cde3a0f0d66c821d595cd97f77dd547
1 <?php
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.
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/>.
18 /**
19 * Prints the list of all workshops in the course
21 * @package mod
22 * @subpackage workshop
23 * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
28 require_once(dirname(__FILE__).'/lib.php');
30 $id = required_param('id', PARAM_INT); // course
32 $course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
34 require_course_login($course);
36 add_to_log($course->id, 'workshop', 'view all', "index.php?id=$course->id", '');
38 $PAGE->set_pagelayout('incourse');
39 $PAGE->set_url('/mod/workshop/index.php', array('id' => $course->id));
40 $PAGE->set_title($course->fullname);
41 $PAGE->set_heading($course->shortname);
42 $PAGE->navbar->add(get_string('modulenameplural', 'workshop'));
44 /// Output starts here
46 echo $OUTPUT->header();
48 /// Get all the appropriate data
50 if (! $workshops = get_all_instances_in_course('workshop', $course)) {
51 echo $OUTPUT->heading(get_string('noworkshops', 'workshop'), 2);
52 echo $OUTPUT->continue_button(new moodle_url('/course/view.php', array('id' => $course->id)));
53 echo $OUTPUT->footer();
54 die();
57 $usesections = course_format_uses_sections($course->format);
58 if ($usesections) {
59 $sections = get_all_sections($course->id);
62 $timenow = time();
63 $strsectionname = get_string('sectionname', 'format_'.$course->format);
64 $strname = get_string('name');
65 $table = new html_table();
67 if ($usesections) {
68 $table->head = array ($strsectionname, $strname);
69 $table->align = array ('center', 'left');
70 } else {
71 $table->head = array ($strname);
72 $table->align = array ('left');
75 foreach ($workshops as $workshop) {
76 if (empty($workshop->visible)) {
77 $link = html_writer::link(new moodle_url('/mod/workshop/view.php', array('id' => $workshop->coursemodule)),
78 $workshop->name, array('class' => 'dimmed'));
79 } else {
80 $link = html_writer::link(new moodle_url('/mod/workshop/view.php', array('id' => $workshop->coursemodule)),
81 $workshop->name);
84 if ($usesections) {
85 $table->data[] = array(get_section_name($course, $sections[$workshop->section]), $link);
86 } else {
87 $table->data[] = array($link);
91 echo $OUTPUT->heading(get_string('modulenameplural', 'workshop'), 2);
92 echo html_writer::table($table);
93 echo $OUTPUT->footer();