Subtree merged git://github.com/skodak/moodle-mod_book.git (master branch) into mod...
[moodle.git] / mod / book / tool / exportimscp / index.php
CommitLineData
8d623d14 1<?php
f3d91d52
PS
2// This file is part of Book plugin for 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/>.
fc9479b8 16
f3d91d52
PS
17/**
18 * Book IMSCP export plugin
19 *
20 * @package booktool
21 * @subpackage exportimscp
22 * @copyright 2001-3001 Antonio Vicent {@link http://ludens.es}
23 * @copyright 2001-3001 Eloy Lafuente (stronk7) {@link http://contiento.com}
24 * @copyright 2011 Petr Skoda {@link http://skodak.org}
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 */
4bc75ecc 27
f3d91d52
PS
28require(dirname(__FILE__).'/../../../../config.php');
29require_once(dirname(__FILE__).'/locallib.php');
e355240d 30require_once($CFG->dirroot.'/mod/book/locallib.php');
c6d2eda2
PS
31require_once($CFG->dirroot.'/backup/lib.php');
32require_once($CFG->libdir.'/filelib.php');
fc9479b8 33
dab784a3 34$id = required_param('id', PARAM_INT); // Course Module ID
fc9479b8 35
f3d91d52
PS
36$cm = get_coursemodule_from_id('book', $id, 0, false, MUST_EXIST);
37$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
38$book = $DB->get_record('book', array('id'=>$cm->instance), '*', MUST_EXIST);
9d2fe179 39
f3d91d52 40$PAGE->set_url('/mod/book/tool/exportimscp/index.php', array('id'=>$id));
fc9479b8 41
f3d91d52 42require_login($course, false, $cm);
c6d2eda2 43
dab784a3 44$context = get_context_instance(CONTEXT_MODULE, $cm->id);
c6d2eda2 45require_capability('mod/book:read', $context);
f3d91d52 46require_capability('booktool/exportimscp:export', $context);
fc9479b8 47
fc9479b8
EL
48$strbooks = get_string('modulenameplural', 'book');
49$strbook = get_string('modulename', 'book');
50$strtop = get_string('top', 'book');
51
f3d91d52 52add_to_log($course->id, 'book', 'generateimscp', 'tool/generateimscp/index.php?id='.$cm->id, $book->id, $cm->id);
fc9479b8 53
f3d91d52 54$file = booktool_exportimscp_build_package($book, $context);
fc9479b8 55
f3d91d52 56send_stored_file($file, 10, 0, true, clean_filename($book->name).'.zip');