[Rt-commit] [rtir] 02/03: Limit what Constituencies are shown

Kevin Falcone falcone at bestpractical.com
Thu Dec 4 18:39:01 EST 2014


This is an automated email from the git hooks/post-receive script.

falcone pushed a commit to branch 3.4/constituency-external-cf
in repository rtir.

commit b14667bed0fdcf0e64881382172664496eda5bbe
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Dec 4 17:37:34 2014 -0500

    Limit what Constituencies are shown
    
    This looks at the current user and the constituency subqueues to see if
    you should be shown a trimmed list.  Essentially the logic from
    EditConstituency but much clearer now because it happens before the
    values come back, not in the display, mixed with all the display logic.
---
 lib/RT/CustomFieldValues/Constituency.pm | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/lib/RT/CustomFieldValues/Constituency.pm b/lib/RT/CustomFieldValues/Constituency.pm
index 2c59610..a85a36c 100644
--- a/lib/RT/CustomFieldValues/Constituency.pm
+++ b/lib/RT/CustomFieldValues/Constituency.pm
@@ -109,7 +109,28 @@ sub ExternalValues {
     }
     $cfvs->Limit( FIELD => 'CustomField', VALUE => $cf->Id );
 
+    my $main_queue = RT::Queue->new($self->CurrentUser);
+    for my $obj ($cf->ACLEquivalenceObjects) {
+        next unless (ref $obj eq 'RT::Queue');
+        $main_queue->Load( $obj->Id );
+        last;
+    }
+    unless ($main_queue->Id) {
+        RT->Logger->debug("Unable to find Queue from Custom Field, loading Incidents");
+
+        $main_queue->Load( 'Incidents' );
+    }
+
+    # Only needed until we don't override RT::Queue->HasRight in RT::IR as much
+    $main_queue->{'disable_constituency_right_check'} = 1;
+    my $show_all = $main_queue->CurrentUserHasRight('OwnTicket') ? 1 : 0;
+
     while( my $cfv = $cfvs->Next ) {
+        unless ($show_all) {
+            my $name = $cfv->Name;
+            my $subqueue = RT::Queue->new($self->CurrentUser);
+            next unless ($subqueue->LoadByCols(Name => $main_queue->Name . " - ".$name) && $subqueue->id && $subqueue->CurrentUserHasRight('OwnTicket'))
+        }
         push @res, {
             name        => $cfv->Name,
             sortorder   => $i++,

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the rt-commit mailing list