fixed log action inserts
[moodle.git] / show.php
CommitLineData
02039379
PS
1<?PHP // $Id: show.php,v 1.1 2006/03/12 18:39:59 skodak Exp $
2
3require('teacheraccess.php'); //page only for teachers
4
5///switch hidden state
6$chapter->hidden = $chapter->hidden ? 0 : 1;
7
8///add slashes to all text fields
9$chapter->content = addslashes($chapter->content);
10$chapter->title = addslashes($chapter->title);
11$chapter->importsrc = addslashes($chapter->importsrc);
12if (!update_record('book_chapters', $chapter)) {
13 error('Could not update your book');
14}
15
16///change visibility of subchapters too
17if (!$chapter->subchapter) {
18 $chapters = get_records('book_chapters', 'bookid', $book->id, 'pagenum', 'id, subchapter, hidden');
19 $found = 0;
20 foreach($chapters as $ch) {
21 if ($ch->id === $chapter->id) {
22 $found = 1;
23 } else if ($found and $ch->subchapter) {
24 $ch->hidden = $chapter->hidden;
25 update_record('book_chapters', $ch);
26 } else if ($found) {
27 break;
28 }
29 }
30}
31
32add_to_log($course->id, 'course', 'update mod', '../mod/book/view.php?id='.$cm->id, 'book '.$book->id);
33add_to_log($course->id, 'book', 'update', 'view.php?id='.$cm->id, $book->id, $cm->id);
34book_check_structure($book->id);
35redirect('view.php?id='.$cm->id.'&chapterid='.$chapter->id);
36die;
37
38?>