[Rt-commit] [rtir] 04/13: Define RT::Queue::HasRight
Kevin Falcone
falcone at bestpractical.com
Wed Apr 16 17:29:40 EDT 2014
This is an automated email from the git hooks/post-receive script.
falcone pushed a commit to branch master
in repository rtir.
commit 5e9955855db0ff63d730d1427a64631c99555b09
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Wed Mar 26 18:33:00 2014 -0400
Define RT::Queue::HasRight
RT 4.2 removed this in favor of just simplifying the logic up into
RT::Record::HasRight so this wrap() fails badly.
Stub it in by just moving up the package change that comes a few lines
later and then rewrite a bit of the code so you don't have to start at
$_[0] all over the place for no reason.
---
lib/RT/IR.pm | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index b490a1d..daaba96 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -641,7 +641,7 @@ if ( RT::IR->HasConstituency ) {
*RT::Interface::Web::Handler::CleanupRequest = sub {
%RT::IR::ConstituencyCache = ();
%RT::IR::HasNoQueueCache = ();
- RT::IR::_FlushQueueHasRightCache();
+ RT::Queue::_FlushQueueHasRightCache();
$orig_CleanupRequest->();
};
@@ -754,24 +754,29 @@ if ( RT::IR->HasConstituency ) {
return $queue;
};
- my $queue_cache = {};
- wrap 'RT::Queue::HasRight', pre => sub {
- return unless $_[0]->id;
- return if $_[0]->{'disable_constituency_right_check'};
- return if $_[0]->{'_for_ticket'};
- return unless $_[0]->__Value('Name') =~
+ require RT::Queue;
+ package RT::Queue;
+
+ { my $queue_cache = {};
+ # RT 4.2 removed RT::Queue's HasRight, meaning we can just stub one in
+ sub HasRight {
+ my $self = shift;
+ return $self->SUPER::HasRight(@_) unless $self->id;
+ return $self->SUPER::HasRight(@_) if $self->{'disable_constituency_right_check'};
+ return $self->SUPER::HasRight(@_) if $self->{'_for_ticket'};
+ return $self->SUPER::HasRight(@_) unless $self->__Value('Name') =~
/^(Incidents|Incident Reports|Investigations|Blocks)$/i;
my $name = $1;
- my %args = (@_[1..(@_-2)]);
- $args{'Principal'} ||= $_[0]->CurrentUser;
+ my %args = @_;
+ $args{'Principal'} ||= $self->CurrentUser;
my $equiv_objects;
if ( $queue_cache->{$name} ) {
$equiv_objects = $queue_cache->{$name};
} else {
my $queues = RT::Queues->new( RT->SystemUser );
- $queues->Limit( FIELD => 'Name', OPERATOR => 'STARTSWITH', VALUE => "$name - " );
+ $queues->Limit( FIELD => 'Name', OPERATOR => 'STARTSWITH', VALUE => "$name - ", CASESENSITIVE => 0 );
$equiv_objects = $queues->ItemsArrayRef;
$queue_cache->{$name} = $equiv_objects;
}
@@ -779,18 +784,15 @@ if ( RT::IR->HasConstituency ) {
my $has_right = $args{'Principal'}->HasRight(
%args,
- Object => $_[0],
+ Object => $self,
EquivObjects => $equiv_objects,
);
- $_[-1] = $has_right;
- return;
+ return $has_right;
};
sub _FlushQueueHasRightCache { undef $queue_cache };
+ }
- require RT::Queue;
- package RT::Queue;
-
sub CorrespondAddress { GetQueueAttribute(shift, 'CorrespondAddress') }
sub CommentAddress { GetQueueAttribute(shift, 'CommentAddress') }
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the rt-commit
mailing list