[Bps-public-commit] r19090 - in RT-Extension-MergeUsers/trunk: lib/RT/Extension
falcone at bestpractical.com
falcone at bestpractical.com
Tue Apr 7 17:29:09 EDT 2009
Author: falcone
Date: Tue Apr 7 17:29:09 2009
New Revision: 19090
Modified:
RT-Extension-MergeUsers/trunk/ (props changed)
RT-Extension-MergeUsers/trunk/lib/RT/Extension/MergeUsers.pm
Log:
r46246 at ketch: falcone | 2009-04-07 17:06:03 -0400
* Start handling the MergedUsers attribute when merging/unmerging
Modified: RT-Extension-MergeUsers/trunk/lib/RT/Extension/MergeUsers.pm
==============================================================================
--- RT-Extension-MergeUsers/trunk/lib/RT/Extension/MergeUsers.pm (original)
+++ RT-Extension-MergeUsers/trunk/lib/RT/Extension/MergeUsers.pm Tue Apr 7 17:29:09 2009
@@ -120,6 +120,20 @@
return $self->SUPER::LoadByCols( @_ );
}
+sub GetMergedUsers {
+ my $self = shift;
+
+ my $merged_users = $self->FirstAttribute('MergedUsers');
+ unless ($merged_users) {
+ $self->SetAttribute(
+ Name => 'MergedUsers',
+ Description => 'Users that have been merged into this user',
+ Content => [] );
+ $merged_users = $self->FirstAttribute('MergedUsers');
+ };
+ return $merged_users;
+}
+
sub MergeInto {
my $self = shift;
my $user = shift;
@@ -172,6 +186,9 @@
Content => $merge->id,
);
+ my $merged_users = $merge->GetMergedUsers;
+ $merged_users->SetContent( [$canonical_self->Id, @{$merged_users->Content}] );
+
$canonical_self->SetComments( join "\n", grep /\S/,
$canonical_self->Comments,
"Merged into ". $merge->EmailAddress ." (". $merge->id .")",
@@ -202,6 +219,13 @@
$merge->Comments,
$self->EmailAddress ." (". $self->id .") unmerged from this user",
);
+ my $merged_users = $merge->GetMergedUsers;
+ my @remaining_users = grep { $_ != $self->Id } @{$merged_users->Content};
+ if (@remaining_users) {
+ $merged_users->SetContent(\@remaining_users);
+ } else {
+ $merged_users->Delete;
+ }
return ($merge->id, "Unmerged from @{[$merge->EmailAddress]}");
}
More information about the Bps-public-commit
mailing list