[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * User enrolment edit script. 19 * 20 * This page allows the current user to edit a user enrolment. 21 * It is not compatible with the frontpage. 22 * 23 * NOTE: plugins are free to implement own edit scripts with extra logic. 24 * 25 * @package core_enrol 26 * @copyright 2011 Sam Hemelryk 27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 28 */ 29 30 require('../config.php'); 31 require_once("$CFG->dirroot/enrol/locallib.php"); // Required for the course enrolment manager. 32 require_once("$CFG->dirroot/enrol/renderer.php"); // Required for the course enrolment users table. 33 require_once("$CFG->dirroot/enrol/editenrolment_form.php"); // Forms for this page. 34 35 $ueid = required_param('ue', PARAM_INT); 36 $filter = optional_param('ifilter', 0, PARAM_INT); // Table filter for return url. 37 38 $ue = $DB->get_record('user_enrolments', array('id' => $ueid), '*', MUST_EXIST); 39 $user = $DB->get_record('user', array('id'=>$ue->userid), '*', MUST_EXIST); 40 $instance = $DB->get_record('enrol', array('id'=>$ue->enrolid), '*', MUST_EXIST); 41 $course = $DB->get_record('course', array('id'=>$instance->courseid), '*', MUST_EXIST); 42 43 // The URL of the enrolled users page for the course. 44 $usersurl = new moodle_url('/enrol/users.php', array('id' => $course->id)); 45 46 // Do not allow any changes if plugin disabled, not available or not suitable. 47 if (!$plugin = enrol_get_plugin($instance->enrol)) { 48 redirect($usersurl); 49 } 50 if (!$plugin->allow_manage($instance)) { 51 redirect($usersurl); 52 } 53 54 // Obviously. 55 require_login($course); 56 // The user must be able to manage enrolments within the course. 57 require_capability('enrol/'.$instance->enrol.':manage', context_course::instance($course->id, MUST_EXIST)); 58 59 // Get the enrolment manager for this course. 60 $manager = new course_enrolment_manager($PAGE, $course, $filter); 61 // Get an enrolment users table object. Doing this will automatically retrieve the the URL params 62 // relating to table the user was viewing before coming here, and allows us to return the user to the 63 // exact page of the users screen they can from. 64 $table = new course_enrolment_users_table($manager, $PAGE); 65 66 // The URl to return the user too after this screen. 67 $returnurl = new moodle_url($usersurl, $manager->get_url_params()+$table->get_url_params()); 68 // The URL of this page. 69 $url = new moodle_url('/enrol/editenrolment.php', $returnurl->params()); 70 71 $PAGE->set_url($url); 72 $PAGE->set_pagelayout('admin'); 73 navigation_node::override_active_url($usersurl); 74 75 // Get the enrolment edit form. 76 $mform = new enrol_user_enrolment_form($url, array('user'=>$user, 'course'=>$course, 'ue'=>$ue)); 77 $mform->set_data($PAGE->url->params()); 78 79 if ($mform->is_cancelled()) { 80 redirect($returnurl); 81 82 } else if ($data = $mform->get_data()) { 83 if ($manager->edit_enrolment($ue, $data)) { 84 redirect($returnurl); 85 } 86 } 87 88 $fullname = fullname($user); 89 $title = get_string('editenrolment', 'core_enrol'); 90 91 $PAGE->set_title($title); 92 $PAGE->set_heading($title); 93 $PAGE->navbar->add($title); 94 $PAGE->navbar->add($fullname); 95 96 echo $OUTPUT->header(); 97 echo $OUTPUT->heading($fullname); 98 $mform->display(); 99 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |