1
<?php // $Id: request.php,v 1.12.2.1 2007/03/19 03:00:54 moodler Exp $
3
/// this allows a student to request a course be created for them.
5
require_once('../config.php');
6
require_once('request_form.php');
1
<?php // $Id: request.php,v 1.14.2.3 2009/01/08 07:05:32 tjhunt Exp $
3
///////////////////////////////////////////////////////////////////////////
5
// NOTICE OF COPYRIGHT //
7
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
8
// http://moodle.org //
10
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
12
// This program is free software; you can redistribute it and/or modify //
13
// it under the terms of the GNU General Public License as published by //
14
// the Free Software Foundation; either version 2 of the License, or //
15
// (at your option) any later version. //
17
// This program is distributed in the hope that it will be useful, //
18
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
20
// GNU General Public License for more details: //
22
// http://www.gnu.org/copyleft/gpl.html //
24
///////////////////////////////////////////////////////////////////////////
27
* Allows a user to request a course be created for them.
29
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
33
require_once(dirname(__FILE__) . '/../config.php');
34
require_once($CFG->dirroot . '/course/request_form.php');
36
/// Where we came from. Used in a number of redirects.
37
$returnurl = $CFG->wwwroot . '/course/index.php';
39
/// Check permissions.
11
error("No guests here!");
42
print_error('guestsarenotallowed', '', $returnurl);
14
44
if (empty($CFG->enablecourserequests)) {
15
print_error('courserequestdisabled');
45
print_error('courserequestdisabled', '', $returnurl);
47
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
48
require_capability('moodle/course:request', $systemcontext);
18
$requestform = new course_request_form();
51
$requestform = new course_request_form($CFG->wwwroot . '/course/request.php');
20
53
$strtitle = get_string('courserequest');
21
print_header($strtitle, $strtitle, $strtitle, $requestform->focus());
23
print_simple_box_start('center');
24
print_string('courserequestintro');
25
print_simple_box_end();
55
/// Standard form processing if statement.
28
56
if ($requestform->is_cancelled()){
30
redirect($CFG->wwwroot);
32
}elseif ($data = $requestform->get_data()) {
59
} else if ($data = $requestform->get_data()) {
60
print_header($strtitle, $strtitle, build_navigation($strtitle), $requestform->focus());
61
print_heading($strtitle);
63
/// Record the request.
33
64
$data->requester = $USER->id;
35
if (insert_record('course_request', $data)) {
36
notice(get_string('courserequestsuccess'));
38
notice(get_string('courserequestfailed'));
43
$requestform->display();
65
if (!insert_record('course_request', $data)) {
66
print_error('errorsavingrequest', '', $returnurl);
69
/// Notify the admin if required.
70
if ($CFG->courserequestnotify) {
71
$users = get_users_from_config($CFG->courserequestnotify, 'moodle/site:approvecourse');
72
foreach ($users as $user) {
73
$subject = get_string('courserequest');
75
$a->link = "$CFG->wwwroot/course/pending.php";
76
$a->user = fullname($USER);
77
$messagetext = get_string('courserequestnotifyemail', 'admin', $a);
78
email_to_user($user, $USER, $subject, $messagetext);
82
/// and redirect back to the course listing.
83
notice(get_string('courserequestsuccess'), $returnurl);
86
/// Show the request form.
87
print_header($strtitle, $strtitle, build_navigation($strtitle), $requestform->focus());
88
print_heading($strtitle);
89
$requestform->display();
b'\\ No newline at end of file'