Merge branch 'MDL-34774_m24' of git://github.com/rwijaya/moodle into MOODLE_24_STABLE
[moodle.git] / mod / workshop / index.php
blob263807a87aa4e17389692425ddb5a9c626a6bf4e
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);
59 $timenow = time();
60 $strsectionname = get_string('sectionname', 'format_'.$course->format);
61 $strname = get_string('name');
62 $table = new html_table();
64 if ($usesections) {
65 $table->head = array ($strsectionname, $strname);
66 $table->align = array ('center', 'left');
67 } else {
68 $table->head = array ($strname);
69 $table->align = array ('left');
72 foreach ($workshops as $workshop) {
73 if (empty($workshop->visible)) {
74 $link = html_writer::link(new moodle_url('/mod/workshop/view.php', array('id' => $workshop->coursemodule)),
75 $workshop->name, array('class' => 'dimmed'));
76 } else {
77 $link = html_writer::link(new moodle_url('/mod/workshop/view.php', array('id' => $workshop->coursemodule)),
78 $workshop->name);
81 if ($usesections) {
82 $table->data[] = array(get_section_name($course, $workshop->section), $link);
83 } else {
84 $table->data[] = array($link);
88 echo $OUTPUT->heading(get_string('modulenameplural', 'workshop'), 2);
89 echo html_writer::table($table);
90 echo $OUTPUT->footer();