-
Bug
-
Resolution: Fixed
-
Major
-
3.4.5, 3.4.6, 3.4.7, 3.5.2, 3.5.3, 3.5.4, 3.6, 3.6.1, 3.6.2
-
MOODLE_34_STABLE, MOODLE_35_STABLE, MOODLE_36_STABLE
-
MOODLE_37_STABLE, MOODLE_38_STABLE
-
Easy
-
If an existing role has one or more allowed roles selected, clearing the list is ignored when saved and the list of allowed roles remains unchanged.
The issue is caused by this code in define_role_table_advanced.php:
// Allowed roles. |
$allow = optional_param_array('allowassign', null, PARAM_INT); |
if (!is_null($allow)) { |
$this->allowassign = $allow; |
}
|
$allow = optional_param_array('allowoverride', null, PARAM_INT); |
if (!is_null($allow)) { |
$this->allowoverride = $allow; |
}
|
$allow = optional_param_array('allowswitch', null, PARAM_INT); |
if (!is_null($allow)) { |
$this->allowswitch = $allow; |
}
|
$allow = optional_param_array('allowview', null, PARAM_INT); |
if (!is_null($allow)) { |
$this->allowview = $allow; |
}
|
Changing it to the following resolves the issue:
// Allowed roles. |
$allow = optional_param_array('allowassign', null, PARAM_INT); |
if (!is_null($allow)) { |
$this->allowassign = $allow; |
} else { |
$this->allowassign = array(); |
}
|
$allow = optional_param_array('allowoverride', null, PARAM_INT); |
if (!is_null($allow)) { |
$this->allowoverride = $allow; |
} else { |
$this->allowoverride = array(); |
}
|
$allow = optional_param_array('allowswitch', null, PARAM_INT); |
if (!is_null($allow)) { |
$this->allowswitch = $allow; |
} else { |
$this->allowswitch = array(); |
}
|
$allow = optional_param_array('allowview', null, PARAM_INT); |
if (!is_null($allow)) { |
$this->allowview = $allow; |
} else { |
$this->allowview = array(); |
}
|
|
Steps to reproduce:
- Log in as admin
- Go to Site administration -> Users -> Permissions
- Edit one of the existing roles
- Select at least one value for all 'Allow role ****' multiple selects.
- Save changes
- Edit the same existing role again.
- Unselect all values in all 'Allow role ****' multiple selects.
- Save changes
- Go to edit the same existing role. The 'Allow role ****' multiple selects are not empty. Changes were not saved.