}
            }
        }
        if ($prohibit) {
            $mform = new core_role_permission_prohibit_form(null, array($context, $capability, $overridableroles));
            if ($mform->is_cancelled()) {
                redirect($PAGE->url);
            } else {
                if ($data = $mform->get_data() and !empty($data->roleid)) {
                    $roleid = $data->roleid;
                    if (isset($overridableroles[$roleid])) {
                        role_change_permission($roleid, $context, $capability->name, CAP_PROHIBIT);
                    }
                    redirect($PAGE->url);
                } else {
                    $a = (object) array('cap' => get_capability_docs_link($capability) . " ({$capability->name})", 'context' => $contextname);
                    $message = get_string('roleprohibitinfo', 'core_role', $a);
                }
            }
        }
        echo $OUTPUT->header();
        echo $OUTPUT->heading($title);
        echo $OUTPUT->box($message);
        $mform->display();
        echo $OUTPUT->footer();
        die;
    }
}
echo $OUTPUT->header();
echo $OUTPUT->heading($title);
$table = new core_role_permissions_table($context, $contextname, $allowoverrides, $allowsafeoverrides, $overridableroles);
Example #2
0
 /**
  * Display the table.
  */
 public function display()
 {
     if (count($this->capabilities) > self::NUM_CAPS_FOR_SEARCH) {
         global $PAGE;
         $jsmodule = array('name' => 'rolescapfilter', 'fullpath' => '/admin/roles/module.js', 'strings' => array(array('filter', 'moodle'), array('clear', 'moodle')), 'requires' => array('node', 'cookie', 'escape'));
         $PAGE->requires->js_init_call('M.core_role.init_cap_table_filter', array($this->id, $this->context->id), false, $jsmodule);
     }
     echo '<table class="' . implode(' ', $this->classes) . '" id="' . $this->id . '">' . "\n<thead>\n";
     echo '<tr><th class="name" align="left" scope="col">' . get_string('capability', 'core_role') . '</th>';
     $this->add_header_cells();
     echo "</tr>\n</thead>\n<tbody>\n";
     // Loop over capabilities.
     $contextlevel = 0;
     $component = '';
     foreach ($this->capabilities as $capability) {
         if ($this->skip_row($capability)) {
             continue;
         }
         // Prints a breaker if component or name or context level has changed.
         if (component_level_changed($capability, $component, $contextlevel)) {
             $this->print_heading_row($capability);
         }
         $contextlevel = $capability->contextlevel;
         $component = $capability->component;
         // Start the row.
         $rowattributes = $this->get_row_attributes($capability);
         // Handle class attributes same as other.
         $rowclasses = array_unique(array_merge(array('rolecap'), $this->get_row_classes($capability)));
         if (array_key_exists('class', $rowattributes)) {
             $rowclasses = array_unique(array_merge($rowclasses, array($rowattributes['class'])));
         }
         $rowattributes['class'] = implode(' ', $rowclasses);
         // Table cell for the capability name.
         $contents = '<th scope="row" class="name"><span class="cap-desc">' . get_capability_docs_link($capability) . '<span class="cap-name">' . $capability->name . '</span></span></th>';
         // Add the cells specific to this table.
         $contents .= $this->add_row_cells($capability);
         echo html_writer::tag('tr', $contents, $rowattributes);
     }
     // End of the table.
     echo "</tbody>\n</table>\n";
 }
Example #3
0
 /**
  * Display the table.
  */
 public function display()
 {
     if (count($this->capabilities) > capability_table_base::NUM_CAPS_FOR_SEARCH) {
         global $PAGE;
         $PAGE->requires->strings_for_js(array('filter', 'clear'), 'moodle');
         $PAGE->requires->js_init_call('M.core_role.init_cap_table_filter', array($this->id, $this->context->id));
     }
     echo '<table class="' . implode(' ', $this->classes) . '" id="' . $this->id . '">' . "\n<thead>\n";
     echo '<tr><th class="name" align="left" scope="col">' . get_string('capability', 'role') . '</th>';
     $this->add_header_cells();
     echo "</tr>\n</thead>\n<tbody>\n";
     /// Loop over capabilities.
     $contextlevel = 0;
     $component = '';
     foreach ($this->capabilities as $capability) {
         if ($this->skip_row($capability)) {
             continue;
         }
         /// Prints a breaker if component or name or context level has changed
         if (component_level_changed($capability, $component, $contextlevel)) {
             $this->print_heading_row($capability);
         }
         $contextlevel = $capability->contextlevel;
         $component = $capability->component;
         /// Start the row.
         echo '<tr class="' . implode(' ', array_unique(array_merge(array('rolecap'), $this->get_row_classes($capability)))) . '">';
         /// Table cell for the capability name.
         echo '<th scope="row" class="name"><span class="cap-desc">' . get_capability_docs_link($capability) . '<span class="cap-name">' . $capability->name . '</span></span></th>';
         /// Add the cells specific to this table.
         $this->add_row_cells($capability);
         /// End the row.
         echo "</tr>\n";
     }
     /// End of the table.
     echo "</tbody>\n</table>\n";
 }
Example #4
0
 /**
  * Render a capabilitiy name, including docs link, internal name and risk icons.
  * @param unknown_type $capability
  * @return string the HTML to output.
  */
 protected function capability_name_full($capability)
 {
     $a = new stdClass();
     $a->name = get_capability_docs_link($capability);
     $a->capabilityname = html_writer::tag('span', $capability->name, array('class' => 'cap-name'));
     $a->risks = $this->risk_icons($capability);
     return html_writer::tag('span', get_string('capabilitynamewithrisks', 'tool_editrolesbycap', $a), array('class' => 'cap-desc'));
 }