From 48f508ab94191f5424dbeb59db268716693ac976 Mon Sep 17 00:00:00 2001 From: defacer Date: Tue, 20 Apr 2004 08:24:37 +0000 Subject: [PATCH] If group mode is no groups and forced, there is no point in displaying the group events filter. Just a nice touch, fixed only in course view for now. Also, minor code rewrite for clarification. --- calendar/lib.php | 106 ++++++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 51 deletions(-) diff --git a/calendar/lib.php b/calendar/lib.php index 5ebd883300..d4acd11ee0 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -560,65 +560,69 @@ function calendar_top_controls($type, $data) { function calendar_filter_controls($type) { global $CFG, $SESSION; - $content = ''; + $groupevents = true; switch($type) { - // A quick check reveals this is not used at all - // case 'upcoming': - // if(!isset($getvars)) { - // global $day, $mon, $yr; - // $getvars = 'from=upcoming&cal_d='.$day.'&cal_m='.$mon.'&cal_y='.$yr; - // } - case 'event': - if(!isset($getvars)) { - global $day, $mon, $yr; - $getvars = 'from=event&id='.$_GET['id']; - } - + global $day, $mon, $yr; + $getvars = 'from=event&id='.$_GET['id']; + break; case 'day': - if(!isset($getvars)) { - global $day, $mon, $yr; - $getvars = 'from=day&cal_d='.$day.'&cal_m='.$mon.'&cal_y='.$yr; - } - + global $day, $mon, $yr; + $getvars = 'from=day&cal_d='.$day.'&cal_m='.$mon.'&cal_y='.$yr; + break; case 'course': - if(!isset($getvars)) { - global $course; - $getvars = 'from=course&id='.$course->id; + global $course; + $getvars = 'from=course&id='.$course->id; + if($course->groupmode == NOGROUPS && $course->groupmodeforce) { + $groupevents = false; } + break; + } - $content .= ''; + $content = '
'; - $content .= ''; - if($SESSION->cal_show_global) { - $content .= ''."\n"; - } - else { - $content .= ''."\n"; - } - if($SESSION->cal_show_course) { - $content .= ''."\n"; - } - else { - $content .= ''."\n"; - } - $content .= "\n"; - $content .= ''; - if($SESSION->cal_show_groups) { - $content .= ''."\n"; - } - else { - $content .= ''."\n"; - } - if($SESSION->cal_show_user) { - $content .= ''."\n"; - } - else { - $content .= ''."\n"; - } - $content .= "\n
'.get_string('globalevents', 'calendar').''.get_string('globalevents', 'calendar').''.get_string('courseevents', 'calendar').''.get_string('courseevents', 'calendar').'
'.get_string('groupevents', 'calendar').''.get_string('groupevents', 'calendar').''.get_string('userevents', 'calendar').''.get_string('userevents', 'calendar').'
\n"; - break; + $content .= ''; + if($SESSION->cal_show_global) { + $content .= ''.get_string('globalevents', 'calendar').''."\n"; + } + else { + $content .= ''.get_string('globalevents', 'calendar').''."\n"; + } + if($SESSION->cal_show_course) { + $content .= ''.get_string('courseevents', 'calendar').''."\n"; } + else { + $content .= ''.get_string('courseevents', 'calendar').''."\n"; + } + $content .= "\n"; + $content .= ''; + + if($groupevents) { + // This course MIGHT have group events defined, so show the filter + if($SESSION->cal_show_groups) { + $content .= ''.get_string('groupevents', 'calendar').''."\n"; + } + else { + $content .= ''.get_string('groupevents', 'calendar').''."\n"; + } + if($SESSION->cal_show_user) { + $content .= ''.get_string('userevents', 'calendar').''."\n"; + } + else { + $content .= ''.get_string('userevents', 'calendar').''."\n"; + } + } + else { + // This course CANNOT have group events, so lose the filter + if($SESSION->cal_show_user) { + $content .= ''.get_string('userevents', 'calendar').''."\n"; + } + else { + $content .= ''.get_string('userevents', 'calendar').''."\n"; + } + } + $content .= "\n\n"; + return $content; } -- 2.39.5