adding some strings
[moodle-linuxchix.git] / mod / chat / index.php
blob84daca9740837c23109b05d241838bf4e8a7ea7e
1 <?php // $Id$
3 require_once('../../config.php');
4 require_once('lib.php');
6 $id = required_param('id', PARAM_INT); // course
8 if (! $course = get_record('course', 'id', $id)) {
9 error('Course ID is incorrect');
12 require_course_login($course);
14 add_to_log($course->id, 'chat', 'view all', "index.php?id=$course->id", '');
17 /// Get all required strings
19 $strchats = get_string('modulenameplural', 'chat');
20 $strchat = get_string('modulename', 'chat');
23 /// Print the header
25 $navlinks = array();
26 $navlinks[] = array('name' => $strchats, 'link' => '', 'type' => 'activity');
27 $navigation = build_navigation($navlinks);
29 print_header_simple($strchats, '', $navigation, '', '', true, '', navmenu($course));
31 /// Get all the appropriate data
33 if (! $chats = get_all_instances_in_course('chat', $course)) {
34 notice('There are no chats', "../../course/view.php?id=$course->id");
35 die();
38 /// Print the list of instances (your module will probably extend this)
40 $timenow = time();
41 $strname = get_string('name');
42 $strweek = get_string('week');
43 $strtopic = get_string('topic');
45 if ($course->format == 'weeks') {
46 $table->head = array ($strweek, $strname);
47 $table->align = array ('center', 'left');
48 } else if ($course->format == 'topics') {
49 $table->head = array ($strtopic, $strname);
50 $table->align = array ('center', 'left', 'left', 'left');
51 } else {
52 $table->head = array ($strname);
53 $table->align = array ('left', 'left', 'left');
56 $currentsection = '';
57 foreach ($chats as $chat) {
58 if (!$chat->visible) {
59 //Show dimmed if the mod is hidden
60 $link = "<a class=\"dimmed\" href=\"view.php?id=$chat->coursemodule\">".format_string($chat->name,true)."</a>";
61 } else {
62 //Show normal if the mod is visible
63 $link = "<a href=\"view.php?id=$chat->coursemodule\">".format_string($chat->name,true)."</a>";
65 $printsection = '';
66 if ($chat->section !== $currentsection) {
67 if ($chat->section) {
68 $printsection = $chat->section;
70 if ($currentsection !== '') {
71 $table->data[] = 'hr';
73 $currentsection = $chat->section;
75 if ($course->format == 'weeks' or $course->format == 'topics') {
76 $table->data[] = array ($printsection, $link);
77 } else {
78 $table->data[] = array ($link);
82 echo '<br />';
84 print_table($table);
86 /// Finish the page
88 print_footer($course);