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 $strchats = get_string('modulenameplural', 'chat');
23 $strchat = get_string('modulename', 'chat');
27 $PAGE->navbar
->add($strchats);
28 $PAGE->set_title($strchats);
29 $PAGE->set_heading($course->fullname
);
30 echo $OUTPUT->header();
32 /// Get all the appropriate data
34 if (! $chats = get_all_instances_in_course('chat', $course)) {
35 notice(get_string('thereareno', 'moodle', $strchats), "../../course/view.php?id=$course->id");
39 $usesections = course_format_uses_sections($course->format
);
41 /// Print the list of instances (your module will probably extend this)
44 $strname = get_string('name');
46 $table = new html_table();
49 $strsectionname = get_string('sectionname', 'format_'.$course->format
);
50 $table->head
= array ($strsectionname, $strname);
51 $table->align
= array ('center', 'left');
53 $table->head
= array ($strname);
54 $table->align
= array ('left');
58 foreach ($chats as $chat) {
59 if (!$chat->visible
) {
60 //Show dimmed if the mod is hidden
61 $link = "<a class=\"dimmed\" href=\"view.php?id=$chat->coursemodule\">".format_string($chat->name
,true)."</a>";
63 //Show normal if the mod is visible
64 $link = "<a href=\"view.php?id=$chat->coursemodule\">".format_string($chat->name
,true)."</a>";
67 if ($chat->section
!== $currentsection) {
69 $printsection = get_section_name($course, $chat->section
);
71 if ($currentsection !== '') {
72 $table->data
[] = 'hr';
74 $currentsection = $chat->section
;
77 $table->data
[] = array ($printsection, $link);
79 $table->data
[] = array ($link);
85 echo html_writer
::table($table);
89 echo $OUTPUT->footer();