[Rt-commit] rt branch, 4.2/extensible-roles, updated. rt-4.0.6-520-g47ef401
Thomas Sibley
trs at bestpractical.com
Thu Nov 8 20:22:13 EST 2012
The branch, 4.2/extensible-roles has been updated
via 47ef401aa871f4852d55596cee5ab5f3e8fabbcf (commit)
via 2476da75def7714c90acee0acdb94bd42053b2db (commit)
from ad7235c12da6c1d1e774dd9eda45c95fe6ea7727 (commit)
Summary of changes:
lib/RT/Record.pm | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
- Log -----------------------------------------------------------------
commit 2476da75def7714c90acee0acdb94bd42053b2db
Author: Thomas Sibley <trs at bestpractical.com>
Date: Thu Nov 8 17:06:01 2012 -0800
Record a txn on the RT::Record object when adding or removing a role member
A transaction is already recorded on the RT::Group itself, but it's
useful to have a transaction directly on the RT::Record too.
Doing this in the generic methods is easier than subclass-by-subclass
since AddRoleMember already validates PrincipalId and translates from
acceptable User/Group arguments. Subclasses which don't want to record
a transaction can simply wrap the methods to force Silent => 1.
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index 3dded63..aa48b75 100644
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -2092,8 +2092,9 @@ sub AddRoleMember {
return (0, $self->loc("One, and only one, of PrincipalId/User/Group is required"))
if 1 != grep { $_ } @args{qw/PrincipalId User Group/};
+ my $type = delete $args{Type};
return (0, $self->loc("No valid Type specified"))
- unless $args{Type} and $self->HasRole($args{Type});
+ unless $type and $self->HasRole($type);
unless ($args{PrincipalId}) {
my $object;
@@ -2111,7 +2112,17 @@ sub AddRoleMember {
return (0, $self->loc("No valid PrincipalId"))
unless $args{PrincipalId};
- return $self->RoleGroup(delete $args{Type})->_AddMember(%args);
+ my ($ok, $msg) = $self->RoleGroup($type)->_AddMember(%args);
+
+ if ($ok and not $args{Silent}) {
+ $self->_NewTransaction(
+ Type => 'AddWatcher', # use "watcher" for history's sake
+ NewValue => $args{PrincipalId},
+ Field => $type,
+ );
+ }
+
+ return ($ok, $msg);
}
=head2 DeleteRoleMember
@@ -2144,7 +2155,16 @@ sub DeleteRoleMember {
return (0, $self->loc("No valid Type specified"))
unless $args{Type} and $self->HasRole($args{Type});
- return $self->RoleGroup($args{Type})->_DeleteMember(delete $args{PrincipalId});
+ my ($ok, $msg) = $self->RoleGroup($args{Type})->_DeleteMember($args{PrincipalId});
+
+ if ($ok and not $args{Silent}) {
+ $self->_NewTransaction(
+ Type => 'DelWatcher', # use "watcher" for history's sake
+ NewValue => $args{PrincipalId},
+ Field => $args{Type},
+ );
+ }
+ return ($ok, $msg);
}
RT::Base->_ImportOverlays();
commit 47ef401aa871f4852d55596cee5ab5f3e8fabbcf
Author: Thomas Sibley <trs at bestpractical.com>
Date: Thu Nov 8 17:08:56 2012 -0800
Validate that PrincipalId is actually passed to DeleteRoleMember, as doc'd
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index aa48b75..d9bd710 100644
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -2155,6 +2155,9 @@ sub DeleteRoleMember {
return (0, $self->loc("No valid Type specified"))
unless $args{Type} and $self->HasRole($args{Type});
+ return (0, $self->loc("No valid PrincipalId"))
+ unless $args{PrincipalId};
+
my ($ok, $msg) = $self->RoleGroup($args{Type})->_DeleteMember($args{PrincipalId});
if ($ok and not $args{Silent}) {
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list