]> git.mjollnir.org Git - moodle.git/commitdiff
some changes for better capabilities list display
authortoyomoyo <toyomoyo>
Thu, 16 Aug 2007 08:48:53 +0000 (08:48 +0000)
committertoyomoyo <toyomoyo>
Thu, 16 Aug 2007 08:48:53 +0000 (08:48 +0000)
admin/roles/manage.html
admin/roles/override.html
lib/accesslib.php

index 6af4d4a85eba0a4873bbf2aeac80b21fec5518a2..eb42f3849ea04229bcfa2f8e8dee2b6541980cc8 100755 (executable)
@@ -130,7 +130,8 @@ foreach ($capabilities as $capability) {
     }
 
     // prints a breaker if component or name or context level
-    if ($capability->component != $component or $capability->contextlevel != $contextlevel) {
+    if (component_level_changed($capability, $component, $contextlevel)) {
+    //if ($capability->component != $component or $capability->contextlevel != $contextlevel) {
         echo ('<tr class="rolecapheading header"><td colspan="10" class="header"><strong>'.
                get_component_string($capability->component, $capability->contextlevel).'</strong></td></tr>');
     }
index 614163af784c46a7fb807b5cec74d7a5e82a702f..bdab5946a6ec00c483e9610d0121760f17754762 100755 (executable)
@@ -40,7 +40,8 @@
             }
 
         // prints a breaker if component or name or context level
-            if ($capability->component != $component or $capability->contextlevel != $contextlevel) {
+            //if ($capability->component != $component or $capability->contextlevel != $contextlevel) {
+            if (component_level_changed($capability, $component, $contextlevel)) {
                 echo ('<tr class="rolecapheading header"><td colspan="10" class="header"><strong>'.get_component_string($capability->component, $capability->contextlevel).'</strong></td></tr>');
             }
 
index 5dfb3071eafcb335c5c5ca03fd98f711f598b309..b73521f701c93172ed12d7675b7db97e5f69398f 100755 (executable)
@@ -3384,7 +3384,13 @@ function get_component_string($component, $contextlevel) {
         break;
 
         case CONTEXT_COURSE:
-            $string = get_string('course');
+            if (preg_match('|^gradeimport/|', $component) 
+                || preg_match('|^gradeexport/|', $component) 
+                || preg_match('|^gradereport/|', $component)) {
+                $string = get_string('gradebook', 'admin');  
+            } else {
+                $string = get_string('course');
+            }
         break;
 
         case CONTEXT_GROUP:
@@ -4179,4 +4185,36 @@ function rebuild_context_rel($context) {
     return $i;
 }
 
+/**
+ * This function helps admin/roles/manage.php etc to detect if a new line should be printed
+ * when we read in a new capability
+ * most of the time, if the 2 components are different we should print a new line, (e.g. course system->rss client)
+ * but when we are in grade, all reports/import/export capabilites should be together
+ * @param string a - component string a
+ * @param string b - component string b
+ * @return bool - whether 2 component are in different "sections"
+ */
+function component_level_changed($cap, $comp, $contextlevel) {
+
+    if ($cap->component == 'enrol/authorize' && $comp =='enrol/authorize') {
+        return false; 
+    }
+
+    if (strstr($cap->component, '/') && strstr($comp, '/')) {
+        $compsa = explode('/', $cap->component);
+        $compsb = explode('/', $comp);
+
+        
+
+        // we are in gradebook, still
+        if (($compsa[0] == 'gradeexport' || $compsa[0] == 'gradeimport' || $compsa[0] == 'gradereport') &&
+            ($compsb[0] == 'gradeexport' || $compsb[0] == 'gradeimport' || $compsb[0] == 'gradereport')) {
+            return false;
+        }    
+    }
+
+    return ($cap->component != $comp || $cap->contextlevel != $contextlevel);
+}
+
 ?>