Commit 7927cab1 authored by Petr Skoda's avatar Petr Skoda
Browse files

convert printing support to new booktool plugin

fixed #6

AMOS BEGIN
 MOV [pluginname,mod_book],[pluginname,booktool_print]
 MOV [printbook,mod_book],[printbook,booktool_print]
 MOV [printchapter,mod_book],[printchapter,booktool_print]
 MOV [printdate,mod_book],[printdate,booktool_print]
 MOV [printedby,mod_book],[printedby,booktool_print]
 MOV [book:print,mod_book],[print:print,booktool_print]
AMOS END
parent 3c6239ee
......@@ -68,19 +68,6 @@ $capabilities = array(
)
),
'mod/book:print' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => array(
'guest' => CAP_ALLOW,
'frontpage' => CAP_ALLOW,
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
)
),
'mod/book:exportimscp' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE
......
......@@ -29,5 +29,4 @@ $logs = array(
array('module'=>'book', 'action'=>'update', 'mtable'=>'book', 'field'=>'name'),
array('module'=>'book', 'action'=>'view', 'mtable'=>'book', 'field'=>'name'),
array('module'=>'book', 'action'=>'view all', 'mtable'=>'book', 'field'=>'name'),
array('module'=>'book', 'action'=>'print', 'mtable'=>'book', 'field'=>'name'),
);
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Book subplugin types declaration
*
* @package mod
* @subpackage book
* @copyright 2011 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$subplugins = array(
'booktool' => 'mod/book/tool',
);
<?php
// This file is part of Book plugin for Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Book module language strings
*
* @package mod
* @subpackage book
* @copyright 2004-2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
$string['modulename'] = 'Book';
$string['modulenameplural'] = 'Books';
......@@ -63,10 +88,6 @@ $string['confchapterdelete'] = 'Do you really want to delete this chapter?';
$string['confchapterdeleteall'] = 'Do you really want to delete this chapter and all its subchapters?';
$string['generateimscp'] = 'Generate IMS content package';
$string['printbook'] = 'Print book';
$string['printchapter'] = 'Print this chapter';
$string['printdate'] = 'Date';
$string['printedby'] = 'Printed by';
$string['top'] = 'top';
$string['navprev'] = 'Previous';
......@@ -88,7 +109,6 @@ $string['book:read'] = 'Read book';
$string['book:edit'] = 'Edit book chapters';
$string['book:viewhiddenchapters'] = 'View hidden book chapters';
$string['book:import'] = 'Import chapters';
$string['book:print'] = 'Print book';
$string['book:exportimscp'] = 'Export book as IMS content package';
$string['errorchapter'] = 'Error reading book chapter.';
\ No newline at end of file
......@@ -248,17 +248,14 @@ function book_extend_settings_navigation(settings_navigation $settingsnav, navig
return;
}
if (has_capability('mod/book:print', $PAGE->cm->context)) {
$url1 = new moodle_url('/mod/book/print.php', array('id'=>$params['id']));
$url2 = new moodle_url('/mod/book/print.php', array('id'=>$params['id'], 'chapterid'=>$params['chapterid']));
if ($CFG->version > 2011020900) {
$action = new action_link($url1, get_string('printbook', 'book'), new popup_action('click', $url1));
$booknode->add('', $action, navigation_node::TYPE_SETTING, null, null, new pix_icon('print_book', '', 'mod_book', array('class'=>'icon')));
$action = new action_link($url2, get_string('printchapter', 'book'), new popup_action('click', $url2));
$booknode->add('', $action, navigation_node::TYPE_SETTING, null, null, new pix_icon('print_chapter', '', 'mod_book', array('class'=>'icon')));
} else {
$booknode->add(get_string('printbook', 'mod_book'), $url1, navigation_node::TYPE_SETTING, null, null, new pix_icon('print_book', '', 'mod_book', array('class'=>'icon')));
$booknode->add(get_string('printchapter', 'mod_book'), $url2, navigation_node::TYPE_SETTING, null, null, new pix_icon('print_chapter', '', 'mod_book', array('class'=>'icon')));
$plugins = get_plugin_list('booktool');
foreach($plugins as $plugin=>$dir) {
if (file_exists("$dir/lib.php")) {
require_once("$dir/lib.php");
}
$function = 'booktool_'.$plugin.'_extend_settings_navigation';
if (function_exists($function)) {
$function($settingsnav, $booknode);
}
}
......
<?php
// This file is part of Book module for Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Book module capability definition
*
* @package booktool
* @subpackage print
* @copyright 2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$capabilities = array(
'booktool/print:print' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => array(
'guest' => CAP_ALLOW,
'frontpage' => CAP_ALLOW,
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
)
),
);
......@@ -17,13 +17,13 @@
/**
* Book printing
*
* @package mod
* @subpackage book
* @package booktool
* @subpackage print
* @copyright 2004-2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../../config.php');
require(dirname(__FILE__).'/../../../../config.php');
require_once($CFG->dirroot.'/mod/book/locallib.php');
$id = required_param('id', PARAM_INT); // Course Module ID
......@@ -41,7 +41,7 @@ require_course_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/book:read', $context);
require_capability('mod/book:print', $context);
require_capability('booktool/print:print', $context);
//check all variables
if ($chapterid) {
......@@ -79,7 +79,7 @@ if ($chapter) {
require_capability('mod/book:viewhiddenchapters', $context);
}
add_to_log($course->id, 'book', 'print', 'print.php?id='.$cm->id.'&chapterid='.$chapter->id, $book->id, $cm->id);
add_to_log($course->id, 'book', 'print', 'tool/print/index.php?id='.$cm->id.'&chapterid='.$chapter->id, $book->id, $cm->id);
/// page header
?>
......@@ -114,7 +114,7 @@ if ($chapter) {
echo '</body> </html>';
} else {
add_to_log($course->id, 'book', 'print', 'print.php?id='.$cm->id, $book->id, $cm->id);
add_to_log($course->id, 'book', 'print', 'tool/print/index.php?id='.$cm->id, $book->id, $cm->id);
$allchapters = $DB->get_records('book_chapters', array('bookid'=>$book->id), 'pagenum');
/// page header
......@@ -142,10 +142,10 @@ if ($chapter) {
<td><?php echo get_string('modulename', 'mod_book') ?>:</td>
<td><?php echo format_string($book->name, true, array('context'=>$context)) ?></td>
</tr><tr>
<td><?php echo get_string('printedby', 'mod_book') ?>:</td>
<td><?php echo get_string('printedby', 'booktool_print') ?>:</td>
<td><?php echo fullname($USER, true) ?></td>
</tr><tr>
<td><?php echo get_string('printdate','mod_book') ?>:</td>
<td><?php echo get_string('printdate','booktool_print') ?>:</td>
<td><?php echo userdate(time()) ?></td>
</tr>
</table></div>
......
<?php
// This file is part of Book plugin for Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Book module language strings
*
* @package booktool
* @subpackage print
* @copyright 2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
$string['pluginname'] = 'Book printing';
$string['printbook'] = 'Print book';
$string['printchapter'] = 'Print this chapter';
$string['printdate'] = 'Date';
$string['printedby'] = 'Printed by';
$string['print:print'] = 'Print book';
<?php
// This file is part of Book plugin for Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Print lib
*
* @package booktool
* @subpackage print
* @copyright 2004-2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
function booktool_print_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $booknode) {
global $USER, $PAGE, $CFG, $DB, $OUTPUT;
if ($PAGE->cm->modname !== 'book') {
return;
}
if (empty($PAGE->cm->context)) {
$PAGE->cm->context = get_context_instance(CONTEXT_MODULE, $PAGE->cm->instance);
}
$params = $PAGE->url->params();
if (empty($params['id']) or empty($params['chapterid'])) {
return;
}
if (has_capability('booktool/print:print', $PAGE->cm->context)) {
$url1 = new moodle_url('/mod/book/tool/print/index.php', array('id'=>$params['id']));
$url2 = new moodle_url('/mod/book/tool/print/index.php', array('id'=>$params['id'], 'chapterid'=>$params['chapterid']));
if ($CFG->version > 2011020900) {
$action = new action_link($url1, get_string('printbook', 'booktool_print'), new popup_action('click', $url1));
$booknode->add('', $action, navigation_node::TYPE_SETTING, null, null, new pix_icon('book', '', 'booktool_print', array('class'=>'icon')));
$action = new action_link($url2, get_string('printchapter', 'booktool_print'), new popup_action('click', $url2));
$booknode->add('', $action, navigation_node::TYPE_SETTING, null, null, new pix_icon('chapter', '', 'booktool_print', array('class'=>'icon')));
} else {
$booknode->add(get_string('printbook', 'booktool_print'), $url1, navigation_node::TYPE_SETTING, null, null, new pix_icon('print_book', '', 'booktool_print', array('class'=>'icon')));
$booknode->add(get_string('printchapter', 'booktool_print'), $url2, navigation_node::TYPE_SETTING, null, null, new pix_icon('print_chapter', '', 'booktool_print', array('class'=>'icon')));
}
}
}
\ No newline at end of file
<?php
// This file is part of Book plugin for Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Book print plugin version info
*
* @package booktool
* @subpackage print
* @copyright 2004-2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
$plugin->version = 2011090800; // The current plugin version (Date: YYYYMMDDXX)
$plugin->component = 'booktool_print'; // Full name of the plugin (used for diagnostics)
......@@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die;
$module->version = 2011032000; // The current module version (Date: YYYYMMDDXX)
$module->version = 2011032001; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2011070101; // Requires this Moodle version
$module->cron = 0; // Period for cron to check this module (secs)
$module->component = 'mod_book'; // Full name of the plugin (used for diagnostics)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment