[Rt-commit] r6194 - in rtir/branches/2.1-EXPERIMENTAL: . etc
etc/upgrade/2.1.1 lib/RT/Condition
ruz at bestpractical.com
ruz at bestpractical.com
Thu Oct 12 15:34:55 EDT 2006
Author: ruz
Date: Thu Oct 12 15:34:54 2006
New Revision: 6194
Added:
rtir/branches/2.1-EXPERIMENTAL/etc/upgrade/2.1.1/
rtir/branches/2.1-EXPERIMENTAL/etc/upgrade/2.1.1/content
rtir/branches/2.1-EXPERIMENTAL/lib/RT/Action/RTIR_SetStartedToNow.pm
rtir/branches/2.1-EXPERIMENTAL/lib/RT/Condition/RTIR_BlockActivation.pm
rtir/branches/2.1-EXPERIMENTAL/lib/RT/Condition/RTIR_LinkingToIncident.pm
Modified:
rtir/branches/2.1-EXPERIMENTAL/ (props changed)
rtir/branches/2.1-EXPERIMENTAL/etc/initialdata
rtir/branches/2.1-EXPERIMENTAL/lib/RT/Action/RTIR_OpenParent.pm
rtir/branches/2.1-EXPERIMENTAL/lib/RT/Condition/RTIR_RequireStateChange.pm
Log:
r1702 at cubic-pc: cubic | 2006-10-12 23:33:18 +0400
* new actions and conditions
Modified: rtir/branches/2.1-EXPERIMENTAL/etc/initialdata
==============================================================================
--- rtir/branches/2.1-EXPERIMENTAL/etc/initialdata (original)
+++ rtir/branches/2.1-EXPERIMENTAL/etc/initialdata Thu Oct 12 15:34:54 2006
@@ -334,6 +334,10 @@
Description => 'Set the starts date to the current time' , # loc
ExecModule => 'RTIR_SetStartsToNow',
},
+ { Name => 'RTIR Set Started to Now', # loc
+ Description => 'Set the started date to the current time' , # loc
+ ExecModule => 'RTIR_SetStartedToNow',
+ },
{ Name => 'RTIR Set Due by SLA', # loc
Description => 'Set the due date according to SLA' , # loc
ExecModule => 'RTIR_SetDueBySLA',
@@ -454,6 +458,16 @@
ApplicableTransTypes => 'Any',
ExecModule => 'RTIR_RequireConstituencyGroupChange',
},
+ { Name => 'RTIR Block Activation', # loc
+ Description => 'A block was activated or created in active state', # loc
+ ApplicableTransTypes => 'Create,CustomField',
+ ExecModule => 'RTIR_BlockActivation',
+ },
+ { Name => 'RTIR Linking To Incident', # loc
+ Description => 'Whenever ticket is linked to incident or created with link', # loc
+ ApplicableTransTypes => 'Create,AddLink',
+ ExecModule => 'RTIR_LinkingToIncident',
+ },
);
@Scrips = (
@@ -491,6 +505,17 @@
ScripAction => 'RTIR Set Starts by Business Hours',
Template => 'Blank' },
+ { Description => "SetStarted",
+ Queue => 'Blocks',
+ ScripCondition => 'RTIR Block Activation',
+ ScripAction => 'RTIR Set Started To Now',
+ Template => 'Blank' },
+ { Description => "SetStarted",
+ Queue => 'Incident Reports',
+ ScripCondition => 'RTIR Linking To Incident',
+ ScripAction => 'RTIR Set Started To Now',
+ Template => 'Blank' },
+
{ Description => "SetDue",
Queue => 'Incident Reports',
ScripCondition => 'On Create',
Added: rtir/branches/2.1-EXPERIMENTAL/etc/upgrade/2.1.1/content
==============================================================================
--- (empty file)
+++ rtir/branches/2.1-EXPERIMENTAL/etc/upgrade/2.1.1/content Thu Oct 12 15:34:54 2006
@@ -0,0 +1,33 @@
+ at ScripActions = (
+ { Name => 'RTIR Set Started to Now', # loc
+ Description => 'Set the started date to the current time' , # loc
+ ExecModule => 'RTIR_SetStartedToNow',
+ },
+);
+
+ at ScripConditions = (
+ { Name => 'RTIR Block Activation', # loc
+ Description => 'A block was activated or created in active state', # loc
+ ApplicableTransTypes => 'Create,CustomField',
+ ExecModule => 'RTIR_BlockActivation',
+ },
+ { Name => 'RTIR Linking To Incident', # loc
+ Description => 'Whenever ticket is linked to incident or created with link', # loc
+ ApplicableTransTypes => 'Create,AddLink',
+ ExecModule => 'RTIR_LinkingToIncident',
+ },
+);
+
+ at Scrips = (
+ { Description => "SetStarted",
+ Queue => 'Blocks',
+ ScripCondition => 'RTIR Block Activation',
+ ScripAction => 'RTIR Set Started To Now',
+ Template => 'Blank' },
+ { Description => "SetStarted",
+ Queue => 'Incident Reports',
+ ScripCondition => 'RTIR Linking To Incident',
+ ScripAction => 'RTIR Set Started To Now',
+ Template => 'Blank' },
+
+);
Modified: rtir/branches/2.1-EXPERIMENTAL/lib/RT/Action/RTIR_OpenParent.pm
==============================================================================
--- rtir/branches/2.1-EXPERIMENTAL/lib/RT/Action/RTIR_OpenParent.pm (original)
+++ rtir/branches/2.1-EXPERIMENTAL/lib/RT/Action/RTIR_OpenParent.pm Thu Oct 12 15:34:54 2006
@@ -45,9 +45,11 @@
# }}} END BPS TAGGED BLOCK
#
package RT::Action::RTIR_OpenParent;
+
use strict;
-use base 'RT::Action::RTIR';
+use warnings;
+use base 'RT::Action::RTIR';
=head2 Prepare
Added: rtir/branches/2.1-EXPERIMENTAL/lib/RT/Action/RTIR_SetStartedToNow.pm
==============================================================================
--- (empty file)
+++ rtir/branches/2.1-EXPERIMENTAL/lib/RT/Action/RTIR_SetStartedToNow.pm Thu Oct 12 15:34:54 2006
@@ -0,0 +1,38 @@
+package RT::Action::RTIR_SetStartedToNow;
+
+use strict;
+use base 'RT::Action::RTIR';
+
+sub Prepare { return 1 }
+
+=head2 Commit
+
+Set the Started date to now.
+
+=cut
+
+sub Commit {
+ my $self = shift;
+
+ my $ticket = $self->TicketObj;
+
+ # set if the Started value isn't already set
+ return 1 if $ticket->StartedObj->Unix > 0;
+
+ my $date = RT::Date->new( $RT::SystemUser );
+ $date->SetToNow;
+ my ($status, $msg) = $ticket->SetStarted( $date->ISO );
+ unless ( $status ) {
+ $RT::Logger->error("Couldn't set date: $msg");
+ return 0;
+ }
+
+ return 1;
+}
+
+eval "require RT::Action::RTIR_SetStartedToNow_Vendor";
+die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetStartedToNow_Vendor.pm});
+eval "require RT::Action::RTIR_SetStartedToNow_Local";
+die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/RTIR_SetStartedToNow_Local.pm});
+
+1;
Added: rtir/branches/2.1-EXPERIMENTAL/lib/RT/Condition/RTIR_BlockActivation.pm
==============================================================================
--- (empty file)
+++ rtir/branches/2.1-EXPERIMENTAL/lib/RT/Condition/RTIR_BlockActivation.pm Thu Oct 12 15:34:54 2006
@@ -0,0 +1,46 @@
+package RT::Condition::RTIR_BlockActivation;
+
+use strict;
+use warnings;
+
+use base 'RT::Condition::RTIR';
+use RT::CustomField;
+
+=head2 IsApplicable
+
+When state of the block changes from C<pending active> to C<active>
+or ticket created with C<active> state.
+
+=cut
+
+sub IsApplicable {
+ my $self = shift;
+
+ my $txn = $self->TransactionObj;
+
+ my $type = $txn->Type;
+ return 1 if $type eq 'Create'
+ && ($self->TicketObj->FirstCustomFieldValue('_RTIR_State')||'') eq 'active';
+
+ if ( $type eq 'CustomField' ) {
+ my $cf = $self->TicketObj->QueueObj->CustomField('_RTIR_State');
+ unless ( $cf->id ) {
+ $RT::Logger->error("Couldn't load the 'State' field");
+ return 0;
+ }
+
+ return 0 unless $cf->id == $txn->Field;
+ return 0 unless ($txn->OldValue) eq 'pending activation';
+ return 0 unless ($txn->NewValue) eq 'active';
+ return 1;
+ }
+
+ return 0;
+}
+
+eval "require RT::Condition::RTIR_BlockActivation_Vendor";
+die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_BlockActivation_Vendor.pm});
+eval "require RT::Condition::RTIR_BlockActivation_Local";
+die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_BlockActivation_Local.pm});
+
+1;
Added: rtir/branches/2.1-EXPERIMENTAL/lib/RT/Condition/RTIR_LinkingToIncident.pm
==============================================================================
--- (empty file)
+++ rtir/branches/2.1-EXPERIMENTAL/lib/RT/Condition/RTIR_LinkingToIncident.pm Thu Oct 12 15:34:54 2006
@@ -0,0 +1,46 @@
+package RT::Condition::RTIR_LinkingToIncident;
+
+use strict;
+use warnings;
+
+use base 'RT::Condition::RTIR';
+
+=head2 IsApplicable
+
+If ticket created with a link to an incident or link's added.
+
+=cut
+
+sub IsApplicable {
+ my $self = shift;
+
+ my $type = $self->TransactionObj->Type;
+ if ( $type eq "Create" ) {
+ my $query = "Queue = 'Incidents'"
+ ." AND HasMember = " . $self->TicketObj->Id;
+ my $parents = RT::Tickets->new( $self->CurrentUser );
+ $parents->FromSQL( $query );
+ return $parents->Count;
+ }
+
+ my $field = $self->TransactionObj->Field;
+ if ( $type eq 'AddLink' && $field eq 'MemberOf' ) {
+ my ($status, $msg, $parent) = $self->TicketObj->__GetTicketFromURI(
+ URI => $self->TransactionObj->NewValue
+ );
+ unless ( $parent && $parent->id ) {
+ $RT::Logger->error( "Couldn't load linked ticket #". $self->TransactionObj->NewValue );
+ return 0;
+ }
+ return $parent->QueueObj->Name eq 'Incidents';
+ }
+
+ return 0;
+}
+
+eval "require RT::Condition::RTIR_LinkingToIncident_Vendor";
+die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_LinkingToIncident_Vendor.pm});
+eval "require RT::Condition::RTIR_LinkingToIncident_Local";
+die $@ if ($@ && $@ !~ qr{^Can't locate RT/Condition/RTIR_LinkingToIncident_Local.pm});
+
+1;
Modified: rtir/branches/2.1-EXPERIMENTAL/lib/RT/Condition/RTIR_RequireStateChange.pm
==============================================================================
--- rtir/branches/2.1-EXPERIMENTAL/lib/RT/Condition/RTIR_RequireStateChange.pm (original)
+++ rtir/branches/2.1-EXPERIMENTAL/lib/RT/Condition/RTIR_RequireStateChange.pm Thu Oct 12 15:34:54 2006
@@ -50,6 +50,7 @@
use strict;
+use warnings;
use base 'RT::Condition::RTIR';
More information about the Rt-commit
mailing list