MDL-43987 core: Remove port numbers in cleanremoteaddr
[moodle.git] / mod / workshop / index.php
blob02c513bba25bc874958a1fc11b7c5f0560cd2acc
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_workshop
22 * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
27 require_once(dirname(__FILE__).'/lib.php');
29 $id = required_param('id', PARAM_INT); // course
31 $course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
33 require_course_login($course);
35 $PAGE->set_pagelayout('incourse');
36 $PAGE->set_url('/mod/workshop/index.php', array('id' => $course->id));
37 $PAGE->set_title($course->fullname);
38 $PAGE->set_heading($course->shortname);
39 $PAGE->navbar->add(get_string('modulenameplural', 'workshop'));
41 /// Output starts here
43 echo $OUTPUT->header();
45 $params = array('context' => context_course::instance($course->id));
46 $event = \mod_workshop\event\course_module_instance_list_viewed::create($params);
47 $event->add_record_snapshot('course', $course);
48 $event->trigger();
50 /// Get all the appropriate data
52 if (! $workshops = get_all_instances_in_course('workshop', $course)) {
53 echo $OUTPUT->heading(get_string('modulenameplural', 'workshop'));
54 notice(get_string('noworkshops', 'workshop'), new moodle_url('/course/view.php', array('id' => $course->id)));
55 echo $OUTPUT->footer();
56 die();
59 $usesections = course_format_uses_sections($course->format);
61 $timenow = time();
62 $strname = get_string('name');
63 $table = new html_table();
65 if ($usesections) {
66 $strsectionname = get_string('sectionname', 'format_'.$course->format);
67 $table->head = array ($strsectionname, $strname);
68 $table->align = array ('center', 'left');
69 } else {
70 $table->head = array ($strname);
71 $table->align = array ('left');
74 foreach ($workshops as $workshop) {
75 if (empty($workshop->visible)) {
76 $link = html_writer::link(new moodle_url('/mod/workshop/view.php', array('id' => $workshop->coursemodule)),
77 $workshop->name, array('class' => 'dimmed'));
78 } else {
79 $link = html_writer::link(new moodle_url('/mod/workshop/view.php', array('id' => $workshop->coursemodule)),
80 $workshop->name);
83 if ($usesections) {
84 $table->data[] = array(get_section_name($course, $workshop->section), $link);
85 } else {
86 $table->data[] = array($link);
89 echo $OUTPUT->heading(get_string('modulenameplural', 'workshop'), 3);
90 echo html_writer::table($table);
91 echo $OUTPUT->footer();