]> git.mjollnir.org Git - moodle.git/commitdiff
role assign: MDL-17323 Show users from parent contexts ... Refine group labels.
authortjhunt <tjhunt>
Fri, 21 Nov 2008 06:19:52 +0000 (06:19 +0000)
committertjhunt <tjhunt>
Fri, 21 Nov 2008 06:19:52 +0000 (06:19 +0000)
admin/roles/lib.php
lang/en_utf8/role.php
lib/accesslib.php

index f65ee7efb20cf180e0215964cd736f59d936c99a..2ea3a02ee16a8500056f780c34853a95cbe014cb 100644 (file)
@@ -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);
             }
         }
     }
index f88d9ababac4769cad7f83bff4403b803223b479..a6d472ec8dc9d56a4e85061a6df3abd168de4e51 100644 (file)
@@ -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';
index b2d9a2119e3f8007b90b8143eb7484b9532b1df4..21421add714b1a7ffcb5e3d914761527e276880f 100755 (executable)
@@ -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.