diff --git a/lib/WebGUI/Asset/Event.pm b/lib/WebGUI/Asset/Event.pm index c9af2c516..24dcde8a0 100644 --- a/lib/WebGUI/Asset/Event.pm +++ b/lib/WebGUI/Asset/Event.pm @@ -158,9 +158,9 @@ Extent the method from the super class to handle iCalSequenceNumbers. =cut -sub addRevision { +override addRevision => sub { my $self = shift; - my $newRev = $self->SUPER::addRevision(@_); + my $newRev = super(); my $sequenceNumber = $newRev->iCalSequenceNumber; if (defined $sequenceNumber) { $sequenceNumber++; @@ -174,7 +174,7 @@ sub addRevision { $newRev->update({storageId => $newStorage->getId}); } return $newRev; -} +}; #------------------------------------------------------------------- diff --git a/lib/WebGUI/Asset/File.pm b/lib/WebGUI/Asset/File.pm index 203fe6507..def703ae1 100644 --- a/lib/WebGUI/Asset/File.pm +++ b/lib/WebGUI/Asset/File.pm @@ -93,9 +93,9 @@ Override the default method in order to deal with attachments. =cut -sub addRevision { - my $self = shift; - my $newSelf = $self->SUPER::addRevision(@_); +override addRevision => sub { + my $self = shift; + my $newSelf = super(); if ($newSelf->storageId && $newSelf->storageId eq $self->storageId) { my $newStorage = $self->getStorageClass->get($self->session, $self->storageId)->copy; @@ -103,7 +103,7 @@ sub addRevision { } return $newSelf; -} +}; #------------------------------------------------------------------- diff --git a/lib/WebGUI/Asset/MatrixListing.pm b/lib/WebGUI/Asset/MatrixListing.pm index f0f10c2ae..ac170eac5 100644 --- a/lib/WebGUI/Asset/MatrixListing.pm +++ b/lib/WebGUI/Asset/MatrixListing.pm @@ -139,23 +139,6 @@ These methods are available from this class: =cut - - -#------------------------------------------------------------------- - -=head2 addRevision - - This method exists for demonstration purposes only. The superclass - handles revisions to MatrixListing Assets. - -=cut - -sub addRevision { - my $self = shift; - my $newSelf = $self->next::method(@_); - return $newSelf; -} - #---------------------------------------------------------------------------- =head2 canAdd ( ) @@ -195,22 +178,6 @@ sub canEdit { #------------------------------------------------------------------- -=head2 duplicate - - This method exists for demonstration purposes only. The superclass - handles duplicating MatrixListing Assets. This method will be called - whenever a copy action is executed - -=cut - -sub duplicate { - my $self = shift; - my $newAsset = $self->next::method(@_); - return $newAsset; -} - -#------------------------------------------------------------------- - =head2 getAutoCommitWorkflowId Gets the WebGUI::VersionTag workflow to use to automatically commit MatrixListings. @@ -538,19 +505,6 @@ sub purge { #------------------------------------------------------------------- -=head2 purgeRevision ( ) - -This method is called when data is purged by the system. - -=cut - -sub purgeRevision { - my $self = shift; - return $self->next::method; -} - -#------------------------------------------------------------------- - =head2 setRatings ( ratings ) Sets the ratings for a matrix listing diff --git a/lib/WebGUI/Asset/Post.pm b/lib/WebGUI/Asset/Post.pm index ac868ef0c..fb5cc00b3 100644 --- a/lib/WebGUI/Asset/Post.pm +++ b/lib/WebGUI/Asset/Post.pm @@ -77,9 +77,6 @@ with 'WebGUI::Role::Asset::AlwaysHidden'; with 'WebGUI::Role::Asset::SetStoragePermissions'; - -use WebGUI::Asset::Template; -use WebGUI::Asset::Post::Thread; use WebGUI::Group; use WebGUI::HTML; use WebGUI::HTMLForm; @@ -139,27 +136,28 @@ Override the default method in order to deal with attachments. =cut -sub addRevision { - my $self = shift; - my $newSelf = $self->SUPER::addRevision(@_); - if ($newSelf->storageId && $newSelf->storageId eq $self->storageId) { - my $newStorage = WebGUI::Storage->get($self->session,$self->storageId)->copy; - $newSelf->update({storageId=>$newStorage->getId}); +override addRevision => sub { + my $self = shift; + my $newSelf = super(); + if ( $newSelf->storageId && $newSelf->storageId eq $self->storageId ) { + my $newStorage = WebGUI::Storage->get( $self->session, $self->storageId )->copy; + $newSelf->update( { storageId => $newStorage->getId } ); + } + my $threadId = $newSelf->threadId; + my $now = time(); + if ( $threadId eq "" ) { # new post + if ( $newSelf->getParent->isa("WebGUI::Asset::Wobject::Collaboration") ) { + $newSelf->update( { threadId => $newSelf->getId } ); } - my $threadId = $newSelf->threadId; - my $now = time(); - if ($threadId eq "") { # new post - if ($newSelf->getParent->isa("WebGUI::Asset::Wobject::Collaboration")) { - $newSelf->update({threadId=>$newSelf->getId}); - } else { - $newSelf->update({threadId=>$newSelf->getParent->threadId}); - } - delete $newSelf->{_thread}; - } - $newSelf->getThread->unmarkRead; + else { + $newSelf->update( { threadId => $newSelf->getParent->threadId } ); + } + delete $newSelf->{_thread}; + } + $newSelf->getThread->unmarkRead; - return $newSelf; -} + return $newSelf; +}; #------------------------------------------------------------------- @@ -269,20 +267,20 @@ increment replies for the parent thread. =cut -sub commit { - my $self = shift; - $self->SUPER::commit; - - $self->notifySubscribers unless ($self->shouldSkipNotification); - - if ($self->isNew) { - if ($self->session->setting->get("useKarma") && $self->getThread->getParent->karmaPerPost) { - my $u = WebGUI::User->new($self->session, $self->ownerUserId); - $u->karma($self->getThread->getParent->karmaPerPost, $self->getId, "Collaboration post"); - } - $self->getThread->incrementReplies($self->revisionDate,$self->getId);# if ($self->isReply); - } -} +override commit => sub { + my $self = shift; + super(); + + $self->notifySubscribers unless ( $self->shouldSkipNotification ); + + if ( $self->isNew ) { + if ( $self->session->setting->get("useKarma") && $self->getThread->getParent->karmaPerPost ) { + my $u = WebGUI::User->new( $self->session, $self->ownerUserId ); + $u->karma( $self->getThread->getParent->karmaPerPost, $self->getId, "Collaboration post" ); + } + $self->getThread->incrementReplies( $self->revisionDate, $self->getId ); # if ($self->isReply); + } +}; #------------------------------------------------------------------- diff --git a/lib/WebGUI/Asset/Post/Thread.pm b/lib/WebGUI/Asset/Post/Thread.pm index 87612c057..e8d86a98e 100644 --- a/lib/WebGUI/Asset/Post/Thread.pm +++ b/lib/WebGUI/Asset/Post/Thread.pm @@ -85,12 +85,12 @@ Extend the base method to handle creating a subscription group for this Thread. =cut -sub addRevision { - my $self = shift; - my $newSelf = $self->SUPER::addRevision(@_); +override addRevision => sub { + my $self = shift; + my $newSelf = super(); $newSelf->createSubscriptionGroup; return $newSelf; -} +}; #------------------------------------------------------------------- diff --git a/lib/WebGUI/Asset/Sku/Product.pm b/lib/WebGUI/Asset/Sku/Product.pm index 94fe766e8..b5bdde68f 100644 --- a/lib/WebGUI/Asset/Sku/Product.pm +++ b/lib/WebGUI/Asset/Sku/Product.pm @@ -178,9 +178,9 @@ Override the default method in order to deal with attachments. =cut -sub addRevision { +override addRevision => sub { my $self = shift; - my $newSelf = $self->SUPER::addRevision(@_); + my $newSelf = super(); if ($newSelf->getRevisionCount > 1) { foreach my $field (qw(image1 image2 image3 brochure manual warranty)) { if ($self->get($field)) { @@ -190,7 +190,7 @@ sub addRevision { } } return $newSelf; -} +}; #------------------------------------------------------------------- diff --git a/lib/WebGUI/Asset/Snippet.pm b/lib/WebGUI/Asset/Snippet.pm index 2b1ca33ce..a1de5415b 100644 --- a/lib/WebGUI/Asset/Snippet.pm +++ b/lib/WebGUI/Asset/Snippet.pm @@ -126,20 +126,6 @@ These methods are available from this class: -#------------------------------------------------------------------- - -=head2 addRevision ( properties, ... ) - -Force the packed snippet to be regenerated. - -=cut - -sub addRevision { - my ( $self, $properties, @args ) = @_; - delete $properties->{ snippetPacked }; - return $self->SUPER::addRevision( $properties, @args ); -} - #------------------------------------------------------------------- =head2 exportGetUrlAsPath ( index ) diff --git a/lib/WebGUI/Asset/Template.pm b/lib/WebGUI/Asset/Template.pm index 646cd8571..e90f32e37 100644 --- a/lib/WebGUI/Asset/Template.pm +++ b/lib/WebGUI/Asset/Template.pm @@ -157,13 +157,13 @@ Override the master addRevision to copy attachments =cut -sub addRevision { +override addRevision => sub { my ( $self, $properties, @args ) = @_; - my $asset = $self->SUPER::addRevision($properties, @args); + my $asset = super(); delete $properties->{templatePacked}; $asset->addAttachments($self->getAttachments); return $asset; -} +}; #------------------------------------------------------------------- @@ -193,12 +193,12 @@ copy. =cut -sub duplicate { - my $self = shift; - my $newTemplate = $self->SUPER::duplicate; +override duplicate => sub { + my $self = shift; + my $newTemplate = super(); $newTemplate->update({isDefault => 0}); return $newTemplate; -} +}; #------------------------------------------------------------------- @@ -710,11 +710,11 @@ Override the master purgeRevision to purge attachments =cut -sub purgeRevision { +override purgeRevision => sub { my $self = shift; $self->removeAttachments; - return $self->SUPER::purgeRevision(@_); -} + return super(); +}; #-------------------------------------------------------------------