From 95dfd8e0deedbe8919acb3cd69b6fbcb395e7127 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Fri, 13 Dec 2019 22:33:51 +0100 Subject: [PATCH] MDL-64764 core_admin: allow to submit empty list of allowed roles. Co-authored-by: Paul Holden --- admin/roles/classes/define_role_table_advanced.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/admin/roles/classes/define_role_table_advanced.php b/admin/roles/classes/define_role_table_advanced.php index f4ab5625bb7..96c6fc89d02 100644 --- a/admin/roles/classes/define_role_table_advanced.php +++ b/admin/roles/classes/define_role_table_advanced.php @@ -157,19 +157,19 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi // Allowed roles. $allow = optional_param_array('allowassign', null, PARAM_INT); if (!is_null($allow)) { - $this->allowassign = $allow; + $this->allowassign = array_filter($allow); } $allow = optional_param_array('allowoverride', null, PARAM_INT); if (!is_null($allow)) { - $this->allowoverride = $allow; + $this->allowoverride = array_filter($allow); } $allow = optional_param_array('allowswitch', null, PARAM_INT); if (!is_null($allow)) { - $this->allowswitch = $allow; + $this->allowswitch = array_filter($allow); } $allow = optional_param_array('allowview', null, PARAM_INT); if (!is_null($allow)) { - $this->allowview = $allow; + $this->allowview = array_filter($allow); } // Now read the permissions for each capability. @@ -618,7 +618,9 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi if ($this->roleid == 0) { $options[-1] = get_string('thisnewrole', 'core_role'); } - return html_writer::select($options, 'allow'.$type.'[]', $selected, false, array('multiple' => 'multiple', + return + html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'allow'.$type.'[]', 'value' => "")) . + html_writer::select($options, 'allow'.$type.'[]', $selected, false, array('multiple' => 'multiple', 'size' => 10, 'class' => 'form-control')); } -- 2.43.0