mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
fix for MDL-9617, calendar performance issues
This commit is contained in:
parent
3cb6bd2c35
commit
7a543c5cfb
2 changed files with 8 additions and 24 deletions
|
@ -1236,31 +1236,13 @@ 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) {
|
||||
if (!$context = get_context_instance(CONTEXT_COURSE, $courseid)) {
|
||||
continue;
|
||||
if (isset($CFG->adminseesall)) {
|
||||
return get_my_courses($USER->id, 'visible DESC', '*', $CFG->adminseesall);
|
||||
}
|
||||
// let's try to see if there is any direct assignments on this context
|
||||
// one can have multiple assignments
|
||||
// just use anyone that has something, or else use empty string
|
||||
// i am not even sure enrolment type is needed here, seems like only the array keys are needed
|
||||
// just keeping this code for safety
|
||||
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)) {
|
||||
$courses[$courseid] = $rs->enrol;
|
||||
break;
|
||||
else {
|
||||
return get_my_courses($USER->id, 'visible DESC', '*', false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $courses;
|
||||
}
|
||||
|
||||
function calendar_preferences_button() {
|
||||
global $CFG, $USER;
|
||||
|
|
|
@ -820,7 +820,9 @@ ORDER BY $sort");
|
|||
}
|
||||
}
|
||||
|
||||
if (!empty($USER->id) && ($USER->id == $userid)) {
|
||||
// MDL-9671, my courses should only get cached when '*' is chosen as the field, otherwise courses
|
||||
// can not be displayed properly as cached courses might contain missing course name etc
|
||||
if (!empty($USER->id) && ($USER->id == $userid) && $fields=='*') {
|
||||
$USER->mycourses[$doanything] = $mycourses;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue