mod-choice MDL-19805 Added PAGE->set_url calls and removed deprecated functions
[moodle.git] / mod / chat / index.php
CommitLineData
1c61c8d6 1<?php // $Id$
1515a89e 2
516121bd 3 require_once('../../config.php');
4 require_once('lib.php');
1515a89e 5
516121bd 6 $id = required_param('id', PARAM_INT); // course
1515a89e 7
d3bf6f92 8 if (! $course = $DB->get_record('course', array('id'=>$id))) {
2f52a088 9 print_error('invalidcourseid');
1515a89e 10 }
11
f950af3c 12 require_course_login($course);
1515a89e 13
516121bd 14 add_to_log($course->id, 'chat', 'view all', "index.php?id=$course->id", '');
1515a89e 15
16
17/// Get all required strings
18
516121bd 19 $strchats = get_string('modulenameplural', 'chat');
20 $strchat = get_string('modulename', 'chat');
1515a89e 21
22
23/// Print the header
296b589e 24 $PAGE->navbar->add($strchats);
25 $PAGE->set_title($strchats);
26 echo $OUTPUT->header();
1515a89e 27
28/// Get all the appropriate data
29
1f106b3f 30 if (! $chats = get_all_instances_in_course('chat', $course)) {
b1892167 31 notice(get_string('thereareno', 'moodle', $strchats), "../../course/view.php?id=$course->id");
516121bd 32 die();
1515a89e 33 }
34
35/// Print the list of instances (your module will probably extend this)
36
516121bd 37 $timenow = time();
38 $strname = get_string('name');
39 $strweek = get_string('week');
40 $strtopic = get_string('topic');
1515a89e 41
af7bad79 42 $table = new html_table();
43
516121bd 44 if ($course->format == 'weeks') {
1515a89e 45 $table->head = array ($strweek, $strname);
516121bd 46 $table->align = array ('center', 'left');
47 } else if ($course->format == 'topics') {
1515a89e 48 $table->head = array ($strtopic, $strname);
516121bd 49 $table->align = array ('center', 'left', 'left', 'left');
1515a89e 50 } else {
51 $table->head = array ($strname);
516121bd 52 $table->align = array ('left', 'left', 'left');
1515a89e 53 }
54
516121bd 55 $currentsection = '';
1f106b3f 56 foreach ($chats as $chat) {
57 if (!$chat->visible) {
58 //Show dimmed if the mod is hidden
59 $link = "<a class=\"dimmed\" href=\"view.php?id=$chat->coursemodule\">".format_string($chat->name,true)."</a>";
60 } else {
61 //Show normal if the mod is visible
62 $link = "<a href=\"view.php?id=$chat->coursemodule\">".format_string($chat->name,true)."</a>";
9ab344ee 63 }
516121bd 64 $printsection = '';
1f106b3f 65 if ($chat->section !== $currentsection) {
66 if ($chat->section) {
67 $printsection = $chat->section;
93285301 68 }
516121bd 69 if ($currentsection !== '') {
93285301 70 $table->data[] = 'hr';
c6cbe2e3 71 }
1f106b3f 72 $currentsection = $chat->section;
93285301 73 }
516121bd 74 if ($course->format == 'weeks' or $course->format == 'topics') {
93285301 75 $table->data[] = array ($printsection, $link);
1515a89e 76 } else {
77 $table->data[] = array ($link);
78 }
79 }
80
516121bd 81 echo '<br />';
1515a89e 82
af7bad79 83 echo $OUTPUT->table($table);
1515a89e 84
85/// Finish the page
86
d8772689 87 echo $OUTPUT->footer();
1515a89e 88
89?>