[Rt-commit] [rtir] 01/04: Refactor IsStaff from RT::Condition::RTIR into RT::IR
Kevin Falcone
falcone at bestpractical.com
Wed Aug 13 21:11:33 EDT 2014
This is an automated email from the git hooks/post-receive script.
falcone pushed a commit to branch 3.2/redirect-on-login
in repository rtir.
commit 6fe927b81bf35b2bb26d7ebfc0676313955a0429
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Wed Aug 13 18:10:23 2014 -0400
Refactor IsStaff from RT::Condition::RTIR into RT::IR
This allows other code to make decisions based on membership in a
DutyTeam
---
lib/RT/Condition/RTIR.pm | 14 +-------------
lib/RT/IR.pm | 28 ++++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 13 deletions(-)
diff --git a/lib/RT/Condition/RTIR.pm b/lib/RT/Condition/RTIR.pm
index 2d94165..2eb5e78 100644
--- a/lib/RT/Condition/RTIR.pm
+++ b/lib/RT/Condition/RTIR.pm
@@ -69,19 +69,7 @@ sub IsStaff {
my $self = shift;
my $actor_id = $self->TransactionObj->Creator;
- my $cgm = RT::CachedGroupMembers->new( RT->SystemUser );
- $cgm->Limit(FIELD => 'MemberId', VALUE => $actor_id );
- my $group_alias = $cgm->Join(
- FIELD1 => 'GroupId', TABLE2 => 'Groups', FIELD2 => 'id'
- );
- $cgm->Limit(
- ALIAS => $group_alias,
- FIELD => 'Name',
- OPERATOR => 'LIKE',
- VALUE => 'DutyTeam',
- );
- $cgm->RowsPerPage(1);
- return $cgm->First? 1 : 0;
+ return RT::IR->IsStaff($actor_id);
}
RT::Base->_ImportOverlays;
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 5ec8ffa..26a62df 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -92,6 +92,34 @@ $RT::Interface::Web::is_whitelisted_component{'/RTIR/Search/Results.html'} = 1;
=head1 FUNCTIONS
+=head2 IsStaff
+
+Is the user id passed in a member of one of the DutyTeam groups
+
+Useful for differentiating between actions by a user of the system vs
+actions by someone flagged to work on RTIR.
+
+=cut
+
+sub IsStaff {
+ my $self = shift;
+ my $actor_id = shift;
+
+ my $cgm = RT::CachedGroupMembers->new( RT->SystemUser );
+ $cgm->Limit(FIELD => 'MemberId', VALUE => $actor_id );
+ my $group_alias = $cgm->Join(
+ FIELD1 => 'GroupId', TABLE2 => 'Groups', FIELD2 => 'id'
+ );
+ $cgm->Limit(
+ ALIAS => $group_alias,
+ FIELD => 'Name',
+ OPERATOR => 'LIKE',
+ VALUE => 'DutyTeam',
+ );
+ $cgm->RowsPerPage(1);
+ return $cgm->First? 1 : 0;
+}
+
=head2 OurQueue
Takes queue name or L<RT::Queue> object and returns its type
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the rt-commit
mailing list