/i/ical.gif" height="14" width="36" ' .'alt="'.get_string('ical', 'calendar').'" ' .'title="'.get_string('quickdownloadcalendar', 'calendar').'" />' .''; } } echo ''; echo ''; echo ''; // END: Main column // START: Last column (3-month display) echo ''; list($prevmon, $prevyr) = calendar_sub_month($mon, $yr); list($nextmon, $nextyr) = calendar_add_month($mon, $yr); $getvars = 'id='.$courseid.'&cal_d='.$day.'&cal_m='.$mon.'&cal_y='.$yr; // For filtering echo '
'; echo '

'.get_string('eventskey', 'calendar').'

'; echo '
'; echo calendar_filter_controls($view, $getvars, NULL, $courses); echo '
'; echo '
'; echo '
'; echo '

'.get_string('monthlyview', 'calendar').'

'; echo '
'; echo calendar_top_controls('display', array('id' => $courseid, 'm' => $prevmon, 'y' => $prevyr)); echo calendar_get_mini($courses, $groups, $users, $prevmon, $prevyr); echo '
'; echo calendar_top_controls('display', array('id' => $courseid, 'm' => $mon, 'y' => $yr)); echo calendar_get_mini($courses, $groups, $users, $mon, $yr); echo '
'; echo calendar_top_controls('display', array('id' => $courseid, 'm' => $nextmon, 'y' => $nextyr)); echo calendar_get_mini($courses, $groups, $users, $nextmon, $nextyr); echo '
'; echo '
'; echo ''; echo ''; print_footer(); function calendar_show_day($d, $m, $y, $courses, $groups, $users, $courseid) { global $CFG, $USER; if (!checkdate($m, $d, $y)) { $now = usergetdate(time()); list($d, $m, $y) = array(intval($now['mday']), intval($now['mon']), intval($now['year'])); } $getvars = 'from=day&cal_d='.$d.'&cal_m='.$m.'&cal_y='.$y; // For filtering $starttime = make_timestamp($y, $m, $d); $endtime = make_timestamp($y, $m, $d + 1) - 1; $events = calendar_get_upcoming($courses, $groups, $users, 1, 100, $starttime); $text = ''; if (!isguest() && !empty($USER->id) && calendar_user_can_add_event()) { $text.= '
'; $text.= '
'; $text.= '
'; $text.= ''; $text.= ''; $text.= ''; $text.= ''; $text.= ''; $text.= ''; $text.= '
'; } $text .= ''. calendar_course_filter_selector($getvars); echo '
'.$text.'
'; echo '
'.calendar_top_controls('day', array('id' => $courseid, 'd' => $d, 'm' => $m, 'y' => $y)).'
'; if (empty($events)) { // There is nothing to display today. echo '

'.get_string('daywithnoevents', 'calendar').'

'; } else { echo '
'; $underway = array(); // First, print details about events that start today foreach ($events as $event) { $event->calendarcourseid = $courseid; if ($event->timestart >= $starttime && $event->timestart <= $endtime) { // Print it now /* $dayend = calendar_day_representation($event->timestart + $event->timeduration); $timeend = calendar_time_representation($event->timestart + $event->timeduration); $enddate = usergetdate($event->timestart + $event->timeduration); // Set printable representation echo calendar_get_link_tag($dayend, CALENDAR_URL.'view.php?view=day'.$morehref.'&', $enddate['mday'], $enddate['mon'], $enddate['year']).' ('.$timeend.')'; */ //unset($event->time); $event->time = calendar_format_event_time($event, time(), '', false, $starttime); calendar_print_event($event); } else { // Save this for later $underway[] = $event; } } // Then, show a list of all events that just span this day if (!empty($underway)) { echo '

'.get_string('spanningevents', 'calendar').':

