mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-59369 enrol: Cleanup enrol pages
* Cleanup edit enrolment form. * Improve edit enrol form validation error message. * Add modal custom data flag to edit enrolment form to hide action buttons if loaded via fragment. * Point return URLs of edit enrolment and user unenrol pages back to participants page.
This commit is contained in:
parent
5719f2ca50
commit
ea758b85e4
@ -41,7 +41,7 @@ $instance = $DB->get_record('enrol', array('id'=>$ue->enrolid), '*', MUST_EXIST)
|
||||
$course = $DB->get_record('course', array('id'=>$instance->courseid), '*', MUST_EXIST);
|
||||
|
||||
// The URL of the enrolled users page for the course.
|
||||
$usersurl = new moodle_url('/enrol/users.php', array('id' => $course->id));
|
||||
$usersurl = new moodle_url('/user/index.php', array('id' => $course->id));
|
||||
|
||||
// Do not allow any changes if plugin disabled, not available or not suitable.
|
||||
if (!$plugin = enrol_get_plugin($instance->enrol)) {
|
||||
|
@ -28,15 +28,10 @@ require_once("$CFG->libdir/formslib.php");
|
||||
|
||||
class enrol_user_enrolment_form extends moodleform {
|
||||
function definition() {
|
||||
global $CFG, $DB;
|
||||
|
||||
$mform = $this->_form;
|
||||
|
||||
$user = $this->_customdata['user'];
|
||||
$course = $this->_customdata['course'];
|
||||
$ue = $this->_customdata['ue'];
|
||||
|
||||
$mform->addElement('header','general', '');
|
||||
$ue = $this->_customdata['ue'];
|
||||
$modal = !empty($this->_customdata['modal']);
|
||||
|
||||
$options = array(ENROL_USER_ACTIVE => get_string('participationactive', 'enrol'),
|
||||
ENROL_USER_SUSPENDED => get_string('participationsuspended', 'enrol'));
|
||||
@ -56,7 +51,10 @@ class enrol_user_enrolment_form extends moodleform {
|
||||
$mform->addElement('hidden', 'ifilter');
|
||||
$mform->setType('ifilter', PARAM_ALPHA);
|
||||
|
||||
$this->add_action_buttons();
|
||||
// Show action buttons if this is not being rendered as a fragment.
|
||||
if (!$modal) {
|
||||
$this->add_action_buttons();
|
||||
}
|
||||
|
||||
$this->set_data(array(
|
||||
'ue' => $ue->id,
|
||||
@ -71,8 +69,7 @@ class enrol_user_enrolment_form extends moodleform {
|
||||
|
||||
if (!empty($data['timestart']) and !empty($data['timeend'])) {
|
||||
if ($data['timestart'] >= $data['timeend']) {
|
||||
$errors['timestart'] = get_string('error');
|
||||
$errors['timeend'] = get_string('error');
|
||||
$errors['timeend'] = get_string('enroltimeendinvalid', 'enrol');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,8 +58,7 @@ if (!$plugin->allow_unenrol_user($instance, $ue) or !has_capability("enrol/$inst
|
||||
$manager = new course_enrolment_manager($PAGE, $course, $filter);
|
||||
$table = new course_enrolment_users_table($manager, $PAGE);
|
||||
|
||||
$returnurl = new moodle_url('/enrol/users.php', array('id' => $course->id)+$manager->get_url_params()+$table->get_url_params());
|
||||
$usersurl = new moodle_url('/enrol/users.php', array('id' => $course->id));
|
||||
$usersurl = new moodle_url('/user/index.php', array('id' => $course->id));
|
||||
|
||||
$PAGE->set_pagelayout('admin');
|
||||
navigation_node::override_active_url($usersurl);
|
||||
@ -67,7 +66,7 @@ navigation_node::override_active_url($usersurl);
|
||||
// If the unenrolment has been confirmed and the sesskey is valid unenrol the user.
|
||||
if ($confirm && confirm_sesskey()) {
|
||||
$plugin->unenrol_user($instance, $ue->userid);
|
||||
redirect($returnurl);
|
||||
redirect($usersurl);
|
||||
}
|
||||
|
||||
$yesurl = new moodle_url($PAGE->url, array('confirm'=>1, 'sesskey'=>sesskey()));
|
||||
@ -82,5 +81,5 @@ $PAGE->navbar->add($fullname);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($fullname);
|
||||
echo $OUTPUT->confirm($message, $yesurl, $returnurl);
|
||||
echo $OUTPUT->confirm($message, $yesurl, $usersurl);
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -43,6 +43,7 @@ $string['deleteinstancenousersconfirm'] = 'You are about to delete the enrolment
|
||||
$string['disableinstanceconfirmself'] = 'Are you really sure you want to disable instance "{$a->name}" that gives you access to this course? It is possible that you will not be able to access this course if you continue.';
|
||||
$string['durationdays'] = '{$a} days';
|
||||
$string['editenrolment'] = 'Edit enrolment';
|
||||
$string['edituserenrolment'] = 'Edit {$a}\'s enrolment';
|
||||
$string['enrol'] = 'Enrol';
|
||||
$string['enrolcandidates'] = 'Not enrolled users';
|
||||
$string['enrolcandidatesmatching'] = 'Matching not enrolled users';
|
||||
@ -67,6 +68,7 @@ $string['enrolusers'] = 'Enrol users';
|
||||
$string['enrolxusers'] = 'Enrol {$a} users';
|
||||
$string['enroltimecreated'] = 'Enrolment created';
|
||||
$string['enroltimeend'] = 'Enrolment ends';
|
||||
$string['enroltimeendinvalid'] = 'Enrolment end date must be after the enrolment start date';
|
||||
$string['enroltimestart'] = 'Enrolment starts';
|
||||
$string['errajaxfailedenrol'] = 'Failed to enrol user';
|
||||
$string['errajaxsearch'] = 'Error when searching users';
|
||||
|
Loading…
x
Reference in New Issue
Block a user