|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00026 require_once(dirname(__FILE__) . '/../config.php'); 00027 require_once($CFG->dirroot . '/course/lib.php'); 00028 require_once($CFG->dirroot . '/course/request_form.php'); 00029 00030 $PAGE->set_url('/course/request.php'); 00031 00033 $returnurl = $CFG->wwwroot . '/course/index.php'; 00034 00035 00037 require_login(); 00038 if (isguestuser()) { 00039 print_error('guestsarenotallowed', '', $returnurl); 00040 } 00041 if (empty($CFG->enablecourserequests)) { 00042 print_error('courserequestdisabled', '', $returnurl); 00043 } 00044 $context = get_context_instance(CONTEXT_SYSTEM); 00045 $PAGE->set_context($context); 00046 require_capability('moodle/course:request', $context); 00047 00049 $data = course_request::prepare(); 00050 $requestform = new course_request_form($CFG->wwwroot . '/course/request.php', compact('editoroptions')); 00051 $requestform->set_data($data); 00052 00053 $strtitle = get_string('courserequest'); 00054 $PAGE->set_title($strtitle); 00055 $PAGE->set_heading($strtitle); 00056 00058 if ($requestform->is_cancelled()){ 00059 redirect($returnurl); 00060 00061 } else if ($data = $requestform->get_data()) { 00062 $request = course_request::create($data); 00063 00064 // and redirect back to the course listing. 00065 notice(get_string('courserequestsuccess'), $returnurl); 00066 } 00067 00068 $PAGE->navbar->add($strtitle); 00069 echo $OUTPUT->header(); 00070 echo $OUTPUT->heading($strtitle); 00071 // Show the request form. 00072 $requestform->display(); 00073 echo $OUTPUT->footer();