See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Book printing 19 * 20 * @package booktool_print 21 * @copyright 2004-2011 Petr Skoda {@link http://skodak.org} 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 require(__DIR__.'/../../../../config.php'); 26 require_once (__DIR__.'/locallib.php'); 27 28 $id = required_param('id', PARAM_INT); // Course Module ID 29 $chapterid = optional_param('chapterid', 0, PARAM_INT); // Chapter ID 30 31 // ========================================================================= 32 // security checks START - teachers and students view 33 // ========================================================================= 34 35 $cm = get_coursemodule_from_id('book', $id, 0, false, MUST_EXIST); 36 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); 37 $book = $DB->get_record('book', array('id' => $cm->instance), '*', MUST_EXIST); 38 39 require_course_login($course, true, $cm); 40 41 $context = context_module::instance($cm->id); 42 require_capability('mod/book:read', $context); 43 require_capability('booktool/print:print', $context); 44 45 // Check all variables. 46 if ($chapterid) { 47 // Single chapter printing - only visible! 48 $chapter = $DB->get_record('book_chapters', array('id' => $chapterid, 'bookid' => $book->id), '*', 49 MUST_EXIST); 50 } else { 51 // Complete book. 52 $chapter = false; 53 } 54 55 $PAGE->set_url('/mod/book/print.php', array('id' => $id, 'chapterid' => $chapterid)); 56 57 $PAGE->activityheader->disable(); 58 $PAGE->set_pagelayout("embedded"); 59 60 unset($id); 61 unset($chapterid); 62 63 // Security checks END. 64 65 // read chapters 66 $chapters = book_preload_chapters($book); 67 68 $strbooks = get_string('modulenameplural', 'mod_book'); 69 $strbook = get_string('modulename', 'mod_book'); 70 $strtop = get_string('top', 'mod_book'); 71 72 // Page header. 73 $strtitle = format_string($book->name, true, array('context' => $context)); 74 $PAGE->set_title($strtitle); 75 $PAGE->set_heading($strtitle); 76 $PAGE->requires->css('/mod/book/tool/print/print.css'); 77 78 $renderer = $PAGE->get_renderer('booktool_print'); 79 80 // Begin page output. 81 echo $OUTPUT->header(); 82 83 if ($chapter) { 84 if ($chapter->hidden) { 85 require_capability('mod/book:viewhiddenchapters', $context); 86 } 87 \booktool_print\event\chapter_printed::create_from_chapter($book, $context, $chapter)->trigger(); 88 $page = new booktool_print\output\print_book_chapter_page($book, $cm, $chapter); 89 } else { 90 \booktool_print\event\book_printed::create_from_book($book, $context)->trigger(); 91 $page = new booktool_print\output\print_book_page($book, $cm); 92 } 93 94 echo $renderer->render($page); 95 96 // Finish page output. 97 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body