From 6c8e840fe60664d4706cf37dce947344df4fe0e3 Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Fri, 16 Feb 2007 19:37:39 +0000 Subject: [PATCH] fix: Events are created with no group information --- docs/changelog/7.x.x.txt | 1 + docs/upgrades/upgrade_7.3.9-7.3.10.pl | 25 +++++++++++++++++++++++++ lib/WebGUI/Asset/Event.pm | 18 +++++++++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index ecb2e7230..659529cbf 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -13,6 +13,7 @@ committed revision of an Event, instead of a random revision. - fix: Calendars created with the 7.2.3-7.3.0 upgrade now have the same URL as the Events Calendars they replace. + - fix: Events are created with no group information. 7.3.9 - fix: SQL Form and big table imports diff --git a/docs/upgrades/upgrade_7.3.9-7.3.10.pl b/docs/upgrades/upgrade_7.3.9-7.3.10.pl index a13427700..fcbc70b3f 100644 --- a/docs/upgrades/upgrade_7.3.9-7.3.10.pl +++ b/docs/upgrades/upgrade_7.3.9-7.3.10.pl @@ -21,6 +21,7 @@ my $quiet; # this line required my $session = start(); # this line required # upgrade functions go here +fixEventGroups($session); finish($session); # this line required @@ -32,7 +33,31 @@ finish($session); # this line required # # and here's our code #} +#---------------------------------------------------------------------------- +sub fixEventGroups { + my $session = shift; + print "\tFixing Event groups for Events created since 7.3.0....."; + my $events = WebGUI::Asset->getRoot($session)->getLineage(['descendents'], { + statesToInclude => ['published','trash','clipboard','clipboard-limbo','trash-limbo'], + statusToInclude => ['pending','approved','deleted','archived'], + includeOnlyClasses => ['WebGUI::Asset::Event'], + returnObjects => 1, + whereClause => q{groupIdView = "" || groupIdEdit = "" || groupIdView IS NULL || groupIdEdit IS NULL}, + }); + + for my $event (@$events) { + my $revisionProperties = $event->get; + + $revisionProperties->{groupIdView} ||= $event->getParent->get("groupIdView"); + $revisionProperties->{groupIdEdit} ||= $event->getParent->get("groupIdEventEdit") + || $event->getParent->get("groupIdEdit"); + + $event->addRevision($revisionProperties, undef, {skipAutoCommitWorkflows=>1}); + } + + print "\tOK\n"; +} # ---- DO NOT EDIT BELOW THIS LINE ---- diff --git a/lib/WebGUI/Asset/Event.pm b/lib/WebGUI/Asset/Event.pm index 56d867fe5..22619e853 100644 --- a/lib/WebGUI/Asset/Event.pm +++ b/lib/WebGUI/Asset/Event.pm @@ -1407,10 +1407,26 @@ sub processPropertiesFromFormPost { } - ### Form is verified + ### Form is verified, fix properties # Events are always hidden from navigation $self->update({ isHidden => 1 }); + # If there is no security information, grab it from the parent + if (!$self->get("groupIdView")) { + $self->update({ + groupIdView => $self->getParent->get("groupIdView"), + }); + } + if (!$self->get("groupIdEdit")) { + my $groupIdEdit = $self->getParent->get("groupIdEventEdit") + || $self->getParent->get("groupIdEdit") + ; + + $self->update({ + groupIdEdit => $groupIdEdit, + }); + } + # Fix times according to input (allday, timezone) if ($form->param("allday")) { $self->update({