Have the Calendar iCal feed pass along the timeZone of events. Fixes bug #12030.

Squashed commit of the following:

commit ce957db5311c7fb11c7d780b9f63c1b0adc17cda
Author: Colin Kuskie <colink@perldreamer.com>
Date:   Mon Jan 31 19:00:23 2011 -0800

    Changelog notice for the ical bugfix with timezones.

commit 24a3bc1c74b20ca6ba689641fa0187b659dc3c5e
Author: Colin Kuskie <colink@perldreamer.com>
Date:   Mon Jan 31 15:32:50 2011 -0800

    Transfer the time zone as one of the WebGUI specific items for the Event.

commit 36f87539ba8b090a5e5c9f1879cd40b6f6e69afc
Author: Colin Kuskie <colink@perldreamer.com>
Date:   Sun Jan 30 21:18:12 2011 -0800

    Refactor the code so that the Event adds itself to a calendar object, giving it access to add other things to the calendar, like a timezone definition.

commit f401966bd53b51950f1402a5a19b92b13dcc6b06
Author: Colin Kuskie <colink@perldreamer.com>
Date:   Sun Jan 30 19:42:49 2011 -0800

    Document which version of Data::ICal that we're now using.

commit 689522e30b26fc445da5b59b81789c0d72e157d4
Author: Colin Kuskie <colink@perldreamer.com>
Date:   Sat Jan 29 14:27:25 2011 -0800

    Fix a typo in the Event preventing menuTitle from being sent out.  Fix issue with the menuTitle being set twice.  Update the test to fix long string handling.

commit 59043eee1536e60d92f23313a33dc54da6f15122
Author: Colin Kuskie <colink@perldreamer.com>
Date:   Fri Jan 28 19:48:16 2011 -0800

    Move iCal generation over to Data::ICal.  Give each event the ability to return itself as an Data::ICal::Entry::Event object.

commit eec448b38c101b599c0fb695f442012e311385fb
Author: Colin Kuskie <colink@perldreamer.com>
Date:   Fri Jan 28 19:47:14 2011 -0800

    Document new testing module.  It't only required if you're doing testing.

commit 3d1e82229423834330dcdd31c0a81df986df0f32
Author: Colin Kuskie <colink@perldreamer.com>
Date:   Fri Jan 28 17:05:09 2011 -0800

    Fix setting the title in the iCal feed.

commit 458f4d2e0e1faa1cc6dcb7107040d06b51b97d36
Author: Colin Kuskie <colink@perldreamer.com>
Date:   Fri Jan 28 13:37:52 2011 -0800

    Rewrite of CalendarUpdateFeeds to use Data::ICal

commit 1a271ebc78bbe8b21a26f7a0dba61d1462922f30
Author: Colin Kuskie <colink@perldreamer.com>
Date:   Fri Jan 28 10:49:27 2011 -0800

    Begin building an ICal object for parsing the ical feeds.
This commit is contained in:
Colin Kuskie 2011-01-31 19:05:04 -08:00
parent 93646ad8e6
commit 8ae16ba37c
8 changed files with 110 additions and 161 deletions

View file

