]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-13229 - Cannot export group events - now make it export group events if 'all...
authortjhunt <tjhunt>
Thu, 19 Jun 2008 17:57:57 +0000 (17:57 +0000)
committertjhunt <tjhunt>
Thu, 19 Jun 2008 17:57:57 +0000 (17:57 +0000)
calendar/export_execute.php

index 001a2c12f165c318e5da852237eadffe2dd60ac0..e2cd72c5b3491309752d7268b1cbd70bce44a07a 100644 (file)
@@ -30,12 +30,19 @@ $allowed_time = array('weeknow', 'weeknext', 'monthnow', 'monthnext', 'recentupc
 if(!empty($what) && !empty($time)) {
     if(in_array($what, $allowed_what) && in_array($time, $allowed_time)) {
         $courses = get_my_courses($user->id, NULL, 'id, visible, shortname');
-        
-        $include_user = ($what == 'all');
-        if ($include_user) {
-            //Also include site (global) events
+
+        if ($what == 'all') {
+            $users = $user->id;
+            $groups = array();
+            foreach ($courses as $course) {
+                $course_groups = groups_get_all_groups($course->id, $user->id);
+                $groups = $groups + array_keys($course_groups);
+            }
             $courses[SITEID] = new stdClass;
             $courses[SITEID]->shortname = get_string('globalevents', 'calendar');
+        } else {
+            $users = false;
+            $groups = false;
         }
 
         switch($time) {
@@ -99,7 +106,7 @@ if(!empty($what) && !empty($time)) {
         die();
     }
 }
-$events = calendar_get_events($timestart, $timeend, $include_user ? array($user->id) : false, false, array_keys($courses), false);
+$events = calendar_get_events($timestart, $timeend, $users, $groups, array_keys($courses), false);
 
 $ical = new iCalendar;
 $ical->add_property('method', 'PUBLISH');