diff options
author | jwangen <jwangen> | 2002-09-30 12:09:17 +0000 |
---|---|---|
committer | jwangen <jwangen> | 2002-09-30 12:09:17 +0000 |
commit | ea76f46e8677d5d0d3fa5400fb1211d2df6071a6 (patch) | |
tree | 1b0483292aae547cf5c2a32d84c77de90952dfa0 | |
parent | 8973b748535409a51987c391c5c892c89d80269f (diff) | |
download | phpicalendar-ea76f46e8677d5d0d3fa5400fb1211d2df6071a6.tar.gz phpicalendar-ea76f46e8677d5d0d3fa5400fb1211d2df6071a6.tar.bz2 phpicalendar-ea76f46e8677d5d0d3fa5400fb1211d2df6071a6.zip |
added yearly recurrence support
merged allday events and regular recurring events, see dev-email list for
details
alldays.ics is a test file that just has allday events
-rw-r--r-- | calendars/alldays.ics | 53 | ||||
-rw-r--r-- | calendars/default.ics | 69 | ||||
-rw-r--r-- | functions/date_functions.php | 2 | ||||
-rw-r--r-- | ical_parser.php | 127 | ||||
-rw-r--r-- | init.inc.php | 9 | ||||
-rw-r--r-- | week.php | 50 |
6 files changed, 242 insertions, 68 deletions
diff --git a/calendars/alldays.ics b/calendars/alldays.ics new file mode 100644 index 0000000..3befac4 --- /dev/null +++ b/calendars/alldays.ics @@ -0,0 +1,53 @@ +BEGIN:VCALENDAR +CALSCALE:GREGORIAN +PRODID:-//Apple Computer\, Inc//iCal 1.0//EN +X-WR-CALNAME;VALUE=TEXT:testing 2 +X-WR-TIMEZONE;VALUE=TEXT:US/Central +VERSION:2.0 +METHOD:PUBLISH +BEGIN:VEVENT +SEQUENCE:8 +UID:CBEE83F3-D467-11D6-A297-0050E4E60429 +DTSTAMP:20020930T094830Z +SUMMARY:Monthly\, every 2 months\, 1st\, 15th\, 20th +RRULE:FREQ=MONTHLY;INTERVAL=2;BYMONTHDAY=1,15,20 +DTSTART;VALUE=DATE:20020915 +DTEND;VALUE=DATE:20020916 +END:VEVENT +BEGIN:VEVENT +SEQUENCE:5 +UID:CBEE8B60-D467-11D6-A297-0050E4E60429 +DTSTAMP:20020930T094910Z +SUMMARY:Weekly\, Mon\, Wed +RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE +DTSTART;VALUE=DATE:20020902 +DTEND;VALUE=DATE:20020903 +END:VEVENT +BEGIN:VEVENT +SEQUENCE:8 +UID:CBEE9067-D467-11D6-A297-0050E4E60429 +DTSTAMP:20020930T095005Z +SUMMARY:Weekly\, 3 days long\, Tue +RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU +DTSTART;VALUE=DATE:20020903 +DTEND;VALUE=DATE:20020906 +END:VEVENT +BEGIN:VEVENT +SEQUENCE:8 +UID:CBEE9556-D467-11D6-A297-0050E4E60429 +DTSTAMP:20020930T112718Z +SUMMARY:yearly sept\, july +RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=7,9 +DTSTART;VALUE=DATE:20020907 +DTEND;VALUE=DATE:20020908 +END:VEVENT +BEGIN:VEVENT +SEQUENCE:7 +UID:CBEE9A6D-D467-11D6-A297-0050E4E60429 +DTSTAMP:20020930T112830Z +SUMMARY:yearly\, aug\, jan\, 3rd friday +RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=3FR;BYMONTH=1,8 +DTSTART;VALUE=DATE:20020818 +DTEND;VALUE=DATE:20020819 +END:VEVENT +END:VCALENDAR diff --git a/calendars/default.ics b/calendars/default.ics index c3a7eba..a39010b 100644 --- a/calendars/default.ics +++ b/calendars/default.ics @@ -12,14 +12,14 @@ SUMMARY:New Event EXDATE;TZID=US/Central:20021212T080000 EXDATE;TZID=US/Central:20030101T080000 EXDATE;TZID=US/Central:20021219T080000 -UID:B89C7854-D106-11D6-846D-0050E4E60429 DTSTART;TZID=US/Central:20021208T080000 +UID:54C82C7E-D456-11D6-A297-0050E4E60429 DURATION:PT1H RRULE:FREQ=DAILY;INTERVAL=1 END:VEVENT BEGIN:VEVENT +UID:54C82C7E-D456-11D6-A297-0050E4E60429 RECURRENCE-ID;TZID=US/Central:20021218T080000 -UID:B89C7854-D106-11D6-846D-0050E4E60429 DTSTART;TZID=US/Central:20021218T080000 DURATION:PT1H DESCRIPTION:this day is extra special @@ -28,8 +28,8 @@ BEGIN:VEVENT RECURRENCE-ID;TZID=US/Central:20021230T080000 DTSTAMP:20020919T034122Z SUMMARY:New Eventsweet +UID:54C82C7E-D456-11D6-A297-0050E4E60429 DTSTART;TZID=US/Central:20021230T080000 -UID:B89C7854-D106-11D6-846D-0050E4E60429 DURATION:PT1H DESCRIPTION:whoo hoo BEGIN:VALARM @@ -38,8 +38,8 @@ ACTION:DISPLAY DESCRIPTION:Event reminder END:VALARM BEGIN:VALARM -ATTACH;VALUE=URI:Ping TRIGGER;VALUE=DURATION:-PT15M +ATTACH;VALUE=URI:Ping ACTION:AUDIO END:VALARM END:VEVENT @@ -47,25 +47,25 @@ BEGIN:VEVENT SEQUENCE:1 DTSTAMP:20020919T041307Z SUMMARY:New Event -UID:B89C8C02-D106-11D6-846D-0050E4E60429 +UID:54C83E68-D456-11D6-A297-0050E4E60429 DTSTART;TZID=US/Central:20021215T094500 DURATION:PT1H30M END:VEVENT BEGIN:VEVENT -SEQUENCE:17 -DTSTAMP:20020921T122925Z +SEQUENCE:29 +DTSTAMP:20020928T231141Z SUMMARY:New Event +UID:54C843B6-D456-11D6-A297-0050E4E60429 DTSTART;TZID=US/Central:20020915T090000 -UID:B89C910F-D106-11D6-846D-0050E4E60429 DURATION:PT1H45M -RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR,SA,SU +RRULE:FREQ=DAILY;INTERVAL=1 END:VEVENT BEGIN:VEVENT SEQUENCE:5 DTSTAMP:20020926T031348Z SUMMARY:New Event +UID:54C848A4-D456-11D6-A297-0050E4E60429 DTSTART;TZID=US/Central:20020922T113000 -UID:B89C95A4-D106-11D6-846D-0050E4E60429 DURATION:PT1H RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=1SU END:VEVENT @@ -74,7 +74,7 @@ SEQUENCE:3 DTSTAMP:20020926T031621Z SUMMARY:Stef in town DTEND;TZID=US/Pacific:20020822T200000 -UID:B89C9A8F-D106-11D6-846D-0050E4E60429 +UID:54C84D52-D456-11D6-A297-0050E4E60429 DTSTART;TZID=US/Pacific:20020822T170000 END:VEVENT BEGIN:VEVENT @@ -83,16 +83,16 @@ DTSTAMP:20020926T031621Z SUMMARY:This is a space \n\n\nOption return and a really long line of text that will be inserted into the event text box. Let's all see what really happens when iCals start being real. -UID:B89C9F10-D106-11D6-846D-0050E4E60429 +UID:54C85294-D456-11D6-A297-0050E4E60429 DTSTART;TZID=US/Pacific:20020918T121500 DURATION:PT2H END:VEVENT BEGIN:VEVENT SEQUENCE:3 -DTSTART;TZID=US/Pacific:20020919T120000 +UID:54C857FC-D456-11D6-A297-0050E4E60429 DTSTAMP:20020926T031621Z SUMMARY:Recurring Monthly -UID:B89CA392-D106-11D6-846D-0050E4E60429 +DTSTART;TZID=US/Pacific:20020919T120000 DTEND;TZID=US/Pacific:20020919T133000 RRULE:FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=19 END:VEVENT @@ -100,8 +100,8 @@ BEGIN:VEVENT SEQUENCE:2 DTSTAMP:20020926T031621Z SUMMARY:Recurring Weekly +UID:54C85D3A-D456-11D6-A297-0050E4E60429 DTSTART;TZID=US/Pacific:20020920T120000 -UID:B89CA818-D106-11D6-846D-0050E4E60429 DURATION:PT1H30M RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=FR END:VEVENT @@ -109,8 +109,8 @@ BEGIN:VEVENT SEQUENCE:3 DTSTAMP:20020926T031621Z SUMMARY:Recurring Daily +UID:54C86548-D456-11D6-A297-0050E4E60429 DTSTART;TZID=US/Pacific:20020921T100000 -UID:B89CAC94-D106-11D6-846D-0050E4E60429 DURATION:PT1H30M RRULE:FREQ=DAILY;INTERVAL=1 END:VEVENT @@ -118,33 +118,33 @@ BEGIN:VEVENT SEQUENCE:4 DTSTAMP:20020926T031621Z SUMMARY:Monthly UNTIL 5 times -UID:B89CB63D-D106-11D6-846D-0050E4E60429 DTSTART;TZID=US/Pacific:20020919T140000 +UID:54C87022-D456-11D6-A297-0050E4E60429 DURATION:PT1H30M RRULE:FREQ=MONTHLY;COUNT=5;INTERVAL=1;BYMONTHDAY=19 END:VEVENT BEGIN:VEVENT -SEQUENCE:11 -UID:B89CBB22-D106-11D6-846D-0050E4E60429 -DTSTAMP:20020926T031621Z -SUMMARY:Monthly UNTiL date +SEQUENCE:12 DTSTART;TZID=US/Pacific:20020919T160000 +DTSTAMP:20020928T232448Z +SUMMARY:Monthly UNTiL date +UID:54C8757E-D456-11D6-A297-0050E4E60429 DTEND;TZID=US/Pacific:20020919T180000 -RRULE:FREQ=MONTHLY;UNTIL=20021223T075959;INTERVAL=1;BYMONTHDAY=19 +RRULE:FREQ=MONTHLY;UNTIL=20021224T075959;INTERVAL=1;BYMONTHDAY=19 END:VEVENT BEGIN:VEVENT SEQUENCE:7 DTSTAMP:20020926T031621Z SUMMARY:Every two weeks on certain days -UID:B89CBFA4-D106-11D6-846D-0050E4E60429 -STATUS:CONFIRMED DTSTART;TZID=US/Pacific:20020920T150000 +STATUS:CONFIRMED +UID:54C87AFE-D456-11D6-A297-0050E4E60429 DURATION:PT1H30M RRULE:FREQ=WEEKLY;INTERVAL=2;BYDAY=TU,WE,FR END:VEVENT BEGIN:VEVENT SEQUENCE:5 -UID:B89CC43E-D106-11D6-846D-0050E4E60429 +UID:54C88006-D456-11D6-A297-0050E4E60429 DTSTAMP:20020926T031621Z SUMMARY:Montly all day RRULE:FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=19,20,21 @@ -153,7 +153,7 @@ DTEND;VALUE=DATE:20020920 END:VEVENT BEGIN:VEVENT SEQUENCE:3 -UID:B89CC8E4-D106-11D6-846D-0050E4E60429 +UID:54C88504-D456-11D6-A297-0050E4E60429 DTSTAMP:20020926T031621Z SUMMARY:Yearly all day RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=9 @@ -164,7 +164,7 @@ BEGIN:VEVENT SEQUENCE:4 DTSTAMP:20020926T031621Z RECURRENCE-ID;TZID=US/Pacific:20020923T100000 -UID:B89CAC94-D106-11D6-846D-0050E4E60429 +UID:54C86548-D456-11D6-A297-0050E4E60429 DTSTART;TZID=US/Pacific:20020923T113000 DURATION:PT1H30M END:VEVENT @@ -174,14 +174,14 @@ DTSTAMP:20020926T031621Z SUMMARY:New Event DTEND;TZID=US/Pacific:20020923T133000 DTSTART;TZID=US/Pacific:20020923T113000 -UID:B89CCD6D-D106-11D6-846D-0050E4E60429 +UID:54C889E0-D456-11D6-A297-0050E4E60429 END:VEVENT BEGIN:VEVENT SEQUENCE:9 DTSTAMP:20020926T032430Z SUMMARY:Monthly\, specific days +UID:54C88EDC-D456-11D6-A297-0050E4E60429 DTSTART;TZID=US/Central:20020915T104500 -UID:B89CD2CF-D106-11D6-846D-0050E4E60429 DURATION:PT1H RRULE:FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=9,13,15,18,25,0 END:VEVENT @@ -189,9 +189,18 @@ BEGIN:VEVENT SEQUENCE:4 DTSTAMP:20020926T032415Z SUMMARY:Monthly\, 2nd sunday +UID:54C89436-D456-11D6-A297-0050E4E60429 DTSTART;TZID=US/Central:20020915T123000 -UID:B89CD75F-D106-11D6-846D-0050E4E60429 DURATION:PT1H15M RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=2SU END:VEVENT +BEGIN:VEVENT +SEQUENCE:6 +UID:54C899A4-D456-11D6-A297-0050E4E60429 +DTSTAMP:20020930T092321Z +SUMMARY:Monthly\, every 2 months\, 1st\, 10th\, 19th +RRULE:FREQ=MONTHLY;INTERVAL=2;BYMONTHDAY=1,10,19 +DTSTART;VALUE=DATE:20020901 +DTEND;VALUE=DATE:20020902 +END:VEVENT END:VCALENDAR diff --git a/functions/date_functions.php b/functions/date_functions.php index 1b09b9d..f2e67d7 100644 --- a/functions/date_functions.php +++ b/functions/date_functions.php @@ -1 +1 @@ -<?php
// date_functions.php
// functions for returning or comparing dates
// takes Apple's 2 character day format and makes it into 3 characters
function two2threeCharDays($day) {
if ($day == "SU") $day_longer = "sun";
elseif ($day == "MO") $day_longer = "mon";
elseif ($day == "TU") $day_longer = "tue";
elseif ($day == "WE") $day_longer = "wed";
elseif ($day == "TH") $day_longer = "thu";
elseif ($day == "FR") $day_longer = "fri";
elseif ($day == "SA") $day_longer = "sat";
return $day_longer;
}
// dateOfWeek() takes a date in Ymd and a day of week in 3 letters or more
// and returns the date of that day. (ie: "sun" or "sunday" would be acceptable values of $day but not "su")
function dateOfWeek($Ymd, $day) {
global $week_start_day;
if (!$week_start_day) $week_start_day = "Sunday";
$timestamp = strtotime($Ymd);
$num = date("w", strtotime($week_start_day));
$start_day_time = strtotime((date("w",$timestamp)==$num ? "$week_start_day" : "last $week_start_day"), $timestamp);
return date("Ymd",strtotime($day,$start_day_time));
}
// function to compare to dates in Ymd and return the number of weeks
// that differ between them. requires dateOfWeek()
function weekCompare($now, $then) {
global $week_start_day;
$sun_now = dateOfWeek($now, $week_start_day);
$sun_then = dateOfWeek($then, $week_start_day);
$seconds_now = strtotime($sun_now);
$seconds_then = strtotime($sun_then);
$diff_seconds = $seconds_now - $seconds_then;
$diff_minutes = $diff_seconds/60;
$diff_hours = $diff_minutes/60;
$diff_days = round($diff_hours/24);
$diff_weeks = $diff_days/7;
return $diff_weeks;
}
// function to compare to dates in Ymd and return the number of days
// that differ between them.
function dayCompare($now, $then) {
$seconds_now = strtotime($now);
$seconds_then = strtotime($then);
$diff_seconds = $seconds_now - $seconds_then;
$diff_minutes = $diff_seconds/60;
$diff_hours = $diff_minutes/60;
$diff_days = round($diff_hours/24);
return $diff_days;
}
// function to compare to dates in Ymd and return the number of months
// that differ between them.
function monthCompare($now, $then) {
ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $now, $date_now);
ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $then, $date_then);
$diff_years = $date_now[1] - $date_then[1];
$diff_months = $date_now[2] - $date_then[2];
if ($date_now[2] < $date_then[2]) {
$diff_years -= 1;
$diff_months = ($diff_months + 12) % 12;
}
$diff_months = ($diff_years * 12) + $diff_months;
return $diff_months;
}
?>
\ No newline at end of file +<?php
// date_functions.php
// functions for returning or comparing dates
// takes Apple's 2 character day format and makes it into 3 characters
function two2threeCharDays($day) {
if ($day == "SU") $day_longer = "sun";
elseif ($day == "MO") $day_longer = "mon";
elseif ($day == "TU") $day_longer = "tue";
elseif ($day == "WE") $day_longer = "wed";
elseif ($day == "TH") $day_longer = "thu";
elseif ($day == "FR") $day_longer = "fri";
elseif ($day == "SA") $day_longer = "sat";
return $day_longer;
}
// dateOfWeek() takes a date in Ymd and a day of week in 3 letters or more
// and returns the date of that day. (ie: "sun" or "sunday" would be acceptable values of $day but not "su")
function dateOfWeek($Ymd, $day) {
global $week_start_day;
if (!$week_start_day) $week_start_day = "Sunday";
$timestamp = strtotime($Ymd);
$num = date("w", strtotime($week_start_day));
$start_day_time = strtotime((date("w",$timestamp)==$num ? "$week_start_day" : "last $week_start_day"), $timestamp);
return date("Ymd",strtotime($day,$start_day_time));
}
// function to compare to dates in Ymd and return the number of weeks
// that differ between them. requires dateOfWeek()
function weekCompare($now, $then) {
global $week_start_day;
$sun_now = dateOfWeek($now, $week_start_day);
$sun_then = dateOfWeek($then, $week_start_day);
$seconds_now = strtotime($sun_now);
$seconds_then = strtotime($sun_then);
$diff_seconds = $seconds_now - $seconds_then;
$diff_minutes = $diff_seconds/60;
$diff_hours = $diff_minutes/60;
$diff_days = round($diff_hours/24);
$diff_weeks = $diff_days/7;
return $diff_weeks;
}
// function to compare to dates in Ymd and return the number of days
// that differ between them.
function dayCompare($now, $then) {
$seconds_now = strtotime($now);
$seconds_then = strtotime($then);
$diff_seconds = $seconds_now - $seconds_then;
$diff_minutes = $diff_seconds/60;
$diff_hours = $diff_minutes/60;
$diff_days = round($diff_hours/24);
return $diff_days;
}
// function to compare to dates in Ymd and return the number of months
// that differ between them.
function monthCompare($now, $then) {
ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $now, $date_now);
ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $then, $date_then);
$diff_years = $date_now[1] - $date_then[1];
$diff_months = $date_now[2] - $date_then[2];
if ($date_now[2] < $date_then[2]) {
$diff_years -= 1;
$diff_months = ($diff_months + 12) % 12;
}
$diff_months = ($diff_years * 12) + $diff_months;
return $diff_months;
}
function yearCompare($now, $then) {
ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $now, $date_now);
ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $then, $date_then);
$diff_years = $date_now[1] - $date_then[1];
return $diff_years;
}
?>
\ No newline at end of file diff --git a/ical_parser.php b/ical_parser.php index 365ce1b..054d13a 100644 --- a/ical_parser.php +++ b/ical_parser.php @@ -76,6 +76,7 @@ foreach($contents as $line) { $except_times = array(); $first_duration = TRUE; $bymonthday = ""; + $byday = ""; $count = 1000000; } elseif (strstr($line, "END:VEVENT")) { @@ -98,8 +99,9 @@ foreach($contents as $line) { } - // Handling of the all day events - if (($allday_start != "") && ($rrule_array == "")) { + // Handling of the all day events +// to go back to old allday way, add to this if--> && ($rrule_array == "") + if (($allday_start != "")) { $start = strtotime("$allday_start"); $end = strtotime("$allday_end"); if (($end > $mArray_begin) && ($end < $mArray_end)) { @@ -120,6 +122,8 @@ foreach($contents as $line) { $rrule_array["END_DAY"] = $allday_end; $rrule_array["END"] = "end"; $recur_start = $allday_start; + $start_date = $allday_start; + $diff_allday_days = dayCompare($allday_end, $allday_start); } else { $rrule_array["START_DATE"] = $start_date; $rrule_array["START_TIME"] = $start_time; @@ -198,7 +202,8 @@ foreach($contents as $line) { $wkst = $val; } elseif ($key == "END") { - +// to go back to old allday way, uncomment this set + /* if ($allday_start != "") { // Since we hit the end of the RRULE array, lets do something. @@ -235,7 +240,7 @@ foreach($contents as $line) { // DAILY and WEEKLY recurrences seem to work fine. Need feedback. // Known bug, doesn't look at UNTIL or COUNT yet. } else { - + */ // again, $parse_to_year is set to January 10 of the upcoming year $parse_to_year_time = mktime(0,0,0,1,10,($this_year + 1)); $start_date_time = strtotime($start_date); @@ -302,10 +307,21 @@ foreach($contents as $line) { // $next_date can fall up to a week behind $next_range_time because of how dateOfWeek works // so we have to check this again. It uses $except_dates so it doesn't add to $master_array // on days that have been deleted by the user + if ($allday_start != "") { + + $start_time = $next_date_time; + $end_time = strtotime("+$diff_allday_days days", $next_date_time); + while ($start_time < $end_time) { + $start_date2 = date("Ymd", $start_time); + $master_array[($start_date2)][("-1")][]= array ("event_text" => "$summary", "description" => $description); + $start_time = strtotime("+1 day", $start_time); + } + } else { // check for overlapping events $nbrOfOverlaps = checkOverlap(); // writes to $master array here $master_array[($next_date)][($hour.$minute)][] = array ("event_start" => $start_time, "event_text" => $summary, "event_end" => $end_time, "event_length" => $length, "event_overlap" => $nbrOfOverlaps, "description" => $description); + } } } } else { @@ -330,11 +346,21 @@ foreach($contents as $line) { $next_date_time = strtotime($next_date); if (($next_date_time > $start_date_time) && ($next_date_time <= $end_date_time) && ($count_to != $count) && !in_array($next_date, $except_dates)) { - // same general concept as the WEEKLY recurrence + if ($allday_start != "") { + + $start_time = $next_date_time; + $end_time = strtotime("+$diff_allday_days days", $next_date_time); + while ($start_time < $end_time) { + $start_date2 = date("Ymd", $start_time); + $master_array[($start_date2)][("-1")][]= array ("event_text" => "$summary", "description" => $description); + $start_time = strtotime("+1 day", $start_time); + } + } else { // check for overlapping events - $nbrOfOverlaps = checkOverlap(); + $nbrOfOverlaps = checkOverlap(); // writes to $master array here - $master_array[($next_date)][($hour.$minute)][] = array ("event_start" => $start_time, "event_text" => $summary, "event_end" => $end_time, "event_length" => $length, "event_overlap" => $nbrOfOverlaps, "description" => $description); + $master_array[($next_date)][($hour.$minute)][] = array ("event_start" => $start_time, "event_text" => $summary, "event_end" => $end_time, "event_length" => $length, "event_overlap" => $nbrOfOverlaps, "description" => $description); + } } } else { $interval = 1; @@ -365,11 +391,20 @@ foreach($contents as $line) { $next_date_time = strtotime(date("Y-m-",$next_range_time).$day); $next_date = date("Ymd", $next_date_time); if (($next_date_time > $start_date_time) && ($next_date_time <= $end_date_time) && ($count_to != $count) && !in_array($next_date, $except_dates)) { - // same general concept as the WEEKLY recurrence + if ($allday_start != "") { + $start_time = $next_date_time; + $end_time = strtotime("+$diff_allday_days days", $next_date_time); + while ($start_time < $end_time) { + $start_date2 = date("Ymd", $start_time); + $master_array[($start_date2)][("-1")][]= array ("event_text" => "$summary", "description" => $description); + $start_time = strtotime("+1 day", $start_time); + } + } else { // check for overlapping events - $nbrOfOverlaps = checkOverlap(); + $nbrOfOverlaps = checkOverlap(); // writes to $master array here - $master_array[($next_date)][($hour.$minute)][] = array ("event_start" => $start_time, "event_text" => $summary, "event_end" => $end_time, "event_length" => $length, "event_overlap" => $nbrOfOverlaps, "description" => $description); + $master_array[($next_date)][($hour.$minute)][] = array ("event_start" => $start_time, "event_text" => $summary, "event_end" => $end_time, "event_length" => $length, "event_overlap" => $nbrOfOverlaps, "description" => $description); + } } } } @@ -384,10 +419,68 @@ foreach($contents as $line) { $next_date_time = strtotime("$on_day +$nth week", $next_range_time); $next_date = date("Ymd", $next_date_time); if (($next_date_time > $start_date_time) && ($next_date_time <= $end_date_time) && ($count_to != $count) && !in_array($next_date, $except_dates)) { - // same general concept as the WEEKLY recurrence -// check for overlapping events + + if ($allday_start != "") { + + $start_time = $next_date_time; + $end_time = strtotime("+$diff_allday_days days", $next_date_time); + while ($start_time < $end_time) { + $start_date2 = date("Ymd", $start_time); + $master_array[($start_date2)][("-1")][]= array ("event_text" => "$summary", "description" => $description); + $start_time = strtotime("+1 day", $start_time); + } + } else { +// check for overlapping events + $nbrOfOverlaps = checkOverlap(); +// writes to $master array here + $master_array[($next_date)][($hour.$minute)][] = array ("event_start" => $start_time, "event_text" => $summary, "event_end" => $end_time, "event_length" => $length, "event_overlap" => $nbrOfOverlaps, "description" => $description); + } + } + } + } + } else { + $interval = 1; + } + $next_range_time = strtotime("+$interval month", $next_range_time); + } else { + // end the loop because we aren't going to write this event anyway + $count_to = $count; + } + + // handle yearly events + } elseif ($rrule_array["FREQ"] == "YEARLY") { + // use yearCompare to see if we even have this event this year + $the_month_day = date("m", $start_date_time); + $diff_years = yearCompare(date("Ymd",$next_range_time), $start_date); + if ($diff_years < $count) { + if ($diff_years % $number == 0) { + foreach($bymonth as $month) { + if (is_array($byday)) { + $next_range_time = strtotime("$this_year-$month-01"); + foreach($byday as $day) { + ereg ("([0-9]{1})([A-Z]{2})", $day, $byday_arr); + $nth = $byday_arr[1]-1; + $on_day = two2threeCharDays($byday_arr[2]); + $next_date_time = strtotime("$on_day +$nth week", $next_range_time); + + } + } else { + $next_date_time = strtotime("$this_year-$month-$the_month_day", $next_range_time); + } + if (($next_date_time > $start_date_time) && ($next_date_time <= $end_date_time) && ($count_to != $count) && !in_array($next_date, $except_dates)) { + if ($allday_start != "") { + + $start_time = $next_date_time; + $end_time = strtotime("+$diff_allday_days days", $next_date_time); + while ($start_time < $end_time) { + $start_date2 = date("Ymd", $start_time); + $master_array[($start_date2)][("-1")][]= array ("event_text" => "$summary", "description" => $description); + $start_time = strtotime("+1 day", $start_time); + } + } else { +// check for overlapping events $nbrOfOverlaps = checkOverlap(); -// writes to $master array here +// writes to $master array here $master_array[($next_date)][($hour.$minute)][] = array ("event_start" => $start_time, "event_text" => $summary, "event_end" => $end_time, "event_length" => $length, "event_overlap" => $nbrOfOverlaps, "description" => $description); } } @@ -395,20 +488,20 @@ foreach($contents as $line) { } else { $interval = 1; } - $next_range_time = strtotime("+$interval month", $next_range_time); + $next_range_time = strtotime("+$interval year", $next_range_time); } else { // end the loop because we aren't going to write this event anyway $count_to = $count; } - - + // anything else we need to end the loop } else { $next_range_time = $end_range_time + 100; $count_to = $count; } } - } +// to go back to old allday way, uncomment this bracket + // } } } } diff --git a/init.inc.php b/init.inc.php index a4bfc35..31f8c1e 100644 --- a/init.inc.php +++ b/init.inc.php @@ -39,6 +39,15 @@ $cal = urlencode($cal_filename); if (!isset($filename)) { $filename = $calendar_path."/".$cal_filename.".ics"; + if (!file_exists($filename)) { + $dir_handle = @opendir($calendar_path) or die("Unable to open $calendar_path"); + while ($file = readdir($dir_handle)) { + if (strstr ($file, ".ics")) { + $filename = $calendar_path."/".$file; + break; + } + } + } } ?>
\ No newline at end of file @@ -127,31 +127,41 @@ for ($i=0;$i<7;$i++) { echo "</tr>"; // The all day events returned here. + $allday_events_this_week = false; $thisdate = $start_week_time; - $i = 0; - echo "<tr>\n"; - echo "<td bgcolor=\"#f5f5f5\" colspan=\"2\"></td>"; - do { + for ($i=0;$i<7;$i++) { $thisday = date("Ymd", $thisdate); - if ($master_array[($thisday)]["-1"]) { - echo "<td bgcolor=\"#f5f5f5\" height=\"24\">\n"; - echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"4\" class=\"V9\">\n"; - foreach($master_array[($thisday)]["-1"] as $allday) { - $all_day_text = $allday["event_text"]; - $description = $allday["description"]; - echo "<tr>\n"; - echo "<td colspan=\"" . $nbrGridCols[$thisday] . "\" valign=\"top\" align=\"center\" bgcolor=\"#6699CC\"><a class=\"psf\" href=\"javascript:openEventInfo('$event_text2', '$calendar_name', '$event_start', '$event_end', '$description')\"><font color=\"#ffffff\">$all_day_text</font></a></td>\n"; - echo "</tr>\n"; - } - echo "</table>\n"; - echo "</td>\n"; + $allday_events_this_week = true; + break; } $thisdate = ($thisdate + (25 * 60 * 60)); - $i++; - } while ($i < 7); - echo "</tr>\n"; - + } + if ($allday_events_this_week) { + $thisdate = $start_week_time; + $i = 0; + echo "<tr>\n"; + echo "<td bgcolor=\"#f5f5f5\" colspan=\"2\"></td>"; + do { + $thisday = date("Ymd", $thisdate); + echo "<td bgcolor=\"#f5f5f5\" height=\"24\">\n"; + if ($master_array[($thisday)]["-1"]) { + echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"4\" class=\"V9\">\n"; + foreach($master_array[($thisday)]["-1"] as $allday) { + $all_day_text = $allday["event_text"]; + $description = $allday["description"]; + echo "<tr>\n"; + echo "<td colspan=\"" . $nbrGridCols[$thisday] . "\" valign=\"top\" align=\"center\" bgcolor=\"#6699CC\"><a class=\"psf\" href=\"javascript:openEventInfo('$event_text2', '$calendar_name', '$event_start', '$event_end', '$description')\"><font color=\"#ffffff\">$all_day_text</font></a></td>\n"; + echo "</tr>\n"; + } + echo "</table>\n"; + } + echo "</td>\n"; + $thisdate = ($thisdate + (25 * 60 * 60)); + $i++; + } while ($i < 7); + echo "</tr>\n"; + } // $master_array[($getdate)]["$day_time"] $thisdate = $start_week_time; |