[Rt-commit] rt branch, 4.4/queue-cf-rights-in-charts, created. rt-4.4.4-63-gfdc698a95

? sunnavy sunnavy at bestpractical.com
Wed Sep 11 13:18:17 EDT 2019


The branch, 4.4/queue-cf-rights-in-charts has been created
        at  fdc698a95b0b162924232b6f3a1acc631708ed6f (commit)

- Log -----------------------------------------------------------------
commit fdc698a95b0b162924232b6f3a1acc631708ed6f
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Sep 12 00:07:25 2019 +0800

    Allow queue CF rights to apply on single-queue searches in charts
    
    This is to group by custom fields that current user has right at queue
    level for single-queue searches. Without this, those custom fields won't
    even show up in group by dropdowns.
    
    It's consistent with query builder, see also 2078d6b5f9

diff --git a/lib/RT/Report/Tickets.pm b/lib/RT/Report/Tickets.pm
index 65733a43f..18850cfbe 100644
--- a/lib/RT/Report/Tickets.pm
+++ b/lib/RT/Report/Tickets.pm
@@ -184,7 +184,7 @@ our %GROUPINGS_META = (
                 my $queue = RT::Queue->new( $self->CurrentUser );
                 $queue->Load($id);
                 next unless $queue->id;
-
+                $CustomFields->SetContextObject( $queue ) if keys %$queues == 1;
                 $CustomFields->LimitToQueue($queue->id);
             }
             $CustomFields->LimitToGlobal;
@@ -200,7 +200,15 @@ our %GROUPINGS_META = (
 
             my ($cf) = ( $args{'SUBKEY'} =~ /^\{(.*)\}$/ );
             if ( $cf =~ /^\d+$/ ) {
-                my $obj = RT::CustomField->new( $self->CurrentUser );
+
+                # When we render label in charts, the cf could surely be
+                # seen by current user(SubFields above checks rights), but
+                # we can't use current user to load cf here because the
+                # right might be granted at queue level and it's not
+                # straightforward to add a related queue as context object
+                # here. That's why we use RT->SystemUser here instead.
+
+                my $obj = RT::CustomField->new( RT->SystemUser );
                 $obj->Load( $cf );
                 $cf = $obj->Name;
             }

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


More information about the rt-commit mailing list