diff --git a/admin/roles/classes/override_permissions_table_advanced.php b/admin/roles/classes/override_permissions_table_advanced.php index a872b963261b1..1a119d82130dd 100644 --- a/admin/roles/classes/override_permissions_table_advanced.php +++ b/admin/roles/classes/override_permissions_table_advanced.php @@ -56,6 +56,24 @@ public function __construct($context, $roleid, $safeoverridesonly) { } } + /** + * This method adds an additional class to a row if capability is other than inherited. + * + * @param stdClass $capability + * @return array + */ + protected function get_row_attributes($capability) { + $rowattributes = parent::get_row_attributes($capability); + if ($this->permissions[$capability->name] !== 0) { + if (empty($rowattributes['class'])) { + $rowattributes['class'] = "overriddenpermission"; + } else { + $rowattributes['class'] .= " overriddenpermission"; + } + } + return $rowattributes; + } + protected function load_parent_permissions() { // Get the capabilities from the parent context, so that can be shown in the interface. $parentcontext = $this->context->get_parent_context(); diff --git a/admin/roles/tests/behat/override_roles_highlighting.feature b/admin/roles/tests/behat/override_roles_highlighting.feature new file mode 100644 index 0000000000000..1ed349d551dc7 --- /dev/null +++ b/admin/roles/tests/behat/override_roles_highlighting.feature @@ -0,0 +1,23 @@ +@core @core_admin @core_admin_roles +Feature: Highlight non-inherited permissions + In order that the status of capabilities can be more easily seen + As an admin + I need altered permissions to be highlighted + + Background: + Given the following "courses" exist: + | fullname | shortname | + | Course fullname | C_shortname | + And I log in as "admin" + And I am on site homepage + + @javascript + Scenario: Override a permission + Given I follow "Course fullname" + When I expand "Users" node + And I follow "Permissions" + And I select "1" from the "roleid" singleselect + And I click on "Prohibit" "radio" in the "View added and updated modules in recent activity block" "table_row" + And I press "Save changes" + And I select "1" from the "roleid" singleselect + Then the "class" attribute of "View added and updated modules in recent activity block" "table_row" should contain "overriddenpermission" diff --git a/theme/bootstrapbase/less/moodle/admin.less b/theme/bootstrapbase/less/moodle/admin.less index 61947c9666d3d..bd85e2b695f99 100644 --- a/theme/bootstrapbase/less/moodle/admin.less +++ b/theme/bootstrapbase/less/moodle/admin.less @@ -850,3 +850,7 @@ img.iconsmall { color: @infoText; background-color: @infoBackground; } + +#overriderolestable .overriddenpermission { + background-color: @warningBackground; +} diff --git a/theme/bootstrapbase/style/moodle.css b/theme/bootstrapbase/style/moodle.css index 7a89d03b93dc2..677e3403027e7 100644 --- a/theme/bootstrapbase/style/moodle.css +++ b/theme/bootstrapbase/style/moodle.css @@ -3234,6 +3234,9 @@ img.iconsmall { color: #3a87ad; background-color: #d9edf7; } +#overriderolestable .overriddenpermission { + background-color: #fcf8e3; +} /* calendar.less */ .calendar_event_course { background-color: #ffd3bd;