From 351262b19208e5772b138f00e49f882f538498bd Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Thu, 12 Mar 2020 01:34:04 +1100 Subject: [PATCH 1/6] MDL-68148 core: remove cellspacing The cellspacing attribute of is not supported in HTML5. So the removed line did not have any effect since ages ago. --- lib/tablelib.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/tablelib.php b/lib/tablelib.php index 81a944a308e..067f9869f5c 100644 --- a/lib/tablelib.php +++ b/lib/tablelib.php @@ -1523,7 +1523,6 @@ class table_sql extends flexible_table { function __construct($uniqueid) { parent::__construct($uniqueid); // some sensible defaults - $this->set_attribute('cellspacing', '0'); $this->set_attribute('class', 'generaltable generalbox'); } From cabbb145dd273dd129b5908bacd9e1ffec50e773 Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Thu, 12 Mar 2020 01:50:40 +1100 Subject: [PATCH 2/6] MDL-68148 output: type attribute is unnecessary for javascript resources --- lib/outputcomponents.php | 6 ++---- lib/outputrequirementslib.php | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php index 505e04d4d85..fa9a76f5ed5 100644 --- a/lib/outputcomponents.php +++ b/lib/outputcomponents.php @@ -2089,12 +2089,10 @@ class html_writer { */ public static function script($jscode, $url=null) { if ($jscode) { - $attributes = array('type'=>'text/javascript'); - return self::tag('script', "\n//\n", $attributes) . "\n"; + return self::tag('script', "\n//\n") . "\n"; } else if ($url) { - $attributes = array('type'=>'text/javascript', 'src'=>$url); - return self::tag('script', '', $attributes) . "\n"; + return self::tag('script', '', ['src' => $url]) . "\n"; } else { return ''; diff --git a/lib/outputrequirementslib.php b/lib/outputrequirementslib.php index 3eb24e2b680..89bca869e3a 100644 --- a/lib/outputrequirementslib.php +++ b/lib/outputrequirementslib.php @@ -1467,14 +1467,14 @@ class page_requirements_manager { ); if ($this->yui3loader->combine) { - return ''; } else { $code = ''; foreach ($baserollups as $rollup) { - $code .= ''; + $code .= ''; } return $code; } From 5dfebd739faf55b05a4b8bd42305b0117ea60f91 Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Thu, 12 Mar 2020 04:31:16 +1100 Subject: [PATCH 3/6] MDL-68148 core_user: set the fullname column as the header column ref: https://www.w3.org/WAI/tutorials/tables/ --- user/classes/participants_table.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/user/classes/participants_table.php b/user/classes/participants_table.php index 0224f52c82c..5074d1d3eda 100644 --- a/user/classes/participants_table.php +++ b/user/classes/participants_table.php @@ -220,6 +220,9 @@ class participants_table extends \table_sql { $this->define_columns($columns); $this->define_headers($headers); + // The name column is a header. + $this->define_header_column('fullname'); + // Make this table sorted by last name by default. $this->sortable(true, 'lastname'); From b77c5e78dc86c75ac2d386d7359edf8902a4a740 Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Thu, 12 Mar 2020 00:55:20 +1100 Subject: [PATCH 4/6] MDL-68148 core_user: avoid multiple enrol buttons with the same id --- enrol/manual/lib.php | 10 +++++++--- user/index.php | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/enrol/manual/lib.php b/enrol/manual/lib.php index 24e312260ad..2e052760c56 100644 --- a/enrol/manual/lib.php +++ b/enrol/manual/lib.php @@ -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; } diff --git a/user/index.php b/user/index.php index 6821dd4de77..fb966706e14 100644 --- a/user/index.php +++ b/user/index.php @@ -360,6 +360,8 @@ echo ''; // Userlist. $enrolrenderer = $PAGE->get_renderer('core_enrol'); echo '
'; +// 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); } From 94a55738ad9f74c33f4eb917a1f1cd048df0691b Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Tue, 17 Mar 2020 09:34:47 +1100 Subject: [PATCH 5/6] MDL-68148 user: fixed stray end tag (input) --- user/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user/index.php b/user/index.php index fb966706e14..6ca32cf4219 100644 --- a/user/index.php +++ b/user/index.php @@ -278,7 +278,7 @@ if ($bulkoperations) { if ($participanttable->get_page_size() < $participanttable->totalrows) { // Select all users, refresh page showing all users and mark them all selected. $label = get_string('selectalluserswithcount', 'moodle', $participanttable->totalrows); - echo html_writer::tag('input', "", array('type' => 'button', 'id' => 'checkall', 'class' => 'btn btn-secondary', + echo html_writer::empty_tag('input', array('type' => 'button', 'id' => 'checkall', 'class' => 'btn btn-secondary', 'value' => $label, 'data-showallink' => $showalllink)); } echo html_writer::end_tag('div'); From c332400ba6add1bf7d34e26668cace4b0732ecf2 Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Wed, 8 Apr 2020 11:32:36 +1000 Subject: [PATCH 6/6] MDL-68148 user: remove the noscript tag The submit button remains deactive if js is disabled. So having a noscript tag to output a submit button here does not make sense. --- user/index.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/user/index.php b/user/index.php index 6ca32cf4219..b8b07c14923 100644 --- a/user/index.php +++ b/user/index.php @@ -338,14 +338,12 @@ if ($bulkoperations) { 'data-toggle' => 'action', 'disabled' => empty($selectall) ); - echo html_writer::tag('div', html_writer::tag('label', get_string("withselectedusers"), - array('for' => 'formactionid', 'class' => 'col-form-label d-inline')) . - html_writer::select($displaylist, 'formaction', '', array('' => 'choosedots'), $selectactionparams)); + $label = html_writer::tag('label', get_string("withselectedusers"), + ['for' => 'formactionid', 'class' => 'col-form-label d-inline']); + $select = html_writer::select($displaylist, 'formaction', '', ['' => 'choosedots'], $selectactionparams); + echo html_writer::tag('div', $label . $select); - echo ''; - echo ''; + echo ''; echo '
'; echo '';