mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 07:56:06 +02:00
MDL-68148 core_user: avoid multiple enrol buttons with the same id
This commit is contained in:
parent
8a805e03a4
commit
3dec4c6ce3
@ -197,14 +197,14 @@ class enrol_manual_plugin extends enrol_plugin {
|
||||
global $CFG, $PAGE;
|
||||
require_once($CFG->dirroot.'/cohort/lib.php');
|
||||
|
||||
static $called = false;
|
||||
|
||||
$instance = null;
|
||||
$instances = array();
|
||||
foreach ($manager->get_enrolment_instances() as $tempinstance) {
|
||||
if ($tempinstance->enrol == 'manual') {
|
||||
if ($instance === null) {
|
||||
$instance = $tempinstance;
|
||||
}
|
||||
$instances[] = array('id' => $tempinstance->id, 'name' => $this->get_instance_name($tempinstance));
|
||||
}
|
||||
}
|
||||
if (empty($instance)) {
|
||||
@ -222,7 +222,11 @@ class enrol_manual_plugin extends enrol_plugin {
|
||||
$context = context_course::instance($instance->courseid);
|
||||
$arguments = array('contextid' => $context->id);
|
||||
|
||||
$PAGE->requires->js_call_amd('enrol_manual/quickenrolment', 'init', array($arguments));
|
||||
if (!$called) {
|
||||
$called = true;
|
||||
// Calling the following more than once will cause unexpected results.
|
||||
$PAGE->requires->js_call_amd('enrol_manual/quickenrolment', 'init', array($arguments));
|
||||
}
|
||||
|
||||
return $button;
|
||||
}
|
||||
|
@ -409,6 +409,8 @@ echo '</div>'; // Userlist.
|
||||
|
||||
$enrolrenderer = $PAGE->get_renderer('core_enrol');
|
||||
echo '<div class="float-right">';
|
||||
// Need to re-generate the buttons to avoid having elements with duplicate ids on the page.
|
||||
$enrolbuttons = $manager->get_manual_enrol_buttons();
|
||||
foreach ($enrolbuttons as $enrolbutton) {
|
||||
echo $enrolrenderer->render($enrolbutton);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user