Skip to content

Commit

Permalink
Performance boost for admins and editing teachers who teach several c…
Browse files Browse the repository at this point in the history
…ourses with NOGROUPS.

See bug 2804.
  • Loading branch information
defacer committed Apr 30, 2005
1 parent 1674313 commit 6976250
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions calendar/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1041,18 +1041,27 @@ function calendar_set_filters(&$courses, &$group, &$user, $courseeventsfrom = NU
}
else {
$grouparray = array();

$groupmodes = NULL;

// We already have the courses to examine in $courses
// For each course...
foreach($groupcourses as $courseid) {

// If the user is an editing teacher in there,
if(!empty($USER->id) && isteacheredit($courseid, $USER->id)) {
// Show events from all groups
if(($grouprecords = get_groups($courseid)) !== false) {

// The first time we get in here, retrieve all groupmodes at once
if($groupmodes === NULL) {
$groupmodes = get_records_list('course', 'id', implode(',', $groupcourses), '', 'id, groupmode');
}

// If this course has groups, show events from all of them
if($groupmodes[$courseid]->groupmode != NOGROUPS && ($grouprecords = get_groups($courseid)) !== false) {
$grouparray = array_merge($grouparray, array_keys($grouprecords));
}
}
// Otherwise show events from the group he is a member of

// Otherwise (not editing teacher) show events from the group he is a member of
else if(isset($USER->groupmember[$courseid])) {
$grouparray[] = $USER->groupmember[$courseid];
}
Expand Down

0 comments on commit 6976250

Please sign in to comment.