[Rt-commit] r6160 - rtir/branches/2.0-TESTING/etc/upgrade/1.1.3

ruz at bestpractical.com ruz at bestpractical.com
Wed Oct 4 07:10:07 EDT 2006


Author: ruz
Date: Wed Oct  4 07:10:06 2006
New Revision: 6160

Modified:
   rtir/branches/2.0-TESTING/etc/upgrade/1.1.3/content

Log:
* in 1.1.3 actions on three scrips were changed. implement this change
  in the upgrade script instead of adding new scrips

Modified: rtir/branches/2.0-TESTING/etc/upgrade/1.1.3/content
==============================================================================
--- rtir/branches/2.0-TESTING/etc/upgrade/1.1.3/content	(original)
+++ rtir/branches/2.0-TESTING/etc/upgrade/1.1.3/content	Wed Oct  4 07:10:06 2006
@@ -27,49 +27,87 @@
 );
 
 @Scrips = (
-   {  Description => "SetRTIRState",
-      Queue            => 'Incident Reports',
-      ScripCondition   => 'RTIR Require Due Change',
-      ScripAction      => 'RTIR Set Incident Due',
-      Template          => 'Blank', },
-   {  Description => "SetRTIRState",
-      Queue            => 'Investigations',
-      ScripCondition   => 'RTIR Require Due Change',
-      ScripAction      => 'RTIR Set Incident Due',
-      Template          => 'Blank', },
-   {  Description => "SetRTIRState",
-      Queue            => 'Blocks',
-      ScripCondition   => 'RTIR Require Due Change',
-      ScripAction      => 'RTIR Set Incident Due',
-      Template          => 'Blank', },
-    {  Description => "SetDueReopen",
-       Queue            => 'Incident Reports',
-       ScripCondition => 'RTIR Reopen Ticket',
-       ScripAction      => 'RTIR Set Due Reopen',
-       Template       => 'Blank' },
-    {  Description => "SetDueReopen",
-       Queue            => 'Investigations',
-       ScripCondition => 'RTIR Reopen Ticket',
-       ScripAction      => 'RTIR Set Due Reopen',
-       Template       => 'Blank' },
-    {  Description => "SetDueReopen",
-       Queue            => 'Blocks',
-       ScripCondition => 'RTIR Reopen Ticket',
-       ScripAction      => 'RTIR Set Due Reopen',
-       Template       => 'Blank' },
-    {  Description => "DetectStaffResponse",
-       Queue          => 'Investigations',
-       ScripCondition => 'RTIR Staff Response',
-       ScripAction      => 'RTIR Set Due Correspond',
-       Template       => 'Blank' },
-    {  Description => "DetectStaffResponse",
-       Queue          => 'Incident Reports',
-       ScripCondition => 'RTIR Staff Response',
-       ScripAction      => 'RTIR Set Due Correspond',
-       Template       => 'Blank' },
-    {  Description => "DetectStaffResponse",
-       Queue          => 'Blocks',
+    {  Description => "SetRTIRState",
+       Queue            => [ 'Incident Reports', 'Investigations', 'Blocks' ],
+       ScripCondition   => 'RTIR Require Due Change',
+       ScripAction      => 'RTIR Set Incident Due',
+       Template          => 'Blank', },
+
+    {  Description    => "DetectStaffResponse",
+       Queue          => [ 'Investigations', 'Incident Reports', 'Blocks' ],
        ScripCondition => 'RTIR Staff Response',
-       ScripAction      => 'RTIR Set Due Correspond',
+       ScripAction    => 'RTIR Set Due Correspond',
        Template       => 'Blank' },
 );
+
+sub get_queue {
+    my $meta = shift;
+
+    require RT::Queue;
+    my $obj = RT::Queue->new( $RT::SystemUser );
+    $obj->LoadByCols( ref $meta? %$meta: ( Name => $meta ) );
+    unless( $obj->id ) {
+        print STDERR "Couldn't load queue.";
+        return;
+    }
+    return $obj;
+
+}
+
+sub get_scrip {
+    my $meta = shift;
+    $meta = { Description => $meta } unless ref $meta;
+
+    if ( $meta->{'Queue'} && $meta->{'Queue'} !~ /^\d+$/ ) {
+        my $queue = get_queue( $meta->{'Queue'} ) or return;
+        $meta->{'Queue'} = $queue->id;
+    }
+
+    require RT::Scrip;
+    my $obj = RT::Scrip->new( $RT::SystemUser );
+    $obj->LoadByCols( %$meta );
+    unless( $obj->id ) {
+        print STDERR "Couldn't load scrip.";
+        return;
+    }
+    return $obj;
+}
+
+sub set_scrip_action {
+    my $scrip = get_scrip( shift ) or return;
+    my $new_action = shift;
+
+    require RT::ScripAction;
+    my $scrip_action = RT::ScripAction->new( $RT::SystemUser );
+    if ( ref $new_action ) {
+        $scrip_action->LoadByCols( %$new_action );
+    } else {
+        $scrip_action->Load( $new_action );
+    }
+    unless ( $scrip_action->Id ) {
+        print STDERR "Couldn't load scrip action.";
+        return;
+    }
+    my ($status, $msg) = $scrip->SetScripAction( $scrip_action->Id );
+    unless ( $status ) {
+        print STDERR "Couldn't set action to ". $scrip_action->Name ." on scrip #". $scrip->id .".";
+        return;
+    }
+    print "Changed action of the scrip #". $scrip->id ."\n";
+}
+
+ at Final = ( sub {
+    set_scrip_action(
+        { Description => 'SetDueReopen', Queue => 'Incident Reports' },
+        'RTIR Set Due Reopen',
+    );
+    set_scrip_action(
+        { Description => 'SetDueReopen', Queue => 'Investigations' },
+        'RTIR Set Due Reopen',
+    );
+    set_scrip_action(
+        { Description => 'SetDueReopen', Queue => 'Blocks' },
+        'RTIR Set Due Reopen',
+    );
+} );
+


More information about the Rt-commit mailing list