MDL-33480 book print tool: display intro images properly
[moodle.git] / course / request.php
blob3e0e097b903808e8b1a0ab2aaf968149a779f943
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * Allows a user to request a course be created for them.
21 * @copyright 1999 Martin Dougiamas http://dougiamas.com
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 * @package course
26 require_once(dirname(__FILE__) . '/../config.php');
27 require_once($CFG->dirroot . '/course/lib.php');
28 require_once($CFG->dirroot . '/course/request_form.php');
30 $PAGE->set_url('/course/request.php');
32 /// Where we came from. Used in a number of redirects.
33 $returnurl = $CFG->wwwroot . '/course/index.php';
36 /// Check permissions.
37 require_login();
38 if (isguestuser()) {
39 print_error('guestsarenotallowed', '', $returnurl);
41 if (empty($CFG->enablecourserequests)) {
42 print_error('courserequestdisabled', '', $returnurl);
44 $context = get_context_instance(CONTEXT_SYSTEM);
45 $PAGE->set_context($context);
46 require_capability('moodle/course:request', $context);
48 /// Set up the form.
49 $data = course_request::prepare();
50 $requestform = new course_request_form($CFG->wwwroot . '/course/request.php', compact('editoroptions'));
51 $requestform->set_data($data);
53 $strtitle = get_string('courserequest');
54 $PAGE->set_title($strtitle);
55 $PAGE->set_heading($strtitle);
57 /// Standard form processing if statement.
58 if ($requestform->is_cancelled()){
59 redirect($returnurl);
61 } else if ($data = $requestform->get_data()) {
62 $request = course_request::create($data);
64 // and redirect back to the course listing.
65 notice(get_string('courserequestsuccess'), $returnurl);
68 $PAGE->navbar->add($strtitle);
69 echo $OUTPUT->header();
70 echo $OUTPUT->heading($strtitle);
71 // Show the request form.
72 $requestform->display();
73 echo $OUTPUT->footer();