/**
  * 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;
 }
 /**
  * Constructor.
  *
  * This method loads loads all the information about the current state of
  * the overrides, then updates that based on any submitted data. It also
  * works out which capabilities should be locked for this user.
  *
  * @param object $context the context this table relates to.
  * @param integer $roleid the role being overridden.
  * @param boolean $safeoverridesonly If true, the user is only allowed to override
  *      capabilities with no risks.
  */
 public function __construct($context, $roleid, $safeoverridesonly)
 {
     parent::__construct($context, 'overriderolestable', $roleid);
     $this->displaypermissions = $this->allpermissions;
     $this->strnotset = get_string('notset', 'core_role');
     // Determine which capabilities should be locked.
     if ($safeoverridesonly) {
         foreach ($this->capabilities as $capid => $cap) {
             if (!is_safe_capability($cap)) {
                 $this->capabilities[$capid]->locked = true;
                 $this->haslockedcapabilities = true;
             }
         }
     }
 }
 public function display()
 {
     global $OUTPUT;
     // Extra fields at the top of the page.
     echo '<div class="topfields clearfix">';
     $this->print_field('shortname', get_string('roleshortname', 'core_role') . '&nbsp;' . $OUTPUT->help_icon('roleshortname', 'core_role'), $this->get_shortname_field('shortname'));
     $this->print_field('name', get_string('customrolename', 'core_role') . '&nbsp;' . $OUTPUT->help_icon('customrolename', 'core_role'), $this->get_name_field('name'));
     $this->print_field('edit-description', get_string('customroledescription', 'core_role') . '&nbsp;' . $OUTPUT->help_icon('customroledescription', 'core_role'), $this->get_description_field('description'));
     $this->print_field('menuarchetype', get_string('archetype', 'core_role') . '&nbsp;' . $OUTPUT->help_icon('archetype', 'core_role'), $this->get_archetype_field('archetype'));
     $this->print_field('', get_string('maybeassignedin', 'core_role'), $this->get_assignable_levels_control());
     $this->print_field('menuallowassign', get_string('allowassign', 'core_role'), $this->get_allow_role_control('assign'));
     $this->print_field('menuallowoverride', get_string('allowoverride', 'core_role'), $this->get_allow_role_control('override'));
     $this->print_field('menuallowswitch', get_string('allowswitch', 'core_role'), $this->get_allow_role_control('switch'));
     if ($risks = $this->get_role_risks_info()) {
         $this->print_field('', get_string('rolerisks', 'core_role'), $risks);
     }
     echo "</div>";
     $this->print_show_hide_advanced_button();
     // Now the permissions table.
     parent::display();
 }