Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bestpractical/rt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Kaiser <craig@bestpractical.com>2019-02-05 00:18:15 +0300
committerCraig Kaiser <craig@bestpractical.com>2019-02-05 00:18:15 +0300
commit07d013eea883e1564cc97ca7cc1339c777208217 (patch)
tree16f98427168653a527b8ba1000dca23c080742c8
parent80d0f7e77128e86d01577ba346082efd241b6efa (diff)
Do not return true if object is applied and disabled4.6/isadded-return-false-if-disabled
The 'IsAdded' method should not return true by default even if added to the context object if the applied object is disabled.
-rw-r--r--lib/RT/CustomRole.pm20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/RT/CustomRole.pm b/lib/RT/CustomRole.pm
index 5d1bfb3d60..22a2e05c3f 100644
--- a/lib/RT/CustomRole.pm
+++ b/lib/RT/CustomRole.pm
@@ -330,9 +330,25 @@ Takes an object id and returns a boolean indicating whether the custom role appl
sub IsAdded {
my $self = shift;
+ my ($ObjectId, $Disabled) = (undef, undef);
+ my @args = @_;
+
+ if ( scalar @args > 1 ) {
+ my %args = @args;
+
+ $ObjectId = $args{'ObjectId'};
+ $Disabled = $args{'Disabled'};
+ } else {
+ $ObjectId = $args[0];
+ RT->Deprecated(
+ Message => "Passing only ObjectId unamed parameter is deprecated.",
+ Instead => "->IsAdded(ObjectId => $ObjectId)", Remove => '4.6',
+ );
+ }
+
my $record = RT::ObjectCustomRole->new( $self->CurrentUser );
- $record->LoadByCols( CustomRole => $self->id, ObjectId => shift );
- return undef unless $record->id;
+ $record->LoadByCols( CustomRole => $self->id, ObjectId => $ObjectId );
+ return undef unless $record->id or ( $record->CustomRoleObj->Disabled and not $Disabled );
return $record;
}