[Bps-public-commit] rt-extension-rightsdebugger branch, master, updated. 223d23cfd1b0d5707b2f5731425bd51c48630fdc

Shawn Moore shawn at bestpractical.com
Tue Mar 7 14:38:37 EST 2017


The branch, master has been updated
       via  223d23cfd1b0d5707b2f5731425bd51c48630fdc (commit)
      from  6c72af87d6cab5a4c2df3e97c41acf3f2d267ff0 (commit)

Summary of changes:
 lib/RT/Extension/RightsDebugger.pm | 47 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

- Log -----------------------------------------------------------------
commit 223d23cfd1b0d5707b2f5731425bd51c48630fdc
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Tue Mar 7 19:38:31 2017 +0000

    First cut of object limiting

diff --git a/lib/RT/Extension/RightsDebugger.pm b/lib/RT/Extension/RightsDebugger.pm
index 4238d6d..c6a2fc4 100644
--- a/lib/RT/Extension/RightsDebugger.pm
+++ b/lib/RT/Extension/RightsDebugger.pm
@@ -103,6 +103,22 @@ sub _PrincipalForSpec {
     return undef;
 }
 
+sub _ObjectForSpec {
+    my $self       = shift;
+    my $type       = shift;
+    my $identifier = shift;
+
+    if ($type =~ /^(t|ticket)$/i) {
+        my $ticket = RT::Ticket->new($self->CurrentUser);
+        $ticket->Load($identifier);
+        return $ticket if $ticket->Id;
+    }
+    else {
+    }
+
+    return undef;
+}
+
 sub Search {
     my $self = shift;
     my %args = (
@@ -126,6 +142,34 @@ sub Search {
         object    => undef,
     );
 
+    if ($args{object}) {
+        if (my ($type, $identifier) = $args{object} =~ m{
+            ^
+                \s*
+                (t|ticket|asset)
+                \s*
+                [:#]
+                \s*
+                (.+?)
+                \s*
+            $
+        }xi) {
+            my $record = $self->_ObjectForSpec($type, $identifier);
+            if (!$record) {
+                return { error => 'Unable to find row' };
+            }
+
+            $has_search = 1;
+            $use_regex_search_for{object} = 0;
+
+            $primary_records{object} = $record;
+
+            for my $obj ($record, $record->ACLEquivalenceObjects, RT->System) {
+                $ACL->LimitToObject($obj);
+            }
+        }
+    }
+
     if ($args{principal}) {
         if (my ($type, $identifier) = $args{principal} =~ m{
             ^
@@ -422,6 +466,9 @@ sub URLForRecord {
     elsif ($record->isa('RT::CustomRole')) {
         return RT->Config->Get('WebURL') . 'Admin/CustomRoles/Modify.html?id=' . $id;
     }
+    elsif ($record->isa('RT::Ticket')) {
+        return RT->Config->Get('WebURL') . 'Ticket/Display.html?id=' . $id;
+    }
 
     return undef;
 }

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


More information about the Bps-public-commit mailing list