Incorrect variable name used for parameter.
[moodle-linuxchix.git] / mod / wiki / index.php
blobf894d4c2366e6c0828f4188412db17d1b1bccec0
1 <?PHP // $Id$
3 /// This page lists all the instances of wiki in a particular course
4 /// Replace wiki with the name of your module
6 require_once("../../config.php");
7 require_once("lib.php");
9 require_variable($id); // course
11 if (! $course = get_record("course", "id", $id)) {
12 error("Course ID is incorrect");
15 require_course_login($course);
17 add_to_log($course->id, "wiki", "view all", "index.php?id=$course->id", "");
20 /// Get all required strings
22 $strwikis = get_string("modulenameplural", "wiki");
23 $strwiki = get_string("modulename", "wiki");
26 /// Print the header
28 print_header_simple("$strwikis", "", "$strwikis", "", "", true, "", navmenu($course));
30 /// Get all the appropriate data
32 if (! $wikis = get_all_instances_in_course("wiki", $course)) {
33 notice("There are no wikis", "../../course/view.php?id=$course->id");
34 die;
37 /// Print the list of instances (your module will probably extend this)
39 $timenow = time();
40 $strname = get_string('wikiname', 'wiki');
41 $strsummary = get_string('summary');
42 $strtype = get_string('wikitype', 'wiki');
43 $strlastmodified = get_string('lastmodified');
44 $strweek = get_string('week');
45 $strtopic = get_string('topic');
47 if ($course->format == "weeks") {
48 $table->head = array ($strweek, $strname, $strsummary, $strtype, $strlastmodified);
49 $table->align = array ('CENTER', 'LEFT', 'LEFT', 'LEFT', 'LEFT');
50 } else if ($course->format == "topics") {
51 $table->head = array ($strtopic, $strname, $strsummary, $strtype, $strlastmodified);
52 $table->align = array ('CENTER', 'LEFT', 'LEFT', 'LEFT', 'LEFT');
53 } else {
54 $table->head = array ($strname, $strsummary, $strtype, $strlastmodified);
55 $table->align = array ('LEFT', 'LEFT', 'LEFT', 'LEFT');
58 foreach ($wikis as $wiki) {
59 if (!$wiki->visible) {
60 //Show dimmed if the mod is hidden
61 $link = '<A class="dimmed" HREF="view.php?id='.$wiki->coursemodule.'">'.format_string($wiki->name,true).'</A>';
62 } else {
63 //Show normal if the mod is visible
64 $link = '<A HREF="view.php?id='.$wiki->coursemodule.'">'.format_string($wiki->name,true).'</A>';
67 $timmod = '<span class="smallinfo">'.userdate($wiki->timemodified).'</span>';
68 $summary = '<span class="smallinfo">'.format_text($wiki->summary).'</span>';
70 $site = get_site();
71 switch ($wiki->wtype) {
73 case 'teacher':
74 $wtype = $site->teacher;
75 break;
77 case 'student':
78 $wtype = $site->student;
79 break;
81 case 'group':
82 default:
83 $wtype = get_string('group');
84 break;
87 $wtype = '<span class="smallinfo">'.$wtype.'</span>';
89 if ($course->format == "weeks" or $course->format == "topics") {
90 $table->data[] = array ($wiki->section, $link, $summary, $wtype, $timmod);
91 } else {
92 $table->data[] = array ($link, $summary, $wtype, $timmod);
96 echo "<br />";
98 print_table($table);
100 /// Finish the page
102 print_footer($course);