Very early version of new chat module, made by Martin using ARSC as
[moodle.git] / mod / chat / index.php
CommitLineData
1515a89e 1<?PHP // $Id$
2
3 require_once("../../config.php");
4 require_once("lib.php");
5
6 require_variable($id); // course
7
8 if (! $course = get_record("course", "id", $id)) {
9 error("Course ID is incorrect");
10 }
11
12 require_login($course->id);
13
14 add_to_log($course->id, "chat", "view all", "index.php?id=$course->id", "");
15
16
17/// Get all required strings
18
19 $strchats = get_string("modulenameplural", "chat");
20 $strchat = get_string("modulename", "chat");
21
22
23/// Print the header
24
25 if ($course->category) {
26 $navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
27 }
28
29 print_header("$course->shortname: $strchats", "$course->fullname", "$navigation $strchats");
30
31/// Get all the appropriate data
32
33 if (! $chats = get_all_instances_in_course("chat", $course->id, "cw.section ASC")) {
34 notice("There are no chats", "../../course/view.php?id=$course->id");
35 die;
36 }
37
38/// Print the list of instances (your module will probably extend this)
39
40 $timenow = time();
41 $strname = get_string("name");
42 $strweek = get_string("week");
43 $strtopic = get_string("topic");
44
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");
54 }
55
56 foreach ($chats as $chat) {
57 $link = "<A HREF=\"view.php?id=$chat->coursemodule\">$chat->name</A>";
58
59 if ($course->format == "weeks" or $course->format == "topics") {
60 $table->data[] = array ($chat->section, $link);
61 } else {
62 $table->data[] = array ($link);
63 }
64 }
65
66 echo "<br />";
67
68 print_table($table);
69
70/// Finish the page
71
72 print_footer($course);
73
74?>