From 6c9584d1e55c7f76f5135ddc52eb1f73b7a00c25 Mon Sep 17 00:00:00 2001 From: defacer Date: Thu, 13 May 2004 10:32:12 +0000 Subject: [PATCH] Addressing bug 1384: Now if you are a teacher in a course, you now see ALL group events in that course. As a result, admins see group events for all courses. Maybe it needs more work than this, though. --- calendar/lib.php | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/calendar/lib.php b/calendar/lib.php index 9faf61f1ce..bf83720b69 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -1063,7 +1063,16 @@ function calendar_set_filters(&$courses, &$group, &$user, $defaultcourses = NULL if($SESSION->cal_show_groups) { if(is_int($groupcourses)) { // One course, whatever group the user is in that course - if(mygroupid($groupcourses)) { + if(isteacher($groupcourses, $USER->id)) { + $grouprecords = get_groups($groupcourses); + if($grouprecords === false) { + $group = false; + } + else { + $group = array_keys($grouprecords); + } + } + else if(mygroupid($groupcourses)) { $group = mygroupid($groupcourses); } else { @@ -1072,25 +1081,28 @@ function calendar_set_filters(&$courses, &$group, &$user, $defaultcourses = NULL } else if(is_array($groupcourses)) { // Many courses, we want all of them - if(empty($USER->groupmember)) { - $group = false; - } - else { - $grouparray = array(); - foreach ($USER->groupmember as $courseid => $mgroupid) { - if (array_key_exists($courseid, $groupcourses)) { - $grouparray[] = $mgroupid; + $grouparray = array(); + + // For each course... + foreach($groupcourses as $courseid => $dummy) { + // If the user is a teacher in there, + if(isteacher($courseid, $USER->id)) { + // Show events from all groups + if(($grouprecords = get_groups($courseid)) !== false) { + $grouparray = array_merge($grouparray, array_keys($grouprecords)); } } - if(!empty($grouparray)) { - // We got some groups at the least - $group = $grouparray; - } - else { - // No groups in these courses - $group = false; + // Otherwise show events from the group he is a member of + else if(isset($USER->groupmember[$courseid])) { + $grouparray[] = $USER->groupmember[$courseid]; } } + if(empty($grouparray)) { + $group = false; + } + else { + $group = $grouparray; + } } else if(is_bool($groupcourses)) { // Override -- 2.39.5