More correct handling of group events, we cannot simply omit them because

the course has "no groups" UNLESS groupmodeforce == 1 as well.

Sadly, this severely weakens the performace optimizations :(

See bug 3303 for an example of what the problem was before.
This commit is contained in:
defacer
2005-05-30 12:40:44 +00:00
parent a0028106e3
commit 7bc4158521
2 changed files with 10 additions and 5 deletions
+7 -2
View File
@@ -596,8 +596,13 @@ function calendar_get_allowed_types(&$allowed) {
$allowed->site = isteacher(SITEID);
if(!empty($SESSION->cal_course_referer) && $SESSION->cal_course_referer != SITEID && isteacher($SESSION->cal_course_referer, $USER->id)) {
$allowed->courses = array($SESSION->cal_course_referer => 1);
$allowed->groups = get_groups($SESSION->cal_course_referer);
$course = get_record('course', 'id', $SESSION->cal_course_referer);
$allowed->courses = array($course->id => 1);
if($course->groupmode != NOGROUPS || !$course->groupmodeforce) {
$allowed->groups = get_groups($SESSION->cal_course_referer);
}
}
}
+3 -3
View File
@@ -642,7 +642,7 @@ function calendar_filter_controls($type, $vars = NULL, $course = NULL) {
} else {
$getvars = '&from=course';
}
if (isset($course->groupmode) and !$course->groupmode and $course->groupmodeforce) {
if (isset($course->groupmode) and $course->groupmode == NOGROUPS and $course->groupmodeforce) {
$groupevents = false;
}
break;
@@ -1055,11 +1055,11 @@ function calendar_set_filters(&$courses, &$group, &$user, $courseeventsfrom = NU
// 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');
$groupmodes = get_records_list('course', 'id', implode(',', $groupcourses), '', 'id, groupmode, groupmodeforce');
}
// If this course has groups, show events from all of them
if(isset($groupmodes[$courseid]) && $groupmodes[$courseid]->groupmode != NOGROUPS && ($grouprecords = get_groups($courseid)) !== false) {
if(isset($groupmodes[$courseid]) && ($groupmodes[$courseid]->groupmode != NOGROUPS || !$groupmodes[$courseid]->groupmodeforce) && ($grouprecords = get_groups($courseid)) !== false) {
$grouparray = array_merge($grouparray, array_keys($grouprecords));
}
}