[Rt-commit] rt branch, 4.2/history-display-groups-in-roles, created. rt-4.1.8-301-gc630a80

Alex Vandiver alexmv at bestpractical.com
Mon May 13 20:49:27 EDT 2013


The branch, 4.2/history-display-groups-in-roles has been created
        at  c630a806d821dc2910ac678c037a8e3402f9c8ba (commit)

- Log -----------------------------------------------------------------
commit c630a806d821dc2910ac678c037a8e3402f9c8ba
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon May 13 20:43:58 2013 -0400

    Properly display transactions dealing with groups in role groups
    
    The new transaction code assumed that the principals added and removed
    from role groups were always users; properly handle the case where they
    are groups instead.
    
    RT 4.0 and earlier displayed them as "AdminCc GroupName added"; this
    changes the wording slightly to add the word "group" before the group
    name, to differentiate it from the cases where a user of that name was
    added.

diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index af70088..21f3d63 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -688,6 +688,16 @@ sub _ProcessReturnValues {
     } @values;
 }
 
+sub _FormatPrincipal {
+    my $self = shift;
+    my $principal = shift;
+    if ($principal->IsUser) {
+        return $self->_FormatUser( $principal->Object );
+    } else {
+        return "group ".$principal->Object->Name;
+    }
+}
+
 sub _FormatUser {
     my $self = shift;
     my $user = shift;
@@ -832,19 +842,19 @@ sub _FormatUser {
         my $self = shift;
         my $principal = RT::Principal->new($self->CurrentUser);
         $principal->Load($self->NewValue);
-        return ( "[_1] [_2] added", $self->loc($self->Field), $self->_FormatUser($principal->Object));    #loc
+        return ( "[_1] [_2] added", $self->loc($self->Field), $self->_FormatPrincipal($principal));    #loc
     },
     DelWatcher => sub {
         my $self = shift;
         my $principal = RT::Principal->new($self->CurrentUser);
         $principal->Load($self->OldValue);
-        return ( "[_1] [_2] deleted", $self->loc($self->Field), $self->_FormatUser($principal->Object));  #loc
+        return ( "[_1] [_2] deleted", $self->loc($self->Field), $self->_FormatPrincipal($principal));  #loc
     },
     SetWatcher => sub {
         my $self = shift;
         my $principal = RT::Principal->new($self->CurrentUser);
         $principal->Load($self->NewValue);
-        return ( "[_1] set to [_2]", $self->loc($self->Field), $self->_FormatUser($principal->Object));  #loc
+        return ( "[_1] set to [_2]", $self->loc($self->Field), $self->_FormatPrincipal($principal));  #loc
     },
     Subject => sub {
         my $self = shift;

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


More information about the Rt-commit mailing list