]> git.mjollnir.org Git - moodle.git/commitdiff
Addressing bug 1384:
authordefacer <defacer>
Thu, 13 May 2004 10:32:12 +0000 (10:32 +0000)
committerdefacer <defacer>
Thu, 13 May 2004 10:32:12 +0000 (10:32 +0000)
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

index 9faf61f1ce74eef10aa8bf5c67efcad28890e8dd..bf83720b691cf5d3aa1bb30c0f6e2b7cb7474a6d 100644 (file)
@@ -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