From c60246816752a18ba37b8f3508799acd17686b30 Mon Sep 17 00:00:00 2001 From: Jim Hu Date: Fri, 2 Jan 2009 07:12:12 +0000 Subject: add download event to event popup --- config.inc.php | 15 +++++++++++++++ default_config.php | 3 ++- functions/ical_parser.php | 4 +++- functions/init.inc.php | 6 ++++-- functions/parse/end_vevent.php | 3 +++ functions/parse/parse_tzs.php | 5 +++-- includes/event.php | 31 +++++++++++++++++++++++++++++++ languages/english.inc.php | 2 +- templates/default/event.tpl | 3 +++ 9 files changed, 65 insertions(+), 7 deletions(-) diff --git a/config.inc.php b/config.inc.php index b940a92..f99799c 100644 --- a/config.inc.php +++ b/config.inc.php @@ -65,6 +65,21 @@ phpicalendar currently supports about 30 language variants. For a list of suppo # 'week_length' => '5', // Number of days to display in the week view # 'day_start' => '0600', // Start time for day grid # 'day_end' => '2000', // End time for day grid +# 'event_download' => 'yes', + + +/* ========= CALENDAR PUBLISHING ========= + + This section is not needed if your calendars directory is accessible via WebDAV or CalDAV. These settings + control the publish.php script provided in the calendars directory. For more information, please see that + file. +*/ + + 'phpicalendar_publishing'=> 1, + + + + ); /* ========= SPECIAL CALENDARS ========= diff --git a/default_config.php b/default_config.php index 18c44bd..7c69307 100644 --- a/default_config.php +++ b/default_config.php @@ -2,7 +2,7 @@ class Configs{ private static $instance; private function __construct(){ - $this->phpicalendar_version = '2.31rc2'; + $this->phpicalendar_version = '2.31rc3'; // Configuration file for PHP iCalendar 2.25rc1 // // To set values, change the text between the single quotes @@ -47,6 +47,7 @@ class Configs{ $this->printview_default = 'no'; // Set print view as the default view. day, week, and month only supported views for $this->default_view (listed well above). $this->show_todos = 'yes'; // Show your todo list on the side of day and week view. $this->show_completed = 'yes'; // Show completed todos on your todo list. + $this->event_download = 'no'; // Show completed todos on your todo list. $this->allow_login = 'no'; // Set to yes to prompt for login to unlock calendars. $this->login_cookies = 'no'; // Set to yes to store authentication information via (unencrypted) cookies. Set to no to use sessions. $this->support_ical = 'no'; // Set to yes to support the Apple iCal calendar database structure. diff --git a/functions/ical_parser.php b/functions/ical_parser.php index 5e1afc6..aaaba93 100644 --- a/functions/ical_parser.php +++ b/functions/ical_parser.php @@ -126,7 +126,6 @@ foreach ($cal_filelist as $cal_key=>$filename) { $nextline = ereg_replace("[\r\n]", "", $nextline); } $line = trim(stripslashes($line)); - switch ($line) { case 'BEGIN:VFREEBUSY': case 'BEGIN:VEVENT': @@ -150,6 +149,7 @@ foreach ($cal_filelist as $cal_key=>$filename) { $url = ''; $geo = ''; $type = ''; + $other = ''; $wkst = 'MO'; $except_dates = array(); @@ -440,6 +440,8 @@ foreach ($cal_filelist as $cal_key=>$filename) { case 'URL': $url = $data; break; + default: + if(strpos(':',$data) > 1) $other .= $data; } } } diff --git a/functions/init.inc.php b/functions/init.inc.php index 1b227cc..8ca11f6 100644 --- a/functions/init.inc.php +++ b/functions/init.inc.php @@ -1,7 +1,11 @@ $class, 'spans_day' => $spans_day, 'location' => $location, + 'categories' => $vtodo_categories, 'organizer' => serialize($organizer), 'attendee' => serialize($attendee), 'calnumber' => $calnumber, 'calname' => $actual_calname, + 'timezone' => $start_tz, + 'other' => trim($other), 'geo' => $geo, 'url' => $url, 'recur' => $recur diff --git a/functions/parse/parse_tzs.php b/functions/parse/parse_tzs.php index 8b02cb5..fb250b2 100644 --- a/functions/parse/parse_tzs.php +++ b/functions/parse/parse_tzs.php @@ -43,9 +43,10 @@ while (!feof($ifile)) { $is_daylight = false; break; case 'END:VTIMEZONE': + if (!isset($offset_d) && isset($offset_s)) $offset_d = $offset_s; $tz_array[$tz_id] = array( - 0 => $offset_s, - 1 => $offset_d, + 0 => @$offset_s, + 1 => @$offset_d, 'dt_start' => @$begin_daylight, 'st_start' => @$begin_std, 'st_name' => @$st_name, diff --git a/includes/event.php b/includes/event.php index c15f3d2..7cafa8a 100644 --- a/includes/event.php +++ b/includes/event.php @@ -11,6 +11,7 @@ require_once(BASE.'functions/template.php'); $event = unserialize(stripslashes($_POST['event_data'])); $organizer = unserialize($event['organizer']); $attendee = unserialize($event['attendee']); +$uid = stripslashes($_POST['uid']); // Format event time // All day @@ -71,6 +72,35 @@ switch ($event['status']){ $event['status'] = '' ; } +$event_download = ''; +if($phpiCal_config->event_download == 'yes') $event_download = " +
+ + + +"; + +if (isset($_POST['submit'])){ +header("Content-Type: text/calendar; charset=utf-8; name=$uid"); +header("Content-Disposition: attachment; filename=$uid"); +echo +"BEGIN:VCALENDAR +VERSION:2.0 +X-WR-CALNAME:".$event['calname']." +BEGIN:VEVENT +UID:$uid +SUMMARY:".$event['event_text']." +CATEGORIES:".$event['calname']." +DTSTART;TZID=".$event['timezone'].":".date("Ymd\THis",$event['start_unixtime'])." +DTEND;TZID=".$event['timezone'].":".date("Ymd\THis",$event['start_unixtime'])." +CLASS:".$event['class']." +".$event['other']." +SEQUENCE:1 +CREATED:20081128T075152 +END:VEVENT +END:VCALENDAR +";exit; +} $page = new Page(BASE.'templates/'.$phpiCal_config->template.'/event.tpl'); $page->replace_tags(array( @@ -83,6 +113,7 @@ $page->replace_tags(array( 'attendee' => $attendee, 'status' => $event['status'], 'location' => $event['location'], + 'event_download' => $event_download, 'url' => $event['url'], 'cal_title_full' => $event['calname'].' '.$lang['l_calendar'], 'template' => $phpiCal_config->template, diff --git a/languages/english.inc.php b/languages/english.inc.php index b85f6a5..075babf 100644 --- a/languages/english.inc.php +++ b/languages/english.inc.php @@ -98,6 +98,7 @@ $lang['l_unset_prefs'] = 'Unset preferences'; $lang['l_organizer'] = 'Organizer'; $lang['l_attendee'] = 'Attendee'; $lang['l_location'] = 'Location'; +$lang['l_download_event'] = 'Download event'; $lang['l_url'] = 'URL'; $lang['l_admin_header'] = 'PHP iCalendar Administration'; $lang['l_username'] = 'Username'; @@ -206,7 +207,6 @@ Notes about dateFormat_* $lang['l_error_title'] = 'Error!'; $lang['l_error_window'] = 'There was an error!'; $lang['l_error_calendar'] = 'The calendar "%s" was being processed when this error occurred.'; -$lang['l_php_version_required'] = 'PHP version "%s" detected. PHP 5.1 or greater is required to run this version of phpicalendar.'; $lang['l_error_path'] = 'Unable to open the path: "%s"'; $lang['l_error_back'] = 'Please use the "Back" button to return.'; $lang['l_error_remotecal'] = 'This server blocks remote calendars which have not been approved.'; diff --git a/templates/default/event.tpl b/templates/default/event.tpl index b0a9a7f..fbd5e44 100644 --- a/templates/default/event.tpl +++ b/templates/default/event.tpl @@ -35,6 +35,9 @@ {L_URL}: {URL}
+ + {EVENT_DOWNLOAD}
+

-- cgit v1.2.3