[Rt-commit] r8661 - rtir/branches/2.3-EXPERIMENTAL/lib/RT/Condition

ruz at bestpractical.com ruz at bestpractical.com
Tue Aug 21 06:48:27 EDT 2007


Author: ruz
Date: Tue Aug 21 06:48:12 2007
New Revision: 8661

Modified:
   rtir/branches/2.3-EXPERIMENTAL/lib/RT/Condition/RTIR.pm

Log:
* add IsStaff check to ::Condition::RTIR

Modified: rtir/branches/2.3-EXPERIMENTAL/lib/RT/Condition/RTIR.pm
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/lib/RT/Condition/RTIR.pm	(original)
+++ rtir/branches/2.3-EXPERIMENTAL/lib/RT/Condition/RTIR.pm	Tue Aug 21 06:48:12 2007
@@ -4,9 +4,20 @@
 use RT::IR;
 
 package RT::Condition::RTIR;
-
 use base 'RT::Condition::Generic';
 
+=head1 NAME
+
+RT::Condition::RTIR - generic checks
+
+=head1 METHODS
+
+=head2 IsStatusChange
+
+Returns true if it's status change of a ticket.
+
+=cut
+
 sub IsStatusChange {
     my $self = shift;
     my $type = $self->TransactionObj->Type;
@@ -17,4 +28,30 @@
     return 0;
 }
 
+=head2 IsStaff
+
+Returns true if creator of a ticket is a staff member. By staff member
+we mean memeber of a group which name contains 'DutyTeam'.
+
+=cut
+
+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;
+}
+
 1;


More information about the Rt-commit mailing list