Proper Moose setup for addRevision...
This commit is contained in:
parent
64f7bd9365
commit
dee5bbe5d0
8 changed files with 58 additions and 120 deletions
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -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 )
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue