[Bps-public-commit] RT-Extension-MergeUsers branch, master, updated. 0.03-4-gd99bd97

Kevin Falcone falcone at bestpractical.com
Sat Oct 3 02:41:52 EDT 2009


The branch, master has been updated
       via  d99bd97decc995d7125d45857d9c5714974e0dd3 (commit)
       via  a1eb2b4e76f4c95fd4341abad22c168605579590 (commit)
       via  b1091d23a096735917cb103bb92a09363c8efd15 (commit)
       via  0c7710f25de948d0b40c65a61ff7bd4e8ea9600c (commit)
      from  70a9991e683f1e13e7eebf74202d1508765b1a93 (commit)

Summary of changes:
 Changes                                            |    6 ++++
 META.yml                                           |    2 +-
 .../Admin/Users/Modify.html/RightColumnBottom      |    6 ++--
 lib/RT/Extension/MergeUsers.pm                     |   27 ++++++++++++++++---
 4 files changed, 32 insertions(+), 9 deletions(-)

- Log -----------------------------------------------------------------
commit 0c7710f25de948d0b40c65a61ff7bd4e8ea9600c
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Fri Oct 2 19:31:06 2009 -0400

    clean up warnings

diff --git a/html/Callbacks/RT-Extension-MergeUsers/Admin/Users/Modify.html/RightColumnBottom b/html/Callbacks/RT-Extension-MergeUsers/Admin/Users/Modify.html/RightColumnBottom
index abb3a50..0501a2b 100644
--- a/html/Callbacks/RT-Extension-MergeUsers/Admin/Users/Modify.html/RightColumnBottom
+++ b/html/Callbacks/RT-Extension-MergeUsers/Admin/Users/Modify.html/RightColumnBottom
@@ -47,7 +47,7 @@
 %# END BPS TAGGED BLOCK }}}
 <br />
 <&| /Widgets/TitleBox, title => loc('Merge user') &>