@ -28,6 +28,7 @@ use WebGUI::Storage;
use Test::Deep::NoTest qw(eq_deeply);
use DateTime::Event::ICal;
use DateTime::Set;
use Data::ICal::Entry::Event;
use base 'WebGUI::Asset';
@ -74,6 +75,54 @@ sub addRevision {
return $newRev;
}
####################################################################
=head2 add_to_calendar ($iCal)
Build a Data::ICal::Entry::Event object that contains the information for this
event and add it to the Data::ICal calendar
=head3 $iCal
A Data::ICal object, representing the top-level calendar instance.
=cut
sub add_to_calendar {
my $self = shift;
my $session = $self->session;
my $calendar = shift;
my $event = Data::ICal::Entry::Event->new();
$event->add_properties(
'last-modified' => WebGUI::DateTime->new($session, $event->get("revisionDate"))->toIcal,
created => WebGUI::DateTime->new($session, $event->get("creationDate"))->toIcal,
sequence => $self->get('iCalSequenceNumber'),
summary => $self->get('title'),
description => $self->get('description'),
location => $self->get('location'),
uid => $self->get('feedUid')
? $self->get('feedUid')
: $self->get('assetId') . '@'. $session->config->get("sitename")->[0],
);
##WebGUI Specific fields
foreach my $prop (qw/groupIdView groupIdEdit url menuTitle timeZone/) {
$event->add_property( 'x-webgui-'.lc($prop) => $self->get($prop));
}
my $eventStart = $self->getIcalStart;
my $start_parameters = {};
if (! $eventStart =~ /T/) {
$start_parameters->{VALUE} = 'DATE';
}
$event->add_property(dtstart => [ $eventStart, $start_parameters ]);
my $eventEnd = $self->getIcalEnd;
my $end_parameters = {};
if (! $eventEnd =~ /T/) {
$end_parameters->{VALUE} = 'DATE';
}
$event->add_property(dtend => [ $eventEnd, $end_parameters ]);
$calendar->add_entry($event);
}
{
my %dayNamesToICal = (

View file

@ -19,6 +19,7 @@ use WebGUI::International;
use WebGUI::Search;
use WebGUI::Form;
use WebGUI::HTML;
use WebGUI::ICal;
use WebGUI::DateTime;
use Class::C3;
@ -1736,97 +1737,20 @@ sub www_ical {
$dt_end = $dt_start->clone->add( seconds => $self->get('icalInterval') );
}
my $ical = WebGUI::ICal->new();
# Get all the events we're going to display
my @events = $self->getEventsIn($dt_start->toMysql,$dt_end->toMysql);
my $ical = qq{BEGIN:VCALENDAR\r\n}
. qq{PRODID:WebGUI }.$WebGUI::VERSION."-".$WebGUI::STATUS.qq{\r\n}
. qq{VERSION:2.0\r\n};
# VEVENT:
EVENT: for my $event (@events) {
next EVENT unless $event->canView();
$ical .= qq{BEGIN:VEVENT\r\n};
### UID
# Use feed's UID to prevent over-propagation
if ($event->get("feedUid")) {
$ical .= qq{UID:}.$event->get("feedUid")."\r\n";
}
# Create a UID for feeds native to this calendar
else {
my $domain = $session->config->get("sitename")->[0];
$ical .= qq{UID:}.$event->get("assetId").'@'.$domain."\r\n";
}
# LAST-MODIFIED (revisionDate)
$ical .= qq{LAST-MODIFIED:}
. WebGUI::DateTime->new($self->session, $event->get("revisionDate"))->toIcal
. "\r\n";
# CREATED (creationDate)
$ical .= qq{CREATED:}
. WebGUI::DateTime->new($self->session, $event->get("creationDate"))->toIcal
. "\r\n";
# SEQUENCE
my $sequenceNumber = $event->get("iCalSequenceNumber");
if (defined $sequenceNumber) {
$ical .= qq{SEQUENCE:}
. $event->get("iCalSequenceNumber")
. "\r\n";
}
# DTSTART
my $eventStart = $event->getIcalStart;
$ical .= 'DTSTART';
if ($eventStart !~ /T/) {
$ical .= ';VALUE=DATE';
}
$ical .= ":$eventStart\r\n";
# DTEND
my $eventEnd = $event->getIcalEnd;
$ical .= 'DTEND';
if ($eventEnd !~ /T/) {
$ical .= ';VALUE=DATE';
}
$ical .= ":$eventEnd\r\n";
# Summary (the title)
# Wrapped at 75 columns
$ical .= $self->wrapIcal("SUMMARY:".$event->get("title"))."\r\n";
# Description (the text)
# Wrapped at 75 columns
$ical .= $self->wrapIcal("DESCRIPTION:".$event->get("description"))."\r\n";
# Location (the text)
# Wrapped at 75 columns
$ical .= $self->wrapIcal("LOCATION:".$event->get("location"))."\r\n";
# X-WEBGUI lines
if ($event->get("groupIdView")) {
$ical .= "X-WEBGUI-GROUPIDVIEW:".$event->get("groupIdView")."\r\n";
}
if ($event->get("groupIdEdit")) {
$ical .= "X-WEBGUI-GROUPIDEDIT:".$event->get("groupIdEdit")."\r\n";
}
$ical .= "X-WEBGUI-URL:".$event->get("url")."\r\n";
$ical .= "X-WEBGUI-MENUTITLE:".$event->get("menuTitle")."\r\n";
$ical .= qq{END:VEVENT\r\n};
$event->add_to_calendar($ical);
}
# ENDVEVENT
$ical .= qq{END:VCALENDAR\r\n};
# Set mime of text/icalendar
#$self->session->http->setMimeType("text/plain");
$self->session->http->setFilename("feed.ics","text/calendar");
return $ical;
return $ical->as_string;
}
#----------------------------------------------------------------------------