]> git.mjollnir.org Git - moodle.git/commitdiff
The "alias" role names were not being used in the role assign screens. Now they...
authormoodler <moodler>
Tue, 18 Sep 2007 08:35:12 +0000 (08:35 +0000)
committermoodler <moodler>
Tue, 18 Sep 2007 08:35:12 +0000 (08:35 +0000)
admin/roles/assign.php
admin/roles/override.php
admin/roles/tabs.php

index c166444a3373ed20b49ba7255acac793887ab5c8..f5958e14f8a50faeeefb940fd0cd68b0ff6b32cf 100755 (executable)
         } else {
             error('Invalid course id');
         }
+        $coursecontext = $context;
+
     } else if (!empty($courseid)){ // we need this for user tabs in user context
         if (!$course = get_record('course', 'id', $courseid)) {
             error('Invalid course id');
         }
+        $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+
     } else {
         $courseid = SITEID;
         $course = clone($SITE);
@@ -65,7 +69,8 @@
 
 /// needed for tabs.php
     $overridableroles = get_overridable_roles($context);
-    $assignableroles  = get_assignable_roles($context);
+    $assignableroles  = get_assignable_roles($context);    // Plain role names, may be altered later
+
 
 /// Get some language strings
 
         include_once('tabs.php');
     }
 
+
+/// Rename some of the role names if needed
+    if (isset($coursecontext)) {
+        if ($aliasnames = get_records('role_names', 'contextid', $coursecontext->id)) {
+            foreach ($aliasnames as $alias) {
+                if (isset($assignableroles[$alias->roleid])) {
+                    $assignableroles[$alias->roleid] = $alias->text.' ('.$assignableroles[$alias->roleid].')';
+                }
+            }
+        }
+    }
+
+
 /// Process incoming role assignment
 
     if ($frm = data_submitted()) {
index 78c7fa116fc01a2a319e379a9307aa6b696f7901..454e55f704bc8151aaa08f11e65cb1ef9ccbc8f3 100755 (executable)
@@ -28,6 +28,9 @@
         if (!$course = get_record('course', 'id', $courseid)) {
             error('Bad course ID');
         }
+
+        $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+
     } else {
         $course = clone($SITE);
         $courseid = SITEID;
         include_once('tabs.php');
     }
 
+/// Rename some of the role names if needed
+    if (isset($coursecontext)) {
+        if ($aliasnames = get_records('role_names', 'contextid', $coursecontext->id)) {
+            foreach ($aliasnames as $alias) {
+                if (isset($overridableroles[$alias->roleid])) {
+                    $overridableroles[$alias->roleid] = $alias->text.' ('.$overridableroles[$alias->roleid].')';
+                }
+            }
+        }
+    }
+
+
     print_heading_with_help(get_string('overrides', 'role'), 'overrides');
 
     if ($roleid) {
index 63347c24e522baf005490cc476d074e563bebde8..e11c5b6671d1dc5f8d99b84364d9870bc0902a76 100755 (executable)
@@ -78,6 +78,8 @@ if ($currenttab != 'update') {
 
             require_login($course);
 
+            $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);   // for role names later
+
             $fullmodulename      = get_string("modulename", $module->name);
             $streditinga         = get_string("editinga", "moodle", $fullmodulename);
             $strmodulenameplural = get_string("modulenameplural", $module->name);
@@ -125,6 +127,7 @@ if ($currenttab != 'update') {
                                     $navlinks[0] = array('name' => $course->shortname,
                                                         'link' => "$CFG->wwwroot/course/view.php?id=$course->id",
                                                         'type' => 'misc');
+                                    $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);   // for role names later
                                 }
                                 $navigation = build_navigation($navlinks);
                                 print_header("$straction: $blockname", $course->fullname, $navigation);