MDL-50015 mod_imscp: New WS mod_imscp_view_imscp
[moodle.git] / mod / book / tool / exportimscp / index.php
CommitLineData
8d623d14 1<?php
b15ef0b0 2// This file is part of Moodle - http://moodle.org/
f3d91d52
PS
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 *
3542c4f4 20 * @package booktool_exportimscp
f3d91d52 21 * @copyright 2001-3001 Antonio Vicent {@link http://ludens.es}
3542c4f4 22 * @copyright 2001-3001 Eloy Lafuente (stronk7) {@link http://stronk7.com}
f3d91d52
PS
23 * @copyright 2011 Petr Skoda {@link http://skodak.org}
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 */
4bc75ecc 26
f3d91d52
PS
27require(dirname(__FILE__).'/../../../../config.php');
28require_once(dirname(__FILE__).'/locallib.php');
e355240d 29require_once($CFG->dirroot.'/mod/book/locallib.php');
c6d2eda2 30require_once($CFG->libdir.'/filelib.php');
fc9479b8 31
dab784a3 32$id = required_param('id', PARAM_INT); // Course Module ID
fc9479b8 33
f3d91d52 34$cm = get_coursemodule_from_id('book', $id, 0, false, MUST_EXIST);
74df2951 35$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
f3d91d52 36$book = $DB->get_record('book', array('id'=>$cm->instance), '*', MUST_EXIST);
9d2fe179 37
f3d91d52 38$PAGE->set_url('/mod/book/tool/exportimscp/index.php', array('id'=>$id));
fc9479b8 39
f3d91d52 40require_login($course, false, $cm);
c6d2eda2 41
1fc9e895 42$context = context_module::instance($cm->id);
c6d2eda2 43require_capability('mod/book:read', $context);
f3d91d52 44require_capability('booktool/exportimscp:export', $context);
fc9479b8 45
ef2a9ece 46\booktool_exportimscp\event\book_exported::create_from_book($book, $context)->trigger();
fc9479b8 47
f3d91d52 48$file = booktool_exportimscp_build_package($book, $context);
fc9479b8 49
a1448fc0 50send_stored_file($file, 10, 0, true, array('filename' => clean_filename($book->name).'.zip'));