From e5d94f3a5bee7dd2a3aa3a98774bc292f0e7732d Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 18 Apr 2011 16:26:57 -0700 Subject: [PATCH] Fix the display of the lastUpdated and lastResult fields for Calendar iCal feeds. Fix the name of the status field in the Asset definition. Update all revisions of all calendars to fix the issue. Fixes bug #12104. --- docs/changelog/7.x.x.txt | 1 + docs/upgrades/upgrade_7.10.13-7.10.14.pl | 30 +++++++++++++++++++++++- lib/WebGUI/Asset/Wobject/Calendar.pm | 13 +++++++++- lib/WebGUI/Form/JsonTable.pm | 5 +++- 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index ee5c090d1..43501bb47 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -14,6 +14,7 @@ - rfe #12105: Make shortcuts related for export purposes - rfe #12108: Mail to Group preference field - fixed #12107: Viewing an individual transaction item fails + - fixed #12104: Calendar iCal feed status and lastUPdated fields missing 7.10.13 - added #12079: Carousel Auto Play diff --git a/docs/upgrades/upgrade_7.10.13-7.10.14.pl b/docs/upgrades/upgrade_7.10.13-7.10.14.pl index 777e30838..69a519076 100644 --- a/docs/upgrades/upgrade_7.10.13-7.10.14.pl +++ b/docs/upgrades/upgrade_7.10.13-7.10.14.pl @@ -22,6 +22,7 @@ use Getopt::Long; use WebGUI::Session; use WebGUI::Storage; use WebGUI::Asset; +use WebGUI::Asset::Wobject::Calendar; my $toVersion = '7.10.14'; @@ -34,6 +35,7 @@ my $session = start(); # this line required addOrganizationsToTransaction($session); removeDuplicateUndergroundStyleTemplates($session); addRichEditToCarousel($session); +fixBadCalendarFeedStatus($session); finish($session); # this line required @@ -48,6 +50,32 @@ finish($session); # this line required #} +#---------------------------------------------------------------------------- +# Describe what our function does +sub fixBadCalendarFeedStatus { + my $session = shift; + print "\tFix the name of the iCal status field in all Calendar assets... " unless $quiet; + # and here's our code + my $fetch_calendar = WebGUI::Asset::Wobject::Calendar->getIsa($session); + my $sth = $session->db->read('select assetId, revisionDate from Calendar'); + CALENDAR: while (my ($assetId, $revisionDate) = $sth->array) { + my $calendar = eval {WebGUI::Asset->new($session, $assetId, 'WebGUI::Asset::Wobject::Calendar', $revisionDate)}; + next CALENDAR if !$calendar; + FEED: foreach my $feed ( @{ $calendar->getFeeds } ) { + my $status = delete $feed->{status}; + if (!exists $feed->{lastResult}) { + $feed->{lastResult} = $status; + } + if (!exists $feed->{lastUpdated}) { + $feed->{lastUpdated} = 'never'; + } + $calendar->setFeed($feed->{feedId}, $feed); + } + } + $sth->finish; + print "DONE!\n" unless $quiet; +} + #---------------------------------------------------------------------------- # Describe what our function does sub addOrganizationsToTransaction { @@ -78,7 +106,7 @@ sub removeDuplicateUndergroundStyleTemplates { # Describe what our function does sub addRichEditToCarousel { my $session = shift; - print "\tAdd RichEdit option to the Carousel" unless $quiet; + print "\tAdd RichEdit option to the Carousel... " unless $quiet; # and here's our code $session->db->write('ALTER TABLE Carousel ADD COLUMN richEditor CHAR(22) BINARY'); $session->db->write(q!update Carousel set richEditor='PBrichedit000000000001'!); diff --git a/lib/WebGUI/Asset/Wobject/Calendar.pm b/lib/WebGUI/Asset/Wobject/Calendar.pm index e21b237bf..ba2054bd4 100644 --- a/lib/WebGUI/Asset/Wobject/Calendar.pm +++ b/lib/WebGUI/Asset/Wobject/Calendar.pm @@ -274,7 +274,7 @@ sub definition { label => $i18n->get('Feed URL'), }, { - name => 'status', + name => 'lastResult', type => 'readonly', label => $i18n->get('434','WebGUI'), }, @@ -869,6 +869,17 @@ sub processPropertiesFromFormPost { $self->createSubscriptionGroup(); } + my @feeds = @{ $self->getFeeds }; + foreach my $feed (@feeds) { + if ($feed->{lastUpdated} eq 'new') { + $feed->{lastUpdated} = 'never'; + } + if ($feed->{lastResult} eq 'new') { + $feed->{lastResult} = ''; + } + $self->setFeed($feed->{feedId}, $feed); + } + return; } diff --git a/lib/WebGUI/Form/JsonTable.pm b/lib/WebGUI/Form/JsonTable.pm index f4976b411..7511766d5 100644 --- a/lib/WebGUI/Form/JsonTable.pm +++ b/lib/WebGUI/Form/JsonTable.pm @@ -203,7 +203,10 @@ sub toHtml { elsif ( $field->{type} eq "id" ) { $fieldHtml .= ''; } - else { # Readonly or unknown + elsif ( $field->{type} eq "hidden" || $field->{type} eq "readonly" ) { + $fieldHtml .= ''; + } + else { # Unknown $fieldHtml = ' '; }