]> git.mjollnir.org Git - moodle.git/commitdiff
My Moodle/Courses: MDL-20472 get_my_courses returns 2 more courses then limit. Repair...
authorericmerrill <ericmerrill>
Thu, 8 Oct 2009 04:52:33 +0000 (04:52 +0000)
committerericmerrill <ericmerrill>
Thu, 8 Oct 2009 04:52:33 +0000 (04:52 +0000)
lib/accesslib.php
lib/datalib.php

index a9bb58004231c11aa11ff6b95cba5a26fea7a11a..2feb7412fdc12bf0a7c00a1dfdd196648e8505b5 100755 (executable)
@@ -1281,10 +1281,12 @@ function get_user_courses_bycap($userid, $cap, $accessdata, $doanything, $sort='
             $c = make_context_subobj($c);
 
             if (has_capability_in_accessdata($cap, $c->context, $accessdata, $doanything)) {
-                $courses[] = $c;
-                if ($limit > 0 && $cc++ > $limit) {
+                if ($limit > 0 && $cc >= $limit) {
                     break;
                 }
+                
+                $courses[] = $c;
+                $cc++;
             }
         }
         $rs->close();
index adfd7d777b5e92dd286f5725fb50209c26387e5b..4301d6df15bc4b8f4a8a7a63840056a91f3b562c 100644 (file)
@@ -926,10 +926,12 @@ function get_my_courses($userid, $sort='visible DESC,sortorder ASC', $fields=NUL
                 // build the context obj
                 $c = make_context_subobj($c);
 
-                $courses[$c->id] = $c;
-                if ($limit > 0 && $cc++ > $limit) {
+                if ($limit > 0 && $cc >= $limit) {
                     break;
                 }
+                
+                $courses[$c->id] = $c;
+                $cc++;
             }
             $rs->close();
             return $courses;