Permalink
Browse files

fix for MDL-8589, found more than one record in get_record_sql

  • Loading branch information...
1 parent ef06f7f commit 92d3d576fb11ce362b6d457c3b9ac641a44561ba moodler committed Mar 6, 2007
Showing with 16 additions and 6 deletions.
  1. +16 −6 calendar/lib.php
View
@@ -1223,12 +1223,22 @@ function calendar_get_default_courses($ignoreref = false) {
// find all course this student can view
if ($allcourses = get_my_courses($USER->id,'visible DESC,sortorder ASC', '*', true)) {
foreach ($allcourses as $courseid=>$acourse) {
+ $auth = '';
$context = get_context_instance(CONTEXT_COURSE, $courseid);
- // let's try to see if there is any direct assignments on tihs context
- if ($roleassign = get_record('role_assignments', 'contextid', $context->id, 'userid', $USER->id)) {
- $courses[$courseid] = $roleassign->enrol;
- }
- }
+ if ($roleassign = get_records_sql("SELECT * FROM {$CFG->prefix}role_assignments
+ WHERE contextid = $context->id
+ AND userid = $USER->id")) {
+ foreach ($roleassign as $rid => $rs) {
+ if (!empty($rs->enrol)) {
+ $auth = $rs->enrol;
+ break;
+ }
+ }
+ } else {
+ $auth = '';
+ }
+ $courses[$courseid] = $auth;
+ }
}
return $courses;
@@ -1354,4 +1364,4 @@ function calendar_set_filters_status($packed_bitfield) {
return true;
}
-?>
+?>

0 comments on commit 92d3d57

Please sign in to comment.