[Rt-commit] [rtir] 01/10: Porting more components to lifecycle name helpers

Jesse Vincent jesse at bestpractical.com
Sat Feb 21 16:15:16 EST 2015


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

jesse pushed a commit to branch 3.4/remove_old_constituencies
in repository rtir.

commit 6b35643cba5dd3a4837d7a10a160929e52127409
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Sat Feb 21 11:11:54 2015 -0800

    Porting more components to lifecycle name helpers
---
 html/RTIR/Incident/Display.html               |  8 ++---
 html/RTIR/Incident/Elements/ShowChildren      |  4 +--
 html/RTIR/Incident/Reply/Refine.html          |  6 ++--
 html/RTIR/Incident/Reply/index.html           | 12 ++++----
 html/RTIR/Tools/Elements/LookupRelatedTickets |  8 ++---
 lib/RT/Action/RTIR_ChangeChildOwnership.pm    |  6 ++--
 lib/RT/Action/RTIR_ResolveChildren.pm         |  4 +--
 lib/RT/IR.pm                                  | 44 ++++++++++++++-------------
 8 files changed, 47 insertions(+), 45 deletions(-)

diff --git a/html/RTIR/Incident/Display.html b/html/RTIR/Incident/Display.html
index 7e7a26c..bc986ab 100644
--- a/html/RTIR/Incident/Display.html
+++ b/html/RTIR/Incident/Display.html
@@ -111,7 +111,7 @@
 </td><td class="boxcontainer" valign="top">
 % $m->callback( %ARGS, Ticket => $TicketObj, CallbackName => 'RightColumnStart' );
 
