From: tjhunt Date: Wed, 12 Nov 2008 10:13:43 +0000 (+0000) Subject: roles explanation: MDL-13538 Integrate into the roles tab bar, and improve wording... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=8a8272b0f47060a528b1d34e685f8be13c80be73;p=moodle.git roles explanation: MDL-13538 Integrate into the roles tab bar, and improve wording a bit. Also, commit the lang strings I missed last time. --- diff --git a/admin/roles/explain.php b/admin/roles/explain.php index e2c4a989be..c21d47f211 100755 --- a/admin/roles/explain.php +++ b/admin/roles/explain.php @@ -36,7 +36,7 @@ $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 @@ -56,8 +56,8 @@ $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) { @@ -85,27 +85,26 @@ } $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(); @@ -116,15 +115,17 @@ 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='; @@ -153,14 +154,15 @@ 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 '' . $result . ''; echo ''; link_to_popup_window($this->baseurl . $capability->name, 'hascapabilityexplanation', @@ -171,10 +173,10 @@ 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(); diff --git a/admin/roles/explainhascapabiltiy.php b/admin/roles/explainhascapabiltiy.php index 5dfba3f55d..44d941212b 100644 --- a/admin/roles/explainhascapabiltiy.php +++ b/admin/roles/explainhascapabiltiy.php @@ -145,8 +145,8 @@ $strperm = array( ); // 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; @@ -155,20 +155,28 @@ if ($userid) { } else { $a->fullname = get_string('nobody'); } -$a->context = reset($contexts)->name; $a->capability = $capability; -echo '

' . get_string('explainpermissionsdetails', 'role', $a) . '

'; +$a->context = reset($contexts)->name; +if ($userhascapability) { + echo '

' . get_string('whydoesuserhavecap', 'role', $a) . '

'; +} else { + echo '

' . get_string('whydoesusernothavecap', 'role', $a) . '

'; +} // Print the table header rows. echo ''; -echo ''; -foreach ($contexts as $con) { - echo ''; +echo ''; +if (count($contexts) > 1) { + echo ''; } +echo ''; echo ''; -echo ''; -echo ''; +echo ''; +foreach (array_slice($contexts, 0, count($contexts) - 1) as $con) { + echo ''; +} +echo ''; // Now print the bulk of the table. foreach ($contexts as $con) { @@ -179,14 +187,14 @@ foreach ($contexts as $con) { } else { $ras = array(0); } - $firstcell = ''; + $firstcell = ''; $rowclass = ' class="newcontext"'; foreach ($ras as $roleid) { $extraclass = ''; if (!$roleid) { $extraclass = ' noroles'; } - echo '' . $firstcell . ''; + echo '' . $firstcell . ''; foreach ($contexts as $ocon) { if ($roleid == 0) { $perm = ''; diff --git a/admin/roles/tabs.php b/admin/roles/tabs.php index 0362c576ac..0819694fd3 100755 --- a/admin/roles/tabs.php +++ b/admin/roles/tabs.php @@ -157,11 +157,11 @@ if ($context->contextlevel != CONTEXT_SYSTEM) { // Print tabs for anything ex } - 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); } @@ -169,7 +169,16 @@ if ($context->contextlevel != CONTEXT_SYSTEM) { // Print tabs for anything ex $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); } diff --git a/admin/settings/users.php b/admin/settings/users.php index 7bae7c8540..39d983bc5d 100644 --- a/admin/settings/users.php +++ b/admin/settings/users.php @@ -81,9 +81,6 @@ if ($hassiteconfig // 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')); @@ -170,9 +167,12 @@ if ($hassiteconfig 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 ?> diff --git a/lang/en_utf8/error.php b/lang/en_utf8/error.php index 7d41d3585e..e936595175 100644 --- a/lang/en_utf8/error.php +++ b/lang/en_utf8/error.php @@ -23,6 +23,7 @@ $string['cannotassignanthing'] = 'Cannot assign moodle/site:doanything'; $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'; @@ -445,6 +446,7 @@ $string['usernotrenamedoff'] = 'User not renamed - renaming not allowed'; $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'; diff --git a/lang/en_utf8/role.php b/lang/en_utf8/role.php index 6b8782b74f..cb64fb68f7 100644 --- a/lang/en_utf8/role.php +++ b/lang/en_utf8/role.php @@ -5,6 +5,7 @@ $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'; @@ -31,6 +32,9 @@ $string['category:create'] = 'Create categories'; $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'; @@ -74,8 +78,8 @@ $string['errorbadroleshortname'] = 'Incorrect role name'; $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'] = '

To use this table:

  1. First look to see if there are any Prohibits. If there are, has_capability will return false.
  2. 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.
  3. If no cell has different numbers of Prevents and Allows, then has_capability will return false.
'; $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'; @@ -128,7 +132,9 @@ $string['overridepermissionsforrole'] = 'Override permissions for role \'$a->rol $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\''; @@ -160,12 +166,16 @@ $string['role:switchroles'] = 'Switch to other roles'; $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'; @@ -205,6 +215,8 @@ $string['userhashiddenassignments'] = 'This user has one or more hidden role ass $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 diff --git a/theme/standard/styles_layout.css b/theme/standard/styles_layout.css index 4f99e6a5c9..524863ef87 100644 --- a/theme/standard/styles_layout.css +++ b/theme/standard/styles_layout.css @@ -1180,22 +1180,17 @@ table.explainpermissions td.cell { 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; }
' . get_string('assignmentcontext', 'role') . - '' . get_string('overridecontext', 'role') . '' . $con->id . '
' . get_string('roleassignments', 'role') . '' . get_string('overridesbycontext', 'role') . '' . get_string('roledefinitions', 'role') . '
' . get_string('role') . '
' . get_string('context', 'role') . + '' . get_string('role') . '' . $con->id . '
' . $con->id . ' ' . $con->name . '' . $con->id . ' ' . $con->name . '' . $rolenames[$roleid] . '' . $rolenames[$roleid] . '