}
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);
}
}
}
$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';
$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';
* 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.