[Rt-commit] rt branch, 4.2/right-granted-message, created. rt-4.2.11-40-gec002ce
Dustin Graves
dustin at bestpractical.com
Tue Aug 4 16:22:44 EDT 2015
The branch, 4.2/right-granted-message has been created
at ec002ce73ba6e275f711075e4611617a64b259ab (commit)
- Log -----------------------------------------------------------------
commit ec002ce73ba6e275f711075e4611617a64b259ab
Author: Dustin Graves <dustin at bestpractical.com>
Date: Tue Aug 4 16:20:43 2015 -0400
add DisplayName method to RT::Principal to return group or user name and
change rights added message to use this text
change error messages in same section to use this as well
Fixes: I#30959
diff --git a/lib/RT/ACE.pm b/lib/RT/ACE.pm
index c27a82b..f09dafd 100644
--- a/lib/RT/ACE.pm
+++ b/lib/RT/ACE.pm
@@ -269,7 +269,7 @@ sub Create {
);
if ( $self->Id ) {
return ( 0, $self->loc('[_1] already has that right',
- $princ_obj->Object->Name) );
+ $princ_obj->DisplayName) );
}
my $id = $self->SUPER::Create( PrincipalId => $princ_obj->id,
@@ -285,7 +285,7 @@ sub Create {
RightName => $self->RightName,
ACE => $self,
);
- return ( $id, $self->loc('Right Granted') );
+ return ( $id, $self->loc("Granted right '[_1]' to [_2].", $self->RightName, $princ_obj->DisplayName));
}
else {
return ( 0, $self->loc('System error. Right not granted.') );
diff --git a/lib/RT/Principal.pm b/lib/RT/Principal.pm
index 8cf509d..bbabe7c 100644
--- a/lib/RT/Principal.pm
+++ b/lib/RT/Principal.pm
@@ -117,8 +117,6 @@ sub IsUser {
}
}
-
-
=head2 Object
Returns the user or group associated with this principal
@@ -146,7 +144,18 @@ sub Object {
}
+=head2 DisplayName
+Returns the relevant display name for this principal
+
+=cut
+
+sub DisplayName {
+ my $self = shift;
+ return undef unless $self->Object;
+ return $self->Object->Name unless $self->Object->InstanceObj;
+ return $self->Object->InstanceObj->Name;
+}
=head2 GrantRight { Right => RIGHTNAME, Object => undef }
-----------------------------------------------------------------------
More information about the rt-commit
mailing list