[Rt-commit] [rtir] 05/05: Move ACLEquivalenceObjects from wrap to method override
Jim Brandt
jbrandt at bestpractical.com
Fri Mar 21 17:18:35 EDT 2014
This is an automated email from the git hooks/post-receive script.
jbrandt pushed a commit to branch 3.2/remove-lexwrap
in repository rtir.
commit f002da54c6491883d7dab98df81a6ae77ed98bfb
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Fri Mar 21 17:13:33 2014 -0400
Move ACLEquivalenceObjects from wrap to method override
The ACLEquivalenceObjects method in RT::Ticket trivially
returns the ticket's QueueObj and notes that it's a good
method to override. Create an RTIR version to process
Constituencies for RTIR queues only.
---
lib/RT/IR.pm | 42 ------------------------------------------
lib/RT/Ticket_Vendor.pm | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 42 deletions(-)
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index e23d2f4..13cd55b 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -624,48 +624,6 @@ if ( RT::IR->HasConstituency ) {
%RT::IR::HasNoQueueCache = ();
&{$orig_Cleanup};
};
-
- require RT::Ticket;
- wrap 'RT::Ticket::ACLEquivalenceObjects', pre => sub {
- my $self = shift;
-
- my $queue = RT::Queue->new(RT->SystemUser);
- $queue->Load($self->__Value('Queue'));
-
- # We do this, rather than fall through to the orignal sub, as that
- # interacts poorly with our overloaded QueueObj below
- # Don't try and load Constituencies outside of RTIR. It results
- # in a lot of useless checks.
- if ( ( $self->CurrentUser->id == RT->SystemUser->id ) ||
- ( $queue->Name !~ /^(Incidents|Incident Reports|Investigations|Blocks)$/i ) ) {
- $_[-1] = [$queue];
- return;
- }
- if ( UNIVERSAL::isa( $self, 'RT::Ticket' ) ) {
- my $const = $RT::IR::ConstituencyCache{ $self->id };
- if (!$const || $const eq '_none' ) {
- my $systicket = RT::Ticket->new(RT->SystemUser);
- $systicket->Load( $self->id );
- $const = $RT::IR::ConstituencyCache{ $self->id } =
- $systicket->FirstCustomFieldValue('Constituency')
- || '_none';
- }
- return if $const eq '_none';
- return if $RT::IR::HasNoQueueCache{ $const };
-
- my $new_queue = RT::Queue->new(RT->SystemUser);
- $new_queue->LoadByCols(
- Name => $queue->Name . " - " . $const
- );
- unless ( $new_queue->id ) {
- $RT::IR::HasNoQueueCache{$const} = 1;
- return;
- }
- $_[-1] = [$queue, $new_queue];
- } else {
- RT->Logger->crit("$self is not a ticket object like I expected");
- }
- };
}
require RT::Ticket;
diff --git a/lib/RT/Ticket_Vendor.pm b/lib/RT/Ticket_Vendor.pm
index 9dc7f78..bac1f45 100644
--- a/lib/RT/Ticket_Vendor.pm
+++ b/lib/RT/Ticket_Vendor.pm
@@ -11,4 +11,47 @@ sub _AddCustomFieldValue {
return $self->SUPER::_AddCustomFieldValue(@_);
}
+sub ACLEquivalenceObjects {
+ my $self = shift;
+
+ my $queue = RT::Queue->new(RT->SystemUser);
+ $queue->Load($self->__Value('Queue'));
+
+ # We do this, rather than fall through to the orignal sub, as that
+ # interacts poorly with our overloaded QueueObj below
+ # Don't try and load Constituencies outside of RTIR. It results
+ # in a lot of useless checks.
+ if ( ( $self->CurrentUser->id == RT->SystemUser->id ) ||
+ ( $queue->Name !~ /^(Incidents|Incident Reports|Investigations|Blocks)$/i ) ) {
+ return $self->QueueObj;
+ }
+
+ if ( UNIVERSAL::isa( $self, 'RT::Ticket' ) ) {
+ my $const = $RT::IR::ConstituencyCache{ $self->id };
+ if (!$const || $const eq '_none' ) {
+ my $systicket = RT::Ticket->new(RT->SystemUser);
+ $systicket->Load( $self->id );
+ $const = $RT::IR::ConstituencyCache{ $self->id } =
+ $systicket->FirstCustomFieldValue('Constituency')
+ || '_none';
+ }
+ return $self->QueueObj
+ if ( $const eq '_none'
+ or $RT::IR::HasNoQueueCache{ $const } );
+
+ my $new_queue = RT::Queue->new(RT->SystemUser);
+ $new_queue->LoadByCols(
+ Name => $queue->Name . " - " . $const
+ );
+ unless ( $new_queue->id ) {
+ $RT::IR::HasNoQueueCache{$const} = 1;
+ return $self->QueueObj;
+ }
+ return $queue, $new_queue;
+ } else {
+ RT->Logger->crit("$self is not a ticket object like I expected");
+ }
+}
+
+
1;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the rt-commit
mailing list