fixed log action inserts
[moodle.git] / index.php
CommitLineData
02039379
PS
1<?PHP // $Id: index.php,v 1.1 2006/03/12 18:39:59 skodak Exp $
2
3/// This page lists all the instances of book in a particular course
4
5require_once('../../config.php');
6require_once('lib.php');
7
8$id = required_param('id', PARAM_INT); // Course Module ID
9
10// =========================================================================
11// security checks START - teachers and students view
12// =========================================================================
13if ($CFG->forcelogin) {
14 require_login();
15}
16
17if (!$course = get_record('course', 'id', $id)) {
18 error('Course ID is incorrect');
19}
20
21if ($course->category) {
22 require_login($course->id);
23}
24
25//check all variables
26unset($id);
27
28// =========================================================================
29// security checks END
30// =========================================================================
31
32/// Get all required strings
33$strbooks = get_string('modulenameplural', 'book');
34$strbook = get_string('modulename', 'book');
35
36/// Print the header
37if ($course->category) {
38 $navigation = '<a href="../../course/view.php?id='.$course->id.'">'.$course->shortname.'</a> ->';
39} else {
40 $navigation = '';
41}
42
43print_header( "$course->shortname: $strbooks",
44 $course->fullname,
45 "$navigation $strbooks",
46 '',
47 '',
48 true,
49 '',
50 navmenu($course)
51 );
52
53add_to_log($course->id, 'book', 'view all', 'index.php?id='.$course->id, '');
54
55/// Get all the appropriate data
56if (!$books = get_all_instances_in_course('book', $course)) {
57 notice('There are no books', '../../course/view.php?id='.$course->id);
58 die;
59}
60
61/// Print the list of instances
62$strname = get_string('name');
63$strweek = get_string('week');
64$strtopic = get_string('topic');
65$strsummary = get_string('summary');
66$strchapters = get_string('chapterscount', 'book');
67
68if ($course->format == 'weeks') {
69 $table->head = array ($strweek, $strname, $strsummary, $strchapters);
70 $table->align = array ('center', 'left', 'left', 'center');
71} else if ($course->format == 'topics') {
72 $table->head = array ($strtopic, $strname, $strsummary, $strchapters);
73 $table->align = array ('center', 'left', 'left', 'center');
74} else {
75 $table->head = array ($strname, $strsummary, $strchapters);
76 $table->align = array ('left', 'left', 'left');
77}
78
79$currentsection = '';
80foreach ($books as $book) {
81 $nocleanoption = new object();
82 $nocleanoption->noclean = true;
83 $book->summary = format_text($book->summary, FORMAT_HTML, $nocleanoption, $course->id);
84 $book->summary = '<span style="font-size:x-small;">'.$book->summary.'</span>';
85
86 if (!$book->visible) {
87 //Show dimmed if the mod is hidden
88 $link = '<a class="dimmed" href="view.php?id='.$book->coursemodule.'">'.$book->name.'</a>';
89 } else {
90 //Show normal if the mod is visible
91 $link = '<a href="view.php?id='.$book->coursemodule.'">'.$book->name.'</a>';
92 }
93
94 $count = count_records('book_chapters', 'bookid', $book->id, 'hidden', '0');
95
96 if ($course->format == 'weeks' or $course->format == 'topics') {
97 $printsection = '';
98 if ($book->section !== $currentsection) {
99 if ($book->section) {
100 $printsection = $book->section;
101 }
102 if ($currentsection !== '') {
103 $table->data[] = 'hr';
104 }
105 $currentsection = $book->section;
106 }
107 $table->data[] = array ($printsection, $link, $book->summary, $count);
108 } else {
109 $table->data[] = array ($link, $book->summary, $count);
110 }
111}
112
113echo '<br />';
114print_table($table);
115
116print_footer($course);
117
118?>