[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/course/ -> request.php (source)

   1  <?php
   2  
   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.
  14  //
  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/>.
  17  
  18  /**
  19   * Allows a user to request a course be created for them.
  20   *
  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
  24   */
  25  
  26  require_once(__DIR__ . '/../config.php');
  27  require_once($CFG->dirroot . '/course/lib.php');
  28  require_once($CFG->dirroot . '/course/request_form.php');
  29  
  30  // Where we came from. Used in a number of redirects.
  31  $url = new moodle_url('/course/request.php');
  32  $return = optional_param('return', null, PARAM_ALPHANUMEXT);
  33  if ($return === 'management') {
  34      $url->param('return', $return);
  35      $returnurl = new moodle_url('/course/management.php', array('categoryid' => $CFG->defaultrequestcategory));
  36  } else {
  37      $returnurl = new moodle_url('/course/index.php');
  38  }
  39  
  40  $PAGE->set_url($url);
  41  
  42  // Check permissions.
  43  require_login(null, false);
  44  if (isguestuser()) {
  45      print_error('guestsarenotallowed', '', $returnurl);
  46  }
  47  if (empty($CFG->enablecourserequests)) {
  48      print_error('courserequestdisabled', '', $returnurl);
  49  }
  50  $context = context_system::instance();
  51  $PAGE->set_context($context);
  52  require_capability('moodle/course:request', $context);
  53  
  54  // Set up the form.
  55  $data = course_request::prepare();
  56  $requestform = new course_request_form($url, compact('editoroptions'));
  57  $requestform->set_data($data);
  58  
  59  $strtitle = get_string('courserequest');
  60  $PAGE->set_title($strtitle);
  61  $PAGE->set_heading($strtitle);
  62  
  63  // Standard form processing if statement.
  64  if ($requestform->is_cancelled()){
  65      redirect($returnurl);
  66  
  67  } else if ($data = $requestform->get_data()) {
  68      $request = course_request::create($data);
  69  
  70      // And redirect back to the course listing.
  71      notice(get_string('courserequestsuccess'), $returnurl);
  72  }
  73  
  74  $PAGE->navbar->add($strtitle);
  75  echo $OUTPUT->header();
  76  echo $OUTPUT->heading($strtitle);
  77  // Show the request form.
  78  $requestform->display();
  79  echo $OUTPUT->footer();


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1