Fix duplicating storages in Posts and subscription groups in threads. Fixes bug #12024.

This commit is contained in:
Colin Kuskie 2011-01-24 19:08:51 -08:00
parent ebf7763d32
commit 052b3dfd45
5 changed files with 66 additions and 2 deletions

View file

@ -403,6 +403,26 @@ sub disqualifyAsLastPost {
#-------------------------------------------------------------------
=head2 duplicate ( )
Extend the base method to handle duplicate storage locations and groups.
=cut
sub duplicate {
my $self = shift;
my $session = $self->session;
my $copy = $self->SUPER::duplicate(@_);
if ($self->get('storageId')) {
my $storage = $self->getStorageLocation;
my $copied_storage = $storage->copy;
$copy->update({storageId => $copied_storage->getId});
}
return $copy;
}
#-------------------------------------------------------------------
=head2 DESTROY
Extend the base method to delete the locally cached thread object.

View file

@ -258,6 +258,27 @@ sub DESTROY {
#-------------------------------------------------------------------
=head2 duplicate
Extends the base method to handle creating a new subscription group.
=cut
sub duplicate {
my $self = shift;
my $session = $self->session;
my $copy = $self->SUPER::duplicate(@_);
if ($self->get('subscriptionGroupId')) {
my $group = WebGUI::Group->new($session, $self->get('subscriptionGroupId'));
my $copied_group = WebGUI::Group->new($session, 'new');
$copied_group->addUsers($group->getUsers('withoutExpired'));
$copy->update({subscriptionGroupId => $copied_group->getId});
}
return $copy;
}
#-------------------------------------------------------------------
=head2 getAdjacentThread ( )
Given a field and an order, returns the nearest thread when sorting by those.