function format_vcal($event)
{
    // Start and end time
    $fevent[StartTime] = vcaldate_to_timestamp($event[dtstart]);
    $fevent[EndTime] = vcaldate_to_timestamp($event[dtend]);
    // Calculate duration in minutes
    $fevent[Duration] = ($fevent[EndTime] - $fevent[StartTime]) / 60;
    if ($fevent[Duration] == '1440') {
        $fevent[Duration] = '0';
        $fevent[Untimed] = 1;
    }
    //All day (untimed)
    $fevent[Summary] = $event['summary'];
    $fevent[Description] = $event['description'];
    $fevent['Private'] = preg_match("/private|confidential/i", $event['class']) ? '1' : '0';
    $fevent[UID] = $event['uid'];
    // Repeats
    //
    // vcal 1.0 repeats can be very complicated and the webcalendar doesn't
    // actually support all of the ways repeats can be specified.  We will
    // focus on vcals dumped from Palm Desktop and Lotus Notes, which are simple
    // and the ones webcalendar should fully support.
    if ($event[rrule]) {
        //split into pieces
        $RR = explode(" ", $event[rrule]);
        if (preg_match("/^D(.+)\$/i", $RR[0], $match)) {
            $fevent[Repeat][Interval] = '1';
            $fevent[Repeat][Frequency] = $match[1];
        } elseif (preg_match("/^W(.+)\$/i", $RR[0], $match)) {
            $fevent[Repeat][Interval] = '2';
            $fevent[Repeat][Frequency] = $match[1];
            $fevent[Repeat][RepeatDays] = rrule_repeat_days($RR);
        } elseif (preg_match("/^MP(.+)\$/i", $RR[0], $match)) {
            $fevent[Repeat][Interval] = '3';
            $fevent[Repeat][Frequency] = $match[1];
            if ($RR[1] == '5+') {
                $fevent[Repeat][Interval] = '6';
                // Last week (monthlyByDayR)
            }
        } elseif (preg_match("/^MD(.+)\$/i", $RR[0], $match)) {
            $fevent[Repeat][Interval] = '4';
            $fevent[Repeat][Frequency] = $match[1];
        } elseif (preg_match("/^YM(.+)\$/i", $RR[0], $match)) {
            $fevent[Repeat][Interval] = '5';
            $fevent[Repeat][Frequency] = $match[1];
        } elseif (preg_match("/^YD(.+)\$/i", $RR[0], $match)) {
            $fevent[Repeat][Interval] = '5';
            $fevent[Repeat][Frequency] = $match[1];
        }
        $end = end($RR);
        // No end in Palm is 12-31-2031
        if ($end != '20311231' && $end != '#0') {
            $fevent[Repeat][EndTime] = rrule_endtime($fevent[Repeat][Interval], $fevent[Repeat][Frequency], $event[dtstart], $end);
        }
        // Repeating exceptions?
        if ($event[exdate]) {
            $fevent[Repeat][Exceptions] = array();
            $EX = explode(",", $event[exdate]);
            foreach ($EX as $exdate) {
                $fevent[Repeat][Exceptions][] = vcaldate_to_timestamp($exdate);
            }
        }
    }
    // end if rrule
    // TODO
    //  $fevent[Category];
    //  $fevent[AlarmSet];
    //  $fevent[AlarmAdvanceAmount];
    //  $fevent[AlarmAdvanceType];
    return $fevent;
}
Example #2
0
function format_vcal($event)
{
    // Start and end time
    $fevent['StartTime'] = vcaldate_to_timestamp($event['dtstart']);
    if ($fevent['StartTime'] == '-1') {
        return false;
    }
    $fevent['EndTime'] = vcaldate_to_timestamp($event['dtend']);
    // Calculate duration in minutes
    $fevent['Duration'] = ($fevent['EndTime'] - $fevent['StartTime']) / 60;
    if ($fevent['Duration'] == '1440') {
        $fevent['Duration'] = '0';
        $fevent['Untimed'] = 1;
    }
    //All day (untimed)
    if (!empty($event['summary'])) {
        $fevent['Summary'] = $event['summary'];
    }
    if (!empty($event['description'])) {
        $fevent['Description'] = $event['description'];
    }
    if (!empty($event['descriptionqp'])) {
        $fevent['Description'] = quoted_printable_decode($event['descriptionqp']);
        // hack for mozilla sunbird's extra = signs
        $fevent['Description'] = preg_replace('/^=/', '', $fevent['Description']);
        $fevent['Description'] = str_replace("\n=", "\n", $fevent['Description']);
    }
    if (!empty($event['class'])) {
        $fevent['Private'] = preg_match("/private|confidential/i", $event['class']) ? '1' : '0';
    } else {
        $fevent['Private'] = '0';
    }
    if (!empty($fevent['UID'])) {
        $fevent['UID'] = $event['uid'];
    }
    // Repeats
    //
    // vcal 1.0 repeats can be very complicated and the webcalendar doesn't
    // actually support all of the ways repeats can be specified.  We will
    // focus on vcals dumped from Palm Desktop and Lotus Notes, which are simple
    // and the ones webcalendar should fully support.
    if (!empty($event['rrule'])) {
        //split into pieces
        $RR = explode(" ", $event['rrule']);
        if (preg_match("/^D(.+)\$/i", $RR[0], $match)) {
            $fevent['Repeat']['Interval'] = '1';
            $fevent['Repeat']['Frequency'] = $match[1];
        } elseif (preg_match("/^W(.+)\$/i", $RR[0], $match)) {
            $fevent['Repeat']['Interval'] = '2';
            $fevent['Repeat']['Frequency'] = $match[1];
            $fevent['Repeat']['RepeatDays'] = rrule_repeat_days($RR);
        } elseif (preg_match("/^MP(.+)\$/i", $RR[0], $match)) {
            $fevent['Repeat']['Interval'] = '3';
            $fevent['Repeat']['Frequency'] = $match[1];
            if ($RR[1] == '5+') {
                $fevent['Repeat']['Interval'] = '6';
                // Last week (monthlyByDayR)
            }
        } elseif (preg_match("/^MD(.+)\$/i", $RR[0], $match)) {
            $fevent['Repeat']['Interval'] = '4';
            $fevent['Repeat']['Frequency'] = $match[1];
        } elseif (preg_match("/^YM(.+)\$/i", $RR[0], $match)) {
            $fevent['Repeat']['Interval'] = '5';
            $fevent['Repeat']['Frequency'] = $match[1];
        } elseif (preg_match("/^YD(.+)\$/i", $RR[0], $match)) {
            $fevent['Repeat']['Interval'] = '5';
            $fevent['Repeat']['Frequency'] = $match[1];
        }
        $end = end($RR);
        // No end in Palm is 12-31-2031
        if ($end != '20311231' && $end != '#0') {
            $fevent['Repeat']['EndTime'] = rrule_endtime($fevent['Repeat']['Interval'], $fevent['Repeat']['Frequency'], $event['dtstart'], $end);
        }
        // Repeating exceptions?
        if (!empty($event['exdate'])) {
            $fevent['Repeat']['Exceptions'] = array();
            $EX = explode(",", $event['exdate']);
            foreach ($EX as $exdate) {
                $fevent['Repeat']['Exceptions'][] = vcaldate_to_timestamp($exdate);
            }
        }
    }
    // end if rrule
    // TODO
    //  $fevent[Category];
    //  $fevent[AlarmSet];
    //  $fevent[AlarmAdvanceAmount];
    //  $fevent[AlarmAdvanceType];
    return $fevent;
}
Example #3
0
function format_ical($event)
{
    $icsOptions = get_option(ADMIN_OPTIONS_NAME);
    $fevent['raw'] = $event['RAW'];
    // Start and end time
    $fevent['StartTime'] = icaldate_to_timestamp($event['dtstart']);
    if (isset($event['dtend'])) {
        $fevent['EndTime'] = icaldate_to_timestamp($event['dtend']);
    } else {
        if (isset($event['duration'])) {
            $fevent['EndTime'] = $fevent['StartTime'] + $event['duration'] * 60;
        } else {
            $fevent['EndTime'] = $fevent['StartTime'];
        }
    }
    // Calculate duration in minutes
    if (isset($event['duration'])) {
        $fevent['Duration'] = $event['duration'];
    } else {
        if (empty($fevent['Duration'])) {
            $fevent['Duration'] = ($fevent['EndTime'] - $fevent['StartTime']) / 60;
        }
    }
    if ($fevent['Duration'] == '1440') {
        // All day event... nothing to do here :-)
    } else {
        if (preg_match("/\\d{8}\$/", $event['dtstart'], $pmatch)) {
            // Untimed event
            $fevent['Duration'] = 0;
            $fevent['Untimed'] = 1;
        }
    }
    if ($icsOptions['privacy_mode'] == '1') {
        $fevent['Summary'] = empty($event['summary']) ? '' : $icsOptions['privacy_mode_name'];
        $fevent['Description'] = empty($event['description']) ? '' : $icsOptions['privacy_mode_name'];
        $fevent['Location'] = empty($event['location']) ? '' : $icsOptions['privacy_mode_name'];
    } else {
        $fevent['Summary'] = format_ical_text($event['summary']);
        $fevent['Description'] = format_ical_text($event['description']);
        $fevent['Location'] = format_ical_text($event['location']);
    }
    $fevent['URL'] = format_ical_text($event['url']);
    $fevent['Private'] = preg_match("/private|confidential/i", $event['class']) ? '1' : '0';
    $fevent['UID'] = $event['uid'];
    $fevent['Status'] = format_ical_text($event['status']);
    if (isset($event['recurrence-id'])) {
        $fevent['RecurrenceID'] = icaldate_to_timestamp($event['recurrence-id']);
    }
    // Repeats
    //
    // Handle RRULE
    if ($event['rrule']) {
        // first remove and EndTime that may have been calculated above
        unset($fevent['Repeat']['EndTime']);
        //split into pieces
        //echo "RRULE line: $event[rrule] <br />\n";
        $RR = explode(";", $event['rrule']);
        // create an associative array of key-value paris in $RR2[]
        for ($i = 0; $i < count($RR); $i++) {
            $ar = explode("=", $RR[$i]);
            $RR2[$ar[0]] = $ar[1];
        }
        for ($i = 0; $i < count($RR); $i++) {
            //echo "RR $i = $RR[$i] <br />";
            if (preg_match("/^FREQ=(.+)\$/i", $RR[$i], $match)) {
                if (preg_match("/YEARLY/i", $match[1], $submatch)) {
                    $fevent['Repeat']['Interval'] = 5;
                } else {
                    if (preg_match("/MONTHLY/i", $match[1], $submatch)) {
                        $fevent['Repeat']['Interval'] = 3;
                    } else {
                        if (preg_match("/WEEKLY/i", $match[1], $submatch)) {
                            $fevent['Repeat']['Interval'] = 2;
                        } else {
                            if (preg_match("/DAILY/i", $match[1], $submatch)) {
                                $fevent['Repeat']['Interval'] = 1;
                            } else {
                                // not supported :-(
                                if (ICAL_EVENTS_DEBUG) {
                                    echo "Unsupported iCal FREQ value \"{$match['1']}\"<br />\n";
                                }
                            }
                        }
                    }
                }
            } else {
                if (preg_match("/^INTERVAL=(.+)\$/i", $RR[$i], $match)) {
                    $fevent['Repeat']['Frequency'] = $match[1];
                } else {
                    if (preg_match("/^UNTIL=(.+)\$/i", $RR[$i], $match)) {
                        // specifies an end date
                        $fevent['Repeat']['EndTime'] = icaldate_to_timestamp($match[1]);
                    } else {
                        if (preg_match("/^COUNT=(.+)\$/i", $RR[$i], $match)) {
                            $fevent['Repeat']['Count'] = $match[1];
                        } else {
                            if (preg_match("/^BYSECOND=(.+)\$/i", $RR[$i], $match)) {
                                // NOT YET SUPPORTED -- TODO
                                if (ICAL_EVENTS_DEBUG) {
                                    echo "Unsupported iCal BYSECOND value \"{$RR[$i]}\"<br />\n";
                                }
                            } else {
                                if (preg_match("/^BYMINUTE=(.+)\$/i", $RR[$i], $match)) {
                                    // NOT YET SUPPORTED -- TODO
                                    if (ICAL_EVENTS_DEBUG) {
                                        echo "Unsupported iCal BYMINUTE value \"{$RR[$i]}\"<br />\n";
                                    }
                                } else {
                                    if (preg_match("/^BYHOUR=(.+)\$/i", $RR[$i], $match)) {
                                        // NOT YET SUPPORTED -- TODO
                                        if (ICAL_EVENTS_DEBUG) {
                                            echo "Unsupported iCal BYHOUR value \"{$RR[$i]}\"<br />\n";
                                        }
                                    } else {
                                        if (preg_match("/^BYMONTH=(.+)\$/i", $RR[$i], $match)) {
                                            // this event repeats during the specified months
                                            $months = explode(",", $match[1]);
                                            if (count($months) == 1) {
                                                // Change this to a monthly event so we can support repeat by
                                                // day of month (if needed)
                                                // Frequency = 3 (by day), 4 (by date), 6 (by day reverse)
                                                if (!empty($RR2['BYDAY'])) {
                                                    if (preg_match("/^-/", $RR2['BYDAY'], $junk)) {
                                                        $fevent['Repeat']['Interval'] = 6;
                                                    } else {
                                                        $fevent['Repeat']['Interval'] = 3;
                                                    }
                                                    // monthly by day
                                                    $fevent['Repeat']['Frequency'] = 12;
                                                    // once every 12 months
                                                } else {
                                                    // could convert this to monthly by date, but we will just
                                                    // leave it as yearly.
                                                    //$fevent['Repeat']['Interval'] = 4; // monthly by date
                                                }
                                            } else {
                                                // WebCalendar does not support this
                                                if (ICAL_EVENTS_DEBUG) {
                                                    echo "Unsupported iCal BYMONTH value \"{$match['1']}\"<br />\n";
                                                }
                                            }
                                        } else {
                                            if (preg_match("/^BYDAY=(.+)\$/i", $RR[$i], $match)) {
                                                $fevent['Repeat']['RepeatDays'] = rrule_repeat_days(explode(',', $match[1]));
                                                //$fevent['Repeat']['ByDay'] = $match[1];
                                            } else {
                                                if (preg_match("/^BYMONTHDAY=(.+)\$/i", $RR[$i], $match)) {
                                                    $fevent['Repeat']['ByMonthDay'] = $match[1];
                                                } else {
                                                    if (preg_match("/^BYSETPOS=(.+)\$/i", $RR[$i], $match)) {
                                                        // NOT YET SUPPORTED -- TODO
                                                        if (ICAL_EVENTS_DEBUG) {
                                                            echo "Unsupported iCal BYSETPOS value \"{$RR[$i]}\"<br />\n";
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        // Repeating exceptions?
        if ($event['exdate']) {
            $fevent['Repeat']['Exceptions'] = array();
            $EX = explode(",", $event['exdate']);
            foreach ($EX as $exdate) {
                if (!empty($exdate)) {
                    $fevent['Repeat']['Exceptions'][] = icaldate_to_timestamp($exdate);
                }
            }
        }
    }
    // end if rrule
    return $fevent;
}
Example #4
0
function format_ical($event)
{
    // Start and end time
    $fevent['StartTime'] = icaldate_to_timestamp($event['dtstart']);
    if ($fevent['StartTime'] == '-1') {
        return false;
    }
    if (isset($event['dtend'])) {
        $fevent['EndTime'] = icaldate_to_timestamp($event['dtend']);
    } else {
        if (isset($event['duration'])) {
            $fevent['EndTime'] = $fevent['StartTime'] + $event['duration'] * 60;
        } else {
            $fevent['EndTime'] = $fevent['StartTime'];
        }
    }
    // Calculate duration in minutes
    if (isset($event['duration'])) {
        $fevent['Duration'] = $event['duration'];
    } else {
        if (empty($fevent['Duration'])) {
            $fevent['Duration'] = ($fevent['EndTime'] - $fevent['StartTime']) / 60;
        }
    }
    if ($fevent['Duration'] == '1440') {
        // All day event... nothing to do here :-)
    } else {
        if (preg_match("/\\d\\d\\d\\d\\d\\d\\d\\d\$/", $event['dtstart'], $pmatch)) {
            // Untimed event
            $fevent['Duration'] = 0;
            $fevent['Untimed'] = 1;
        }
    }
    if (preg_match("/\\d\\d\\d\\d\\d\\d\\d\\d\$/", $event['dtstart'], $pmatch) && preg_match("/\\d\\d\\d\\d\\d\\d\\d\\d\$/", $event['dtend'], $pmatch2) && $event['dtstart'] != $event['dtend']) {
        $startTime = icaldate_to_timestamp($event['dtstart']);
        $endTime = icaldate_to_timestamp($event['dtend']);
        // Not sure... should this be untimed or allday?
        if ($endTime - $startTime == 3600 * 24) {
            // They used a DTEND set to the next day to say this is an all day
            // event.  We will call this an untimed event.
            $fevent['Duration'] = '0';
            $fevent['Untimed'] = 1;
        } else {
            // Event spans multiple days.  The EndTime actually represents
            // the first day the event does _not_ take place.  So,
            // we need to back up one day since WebCalendar end date is the
            // last day the event takes place.
            $fevent['Repeat']['Interval'] = '1';
            // 1 = daily
            $fevent['Repeat']['Frequency'] = '1';
            // 1 = every day
            $fevent['Duration'] = '0';
            $fevent['Untimed'] = 1;
            $fevent['Repeat']['EndTime'] = $endTime - 24 * 3600;
        }
    }
    $fevent['Summary'] = $event['summary'];
    if (!empty($event['description'])) {
        $fevent['Description'] = $event['description'];
    } else {
        $fevent['Description'] = $event['summary'];
    }
    if (!empty($event['class'])) {
        $fevent['Private'] = preg_match("/private|confidential/i", $event['class']) ? '1' : '0';
    }
    $fevent['UID'] = $event['uid'];
    // Repeats
    //
    // Handle RRULE
    if (!empty($event['rrule'])) {
        // first remove and EndTime that may have been calculated above
        unset($fevent['Repeat']['EndTime']);
        //split into pieces
        //echo "RRULE line: $event[rrule] <br />\n";
        $RR = explode(";", $event['rrule']);
        // create an associative array of key-value paris in $RR2[]
        for ($i = 0; $i < count($RR); $i++) {
            $ar = explode("=", $RR[$i]);
            $RR2[$ar[0]] = $ar[1];
        }
        for ($i = 0; $i < count($RR); $i++) {
            //echo "RR $i = $RR[$i] <br />";
            if (preg_match("/^FREQ=(.+)\$/i", $RR[$i], $match)) {
                if (preg_match("/YEARLY/i", $match[1], $submatch)) {
                    $fevent['Repeat']['Interval'] = 5;
                } else {
                    if (preg_match("/MONTHLY/i", $match[1], $submatch)) {
                        $fevent['Repeat']['Interval'] = 2;
                    } else {
                        if (preg_match("/WEEKLY/i", $match[1], $submatch)) {
                            $fevent['Repeat']['Interval'] = 2;
                        } else {
                            if (preg_match("/DAILY/i", $match[1], $submatch)) {
                                $fevent['Repeat']['Interval'] = 1;
                            } else {
                                // not supported :-(
                                echo "Unsupported iCal FREQ value \"{$match['1']}\"<br />\n";
                            }
                        }
                    }
                }
            } else {
                if (preg_match("/^INTERVAL=(.+)\$/i", $RR[$i], $match)) {
                    $fevent['Repeat']['Frequency'] = $match[1];
                } else {
                    if (preg_match("/^UNTIL=(.+)\$/i", $RR[$i], $match)) {
                        // specifies an end date
                        $fevent['Repeat']['EndTime'] = icaldate_to_timestamp($match[1]);
                    } else {
                        if (preg_match("/^COUNT=(.+)\$/i", $RR[$i], $match)) {
                            // NOT YET SUPPORTED -- TODO
                            echo "Unsupported iCal COUNT value \"{$RR[$i]}\"<br />\n";
                        } else {
                            if (preg_match("/^BYSECOND=(.+)\$/i", $RR[$i], $match)) {
                                // NOT YET SUPPORTED -- TODO
                                echo "Unsupported iCal BYSECOND value \"{$RR[$i]}\"<br />\n";
                            } else {
                                if (preg_match("/^BYMINUTE=(.+)\$/i", $RR[$i], $match)) {
                                    // NOT YET SUPPORTED -- TODO
                                    echo "Unsupported iCal BYMINUTE value \"{$RR[$i]}\"<br />\n";
                                } else {
                                    if (preg_match("/^BYHOUR=(.+)\$/i", $RR[$i], $match)) {
                                        // NOT YET SUPPORTED -- TODO
                                        echo "Unsupported iCal BYHOUR value \"{$RR[$i]}\"<br />\n";
                                    } else {
                                        if (preg_match("/^BYMONTH=(.+)\$/i", $RR[$i], $match)) {
                                            // this event repeats during the specified months
                                            $months = explode(",", $match[1]);
                                            if (count($months) == 1) {
                                                // Change this to a monthly event so we can support repeat by
                                                // day of month (if needed)
                                                // Frequency = 3 (by day), 4 (by date), 6 (by day reverse)
                                                if (!empty($RR2['BYDAY'])) {
                                                    if (preg_match("/^-/", $RR2['BYDAY'], $junk)) {
                                                        $fevent['Repeat']['Interval'] = 6;
                                                    } else {
                                                        $fevent['Repeat']['Interval'] = 3;
                                                    }
                                                    // monthly by day
                                                    $fevent['Repeat']['Frequency'] = 12;
                                                    // once every 12 months
                                                } else {
                                                    // could convert this to monthly by date, but we will just
                                                    // leave it as yearly.
                                                    //$fevent['Repeat']['Interval'] = 4; // monthly by date
                                                }
                                            } else {
                                                // WebCalendar does not support this
                                                echo "Unsupported iCal BYMONTH value \"{$match['1']}\"<br />\n";
                                            }
                                        } else {
                                            if (preg_match("/^BYDAY=(.+)\$/i", $RR[$i], $match)) {
                                                $fevent['Repeat']['RepeatDays'] = rrule_repeat_days($match[1]);
                                            } else {
                                                if (preg_match("/^BYMONTHDAY=(.+)\$/i", $RR[$i], $match)) {
                                                    $fevent['Repeat']['Frequency'] = 4;
                                                    //monthlyByDate
                                                    //echo "Partially Supported iCal BYSETPOS value \"$RR[$i]\"<br />\n";
                                                } else {
                                                    if (preg_match("/^BYSETPOS=(.+)\$/i", $RR[$i], $match)) {
                                                        // NOT YET SUPPORTED -- TODO
                                                        echo "Unsupported iCal BYSETPOS value \"{$RR[$i]}\"<br />\n";
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        // Repeating exceptions?
        if (!empty($event['exdate']) && $event['exdate']) {
            $fevent['Repeat']['Exceptions'] = array();
            $EX = explode(",", $event['exdate']);
            foreach ($EX as $exdate) {
                $fevent['Repeat']['Exceptions'][] = icaldate_to_timestamp($exdate);
            }
        }
    }
    // end if rrule
    return $fevent;
}
Example #5
0
function format_vcal($event)
{
    // Start and end time
    // Set Calendar Type for easier processing later
    $fevent['CalendarType'] = $event['state'];
    $fevent['Untimed'] = $fevent['AllDay'] = 0;
    $fevent['StartTime'] = vcaldate_to_timestamp($event['dtstart']);
    if ($fevent['StartTime'] == '-1') {
        return false;
    }
    $fevent['EndTime'] = vcaldate_to_timestamp($event['dtend']);
    if ($fevent['StartTime'] == $fevent['EndTime']) {
        $fevent['Untimed'] = 1;
        $fevent['Duration'] = 0;
    } else {
        // Calculate duration in minutes
        $fevent['Duration'] = ($fevent['EndTime'] - $fevent['StartTime']) / 60;
        if ($fevent['Duration'] == '1440' && date('His', $fevent['StartTime']) == 0) {
            $fevent['AllDay'] = 1;
        }
    }
    if (!empty($event['summary'])) {
        $fevent['Summary'] = $event['summary'];
    }
    if (!empty($event['description'])) {
        $fevent['Description'] = $event['description'];
    }
    if (!empty($event['descriptionqp'])) {
        $fevent['Description'] = quoted_printable_decode($event['descriptionqp']);
        // hack for mozilla sunbird's extra = signs
        $fevent['Description'] = preg_replace('/^=/', '', $fevent['Description']);
        $fevent['Description'] = str_replace("\n=", "\n", $fevent['Description']);
    }
    if (!empty($event['class'])) {
        // Added  Confidential as new CLASS
        if (preg_match('/private/i', $event['class'])) {
            $fevent['Class'] = 'R';
        } elseif (preg_match('/confidential/i', $event['class'])) {
            $fevent['Class'] = 'C';
        } else {
            $fevent['Class'] = 'P';
        }
    }
    if (!empty($fevent['UID'])) {
        $fevent['UID'] = $event['uid'];
    }
    // Repeats
    // vcal 1.0 repeats can be very complicated and the webcalendar doesn't
    // actually support all of the ways repeats can be specified. We will
    // focus on vcals dumped from Palm Desktop and Lotus Notes, which are simple
    // and the ones webcalendar should fully support.
    if (!empty($event['rrule'])) {
        // split into pieces
        $RR = explode(' ', $event['rrule']);
        if (preg_match('/^D(.+)$/i', $RR[0], $match)) {
            $fevent['Repeat']['Frequency'] = '1';
            $fevent['Repeat']['Interval'] = $match[1];
        } elseif (preg_match('/^W(.+)$/i', $RR[0], $match)) {
            $fevent['Repeat']['Frequency'] = '2';
            $fevent['Repeat']['Interval'] = $match[1];
            $fevent['Repeat']['ByDay'] = rrule_repeat_days($RR);
        } elseif (preg_match('/^MP(.+)$/i', $RR[0], $match)) {
            $fevent['Repeat']['Frequency'] = '3';
            $fevent['Repeat']['Interval'] = $match[1];
            if ($RR[1] == '5+') {
                $fevent['Repeat']['Frequency'] = '3';
            }
        } elseif (preg_match('/^MD(.+)$/i', $RR[0], $match)) {
            $fevent['Repeat']['Frequency'] = '4';
            $fevent['Repeat']['Interval'] = $match[1];
        } elseif (preg_match('/^YM(.+)$/i', $RR[0], $match)) {
            $fevent['Repeat']['Frequency'] = '6';
            $fevent['Repeat']['Interval'] = $match[1];
        } elseif (preg_match('/^YD(.+)$/i', $RR[0], $match)) {
            $fevent['Repeat']['Frequency'] = '6';
            $fevent['Repeat']['Interval'] = $match[1];
        }
        $end = end($RR);
        // No end in Palm is 12-31-2031
        if ($end != '20311231' && $end != '#0') {
            if (preg_match('/^\\#(.+)$/i', $end, $match)) {
                $fevent['Repeat']['Count'] = $match[1];
            }
        }
        //.
        // Repeating exceptions?
        if (!empty($event['exdate'])) {
            $fevent['Repeat']['Exceptions'] = array();
            $EX = explode(',', $event['exdate']);
            foreach ($EX as $exdate) {
                $fevent['Repeat']['Exceptions'][] = vcaldate_to_timestamp($exdate);
            }
        }
    }
    // end if rrule
    // TODO
    // $fevent[Category];
    return $fevent;
}