示例#1
0
require_once dirname(__FILE__) . '/../config.php';
require_once $CFG->dirroot . '/course/request_form.php';
/// Where we came from. Used in a number of redirects.
$returnurl = $CFG->wwwroot . '/course/index.php';
/// Check permissions.
require_login();
if (isguestuser()) {
    print_error('guestsarenotallowed', '', $returnurl);
}
if (empty($CFG->enablecourserequests)) {
    print_error('courserequestdisabled', '', $returnurl);
}
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/course:request', $systemcontext);
/// Set up the form.
$requestform = new course_request_form($CFG->wwwroot . '/course/request.php');
$strtitle = get_string('courserequest');
/// Standard form processing if statement.
if ($requestform->is_cancelled()) {
    redirect($returnurl);
} else {
    if ($data = $requestform->get_data()) {
        print_header($strtitle, $strtitle, build_navigation($strtitle), $requestform->focus());
        print_heading($strtitle);
        /// Record the request.
        $data->requester = $USER->id;
        if (!insert_record('course_request', $data)) {
            print_error('errorsavingrequest', '', $returnurl);
        }
        /// Notify the admin if required.
        if ($CFG->courserequestnotify) {
示例#2
0
}
$PAGE->set_url($url);
// Check permissions.
require_login(null, false);
if (isguestuser()) {
    print_error('guestsarenotallowed', '', $returnurl);
}
if (empty($CFG->enablecourserequests)) {
    print_error('courserequestdisabled', '', $returnurl);
}
$context = context_system::instance();
$PAGE->set_context($context);
require_capability('moodle/course:request', $context);
// Set up the form.
$data = course_request::prepare();
$requestform = new course_request_form($url, compact('editoroptions'));
$requestform->set_data($data);
$strtitle = get_string('courserequest');
$PAGE->set_title($strtitle);
$PAGE->set_heading($strtitle);
// Standard form processing if statement.
if ($requestform->is_cancelled()) {
    redirect($returnurl);
} else {
    if ($data = $requestform->get_data()) {
        $request = course_request::create($data);
        // And redirect back to the course listing.
        notice(get_string('courserequestsuccess'), $returnurl);
    }
}
$PAGE->navbar->add($strtitle);
示例#3
0
文件: request.php 项目: r007/PMoodle
<?php

// $Id$
/// this allows a student to request a course be created for them.
require_once '../config.php';
require_once 'request_form.php';
require_login();
if (isguest()) {
    error("No guests here!");
}
if (empty($CFG->enablecourserequests)) {
    print_error('courserequestdisabled');
}
$requestform = new course_request_form();
$strtitle = get_string('courserequest');
$navlinks = array();
$navlinks[] = array('name' => $strtitle, 'link' => null, 'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header($strtitle, $strtitle, $navigation, $requestform->focus());
print_simple_box_start('center');
print_string('courserequestintro');
print_simple_box_end();
if ($requestform->is_cancelled()) {
    redirect($CFG->wwwroot);
} elseif ($data = $requestform->get_data()) {
    $data->requester = $USER->id;
    if (insert_record('course_request', $data)) {
        notice(get_string('courserequestsuccess'));
    } else {
        notice(get_string('courserequestfailed'));
    }