From: defacer Date: Thu, 20 May 2004 15:16:42 +0000 (+0000) Subject: Major calendar overhaul: X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=43c3ffbe2207afed3260097fd22f9ef3ebf40fa2;p=moodle.git Major calendar overhaul: 1. Much better and more intuitive handling of filters. 2. Simplified user interface for guests. 3. Feature request implemented: bug #1431 4. A number of significant bugfixes --- diff --git a/blocks/calendar_month/block_calendar_month.php b/blocks/calendar_month/block_calendar_month.php index 60b68c51cf..f8997f0f37 100644 --- a/blocks/calendar_month/block_calendar_month.php +++ b/blocks/calendar_month/block_calendar_month.php @@ -26,21 +26,16 @@ class CourseBlock_calendar_month extends MoodleBlock { if($this->course === NULL) { // Overrides: use no course at all $courseshown = false; - $defaultcourses = NULL; + $filtercourse = array(); } else { $courseshown = $this->course->id; - $defaultcourses = array($courseshown => 1); + $filtercourse = array($courseshown => 1); } // We 'll need this later calendar_set_referring_course($courseshown); - if($courseshown !== false && $SESSION->cal_show_course !== false) { - // By default, the course filter will show this course only - $SESSION->cal_show_course = $courseshown; - } - // [pj] Let's leave this in, the above may not be the final solution /* if($courseshown !== false && is_int($SESSION->cal_show_course) && $SESSION->cal_show_course != $courseshown) { @@ -58,7 +53,7 @@ class CourseBlock_calendar_month extends MoodleBlock { // Be VERY careful with the format for default courses arguments! // Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions. - calendar_set_filters($courses, $group, $user, $defaultcourses, $defaultcourses); + calendar_set_filters($courses, $group, $user, $filtercourse, $filtercourse); if($courseshown == 1) { // For the front page diff --git a/blocks/calendar_upcoming/block_calendar_upcoming.php b/blocks/calendar_upcoming/block_calendar_upcoming.php index 01b57389d1..45ae6a750e 100644 --- a/blocks/calendar_upcoming/block_calendar_upcoming.php +++ b/blocks/calendar_upcoming/block_calendar_upcoming.php @@ -27,39 +27,20 @@ class CourseBlock_calendar_upcoming extends MoodleBlock { if($this->course === NULL) { // Overrides: use no course at all $courseshown = false; - $defaultcourses = NULL; + $filtercourse = array(); } else { $courseshown = $this->course->id; - $defaultcourses = array($courseshown => 1); + $filtercourse = array($courseshown => 1); } // We 'll need this later calendar_set_referring_course($courseshown); - if($courseshown !== false && $SESSION->cal_show_course !== false) { - // By default, the course filter will show this course only - $SESSION->cal_show_course = $courseshown; - } - - // [pj] Let's leave this in, the above may not be the final solution - /* - if($courseshown !== false && is_int($SESSION->cal_show_course) && $SESSION->cal_show_course != $courseshown) { - // There is a filter in action that shows events from a course other than the current - // Change it to show only the current course - $SESSION->cal_show_course = $courseshown; - } - else if($courseshown !== false && is_array($SESSION->cal_show_course) && !in_array($courseshown, $SESSION->cal_show_course)) { - // Same as above, only there are many courses being shown. Unfortunately, not this one. - // Change it to show only the current course - $SESSION->cal_show_course = $courseshown; - } - */ - // Be VERY careful with the format for default courses arguments! // Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions. - calendar_set_filters($courses, $group, $user, $defaultcourses, $defaultcourses); + calendar_set_filters($courses, $group, $user, $filtercourse, $filtercourse, false); $this->content->text = calendar_get_sideblock_upcoming($courses, $group, $user, get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS), get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS)); diff --git a/calendar/i/event.gif b/calendar/i/event.gif new file mode 100644 index 0000000000..a827d8b522 Binary files /dev/null and b/calendar/i/event.gif differ diff --git a/calendar/lib.php b/calendar/lib.php index 3362e6f82b..5927bb7b39 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -170,7 +170,7 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y $popupcontent .= '
modpixpath.'/'.$events[$eventid]->modulename.'/icon.gif\\\' style=\\\'vertical-align: middle; margin-right: 4px;\\\' alt=\\\''.$events[$eventid]->modulename.'\\\' />id.'\\\'>'.addslashes(htmlspecialchars($events[$eventid]->name)).'
'; } else { - $popupcontent .= '
id.'\\\'>'.addslashes(htmlspecialchars($events[$eventid]->name)).'
'; + $popupcontent .= '
wwwroot.'/calendar/i/event.gif\\\' style=\\\'vertical-align: middle; margin-right: 4px;\\\' alt=\\\'\\\' />id.'\\\'>'.addslashes(htmlspecialchars($events[$eventid]->name)).'
'; } } @@ -363,7 +363,7 @@ function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxeve $eventtype = get_string($event->eventtype, $event->modulename); $icon = $CFG->modpixpath.'/'.$event->modulename.'/icon.gif'; $output[$outkey]->referer = ''.$event->name.''; - $output[$outkey]->icon = ''; + $output[$outkey]->icon = ''; $output[$outkey]->name = $event->name; $output[$outkey]->time = $eventtime; $output[$outkey]->description = $event->description; @@ -372,7 +372,7 @@ function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxeve // Global event global $site; $output[$outkey]->referer = ''.$site->shortname.''; - $output[$outkey]->icon = ''; + $output[$outkey]->icon = ''; $output[$outkey]->name = $event->name; $output[$outkey]->time = $eventtime; $output[$outkey]->description = $event->description; @@ -382,21 +382,21 @@ function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxeve calendar_get_course_cached($coursecache, $event->courseid); $output[$outkey]->referer = ''.$coursecache[$event->courseid]->fullname.''; - $output[$outkey]->icon = ''; + $output[$outkey]->icon = ''; $output[$outkey]->name = $event->name; $output[$outkey]->time = $eventtime; $output[$outkey]->description = $event->description; } else if($event->groupid) { // Group event - $output[$outkey]->icon = ''; + $output[$outkey]->icon = ''; $output[$outkey]->name = $event->name; $output[$outkey]->time = $eventtime; $output[$outkey]->description = $event->description; - } + } else if($event->userid) { // User event - $output[$outkey]->icon = ''; + $output[$outkey]->icon = ''; $output[$outkey]->name = $event->name; $output[$outkey]->time = $eventtime; $output[$outkey]->description = $event->description; @@ -511,20 +511,7 @@ function calendar_top_controls($type, $data) { $content .= ''; break; case 'upcoming': - // A quick check reveals that this is not used at all - /* - list($prevmonth, $prevyear) = calendar_sub_month($data['m'], $data['y']); - list($nextmonth, $nextyear) = calendar_add_month($data['m'], $data['y']); - $prevdate = getdate(calendar_mktime_check($prevmonth, 1, $prevyear)); - $nextdate = getdate(calendar_mktime_check($nextmonth, 1, $nextyear)); - $prevname = calendar_month_name($prevdate['month']); - $nextname = calendar_month_name($nextdate['month']); - $content .= "\n"; - $content .= ''.$prevname.' '.$prevyear."\n"; - $content .= ''.$monthname.' '.$data['y']."\n"; - $content .= ''.$nextname.' '.$nextyear."\n"; - $content .= "\n"; - */ + $content .= '
'.strftime(get_string('strftimemonthyear'), $time)."
\n"; break; case 'display': $content .= '
'.strftime(get_string('strftimemonthyear'), $time)."
\n"; @@ -568,7 +555,7 @@ function calendar_top_controls($type, $data) { } function calendar_filter_controls($type, $vars = NULL) { - global $CFG, $SESSION; + global $CFG, $SESSION, $USER; $groupevents = true; @@ -616,31 +603,33 @@ function calendar_filter_controls($type, $vars = NULL) { 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"; + if(!isguest($USER->id)) { + $content .= "\n"; + + 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 { - $content .= ''.get_string('userevents', 'calendar').''."\n"; + // 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"; @@ -767,7 +756,7 @@ function calendar_get_sideblock_upcoming($courses, $groups, $users, $daysinfutur for ($i = 0; $i < $lines; ++$i) { $content .= '
'.$events[$i]->icon.' '; - if (!empty($events[$i]->icon)) { + if (!empty($events[$i]->referer)) { // That's an activity event, so let's provide the hyperlink $content .= $events[$i]->referer; } else { @@ -901,6 +890,9 @@ function calendar_session_vars() { if(!isset($SESSION->cal_show_user)) { $SESSION->cal_show_user = $USER->id; } + if(empty($SESSION->cal_courses_shown)) { + $SESSION->cal_courses_shown = calendar_get_default_courses(true); + } } function calendar_overlib_html() { @@ -913,143 +905,43 @@ function calendar_overlib_html() { return $html; } -// OBSOLETE, now that we have the blocks system in place. -// Keeping it for a few revisions, just in case. -/* -function calendar_print_side_blocks($forcecourse = NULL) { - // WARNING: Keep in mind that using $forcecourse will override the $SESSION - // filters, and thus not respect the user's filter settings. Use it sparingly. - - global $USER, $CFG, $SESSION, $course; - optional_variable($_GET['cal_m']); - optional_variable($_GET['cal_y']); - - calendar_session_vars(); - - if(is_int($forcecourse)) { - // Overrides the course to use - $courseshown = $forcecourse; - $defaultcourses = array($courseshown => 1); - } - else if($forcecourse === false) { - // Overrides: use no course at all - $courseshown = false; - $defaultcourses = NULL; - } - else { - // Normal behavior: use displayed course, or front page if no course - $courseshown = ($course === NULL) ? 1 : $course->id; - $defaultcourses = array($courseshown => 1); - } - - // I 'm not really sure if this belongs here... - calendar_set_referring_course($courseshown); - - if($courseshown !== false && is_int($SESSION->cal_show_course) && $SESSION->cal_show_course != $courseshown) { - // There is a filter in action that shows events from a course other than the current - // Obviously we have to cut it out - $SESSION->cal_show_course = true; - } - else if($courseshown !== false && is_array($SESSION->cal_show_course) && !in_array($courseshown, $SESSION->cal_show_course)) { - // Same as above, only there are many courses being shown. Unfortunately, not this one. - $SESSION->cal_show_course = true; - } - - // Be VERY careful with the format for default courses arguments! - // Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions. - - calendar_set_filters($courses, $group, $user, $defaultcourses, $defaultcourses); - - if(get_user_preferences('calendar_showmonth', true)) { - if($courseshown == 1) { - // For the front page - echo calendar_overlib_html(); - print_side_block_start(get_string('calendar', 'calendar')); - echo calendar_top_controls('frontpage', array('m' => $_GET['cal_m'], 'y' => $_GET['cal_y'])); - echo calendar_get_mini($courses, $group, $user, $_GET['cal_m'], $_GET['cal_y']); - // No filters for now - print_side_block_end(); - } - else { - // For any other course - echo calendar_overlib_html(); - print_side_block_start(get_string('calendar', 'calendar')); - echo calendar_top_controls('course', array('id' => $courseshown, 'm' => $_GET['cal_m'], 'y' => $_GET['cal_y'])); - echo calendar_get_mini($courses, $group, $user, $_GET['cal_m'], $_GET['cal_y']); - echo calendar_filter_controls('course'); - print_side_block_end(); - } - } - if(get_user_preferences('calendar_showupcoming', true)) { - $block = calendar_get_sideblock_upcoming($courses, $group, $user, get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS), get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS)); - if(!empty($block)) { - print_side_block_start(get_string('upcomingevents', 'calendar')); - echo $block; - print_side_block_end(); - } - } -} -*/ - function calendar_set_referring_course($courseid) { global $SESSION; $SESSION->cal_course_referer = intval($courseid); } -function calendar_set_filters(&$courses, &$group, &$user, $defaultcourses = NULL, $groupcourses = NULL) { +function calendar_set_filters(&$courses, &$group, &$user, $courseeventsfrom = NULL, $groupeventsfrom = NULL, $ignorefilters = false) { global $SESSION, $USER; - // WARNING: When calling this function, be VERY careful with the format for default courses arguments! - // Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions. - - // Insidious bug-wannabe: setting $SESSION->cal_show_course to $course->id would cause + // Insidious bug-wannabe: setting $SESSION->cal_courses_shown to $course->id would cause // the code to function incorrectly UNLESS we convert it to an integer. One case where // PHP's loose type system works against us. - if(is_string($SESSION->cal_show_course)) { - $SESSION->cal_show_course = intval($SESSION->cal_show_course); + if(is_string($SESSION->cal_courses_shown)) { + $SESSION->cal_courses_shown = intval($SESSION->cal_courses_shown); } - $showcourse = ( - (is_int($SESSION->cal_show_course) && $SESSION->cal_show_course) || - (is_array($SESSION->cal_show_course) && count($SESSION->cal_show_course)) || - ($SESSION->cal_show_course === true) - ); - - if($defaultcourses === NULL) { - $defaultcourses = array(); - } - if($groupcourses === NULL) { - $groupcourses = array(); + if($courseeventsfrom === NULL) { + $courseeventsfrom = $SESSION->cal_courses_shown; } - - if(is_array($defaultcourses) && array_key_exists(1, $defaultcourses)) { - // This should never happen, so let's be sure just in case - $defaultcourses = array_diff_assoc($defaultcourses, array(1 => 1)); + if($groupeventsfrom === NULL) { + $groupeventsfrom = $SESSION->cal_courses_shown; } - if($showcourse && $SESSION->cal_show_global) { - if(is_int($SESSION->cal_show_course)) { - $courses = array(1, $SESSION->cal_show_course); + if(($SESSION->cal_show_course && $SESSION->cal_show_global) || $ignorefilters) { + if(is_int($courseeventsfrom)) { + $courses = array(1, $courseeventsfrom); } - else if(is_array($SESSION->cal_show_course)) { - $courses = array(1) + $SESSION->cal_show_course; - - } - else { - $courses = array_keys($defaultcourses); + else if(is_array($courseeventsfrom)) { + $courses = array_keys($courseeventsfrom); $courses[] = 1; } } - else if($showcourse) { - if(is_int($SESSION->cal_show_course)) { - $courses = array($SESSION->cal_show_course); + else if($SESSION->cal_show_course) { + if(is_int($courseeventsfrom)) { + $courses = array($courseeventsfrom); } - else if(is_array($SESSION->cal_show_course)) { - $courses = $SESSION->cal_show_course; - } - else { - $courses = array_keys($defaultcourses); - if(empty($courses)) $courses = false; + else if(is_array($courseeventsfrom)) { + $courses = array_keys($courseeventsfrom); } } else if($SESSION->cal_show_global) { @@ -1059,7 +951,7 @@ function calendar_set_filters(&$courses, &$group, &$user, $defaultcourses = NULL $courses = false; } - if($SESSION->cal_show_user) { + if($SESSION->cal_show_user || $ignorefilters) { // This ignores the "which user to see" setting // The functionality to do that does exist, but this was // the most painless way to solve bug 1323. And anyway, @@ -1070,57 +962,35 @@ function calendar_set_filters(&$courses, &$group, &$user, $defaultcourses = NULL else { $user = false; } - if($SESSION->cal_show_groups) { - if(is_int($groupcourses)) { - // One course, whatever group the user is in that course - 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 { - $group = false; - } + if($SESSION->cal_show_groups || $ignorefilters) { + if(is_int($groupeventsfrom)) { + $groupcourses = array($groupeventsfrom); } - else if(is_array($groupcourses)) { - // Many courses, we want all of them - $grouparray = array(); - - // For each course... - foreach($groupcourses as $courseid => $dummy) { - // If the user is an editing teacher in there, - if(isteacheredit($courseid, $USER->id)) { - // Show events from all groups - if(($grouprecords = get_groups($courseid)) !== false) { - $grouparray = array_merge($grouparray, array_keys($grouprecords)); - } - } - // Otherwise show events from the group he is a member of - else if(isset($USER->groupmember[$courseid])) { - $grouparray[] = $USER->groupmember[$courseid]; + else if(is_array($groupeventsfrom)) { + $groupcourses = array_keys($groupeventsfrom); + } + $grouparray = array(); + + // We already have the courses to examine in $courses + // For each course... + foreach($groupcourses as $courseid) { + // If the user is an editing teacher in there, + if(isteacheredit($courseid, $USER->id)) { + // Show events from all groups + if(($grouprecords = get_groups($courseid)) !== false) { + $grouparray = array_merge($grouparray, array_keys($grouprecords)); } } - if(empty($grouparray)) { - $group = false; - } - else { - $group = $grouparray; + // Otherwise show events from the group he is a member of + else if(isset($USER->groupmember[$courseid])) { + $grouparray[] = $USER->groupmember[$courseid]; } } - else if(is_bool($groupcourses)) { - // Override - $group = $groupcourses; + if(empty($grouparray)) { + $group = false; } else { - // Sanity - $group = false; + $group = $grouparray; } } else { diff --git a/calendar/set.php b/calendar/set.php index 5cf05ea80a..842ce75852 100644 --- a/calendar/set.php +++ b/calendar/set.php @@ -55,25 +55,21 @@ case 'setcourse': $id = intval($_GET['id']); if($id == 0) { - $SESSION->cal_show_course = false; + $SESSION->cal_courses_shown = array(); } else if($id == 1) { - $SESSION->cal_show_course = true; + $SESSION->cal_courses_shown = calendar_get_default_courses(true); } - else if(isstudent($id, $USER->id) || isteacher($id, $USER->id)) { - $SESSION->cal_show_course = $id; + else { + // We don't check for membership anymore: if(isstudent($id, $USER->id) || isteacher($id, $USER->id)) { + $SESSION->cal_courses_shown = $id; } break; case 'showgroups': $SESSION->cal_show_groups = !$SESSION->cal_show_groups; break; case 'showcourses': - if(empty($SESSION->cal_show_course)) { - $SESSION->cal_show_course = calendar_get_default_courses(); - } - else { - $SESSION->cal_show_course = false; - } + $SESSION->cal_show_course = !$SESSION->cal_show_course; break; case 'showglobal': $SESSION->cal_show_global = !$SESSION->cal_show_global; diff --git a/calendar/view.php b/calendar/view.php index 33704907e2..16b07823e1 100644 --- a/calendar/view.php +++ b/calendar/view.php @@ -94,6 +94,20 @@ break; } + if(isguest($USER->id)) { + $defaultcourses = calendar_get_default_courses(); + calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses); + } + else { + if($_GET['view'] == 'upcoming') { + $defaultcourses = calendar_get_default_courses(); + calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses, false); + } + else { + calendar_set_filters($courses, $groups, $users); + } + } + // Let's see if we are supposed to provide a referring course link // but NOT for the "main page" course if($SESSION->cal_course_referer > 1 && @@ -103,7 +117,6 @@ } $strcalendar = get_string('calendar', 'calendar'); - $prefsbutton = calendar_preferences_button(); // Print title and header @@ -120,37 +133,6 @@ echo ''; - if($_GET['view'] == 'month') { - if(is_numeric($SESSION->cal_show_course)) { - $defaultcourses = array($SESSION->cal_show_course => 1); - } - else if($SESSION->cal_show_course === true) { - $defaultcourses = calendar_get_default_courses(true); - } - else if($SESSION->cal_show_course === false) { - $defaultcourses = array(); - } - } - else { - $defaultcourses = calendar_get_default_courses(); - } - - $courses = array(); - - calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses); -/* - // Are we left with a bad filter in effect? - if($_GET['view'] != 'month' && !empty($SESSION->cal_course_referer)) { - if(is_numeric($SESSION->cal_show_course)) { - if($SESSION->cal_course_referer != $SESSION->cal_show_course) { - $SESSION->cal_show_course = intval($SESSION->cal_course_referer); - } - } - if(is_array($SESSION->cal_show_course) && !in_array($SESSION->cal_course_referer, $SESSION->cal_show_course)) { - $SESSION->cal_show_course = intval($SESSION->cal_course_referer); - } - } -*/ switch($_GET['view']) { case 'event': optional_variable($_GET['id'], 0); @@ -368,6 +350,34 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) { } print_side_block_start($text, '', 'mycalendar'); + + if(isadmin($USER->id)) { + $coursesdata = get_courses('all', 'c.shortname'); + } + elseif(!isguest($USER->id)) { + $coursesdata = get_my_courses($USER->id, 'shortname'); + } + else { + $coursesdata = get_record('course', 'id', $SESSION->cal_course_referer); + } + $coursesdata = array_diff_assoc($coursesdata, array(1 => 1)); + + if(!isguest($USER->id)) { + echo '

'.get_string('eventsfromcourse', 'calendar').': '; + echo '

'; + } + echo calendar_top_controls('month', array('m' => $m, 'y' => $y)); // Start calendar display @@ -502,58 +512,41 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) { echo get_string('hidden', 'calendar').' ('.get_string('clickshow', 'calendar').')'."\n"; } - // Course events (this is kinda... tricky... :) - echo 'cal_show_course !== false) { - echo 'class="cal_event_course" '; - } - echo 'style="width: 8px;">'.get_string('courseevents', 'calendar').': '; - - if(isadmin($USER->id)) { - $coursesdata = get_courses('all', 'c.shortname'); + // Course events + if(!empty($SESSION->cal_show_course)) { + echo ''.get_string('courseevents', 'calendar').': '; + echo get_string('shown', 'calendar').' ('.get_string('clickhide', 'calendar').')'."\n"; } else { - $coursesdata = get_my_courses($USER->id, 'shortname'); + echo ''.get_string('courseevents', 'calendar').': '; + echo get_string('hidden', 'calendar').' ('.get_string('clickshow', 'calendar').')'."\n"; } - $coursesdata = array_diff_assoc($coursesdata, array(1 => 1)); - echo ''; - echo ''; echo "\n"; - echo ''; - // Group events - if($SESSION->cal_show_groups) { - echo ''.get_string('groupevents', 'calendar').': '; - echo get_string('shown', 'calendar').' ('.get_string('clickhide', 'calendar').')'."\n"; - } - else { - echo ''.get_string('groupevents', 'calendar').': '; - echo get_string('hidden', 'calendar').' ('.get_string('clickshow', 'calendar').')'."\n"; - } - // User events - if($SESSION->cal_show_user) { - echo ''.get_string('userevents', 'calendar').': '; - echo get_string('shown', 'calendar').' ('.get_string('clickhide', 'calendar').')'."\n"; - } - else { - echo ''.get_string('userevents', 'calendar').': '; - echo get_string('hidden', 'calendar').' ('.get_string('clickshow', 'calendar').')'."\n"; + if(!isguest($USER->id)) { + echo ''; + // Group events + if($SESSION->cal_show_groups) { + echo ''.get_string('groupevents', 'calendar').': '; + echo get_string('shown', 'calendar').' ('.get_string('clickhide', 'calendar').')'."\n"; + } + else { + echo ''.get_string('groupevents', 'calendar').': '; + echo get_string('hidden', 'calendar').' ('.get_string('clickshow', 'calendar').')'."\n"; + } + // User events + if($SESSION->cal_show_user) { + echo ''.get_string('userevents', 'calendar').': '; + echo get_string('shown', 'calendar').' ('.get_string('clickhide', 'calendar').')'."\n"; + } + else { + echo ''.get_string('userevents', 'calendar').': '; + echo get_string('hidden', 'calendar').' ('.get_string('clickshow', 'calendar').')'."\n"; + } + echo "\n"; } - echo "\n"; echo '
'; print_side_block_end(); }