Also, commit the lang strings I missed last time.
$canview = has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride',
'moodle/role:override', 'moodle/role:manage'), $context);
if (!$canview) {
- print_error('nopermissions', 'error', '', get_string('explainpermissions', 'role'));
+ print_error('nopermissions', 'error', '', get_string('checkpermissions', 'role'));
}
/// These are needed early because of tabs.php
$userselector->set_rows(10);
/// Work out an appropriate page title.
- $title = get_string('explainpermissionsin', 'role', $contextname);
- $straction = get_string('explainpermissions', 'role'); // Used by tabs.php
+ $title = get_string('checkpermissionsin', 'role', $contextname);
+ $straction = get_string('checkpermissions', 'role'); // Used by tabs.php
/// Print the header and tabs
if ($context->contextlevel == CONTEXT_USER) {
}
$showroles = 1;
- $currenttab = 'explain';
+ $currenttab = 'check';
include_once($CFG->dirroot.'/user/tabs.php');
} else if ($context->contextlevel == CONTEXT_SYSTEM) {
- admin_externalpage_setup('assignroles');
-// admin_externalpage_setup('explainpermissions');
+ admin_externalpage_setup('checkpermissions');
admin_externalpage_print_header();
} else if ($context->contextlevel == CONTEXT_COURSE and $context->instanceid == SITEID) {
- admin_externalpage_setup('explainfrontpagepermissions');
+ admin_externalpage_setup('frontpageroles');
admin_externalpage_print_header();
- $currenttab = 'explain';
+ $currenttab = 'check';
include_once('tabs.php');
} else {
- $currenttab = 'explain';
+ $currenttab = 'check';
include_once('tabs.php');
}
/// Print heading.
- print_heading_with_help($title, 'explainpermissions');
+ print_heading_with_help($title, 'checkpermissions');
/// If a user has been chosen, show all the permissions for this user.
$user = $userselector->get_selected_user();
protected $user;
protected $fullname;
protected $baseurl;
+ protected $contextname;
protected $stryes;
protected $strno;
protected $strexplanation;
private $hascap;
- public function __construct($context, $user) {
+ public function __construct($context, $user, $contextname) {
global $CFG;
parent::__construct($context, 'explaincaps');
$this->user = $user;
$this->fullname = fullname($user);
+ $this->contextname = $contextname;
$this->baseurl = $CFG->wwwroot . '/' . $CFG->admin .
'/roles/explainhascapabiltiy.php?user=' . $user->id .
'&contextid=' . $context->id . '&capability=';
protected function add_row_cells($capability) {
if ($this->hascap) {
$result = $this->stryes;
- $tooltip = 'explainwhyhascap';
+ $tooltip = 'whydoesuserhavecap';
} else {
$result = $this->strno;
- $tooltip = 'explainwhyhasnotcap';
+ $tooltip = 'whydoesusernothavecap';
}
$a = new stdClass;
- $a->username = $this->fullname;
+ $a->fullname = $this->fullname;
$a->capability = $capability->name;
+ $a->context = $this->contextname;
echo '<td>' . $result . '</td>';
echo '<td>';
link_to_popup_window($this->baseurl . $capability->name, 'hascapabilityexplanation',
require_js(array('yui_yahoo', 'yui_dom', 'yui_event'));
require_js($CFG->admin . '/roles/roles.js');
- print_box_start('generalbox boxaligncenter');
+ print_box_start('generalbox boxaligncenter boxwidthwide');
print_heading(get_string('permissionsforuser', 'role', fullname($user)), '', 3);
- $table = new explain_cabability_table($context, $user);
+ $table = new explain_cabability_table($context, $user, $contextname);
$table->display();
print_box_end();
);
// Start the output.
-print_header(get_string('explainpermissions', 'role'));
-print_heading(get_string('explainpermissions', 'role'));
+print_header(get_string('explainpermission', 'role'));
+print_heading(get_string('explainpermission', 'role'));
// Print a summary of what we are doing.
$a = new stdClass;
} else {
$a->fullname = get_string('nobody');
}
-$a->context = reset($contexts)->name;
$a->capability = $capability;
-echo '<p>' . get_string('explainpermissionsdetails', 'role', $a) . '</p>';
+$a->context = reset($contexts)->name;
+if ($userhascapability) {
+ echo '<p>' . get_string('whydoesuserhavecap', 'role', $a) . '</p>';
+} else {
+ echo '<p>' . get_string('whydoesusernothavecap', 'role', $a) . '</p>';
+}
// Print the table header rows.
echo '<table class="generaltable explainpermissions"><thead>';
-echo '<tr><th scope="col" rowspan="2" class="header">' . get_string('assignmentcontext', 'role') .
- '</th><th scope="row" class="header overridecontextheader">' . get_string('overridecontext', 'role') . '</th>';
-foreach ($contexts as $con) {
- echo '<th scope="col" rowspan="2" class="header overridecontext">' . $con->id . '</th>';
+echo '<tr><th scope="col" colspan="2" class="header assignment">' . get_string('roleassignments', 'role') . '</th>';
+if (count($contexts) > 1) {
+ echo '<th scope="col" colspan="' . (count($contexts) - 1) . '" class="header">' . get_string('overridesbycontext', 'role') . '</th>';
}
+echo '<th scope="col" rowspan="2" class="header">' . get_string('roledefinitions', 'role') . '</th>';
echo '</tr>';
-echo '<tr><th scope="col" class="header rolename">' . get_string('role') . '</th></tr>';
-echo '</thead><tbody>';
+echo '<tr class="row2"><th scope="col" class="header assignment">' . get_string('context', 'role') .
+ '</th><th scope="col" class="header assignment">' . get_string('role') . '</th>';
+foreach (array_slice($contexts, 0, count($contexts) - 1) as $con) {
+ echo '<th scope="col" class="header overridecontext">' . $con->id . '</th>';
+}
+echo '</tr></thead><tbody>';
// Now print the bulk of the table.
foreach ($contexts as $con) {
} else {
$ras = array(0);
}
- $firstcell = '<th class="cell assignmentcontext" rowspan="' . count($ras) . '">' . $con->id . ' ' . $con->name . '</th>';
+ $firstcell = '<th class="cell assignment" rowspan="' . count($ras) . '">' . $con->id . ' ' . $con->name . '</th>';
$rowclass = ' class="newcontext"';
foreach ($ras as $roleid) {
$extraclass = '';
if (!$roleid) {
$extraclass = ' noroles';
}
- echo '<tr' . $rowclass . '>' . $firstcell . '<th class="cell rolename' . $extraclass . '" scope="row">' . $rolenames[$roleid] . '</th>';
+ echo '<tr' . $rowclass . '>' . $firstcell . '<th class="cell assignment' . $extraclass . '" scope="row">' . $rolenames[$roleid] . '</th>';
foreach ($contexts as $ocon) {
if ($roleid == 0) {
$perm = '';
}
- if (!empty($assignableroles)) {
+ if (!empty($assignableroles) || $currenttab=='assign') {
$toprow[] = new tabobject('assign',
$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$context->id,
get_string('localroles', 'role'),
- get_string('showallroles', 'role'),
+ '',
true);
}
$toprow[] = new tabobject('override',
$CFG->wwwroot.'/'.$CFG->admin.'/roles/override.php?contextid='.$context->id,
get_string('overridepermissions', 'role'),
- get_string('showallroles', 'role'),
+ '',
+ true);
+ }
+
+ if (has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride',
+ 'moodle/role:override', 'moodle/role:assign'), $context)) {
+ $toprow[] = new tabobject('check',
+ $CFG->wwwroot.'/'.$CFG->admin.'/roles/explain.php?contextid='.$context->id,
+ get_string('checkpermissions', 'role'),
+ '',
true);
}
// stuff under the "roles" subcategory
$ADMIN->add('users', new admin_category('roles', get_string('permissions', 'role')));
- $ADMIN->add('roles', new admin_externalpage('defineroles', get_string('defineroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/manage.php", 'moodle/role:manage'));
- $ADMIN->add('roles', new admin_externalpage('assignroles', get_string('assignglobalroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/assign.php?contextid=".$systemcontext->id, 'moodle/role:assign'));
-
// "userpolicies" settingpage
$temp = new admin_settingpage('userpolicies', get_string('userpolicies', 'admin'));
get_string('extrauserselectorfields', 'admin'), get_string('configextrauserselectorfields', 'admin'), array('email' => '1'),
array('email' => get_string('email'), 'idnumber' => get_string('idnumber'), 'username' => get_string('username'), )));
}
-
$ADMIN->add('roles', $temp);
+ $ADMIN->add('roles', new admin_externalpage('defineroles', get_string('defineroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/manage.php", 'moodle/role:manage'));
+ $ADMIN->add('roles', new admin_externalpage('assignroles', get_string('assignglobalroles', 'role'), "$CFG->wwwroot/$CFG->admin/roles/assign.php?contextid=".$systemcontext->id, 'moodle/role:assign'));
+ $ADMIN->add('roles', new admin_externalpage('checkpermissions', get_string('checkglobalpermissions', 'role'), "$CFG->wwwroot/$CFG->admin/roles/explain.php?contextid=".$systemcontext->id, array('moodle/role:assign', 'moodle/role:safeoverride', 'moodle/role:override', 'moodle/role:manage')));
+
} // end of speedup
?>
$string['cannotassignrole'] = 'Cannot assign role in course';
$string['cannotassignrolehere'] = 'You are not allowed to assign this role (id = $a->roleid) in this context ($a->context)';
$string['cannotassignselfasparent'] = 'Cannot assign self as parent!';
+$string['cannotcallusgetselecteduser'] = 'You cannot called user_selector::get_selected_user if multiselect is true.';
$string['cannotcallscript'] = 'You cannot call this script in that way';
$string['cannotcreatebackupdir'] = 'Could not create backupdata folder. The site administrator needs to fix the file permissions';
$string['cannotcreatecategory'] = 'The category was not inserted';
$string['usernotupdatedadmin'] = 'Cannot update admin accounts';
$string['usernotupdatederror'] = 'User not updated - error';
$string['usernotupdatednotexists'] = 'User not updated - does not exist';
+$string['userselectortoomany'] = 'user_selector got more than one selected user, even though multiselect is false.';
$string['updatersserror'] = 'There was an error trying to update RSS feed with id: $a';
$string['upgradeversionfail'] = 'Upgrade of backup system failed! (Could not update version in config table.)';
$string['upgradefail'] = 'Upgrade failed! $a';
$string['addrole'] = 'Add a new role';
$string['allow'] = 'Allow';
$string['allowassign'] = 'Allow role assignments';
+$string['allowed'] = 'Allowed';
$string['allowoverride'] = 'Allow role overrides';
$string['allsiteusers'] = 'All site users';
$string['assignanotherrole'] = 'Assign another role';
$string['category:delete'] = 'Delete categories';
$string['category:update'] = 'Update categories';
$string['category:visibility'] = 'See hidden categories';
+$string['checkglobalpermissions'] = 'Check system permissions';
+$string['checkpermissions'] = 'Check permissions';
+$string['checkpermissionsin'] = 'Check permissions in $a';
$string['chooseroletoassign'] = 'Please choose a role to assign';
$string['context'] = 'Context';
$string['course:activityvisibility'] = 'Hide/show activities';
$string['errorexistsrolename'] = 'Role name already exists';
$string['errorexistsroleshortname'] = 'Role name already exists';
$string['existingusers'] = '$a existing users';
-$string['explainpermissions'] = 'Explain permissions';
-$string['explainpermissionsdetails'] = 'For capability $a->capability in context $a->context when logged in as $a->fullname.';
+$string['explanation'] = 'Explanation';
+$string['explainpermission'] = 'Explain permission';
$string['explainpermissionsinfo'] = '<p>To use this table:</p><ol><li>First look to see if there are any Prohibits. If there are, has_capability will return false.</li><li>Otherwise, read across the rows, left-to-right, top-to-bottom, and find the first cell where the number of Prevents and Allows are different. If there are more Allows than Prevents in that cell, then has_capability will return true, otherwise it will return false.</li><li>If no cell has different numbers of Prevents and Allows, then has_capability will return false.</li></ol>';
$string['explainpermissionsdoanything'] = 'Note that this user has the moodle/site:doanything capability, so even though the table above shows that has_capability will return false, this user will actually be deemed to have the capability $a in most circumstances.';
$string['extusers'] = 'Existing users';
$string['overrideroles'] = 'Override roles';
$string['overriderolesin'] = 'Override roles in $a';
$string['overrides'] = 'Overrides';
+$string['overridesbycontext'] = 'Overrides (by context)';
$string['permissions'] = 'Permissions';
+$string['permissionsforuser'] = 'Permissions for user $a';
$string['potentialusers'] = '$a potential users';
$string['potusers'] = 'Potential users';
$string['potusersmatching'] = 'Potential users matching \'$a\'';
$string['role:unassignself'] = 'Unassign own roles';
$string['role:viewhiddenassigns'] = 'View hidden role assignments';
$string['roleassignments'] = 'Role assignments';
+$string['roledefinitions'] = 'Role definitions';
$string['roles'] = 'Roles';
$string['roletoassign'] = 'Role to assign';
$string['roletooverride'] = 'Role to override';
$string['safeoverridenotice'] = 'Note: Capabilities with higher risks are locked because you are only allowed to override safe capabilities.';
+$string['selectauser'] = 'Select a user';
+$string['selectanotheruser'] = 'Select another user';
$string['selectrole'] = 'Select a role';
$string['showallroles'] = 'Show all roles';
+$string['showthisuserspermissions'] = 'Show this user\'s permissions';
$string['site:accessallgroups'] = 'Access all groups';
$string['site:approvecourse'] = 'Approve course creation';
$string['site:backup'] = 'Backup courses';
$string['userswiththisrole'] = 'Users with role';
$string['userswithrole'] = 'All users with a role';
$string['viewrole'] = 'View role details';
+$string['whydoesuserhavecap'] = 'Why does $a->fullname have capability $a->capability in context $a->context?';
+$string['whydoesusernothavecap'] = 'Why does $a->fullname not have capability $a->capability in context $a->context?';
$string['xuserswiththerole'] = 'Users with the role \"$a->role\"';
// MNET
border-right: 1px solid black;
}
table.explainpermissions .newcontext .cell,
-table.explainpermissions th.header.rolename {
+table.explainpermissions .row2 th.header {
border-top: 1px solid black;
}
table.explainpermissions .cell.inherit,
table.explainpermissions .cell.noroles {
color: grey;
}
-table.explainpermissions th.assignmentcontext,
-table.explainpermissions th.rolename {
+table.explainpermissions th.assignment {
text-align: left;
padding-left: 0.5em;
}
-table.explainpermissions th.overridecontextheader {
- text-align: right;
- padding-right: 0.5em;
-}
table.explainpermissions .cell.prohibit {
font-weight: bold;
}