-<p class="error"><% $result %></p>
+<p class="error"><% $result||'' %></p>
 % my ($EffectiveId) = $UserObj->Attributes->Named("EffectiveId");
 % my $MergedUsers = $UserObj->FirstAttribute('MergedUsers');
 % if ($EffectiveId) {
diff --git a/lib/RT/Extension/MergeUsers.pm b/lib/RT/Extension/MergeUsers.pm
index c3ef692..db2d309 100644
--- a/lib/RT/Extension/MergeUsers.pm
+++ b/lib/RT/Extension/MergeUsers.pm
@@ -190,11 +190,11 @@ sub MergeInto {
     $merged_users->SetContent( [$canonical_self->Id, @{$merged_users->Content}] );
 
     $canonical_self->SetComments( join "\n", grep /\S/,
-        $canonical_self->Comments,
+        $canonical_self->Comments||'',
         "Merged into ". $merge->EmailAddress ." (". $merge->id .")",
     );
     $merge->SetComments(join "\n", grep /\S/,
-        $merge->Comments,
+        $merge->Comments||'',
         $canonical_self->EmailAddress." (".$canonical_self->id.") merged into this user",
     );
     return (1, "Merged users successfuly");
@@ -211,7 +211,7 @@ sub UnMerge {
 
     $current->Delete;
     $self->SetComments( join "\n", grep /\S/,
-        $self->Comments,
+        $self->Comments||'',
         "Unmerged from ". $merge->EmailAddress ." (".$merge->id.")",
     );
 

commit b1091d23a096735917cb103bb92a09363c8efd15
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Fri Oct 2 20:29:12 2009 -0400

    Prevent the cache from incorrectly preserving merges when unmerging

diff --git a/lib/RT/Extension/MergeUsers.pm b/lib/RT/Extension/MergeUsers.pm
index db2d309..4eea944 100644
--- a/lib/RT/Extension/MergeUsers.pm
+++ b/lib/RT/Extension/MergeUsers.pm
@@ -206,6 +206,10 @@ sub UnMerge {
     my ($current) = $self->Attributes->Named("EffectiveId");
     return (0, "Not a merged user") unless $current;
 
+    # flush the cache, or the Sets below will
+    # clobber $self
+    delete $EFFECTIVE_ID_CACHE{$self->Id};
+
     my $merge = RT::User->new($RT::SystemUser);
     $merge->Load( $current->Content );
 

commit a1eb2b4e76f4c95fd4341abad22c168605579590
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Fri Oct 2 20:29:43 2009 -0400

    Show the name and the email of the user (unless they're the same)
    mimics some of the behavior of 3.8's new user display even on 3.6
    
    Based on proposed patch from Jason A Smith

diff --git a/html/Callbacks/RT-Extension-MergeUsers/Admin/Users/Modify.html/RightColumnBottom b/html/Callbacks/RT-Extension-MergeUsers/Admin/Users/Modify.html/RightColumnBottom
index 0501a2b..cae54a9 100644
--- a/html/Callbacks/RT-Extension-MergeUsers/Admin/Users/Modify.html/RightColumnBottom
+++ b/html/Callbacks/RT-Extension-MergeUsers/Admin/Users/Modify.html/RightColumnBottom
@@ -54,13 +54,13 @@
 This user has been merged with <a href="Modify.html?id=<% $EffectiveId->Content %>">
 % my $real = RT::User->new($session{'CurrentUser'});
 % $real->Load($EffectiveId->Content);
-<% $real->EmailAddress %></a>; <input type="submit" name="Unmerge" value="Unmerge" />
+<% $real->NameAndEmail %></a>; <input type="submit" name="Unmerge" value="Unmerge" />
 % } elsif ($MergedUsers) {
 The following users have been merged into this user:<br>
 %   foreach my $user_id (@{$MergedUsers->Content}) {
 %       my $user = RT::User->new($session{'CurrentUser'});
 %       $user->LoadOriginal(Id => $user_id);
-<% $user->EmailAddress %><input type="submit" name="Unmerge<%$user_id%>" value="Unmerge"><br>
+<% $user->NameAndEmail %><input type="submit" name="Unmerge<%$user_id%>" value="Unmerge"><br>
 %   }
 % } else {
 Merge this user into: <input name="MergeUser" value="" />
diff --git a/lib/RT/Extension/MergeUsers.pm b/lib/RT/Extension/MergeUsers.pm
index 4eea944..f42a5cd 100644
--- a/lib/RT/Extension/MergeUsers.pm
+++ b/lib/RT/Extension/MergeUsers.pm
@@ -223,6 +223,7 @@ sub UnMerge {
         $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) {
@@ -231,7 +232,7 @@ sub UnMerge {
         $merged_users->Delete;
     }
 
-    return ($merge->id, "Unmerged from @{[$merge->EmailAddress]}");
+    return ($merge->id, "Unmerged @{[$self->NameAndEmail]} from @{[$merge->NameAndEmail]}");
 }
 
 sub SetEmailAddress {
@@ -253,6 +254,18 @@ sub SetEmailAddress {
     return $self->_Set( Field => 'EmailAddress', Value => $value );
 }
 
+sub NameAndEmail {
+    my $self = shift;
+    my $name = $self->Name;
+    my $email = $self->EmailAddress;
+
+    if ($name eq $email) {
+        return $email;
+    } else {
+        return "$name <$email>";
+    }
+}
+
 package RT::Users;
 use RT::Users;
         

commit d99bd97decc995d7125d45857d9c5714974e0dd3
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Fri Oct 2 20:32:17 2009 -0400

    bump version to 0.04_01

diff --git a/Changes b/Changes
index b716e33..edb7499 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,9 @@
+0.04_01
+
+    Fix bug in cache and unmerging
+    Apply modified patch from Jason A Smith to make it clearer
+     which users are being affected.
+
 0.03
 
     Release updates from 0.03 prereleases 
diff --git a/META.yml b/META.yml
index 92260a6..ce78cbe 100644
--- a/META.yml
+++ b/META.yml
@@ -20,4 +20,4 @@ no_index:
     - t
 requires:
   Hook::LexWrap: 0
-version: 0.03
+version: 0.04_01
diff --git a/lib/RT/Extension/MergeUsers.pm b/lib/RT/Extension/MergeUsers.pm
index f42a5cd..fbcf5e2 100644
--- a/lib/RT/Extension/MergeUsers.pm
+++ b/lib/RT/Extension/MergeUsers.pm
@@ -48,7 +48,7 @@ use warnings; no warnings qw(redefine);
 
 package RT::Extension::MergeUsers;
 
-our $VERSION = '0.03';
+our $VERSION = '0.04_01';
 
 package RT::User;
 

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list