MDL-11082 Improved groups upgrade performance 1.8x -> 1.9; thanks Eloy for telling...
[moodle-pu.git] / mod / wiki / index.php
blob5f7f351643dde8407be560f489ba84cb00006fe8
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 $id = required_param('id', PARAM_INT); // 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
27 $navlinks = array();
28 $navlinks[] = array('name' => $strwikis, 'link' => "index.php?id=$course->id", 'type' => 'activity');
29 $navigation = build_navigation($navlinks);
31 print_header_simple("$strwikis", "", $navigation, "", "", true, "", navmenu($course));
33 /// Get all the appropriate data
35 if (! $wikis = get_all_instances_in_course("wiki", $course)) {
36 notice("There are no wikis", "../../course/view.php?id=$course->id");
37 die;
40 /// Print the list of instances (your module will probably extend this)
42 $timenow = time();
43 $strname = get_string('wikiname', 'wiki');
44 $strsummary = get_string('summary');
45 $strtype = get_string('wikitype', 'wiki');
46 $strlastmodified = get_string('lastmodified');
47 $strweek = get_string('week');
48 $strtopic = get_string('topic');
50 if ($course->format == "weeks") {
51 $table->head = array ($strweek, $strname, $strsummary, $strtype, $strlastmodified);
52 $table->align = array ('CENTER', 'LEFT', 'LEFT', 'LEFT', 'LEFT');
53 } else if ($course->format == "topics") {
54 $table->head = array ($strtopic, $strname, $strsummary, $strtype, $strlastmodified);
55 $table->align = array ('CENTER', 'LEFT', 'LEFT', 'LEFT', 'LEFT');
56 } else {
57 $table->head = array ($strname, $strsummary, $strtype, $strlastmodified);
58 $table->align = array ('LEFT', 'LEFT', 'LEFT', 'LEFT');
61 foreach ($wikis as $wiki) {
62 if (!$wiki->visible) {
63 //Show dimmed if the mod is hidden
64 $link = '<a class="dimmed" href="view.php?id='.$wiki->coursemodule.'">'.format_string($wiki->name,true).'</a>';
65 } else {
66 //Show normal if the mod is visible
67 $link = '<a href="view.php?id='.$wiki->coursemodule.'">'.format_string($wiki->name,true).'</a>';
70 $timmod = '<span class="smallinfo">'.userdate($wiki->timemodified).'</span>';
71 $summary = '<span class="smallinfo">'.format_text($wiki->summary).'</span>';
73 $site = get_site();
74 switch ($wiki->wtype) {
76 case 'teacher':
77 $wtype = $site->teacher;
78 break;
80 case 'student':
81 $wtype = $site->student;
82 break;
84 case 'group':
85 default:
86 $wtype = get_string('group');
87 break;
90 $wtype = '<span class="smallinfo">'.$wtype.'</span>';
92 if ($course->format == "weeks" or $course->format == "topics") {
93 $table->data[] = array ($wiki->section, $link, $summary, $wtype, $timmod);
94 } else {
95 $table->data[] = array ($link, $summary, $wtype, $timmod);
99 echo "<br />";
101 print_table($table);
103 /// Finish the page
105 print_footer($course);