From 490740d6cbb8a28b5af0a6a4f7a7fafc089e32ed Mon Sep 17 00:00:00 2001 From: tjhunt Date: Fri, 21 Nov 2008 06:19:52 +0000 Subject: [PATCH] role assign: MDL-17323 Show users from parent contexts ... Refine group labels. --- admin/roles/lib.php | 12 ++++++++---- lang/en_utf8/role.php | 8 ++++---- lib/accesslib.php | 18 ++++++++++++++++++ 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/admin/roles/lib.php b/admin/roles/lib.php index f65ee7efb2..2ea3a02ee1 100644 --- a/admin/roles/lib.php +++ b/admin/roles/lib.php @@ -1177,17 +1177,21 @@ class existing_role_holders extends role_assign_user_selector_base { } protected function this_con_group_name($search, $numusers) { + $contexttype = get_contextlevel_name($this->context->contextlevel); if ($search) { + $a = new stdClass; + $a->search = $search; + $a->contexttype = $contexttype; if ($numusers) { - return get_string('usersinthiscontextmatching', 'role', $search); + return get_string('usersinthisxmatching', 'role', $a); } else { - return get_string('noneinthiscontextmatching', 'role', $search); + return get_string('noneinthisxmatching', 'role', $a); } } else { if ($numusers) { - return get_string('usersinthiscontext', 'role'); + return get_string('usersinthisx', 'role', $contexttype); } else { - return get_string('noneinthiscontext', 'role'); + return get_string('noneinthisx', 'role', $contexttype); } } } diff --git a/lang/en_utf8/role.php b/lang/en_utf8/role.php index f88d9ababa..a6d472ec8d 100644 --- a/lang/en_utf8/role.php +++ b/lang/en_utf8/role.php @@ -134,8 +134,8 @@ $string['morethan'] = 'More than $a'; $string['multipleroles'] = 'Multiple roles'; $string['my:manageblocks'] = 'Manage myMoodle page blocks'; $string['nocapabilitiesincontext'] = 'No capabilities available in this context'; -$string['noneinthiscontext'] = 'None in this context'; -$string['noneinthiscontextmatching'] = 'No users matching \'$a\' in this context'; +$string['noneinthisx'] = 'None in this $a'; +$string['noneinthisxmatching'] = 'No users matching \'$a->search\' in this $a->contexttype'; $string['notabletoassignroleshere'] = 'You are not able to assign any roles here'; $string['notabletooverrideroleshere'] = 'You are not able to override the permissions on any roles here'; $string['notset'] = 'Not set'; @@ -230,8 +230,8 @@ $string['user:viewuseractivitiesreport'] = 'See user activity reports'; $string['userhashiddenassignments'] = 'This user has one or more hidden role assignments in this course'; $string['usersfrom'] = 'Users from $a'; $string['usersfrommatching'] = 'Users from $a->contextname matching \'$a->search\''; -$string['usersinthiscontext'] = 'Users in this context'; -$string['usersinthiscontextmatching'] = 'Users in this context matching \'$a\''; +$string['usersinthisx'] = 'Users in this $a'; +$string['usersinthisxmatching'] = 'Users in this $a->contexttype matching \'$a->search\''; $string['userswiththisrole'] = 'Users with role'; $string['userswithrole'] = 'All users with a role'; $string['useshowadvancedtochange'] = 'Use \'Show advanced\' to change'; diff --git a/lib/accesslib.php b/lib/accesslib.php index b2d9a2119e..21421add71 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -3303,6 +3303,24 @@ function capabilities_cleanup($component, $newcapdef=NULL) { * UI FUNCTIONS * ****************/ +/** + * @param integer $contextlevel $context->context level. One of the CONTEXT_... constants. + * @return string the name for this type of context. + */ +function get_contextlevel_name($contextlevel) { + static $strcontextlevels = null; + if (is_null($strcontextlevels)) { + $strcontextlevels = array( + CONTEXT_SYSTEM => get_string('coresystem'), + CONTEXT_USER => get_string('user'), + CONTEXT_COURSECAT => get_string('category'), + CONTEXT_COURSE => get_string('course'), + CONTEXT_MODULE => get_string('activitymodule'), + CONTEXT_BLOCK => get_string('block') + ); + } + return $strcontextlevels[$contextlevel]; +} /** * Prints human readable context identifier. -- 2.39.5