~ubuntu-branches/ubuntu/jaunty/moodle/jaunty

« back to all changes in this revision

Viewing changes to course/request.php

  • Committer: Bazaar Package Importer
  • Author(s): Jordan Mantha, Matt Oquist
  • Date: 2009-02-25 15:16:22 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20090225151622-0ekt1liwhv2obfza
Tags: 1.9.4.dfsg-0ubuntu1
* Merge with Debian git (Closes LP: #322961, #239481, #334611):
  - use Ubuntu's smarty lib directory for linking
  - use internal yui library 
  - add update-notifier support back in

[Matt Oquist]
  * renamed prerm script
  * significantly rewrote postinst and other maintainer scripts to improve
    user experience and package maintainability
    (Closes LP: #225662, #325450, #327843, #303078, #234609)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php  // $Id: request.php,v 1.12.2.1 2007/03/19 03:00:54 moodler Exp $
2
 
 
3
 
    /// this allows a student to request a course be created for them.
4
 
 
5
 
    require_once('../config.php');
6
 
    require_once('request_form.php');
7
 
 
 
1
<?php  // $Id: request.php,v 1.14.2.3 2009/01/08 07:05:32 tjhunt Exp $
 
2
 
 
3
///////////////////////////////////////////////////////////////////////////
 
4
//                                                                       //
 
5
// NOTICE OF COPYRIGHT                                                   //
 
6
//                                                                       //
 
7
// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
 
8
//          http://moodle.org                                            //
 
9
//                                                                       //
 
10
// Copyright (C) 1999 onwards Martin Dougiamas  http://dougiamas.com     //
 
11
//                                                                       //
 
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.                                   //
 
16
//                                                                       //
 
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:                          //
 
21
//                                                                       //
 
22
//          http://www.gnu.org/copyleft/gpl.html                         //
 
23
//                                                                       //
 
24
///////////////////////////////////////////////////////////////////////////
 
25
 
 
26
/**
 
27
 * Allows a user to request a course be created for them.
 
28
 *
 
29
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 
30
 * @package course
 
31
 *//** */
 
32
 
 
33
    require_once(dirname(__FILE__) . '/../config.php');
 
34
    require_once($CFG->dirroot . '/course/request_form.php');
 
35
 
 
36
/// Where we came from. Used in a number of redirects.
 
37
    $returnurl = $CFG->wwwroot . '/course/index.php';
 
38
 
 
39
/// Check permissions.
8
40
    require_login();
9
 
 
10
 
    if (isguest()) {
11
 
        error("No guests here!");
 
41
    if (isguestuser()) {
 
42
        print_error('guestsarenotallowed', '', $returnurl);
12
43
    }
13
 
 
14
44
    if (empty($CFG->enablecourserequests)) {
15
 
        print_error('courserequestdisabled');
 
45
        print_error('courserequestdisabled', '', $returnurl);
16
46
    }
 
47
    $systemcontext = get_context_instance(CONTEXT_SYSTEM);
 
48
    require_capability('moodle/course:request', $systemcontext);
17
49
 
18
 
    $requestform = new course_request_form();
 
50
/// Set up the form.
 
51
    $requestform = new course_request_form($CFG->wwwroot . '/course/request.php');
19
52
 
20
53
    $strtitle = get_string('courserequest');
21
 
    print_header($strtitle, $strtitle, $strtitle, $requestform->focus());
22
 
 
23
 
    print_simple_box_start('center');
24
 
    print_string('courserequestintro');
25
 
    print_simple_box_end();
26
 
 
27
 
 
 
54
 
 
55
/// Standard form processing if statement.
28
56
    if ($requestform->is_cancelled()){
29
 
 
30
 
        redirect($CFG->wwwroot);
31
 
 
32
 
    }elseif ($data = $requestform->get_data()) {
 
57
        redirect($returnurl);
 
58
 
 
59
    } else if ($data = $requestform->get_data()) {
 
60
        print_header($strtitle, $strtitle, build_navigation($strtitle), $requestform->focus());
 
61
        print_heading($strtitle);
 
62
 
 
63
    /// Record the request.
33
64
        $data->requester = $USER->id;
34
 
 
35
 
        if (insert_record('course_request', $data)) {
36
 
            notice(get_string('courserequestsuccess'));
37
 
        } else {
38
 
            notice(get_string('courserequestfailed'));
39
 
        }
40
 
 
41
 
    } else {
42
 
 
43
 
        $requestform->display();
 
65
        if (!insert_record('course_request', $data)) {
 
66
            print_error('errorsavingrequest', '', $returnurl);
 
67
        }
 
68
 
 
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');
 
74
                $a = new object();
 
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);
 
79
            }
 
80
        }
 
81
 
 
82
    /// and redirect back to the course listing.
 
83
        notice(get_string('courserequestsuccess'), $returnurl);
44
84
    }
45
85
 
 
86
/// Show the request form.
 
87
    print_header($strtitle, $strtitle, build_navigation($strtitle), $requestform->focus());
 
88
    print_heading($strtitle);
 
89
    $requestform->display();
46
90
    print_footer();
47
91
 
48
 
?>
 
92
?>
 
 
b'\\ No newline at end of file'