3 require_once('../../config.php');
4 require_once('lib.php');
6 $id = required_param('id', PARAM_INT); // course
8 $PAGE->set_url('/mod/chat/index.php', array('id'=>$id));
10 if (! $course = $DB->get_record('course', array('id'=>$id))) {
11 print_error('invalidcourseid');
14 require_course_login($course);
15 $PAGE->set_pagelayout('incourse');
17 add_to_log($course->id, 'chat', 'view all', "index.php?id=$course->id", '');
20 /// Get all required strings
22 $strsectionname = get_string('sectionname', 'format_'.$course->format);
23 $strchats = get_string('modulenameplural', 'chat');
24 $strchat = get_string('modulename', 'chat');
28 $PAGE->navbar->add($strchats);
29 $PAGE->set_title($strchats);
30 $PAGE->set_heading($course->fullname);
31 echo $OUTPUT->header();
32 echo $OUTPUT->heading($strchats, 2);
34 /// Get all the appropriate data
36 if (! $chats = get_all_instances_in_course('chat', $course)) {
37 notice(get_string('thereareno', 'moodle', $strchats), "../../course/view.php?id=$course->id");
41 $usesections = course_format_uses_sections($course->format);
43 /// Print the list of instances (your module will probably extend this)
46 $strname = get_string('name');
48 $table = new html_table();
51 $table->head = array ($strsectionname, $strname);
52 $table->align = array ('center', 'left');
54 $table->head = array ($strname);
55 $table->align = array ('left');
59 foreach ($chats as $chat) {
60 if (!$chat->visible) {
61 //Show dimmed if the mod is hidden
62 $link = "<a class=\"dimmed\" href=\"view.php?id=$chat->coursemodule\">".format_string($chat->name,true)."</a>";
64 //Show normal if the mod is visible
65 $link = "<a href=\"view.php?id=$chat->coursemodule\">".format_string($chat->name,true)."</a>";
68 if ($chat->section !== $currentsection) {
70 $printsection = get_section_name($course, $chat->section);
72 if ($currentsection !== '') {
73 $table->data[] = 'hr';
75 $currentsection = $chat->section;
78 $table->data[] = array ($printsection, $link);
80 $table->data[] = array ($link);
86 echo html_writer::table($table);
90 echo $OUTPUT->footer();