diff --git a/admin/roles/check.php b/admin/roles/check.php
index 0c2c822351f..47311020b84 100644
--- a/admin/roles/check.php
+++ b/admin/roles/check.php
@@ -24,7 +24,7 @@
require_once(dirname(__FILE__) . '/../../config.php');
-$contextid = required_param('contextid',PARAM_INT);
+$contextid = required_param('contextid', PARAM_INT);
list($context, $course, $cm) = get_context_info_array($contextid);
@@ -44,7 +44,7 @@ if ($course) {
}
}
-// security first
+// Security first.
require_login($course, false, $cm);
if (!has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride', 'moodle/role:override', 'moodle/role:manage'), $context)) {
print_error('nopermissions', 'error', '', get_string('checkpermissions', 'role'));
diff --git a/admin/roles/classes/capability_table_base.php b/admin/roles/classes/capability_table_base.php
index df442751390..9c9d7f9029b 100644
--- a/admin/roles/classes/capability_table_base.php
+++ b/admin/roles/classes/capability_table_base.php
@@ -15,7 +15,7 @@
// along with Moodle. If not, see .
/**
- * Library code used by the roles administration interfaces.
+ * Base capability table.
*
* @package core_role
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
@@ -49,13 +49,13 @@ abstract class core_role_capability_table_base {
const NUM_CAPS_FOR_SEARCH = 12;
/**
- * Constructor
- * @param object $context the context this table relates to.
+ * Constructor.
+ * @param context $context the context this table relates to.
* @param string $id what to put in the id="" attribute.
*/
- public function __construct($context, $id) {
+ public function __construct(context $context, $id) {
$this->context = $context;
- $this->capabilities = fetch_context_capabilities($context);
+ $this->capabilities = $context->get_capabilities();
$this->id = $id;
}
@@ -74,15 +74,15 @@ abstract class core_role_capability_table_base {
public function display() {
if (count($this->capabilities) > self::NUM_CAPS_FOR_SEARCH) {
global $PAGE;
- $PAGE->requires->strings_for_js(array('filter','clear'),'moodle');
+ $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 '
' . "\n\n";
- echo '| ' . get_string('capability','role') . ' | ';
+ echo '
|---|
| ' . get_string('capability', 'core_role') . ' | ';
$this->add_header_cells();
echo "
\n\n\n";
- /// Loop over capabilities.
+ // Loop over capabilities.
$contextlevel = 0;
$component = '';
foreach ($this->capabilities as $capability) {
@@ -90,35 +90,35 @@ abstract class core_role_capability_table_base {
continue;
}
- /// Prints a breaker if component or name or context level has changed
+ // 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.
+ // Start the row.
echo '';
- /// Table cell for the capability name.
+ // Table cell for the capability name.
echo '| ' . get_capability_docs_link($capability) .
'' . $capability->name . ' | ';
- /// Add the cells specific to this table.
+ // Add the cells specific to this table.
$this->add_row_cells($capability);
- /// End the row.
+ // End the row.
echo "
\n";
}
- /// End of the table.
+ // End of the table.
echo "\n
\n";
}
/**
* Used to output a heading rows when the context level or component changes.
- * @param object $capability gives the new component and contextlevel.
+ * @param stdClass $capability gives the new component and contextlevel.
*/
protected function print_heading_row($capability) {
echo '