[Rt-commit] rt branch, 4.6/isadded-return-false-if-disabled, created. rt-4.4.3-196-g07d013eea

Craig Kaiser craig at bestpractical.com
Mon Feb 4 17:09:25 EST 2019


The branch, 4.6/isadded-return-false-if-disabled has been created
        at  07d013eea883e1564cc97ca7cc1339c777208217 (commit)

- Log -----------------------------------------------------------------
commit 07d013eea883e1564cc97ca7cc1339c777208217
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Mon Feb 4 16:18:15 2019 -0500

    Do not return true if object is applied and disabled
    
    The 'IsAdded' method should not return true by default
    even if added to the context object if the applied object is disabled.

diff --git a/lib/RT/CustomRole.pm b/lib/RT/CustomRole.pm
index 5d1bfb3d6..22a2e05c3 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;
 }
 

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


More information about the rt-commit mailing list