]> git.mjollnir.org Git - moodle.git/commitdiff
Some changes to GROUP BY clause to be cross-db (all non aggregate fields
authorstronk7 <stronk7>
Fri, 12 Jan 2007 12:57:50 +0000 (12:57 +0000)
committerstronk7 <stronk7>
Fri, 12 Jan 2007 12:57:50 +0000 (12:57 +0000)
in SELECT must be in GROUP BY). Review the logic! MDL-8160

lib/accesslib.php

index cd0f7ebd2a84712169ab157ff4f9fdfb2c7c6d71..f5bf96eb8144b51c2f0a0dc87e27b23daac6084b 100755 (executable)
@@ -706,6 +706,7 @@ function roles_context_cmp($contexta, $contextb) {
 function load_user_capability($capability='', $context = NULL, $userid='') {
 
     global $USER, $CFG;
+
     // this flag has not been set! 
     // (not clean install, or upgraded successfully to 1.7 and up)
     if (empty($CFG->rolesactive)) {
@@ -794,7 +795,7 @@ function load_user_capability($capability='', $context = NULL, $userid='') {
                      $capsearch
                      $timesql
               GROUP BY
-                     rc.capability, c1.id
+                     rc.capability, c1.id, c1.contextlevel * 100
                      HAVING
                      SUM(rc.permission) != 0          
             
@@ -816,7 +817,7 @@ function load_user_capability($capability='', $context = NULL, $userid='') {
                      $timesql
                      AND cr.c2 = c1.id
               GROUP BY
-                     rc.capability, id1, id2
+                     rc.capability, c1.id, c2.id, c1.contextlevel * 100 + c2.contextlevel
                      HAVING
                      SUM(rc.permission) != 0
               ORDER BY
@@ -3480,4 +3481,4 @@ function build_context_rel() {
         }
     } 
 }
-?>
\ No newline at end of file
+?>