diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 4fbe18b81..8670f9b98 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -10,6 +10,7 @@ - fixed #11990: calendar event view - fixed #12028: i18n Account_Shop - fixed #11989: calendar list view + - fixed #12024: Copied Collaboration System re-sends subscription mail 7.10.7 - rfe #10521: Use monospaced font in template edit textarea diff --git a/lib/WebGUI/Asset/Post.pm b/lib/WebGUI/Asset/Post.pm index a59d71611..a9633cd35 100644 --- a/lib/WebGUI/Asset/Post.pm +++ b/lib/WebGUI/Asset/Post.pm @@ -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. diff --git a/lib/WebGUI/Asset/Post/Thread.pm b/lib/WebGUI/Asset/Post/Thread.pm index 3cb93a6c5..0a764964f 100644 --- a/lib/WebGUI/Asset/Post/Thread.pm +++ b/lib/WebGUI/Asset/Post/Thread.pm @@ -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. diff --git a/t/Asset/Post.t b/t/Asset/Post.t index b33219df0..d03d54276 100644 --- a/t/Asset/Post.t +++ b/t/Asset/Post.t @@ -19,7 +19,7 @@ use strict; use lib "$FindBin::Bin/../lib"; use WebGUI::Test; use WebGUI::Session; -use Test::More tests => 18; # increment this value for each test you create +use Test::More tests => 20; # increment this value for each test you create use Test::Deep; use WebGUI::Asset::Wobject::Collaboration; use WebGUI::Asset::Post; @@ -203,4 +203,16 @@ cmp_bag( 'checking attachment loop with multiple attachments for handling of image and non-image types' ); +###################################################################### +# +# duplicate +# +###################################################################### + +{ + my $post1_copy = $post1->duplicate; + ok $post1_copy->get('storageId'), 'copied post has a storage location'; + isnt $post1->get('storageId'), $post1_copy->get('storageId'), '... and it is different from the source post'; +} + # vim: syntax=perl filetype=perl diff --git a/t/Asset/Post/Thread.t b/t/Asset/Post/Thread.t index b89ae98ec..4e07ae6c9 100644 --- a/t/Asset/Post/Thread.t +++ b/t/Asset/Post/Thread.t @@ -13,7 +13,7 @@ use strict; use lib "$FindBin::Bin/../../lib"; use WebGUI::Test; use WebGUI::Session; -use Test::More tests => 15; # increment this value for each test you create +use Test::More tests => 17; # increment this value for each test you create use Test::MockObject::Extends; use Test::Exception; use WebGUI::Asset::Wobject::Collaboration; @@ -104,4 +104,14 @@ like $thread->getCSLinkUrl, qr/\?pn=5/, 'checking thread on another page, with a $collab->update({threadsPerPage => 0, postsPerPage => 0,}); lives_ok { $uncommittedThread->getCSLinkUrl } '... works when pagination set to 0'; +###################################################################### +# +# duplicate +# +###################################################################### + +my $thread_copy = $thread->duplicate(); +ok $thread_copy->get('subscriptionGroupId'), 'duplicate: copied thread got a subscription group'; +isnt $thread_copy->get('subscriptionGroupId'), $thread->get('subscriptionGroupId'), '... and it is different from the original thread'; + # vim: syntax=perl filetype=perl