-% foreach my $lifecycle ( 'incident_reports', 'investigations', 'blocks' ) {
+% foreach my $lifecycle ( RT::IR->lifecycle_report, RT::IR->lifecycle_investigation, RT::IR->lifecycle_countermeasure ) {
 <& /RTIR/Incident/Elements/ShowChildren,
     IncidentObj => $TicketObj,
     Lifecycle   => $lifecycle
@@ -213,7 +213,7 @@ my $new_ticket = 0;
 if ( $id eq 'new' ) {
     my $QueueObj = RT::Queue->new( $session{'CurrentUser'} );
     $QueueObj->Load( $Queue ) || Abort(loc("Couldn't load queue."));
-    unless( $QueueObj->Lifecycle eq 'incidents' ) {
+    unless( $QueueObj->Lifecycle eq RT::IR->lifecycle_incident ) {
         return $m->comp('/RTIR/Display.html', %ARGS );
     }
     ($TicketObj, @results) = CreateTicket( %ARGS );
@@ -227,7 +227,7 @@ $m->callback(CallbackName => 'ProcessArguments',
             ARGSRef => \%ARGS,  
             Actions => \@results);
 
-unless( $TicketObj->QueueObj->Lifecycle eq 'incidents' ) {
+unless( $TicketObj->QueueObj->Lifecycle eq RT::IR->lifecycle_incident ) {
     return $m->comp('/RTIR/Display.html', %ARGS );
 }
 $ARGS{'id'} = $id = $TicketObj->Id;
@@ -311,7 +311,7 @@ my $attachments = $TicketObj->Attachments;
 
 <%ARGS>
 $id => undef
-$Queue => 'Incidents'
+$Queue => RT::IR->lifecycle_incident
 $Child => undef
 $SelectedTicket => undef
 @SelectedTickets => ()
diff --git a/html/RTIR/Incident/Elements/ShowChildren b/html/RTIR/Incident/Elements/ShowChildren
index 9d65f70..a6d4df7 100644
--- a/html/RTIR/Incident/Elements/ShowChildren
+++ b/html/RTIR/Incident/Elements/ShowChildren
@@ -82,7 +82,7 @@ $Rows  => 8
 <%INIT>
 
 
-return if $Lifecycle eq 'blocks' && RT->Config->Get('RTIR_DisableBlocksQueue');
+return if $Lifecycle eq RT::IR->lifecycle_countermeasure && RT->Config->Get('RTIR_DisableBlocksQueue');
 
 
 my $FriendlyLifecycle = RT::IR::FriendlyLifecycle($Lifecycle);
@@ -114,7 +114,7 @@ if ( $IncidentObj->CurrentUserHasRight('ModifyTicket') ) {
     if (1) { # XXX TODO RESTORE THIS ACL CHECK
     # $QueueObj->Id and $QueueObj->CurrentUserHasRight('CreateTicket') ) {
         push @box_actions, {
-            title => $Lifecycle ne 'investigations'? loc('Create') : loc('Launch'),
+            title => $Lifecycle ne RT::IR->lifecycle_investigation? loc('Create') : loc('Launch'),
             path => "/RTIR/Create.html?Incident=$id&Lifecycle=".$Lifecycle,
         };
     }
diff --git a/html/RTIR/Incident/Reply/Refine.html b/html/RTIR/Incident/Reply/Refine.html
index 554f130..361771e 100644
--- a/html/RTIR/Incident/Reply/Refine.html
+++ b/html/RTIR/Incident/Reply/Refine.html
@@ -46,9 +46,9 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 <%INIT>
-my @lifecycles = ('incident_reports');
-push @lifecycles, 'investigations' if $ARGS{'All'};
-push @lifecycles, 'blocks' if $ARGS{'All'} && !RT->Config->Get('RTIR_DisableBlocksQueue');
+my @lifecycles = (RT::IR->lifecycle_report);
+push @lifecycles, RT::IR->lifecycle_investigation if $ARGS{'All'};
+push @lifecycles, RT::IR->lifecycle_countermeasure if $ARGS{'All'} && !RT->Config->Get('RTIR_DisableBlocksQueue');
 
 return $m->comp(
     '/RTIR/Search/Elements/RefinePage',
diff --git a/html/RTIR/Incident/Reply/index.html b/html/RTIR/Incident/Reply/index.html
index 3205778..9c1bad5 100644
--- a/html/RTIR/Incident/Reply/index.html
+++ b/html/RTIR/Incident/Reply/index.html
@@ -69,7 +69,7 @@
 <h2><&|/l&>Reporters</&></h2>
 <& /RTIR/Search/Elements/ShowResults,
     BaseURL       => $BaseURL,
-    BaseQuery     => RT::IR->Query(Lifecycle => 'incident_reports', MemberOf => $id),
+    BaseQuery     => RT::IR->Query(Lifecycle => RT::IR->lifecycle_report, MemberOf => $id),
     Query         => $Query,
     DisplayFormat => "__CheckBox.{SelectedReports}__, $Format",
     Format        => $Format,
@@ -82,7 +82,7 @@
 <h2><&|/l&>Investigation Correspondents</&></h2>
 <& /RTIR/Search/Elements/ShowResults,
     BaseURL       => $BaseURL,
-    BaseQuery     => RT::IR->Query(Lifecycle => 'investigations', MemberOf => $id),
+    BaseQuery     => RT::IR->Query(Lifecycle => RT::IR->lifecycle_investigation, MemberOf => $id),
     Query         => $Query,
     DisplayFormat => "__CheckBox.{SelectedInvestigations}__, $Format",
     Format        => $Format,
@@ -95,7 +95,7 @@
 <h2><&|/l&>Blocks Correspondents</&></h2>
 <& /RTIR/Search/Elements/ShowResults,
     BaseURL       => $BaseURL,
-    BaseQuery     => RT::IR->Query(Lifecycle => 'blocks', MemberOf => $id),
+    BaseQuery     => RT::IR->Query(Lifecycle => RT::IR->lifecycle_countermeasure, MemberOf => $id),
     Query         => $Query,
     DisplayFormat => "__CheckBox.{SelectedBlocks}__, $Format",
     Format        => $Format,
@@ -240,9 +240,9 @@ if ($Status eq 'resolved') {
     }
 }
 
-my @lifecycles = ('incident_reports');
-push @lifecycles, 'investigations' if $All;
-push @lifecycles, 'blocks' unless RT->Config->Get('RTIR_DisableBlocksQueue');
+my @lifecycles = (RT::IR->lifecycle_report);
+push @lifecycles, RT::IR->lifecycle_investigation if $All;
+push @lifecycles, RT::IR->lifecycle_countermeasure unless RT->Config->Get('RTIR_DisableBlocksQueue');
 
 $Query ||= RT::IR->ActiveQuery( Lifecycle => \@lifecycles );
 
diff --git a/html/RTIR/Tools/Elements/LookupRelatedTickets b/html/RTIR/Tools/Elements/LookupRelatedTickets
index 820f071..e2c6745 100644
--- a/html/RTIR/Tools/Elements/LookupRelatedTickets
+++ b/html/RTIR/Tools/Elements/LookupRelatedTickets
@@ -48,20 +48,20 @@
 <table width="100%" border="0" cellpadding="2" cellspacing="0">
 <tr><td valign="top" width="50%">
 
-<& LookupSummary, %ARGS, Lifecycle => 'incidents', Query => $query &>
+<& LookupSummary, %ARGS, Lifecycle => RT::IR->lifecycle_incident, Query => $query &>
 
 </td><td valign="top" width="50%">
 
-<& LookupSummary, %ARGS, Lifecycle => 'investigations', Query => $query &>
+<& LookupSummary, %ARGS, Lifecycle => RT::IR->lifecycle_investigation, Query => $query &>
 
 </td></tr><tr><td valign="top" width="50%">
 
-<& LookupSummary, %ARGS, Lifecycle => 'incident_reports', Query => $query &>
+<& LookupSummary, %ARGS, Lifecycle => RT::IR->lifecycle_report, Query => $query &>
 
 </td><td width="50%" valign="top">
 
 % unless ( RT->Config->Get('RTIR_DisableBlocksQueue') ) {
-<& LookupSummary, %ARGS, Lifecycle => 'blocks', Query => $query &>
+<& LookupSummary, %ARGS, Lifecycle => RT::IR->lifecycle_countermeasure, Query => $query &>
 % }
 
 </td></tr>
diff --git a/lib/RT/Action/RTIR_ChangeChildOwnership.pm b/lib/RT/Action/RTIR_ChangeChildOwnership.pm
index 819c33e..4e5d6ac 100644
--- a/lib/RT/Action/RTIR_ChangeChildOwnership.pm
+++ b/lib/RT/Action/RTIR_ChangeChildOwnership.pm
@@ -73,9 +73,9 @@ sub Commit {
     }
 
     # change owner of child Incident Reports, Investigations, Blocks
-    my $query =  "(Lifecycle = 'incident_reports'"
-                ." OR Lifecycle = 'investigations'"
-                ." OR Lifecycle = 'blocks'"
+    my $query =  "(Lifecycle = '".RT::IR->lifecycle_report."'"
+                ." OR Lifecycle ='". RT::IR->lifecycle_investigation."'"
+                ." OR Lifecycle = '".RT::IR->lifecycle_countermeasure."'"
                 .") AND MemberOf = ". $self->TicketObj->Id
                 ." AND Owner != ". $transaction->NewValue;
     my $members = RT::Tickets->new( $actor );
diff --git a/lib/RT/Action/RTIR_ResolveChildren.pm b/lib/RT/Action/RTIR_ResolveChildren.pm
index 9b7e247..8596be3 100644
--- a/lib/RT/Action/RTIR_ResolveChildren.pm
+++ b/lib/RT/Action/RTIR_ResolveChildren.pm
@@ -76,8 +76,8 @@ sub Commit {
     my $incident = $self->TicketObj;
     my $id = $incident->Id;
 
-    foreach my $lifecycle ( 'incident_reports', 'investigations', 'blocks' ) {
-        next if $lifecycle eq 'blocks' && RT->Config->Get('RTIR_DisableBlocksQueue');
+    foreach my $lifecycle ( RT::IR->lifecycle_report, RT::IR->lifecycle_investigation, RT::IR->lifecycle_countermeasure ) {
+        next if $lifecycle eq RT::IR->lifecycle_countermeasure && RT->Config->Get('RTIR_DisableBlocksQueue');
 
         my $members = RT::IR->IncidentChildren(
             $incident, Lifecycle => $lifecycle,
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 8aa4e6c..9c6b224 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -62,7 +62,16 @@ use Scalar::Util qw(blessed);
 use RT::IR::Config;
 RT::IR::Config::Init();
 
-my @LIFECYCLES = ('incidents', 'incident_reports', 'investigations','blocks');
+
+
+sub lifecycle_report {'incident_reports'}
+sub lifecycle_incident {'incidents'}
+sub lifecycle_investigation {'investigations'}
+sub lifecycle_countermeasure {'blocks'}
+
+
+my @LIFECYCLES = (RT::IR->lifecycle_incident, RT::IR->lifecycle_report, RT::IR->lifecycle_investigation, RT::IR->lifecycle_countermeasure);
+
 my @QUEUES = ('Incidents', 'Incident Reports', 'Investigations', 'Blocks');
 my %QUEUES = map { lc($_) => $_ } @QUEUES;
 my %TYPE = (
@@ -74,18 +83,13 @@ my %TYPE = (
 );
 
 my %FRIENDLY_LIFECYCLE = (
-    'incidents'        => 'Incidents',
-    'incident_reports' => 'Incident Reports',
-    'investigations'   => 'Investigations',
-    'blocks'           => 'Blocks',
+    RT::IR->lifecycle_incident        => 'Incidents',
+    RT::IR->lifecycle_report => 'Incident Reports',
+    RT::IR->lifecycle_investigation   => 'Investigations',
+    RT::IR->lifecycle_countermeasure           => 'Blocks',
 
 );
 
-sub lifecycle_report {'incident_reports'}
-sub lifecycle_incident {'incidents'}
-sub lifecycle_investigation {'investigations'}
-sub lifecycle_countermeasure {'blocks'}
-
 
 use Parse::BooleanLogic;
 my $ticket_sql_parser = Parse::BooleanLogic->new;
@@ -678,9 +682,8 @@ require RT::Action::AutoOpen;
     my $prepare = RT::Action::AutoOpen->can('Prepare');
     *RT::Action::AutoOpen::Prepare = sub {
         my $self = shift;
-        my $ticket = $self->TicketObj;
-        my $type = RT::IR::TicketType( Ticket => $ticket );
-        return 0 if $type && ( $type eq 'Block' || $type eq 'Report' );
+        my $type = $self->TicketObj->QueueObj->Lifecycle;
+        return 0 if $type && ( $type eq RT::IR->lifecycle_countermeasure || $type eq RT::IR->lifecycle_report);
         return $self->$prepare(@_);
     };
 }
@@ -690,9 +693,8 @@ require RT::Action::AutoOpenInactive;
     my $prepare = RT::Action::AutoOpenInactive->can('Prepare');
     *RT::Action::AutoOpenInactive::Prepare = sub {
         my $self = shift;
-        my $ticket = $self->TicketObj;
-        my $type = RT::IR::TicketType( Ticket => $ticket );
-        return 0 if $type && ( $type eq 'Block' || $type eq 'Report' );
+        my $type = $self->TicketObj->QueueObj->Lifecycle;
+        return 0 if $type && ( $type eq RT::IR->lifecycle_countermeasure || $type eq RT::IR->lifecycle_report);
         return $self->$prepare(@_);
     };
 }
@@ -746,7 +748,7 @@ package RT::Search::Simple;
 
 sub HandleRtirip {
     return 'RTIR IP' => RT::IR->Query(
-        Lifecycle => ['incidents', 'incident_reports', 'investigations', 'blocks'],
+        Lifecycle => \@LIFECYCLES,
         And => "'CustomField.{IP}' = '$_[1]'",
     );
 }
@@ -757,9 +759,9 @@ sub HandleRtirrequestor {
 
     my $children = RT::Tickets->new( $self->TicketsObj->CurrentUser );
     $children->FromSQL(
-        "( Lifecycle = 'incident_reports' OR
-           Lifecycle = 'investigations' OR
-           Lifecycle = 'blocks'
+        "( Lifecycle = '".RT::IR->lifecycle_report."' OR
+           Lifecycle = '".RT::IR->lifecycle_investigation."' OR
+           Lifecycle = '".RT::IR->lifecycle_countermeasure."'
          ) AND Requestor LIKE '$value'"
     );
     my $query = '';
@@ -768,7 +770,7 @@ sub HandleRtirrequestor {
         $query .= "HasMember = " . $child->Id;
     }
     $query ||= 'id = 0';
-    return 'RTIR Requestor' => "Lifecycle = 'incidents' AND ($query)";
+    return 'RTIR Requestor' => "Lifecycle = '".RT::IR->lifecycle_incident."' AND ($query)";
 }
 
 package RT::IR;

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


More information about the rt-commit mailing list