From a083737ab3a31bcbbdd2289c7faf78a22a96b590 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 3 Jan 2011 17:24:29 -0800 Subject: [PATCH] Do not extend recurrent for events in the trash. Do not extend them in the clipboard either, since it'll either make a mess in the clipboard or pop them up on the calendar automatically. Fixes bug #11995 --- docs/changelog/7.x.x.txt | 1 + .../Activity/ExtendCalendarRecurrences.pm | 5 +++ .../Activity/ExtendCalendarRecurrences.t | 37 ++++++++++++++++++- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 214efc408..f4c08cfdc 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -15,6 +15,7 @@ - fixed #12012: WebGUI Account system does not present login to visitors for proper redirect - fixed #12015: Thingy: Custom 'File' form fields get deleted upon save - fixed #11994: recurring calendar entries + - fixed #11995: recurring calendar entries in trash 7.10.6 - fixed #11974: Toolbar icons unclickable in Webkit using HTML5 diff --git a/lib/WebGUI/Workflow/Activity/ExtendCalendarRecurrences.pm b/lib/WebGUI/Workflow/Activity/ExtendCalendarRecurrences.pm index 465b3cb2e..d5e35ff15 100644 --- a/lib/WebGUI/Workflow/Activity/ExtendCalendarRecurrences.pm +++ b/lib/WebGUI/Workflow/Activity/ExtendCalendarRecurrences.pm @@ -170,6 +170,11 @@ sub processRecurrence { $self->session->log->warn("Unable to instanciate event with assetId $eventId"); return 0; } + ##Ignore assets in the trash. Same with assets in the clipboard since they would not be + ##put into the clipboard. + if ($event->get('state') ne 'published') { + return 0; + } my $recur = $event->getRecurrence; my $versionTag = WebGUI::VersionTag->create($self->session, {name => 'Extend Calendar Recurrence for assetId '.$event->getId, }); diff --git a/t/Workflow/Activity/ExtendCalendarRecurrences.t b/t/Workflow/Activity/ExtendCalendarRecurrences.t index 7bb514eec..befc87a97 100644 --- a/t/Workflow/Activity/ExtendCalendarRecurrences.t +++ b/t/Workflow/Activity/ExtendCalendarRecurrences.t @@ -41,9 +41,26 @@ my $event = $calendar->addChild( }, undef, undef, {skipAutoCommitWorkflows => 1, } ); +my $trashed_event = $calendar->addChild( + { className => 'WebGUI::Asset::Event', + startDate => $one_year_ago, + endDate => $one_year_ago, + }, undef, undef, {skipAutoCommitWorkflows => 1, } +); +$trashed_event->trash; + +my $clipped_event = $calendar->addChild( + { className => 'WebGUI::Asset::Event', + startDate => $one_year_ago, + endDate => $one_year_ago, + }, undef, undef, {skipAutoCommitWorkflows => 1, } +); +$clipped_event->cut; + $tag->commit; -$calendar = $calendar->cloneFromDb; -$event = $event->cloneFromDb; +foreach my $asset($calendar, $event, $clipped_event, $trashed_event) { + $asset = $asset->cloneFromDb; +} my $recurId = $event->setRecurrence( { recurType => 'monthDay', @@ -53,6 +70,22 @@ my $recurId = $event->setRecurrence( } ); +$trashed_event->setRecurrence( + { recurType => 'monthDay', + every => 2, + startDate => $trashed_event->get('startDate'), + dayNumber => $eventStartDate->day, + } +); + +$clipped_event->setRecurrence( + { recurType => 'monthDay', + every => 2, + startDate => $clipped_event->get('startDate'), + dayNumber => $eventStartDate->day, + } +); + my $workflow = WebGUI::Workflow->create( $session, { enabled => 1,