From 30158b7f8df73b0ece12bab52cbab9a8fe78cce9 Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Tue, 17 Feb 2009 23:21:30 +0000 Subject: [PATCH] fixed: Collab groupToEditPost shouldn't be empty fixed: WebGUI::User->isInGroup has bad defaulting behavior --- docs/changelog/7.x.x.txt | 2 ++ docs/upgrades/upgrade_7.6.11-7.6.12.pl | 18 ++++++++++++++++++ lib/WebGUI/User.pm | 7 ++++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 6a381e7a0..c2799e19f 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -11,6 +11,8 @@ - fixed #9749: Account Manager: AIM link - fixed #9751: Account Manager: problem sorting in Contributions - fixed #9750: Account Manager: Inbox Messages per Page [TEMPLATE] + - fixed: Collaboration groupToEditPost should not be blank + - fixed: WebGUI::User->isInGroup had bad default groupId 7.6.11 - fixed: Asset Manager can generate URLs that are too long diff --git a/docs/upgrades/upgrade_7.6.11-7.6.12.pl b/docs/upgrades/upgrade_7.6.11-7.6.12.pl index 322f3ff49..afbe63933 100644 --- a/docs/upgrades/upgrade_7.6.11-7.6.12.pl +++ b/docs/upgrades/upgrade_7.6.11-7.6.12.pl @@ -32,6 +32,7 @@ my $quiet; # this line required my $session = start(); # this line required addAssetDiscoveryServiceAgain( $session ); changeMatrixAttributeIndexing( $session ); +fixCollaborationGroupToEditPost( $session ); # upgrade functions go here @@ -75,6 +76,23 @@ sub changeMatrixAttributeIndexing { print "Done.\n" unless $quiet; } +#---------------------------------------------------------------------------- +# Fix the groupToEditPost in the Collaboration (should not be "") +sub fixCollaborationGroupToEditPost { + my $session = shift; + print "\tFixing group to edit post in Collaboration..." unless $quiet; + # and here's our code + $session->db->write(<<'SQL'); +UPDATE Collaboration +SET groupToEditPost= ( + SELECT groupIdEdit FROM assetData + WHERE assetData.assetId=Collaboration.assetId + AND assetData.revisionDate = Collaboration.revisionDate +) +WHERE groupToEditPost = ""; +SQL + print "DONE!\n" unless $quiet; +} # -------------- DO NOT EDIT BELOW THIS LINE -------------------------------- #---------------------------------------------------------------------------- diff --git a/lib/WebGUI/User.pm b/lib/WebGUI/User.pm index 6181c5d0c..1c9255ab2 100644 --- a/lib/WebGUI/User.pm +++ b/lib/WebGUI/User.pm @@ -636,7 +636,7 @@ The group that you wish to verify against the user. Defaults to group with Id 3 sub isInGroup { my (@data, $groupId); my ($self, $gid, $secondRun) = @_; - $gid = 3 unless (defined $gid); + $gid = 3 unless $gid; my $uid = $self->userId; ### The following several checks are to increase performance. If this section were removed, everything would continue to work as normal. #my $eh = $self->session->errorHandler; @@ -650,8 +650,9 @@ sub isInGroup { return $isInGroup->{$uid}{$gid} if exists $isInGroup->{$uid}{$gid}; ### Lookup the actual groupings. my $group = WebGUI::Group->new($self->session,$gid); - # Cope with non-existant groups. Default to the admin group if the groupId is invalid. - $group = WebGUI::Group->new($self->session, 3) unless $group; + if ( !$group ) { + $group = WebGUI::Group->new($self->session,3); + } ### Check for groups of groups. my $users = $group->getAllUsers(); foreach my $user (@{$users}) {