'; foreach ($underway as $event) { $event->time = calendar_format_event_time($event, time(), '', false, $starttime); calendar_print_event($event); } } echo '
'; } } function calendar_show_month_detailed($m, $y, $courses, $groups, $users, $courseid) { global $CFG, $SESSION, $USER, $CALENDARDAYS; global $day, $mon, $yr; $getvars = 'from=month&cal_d='.$day.'&cal_m='.$mon.'&cal_y='.$yr; // For filtering $display = &New stdClass; $display->minwday = get_user_preferences('calendar_startwday', CALENDAR_STARTING_WEEKDAY); $display->maxwday = $display->minwday + 6; if(!empty($m) && !empty($y)) { $thisdate = usergetdate(time()); // Time and day at the user's location if($m == $thisdate['mon'] && $y == $thisdate['year']) { // Navigated to this month $date = $thisdate; $display->thismonth = true; } else { // Navigated to other month, let's do a nice trick and save us a lot of work... if(!checkdate($m, 1, $y)) { $date = array('mday' => 1, 'mon' => $thisdate['mon'], 'year' => $thisdate['year']); $display->thismonth = true; } else { $date = array('mday' => 1, 'mon' => $m, 'year' => $y); $display->thismonth = false; } } } else { $date = usergetdate(time()); $display->thismonth = true; } // Fill in the variables we 're going to use, nice and tidy list($d, $m, $y) = array($date['mday'], $date['mon'], $date['year']); // This is what we want to display $display->maxdays = calendar_days_in_month($m, $y); $startwday = 0; if (get_user_timezone_offset() < 99) { // We 'll keep these values as GMT here, and offset them when the time comes to query the db $display->tstart = gmmktime(0, 0, 0, $m, 1, $y); // This is GMT $display->tend = gmmktime(23, 59, 59, $m, $display->maxdays, $y); // GMT $startwday = gmdate('w', $display->tstart); // $display->tstart is already GMT, so don't use date(): messes with server's TZ } else { // no timezone info specified $display->tstart = mktime(0, 0, 0, $m, 1, $y); $display->tend = mktime(23, 59, 59, $m, $display->maxdays, $y); $startwday = date('w', $display->tstart); // $display->tstart not necessarily GMT, so use date() } // Align the starting weekday to fall in our display range if($startwday < $display->minwday) { $startwday += 7; } // Get events from database $events = calendar_get_events(usertime($display->tstart), usertime($display->tend), $users, $groups, $courses); if (!empty($events)) { foreach($events as $eventid => $event) { if (!empty($event->modulename)) { $cm = get_coursemodule_from_instance($event->modulename, $event->instance); if (!groups_course_module_visible($cm)) { unset($events[$eventid]); } } } } // Extract information: events vs. time calendar_events_by_day($events, $m, $y, $eventsbyday, $durationbyday, $typesbyday, $courses); $text = ''; if(!isguest() && !empty($USER->id) && calendar_user_can_add_event()) { $text.= '
'; $text.= '
'; $text.= ''; $text.= ''; $text.= ''; $text.= ''; $text.= ''; $text.= '
'; } $text .= ''. calendar_course_filter_selector($getvars); echo '
'.$text.'
'; echo '
'; echo calendar_top_controls('month', array('id' => $courseid, 'm' => $m, 'y' => $y)); echo '
'; // Start calendar display echo ''; // Begin table. First row: day names // Print out the names of the weekdays for($i = $display->minwday; $i <= $display->maxwday; ++$i) { // This uses the % operator to get the correct weekday no matter what shift we have // applied to the $display->minwday : $display->maxwday range from the default 0 : 6 echo ''; } echo ''; // End of day names; prepare for day numbers // For the table display. $week is the row; $dayweek is the column. $week = 1; $dayweek = $startwday; // Paddding (the first week may have blank days in the beginning) for($i = $display->minwday; $i < $startwday; ++$i) { echo ''."\n"; } // Now display all the calendar for($aday = 1; $aday <= $display->maxdays; ++$aday, ++$dayweek) { if($dayweek > $display->maxwday) { // We need to change week (table row) echo "\n"; $dayweek = $display->minwday; ++$week; } // Reset vars $cell = ''; $dayhref = calendar_get_link_href(CALENDAR_URL.'view.php?view=day&course='.$courseid.'&', $aday, $m, $y); if(CALENDAR_WEEKEND & (1 << ($dayweek % 7))) { // Weekend. This is true no matter what the exact range is. $class = 'weekend'; } else { // Normal working day. $class = ''; } // Special visual fx if an event is defined if(isset($eventsbyday[$aday])) { if(count($eventsbyday[$aday]) == 1) { $title = get_string('oneevent', 'calendar'); } else { $title = get_string('manyevents', 'calendar', count($eventsbyday[$aday])); } $cell = '
'.$aday.'
'; } else { $cell = '
'.$aday.'
'; } // Special visual fx if an event spans many days if(isset($typesbyday[$aday]['durationglobal'])) { $class .= ' duration_global'; } else if(isset($typesbyday[$aday]['durationcourse'])) { $class .= ' duration_course'; } else if(isset($typesbyday[$aday]['durationgroup'])) { $class .= ' duration_group'; } else if(isset($typesbyday[$aday]['durationuser'])) { $class .= ' duration_user'; } // Special visual fx for today if($display->thismonth && $aday == $d) { $class .= ' today'; } else { $class .= ' nottoday'; } // Just display it if(!empty($class)) { $class = ' class="'.trim($class).'"'; } echo ''.$cell; if(isset($eventsbyday[$aday])) { echo ''; } if(isset($durationbyday[$aday])) { echo ''; } echo "\n"; } // Paddding (the last week may have blank days at the end) for($i = $dayweek; $i <= $display->maxwday; ++$i) { echo ''; } echo "\n"; // Last row ends echo "
'.get_string($CALENDARDAYS[$i % 7], 'calendar').'
 
 
\n"; // Tabular display of days ends // OK, now for the filtering display echo '
'; // Global events if($SESSION->cal_show_global) { echo ''."\n"; } else { echo ''."\n"; } // Course events if(!empty($SESSION->cal_show_course)) { echo ''."\n"; } else { echo ''."\n"; } echo "\n"; if(!empty($USER->id) && !isguest()) { echo ''; // Group events if($SESSION->cal_show_groups) { echo ''."\n"; } else { echo ''."\n"; } // User events if($SESSION->cal_show_user) { echo ''."\n"; } else { echo ''."\n"; } echo "\n"; } echo '
'.get_string('globalevents', 'calendar').': '; echo get_string('shown', 'calendar').' ('.get_string('clickhide', 'calendar').')'.get_string('globalevents', 'calendar').': '; echo get_string('hidden', 'calendar').' ('.get_string('clickshow', 'calendar').')'.get_string('courseevents', 'calendar').': '; echo get_string('shown', 'calendar').' ('.get_string('clickhide', 'calendar').')'.get_string('courseevents', 'calendar').': '; echo get_string('hidden', 'calendar').' ('.get_string('clickshow', 'calendar').')
'.get_string('groupevents', 'calendar').': '; echo get_string('shown', 'calendar').' ('.get_string('clickhide', 'calendar').')'.get_string('groupevents', 'calendar').': '; echo get_string('hidden', 'calendar').' ('.get_string('clickshow', 'calendar').')'.get_string('userevents', 'calendar').': '; echo get_string('shown', 'calendar').' ('.get_string('clickhide', 'calendar').')'.get_string('userevents', 'calendar').': '; echo get_string('hidden', 'calendar').' ('.get_string('clickshow', 'calendar').')
'; } function calendar_show_upcoming_events($courses, $groups, $users, $futuredays, $maxevents, $courseid) { global $USER; $events = calendar_get_upcoming($courses, $groups, $users, $futuredays, $maxevents); $text = ''; if(!isguest() && !empty($USER->id) && calendar_user_can_add_event()) { $text.= '
'; $text.= '
'; $text.= '
'; $text.= ''; $text.= ''; $text.= ''; $text.= '
'; } $text .= ''. calendar_course_filter_selector('from=upcoming'); echo '
'.$text.'
'; if ($events) { echo '
'; foreach ($events as $event) { $event->calendarcourseid = $courseid; calendar_print_event($event); } echo '
'; } else { print_heading(get_string('noupcomingevents', 'calendar')); } } function calendar_course_filter_selector($getvars = '') { global $USER, $SESSION; if (empty($USER->id) or isguest()) { return ''; } if (has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_SYSTEM)) && !empty($CFG->calendar_adminseesall)) { $courses = get_courses('all', 'c.shortname','c.id,c.shortname'); } else { $courses = get_my_courses($USER->id, 'shortname'); } unset($courses[SITEID]); $courseoptions[SITEID] = get_string('fulllistofcourses'); foreach ($courses as $course) { $courseoptions[$course->id] = format_string($course->shortname); } if (is_numeric($SESSION->cal_courses_shown)) { $selected = $SESSION->cal_courses_shown; } else { $selected = ''; } return popup_form(CALENDAR_URL.'set.php?var=setcourse&'.$getvars.'&id=', $courseoptions, 'cal_course_flt', $selected, '', '', '', true); } ?> ; } ?>