Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Request Tracker: Commit

r6014 - in rtir/branches/2.1-EXPERIMENTAL: .

 

 

Request Tracker commit RSS feed   Index | Next | Previous | View Threaded


ruz at bestpractical

Sep 20, 2006, 7:57 PM

Post #1 of 1 (253 views)
Permalink
r6014 - in rtir/branches/2.1-EXPERIMENTAL: .

Author: ruz
Date: Wed Sep 20 22:57:43 2006
New Revision: 6014

Modified:
rtir/branches/2.1-EXPERIMENTAL/ (props changed)
rtir/branches/2.1-EXPERIMENTAL/lib/RT/Action/RTIR_SetConstituency.pm

Log:
r1614 [at] cubic-p: cubic | 2006-09-21 07:08:17 +0400
* make a failing test pass


Modified: rtir/branches/2.1-EXPERIMENTAL/lib/RT/Action/RTIR_SetConstituency.pm
==============================================================================
--- rtir/branches/2.1-EXPERIMENTAL/lib/RT/Action/RTIR_SetConstituency.pm (original)
+++ rtir/branches/2.1-EXPERIMENTAL/lib/RT/Action/RTIR_SetConstituency.pm Wed Sep 20 22:57:43 2006
@@ -26,25 +26,7 @@

my $transaction = $self->TransactionObj;
if ( $transaction->Type eq 'Create' ) {
- # on create fetch value from X-RT-Mail-Extension field
- my $attachments = $transaction->Attachments;
- $attachments->OrderByCols(
- { FIELD => 'Created', ORDER => 'ASC' },
- { FIELD => 'id', ORDER => 'ASC' },
- );
- $attachments->Columns( qw(id Parent TransactionId ContentType ContentEncoding Headers Subject Created) );
- my $attachment = $attachments->First;
- return 1 unless $attachment;
-
- my $value = $attachment->GetHeader('X-RT-Mail-Extension');
- return 1 unless $self->IsValidConstituency( $value );
-
- my ($status, $msg) = $ticket->AddCustomFieldValue(
- Field => '_RTIR_Constituency',
- Value => $value,
- );
- return ($status, $msg) unless $status;
- return 1;
+ return $self->SetConstituencyOnCreate;
}

my $constituency = $ticket->FirstCustomFieldValue('_RTIR_Constituency');
@@ -76,6 +58,51 @@
return 1;
}

+sub SetConstituencyOnCreate {
+ my $self = shift;
+ my $ticket = $self->TicketObj;
+ my ($current, $value);
+ $current = $value = $ticket->FirstCustomFieldValue('_RTIR_Constituency');
+ if ( my $tmp = $self->GetConstituencyFromParent ) {
+ $value = $tmp;
+ }
+ $value ||= $self->GetConstituencyFromAttachment;
+ return 1 if ($current||'') eq ($value||'');
+
+ my ($status, $msg) = $ticket->AddCustomFieldValue(
+ Field => '_RTIR_Constituency',
+ Value => $value,
+ );
+ return ($status, $msg) unless $status;
+ return 1;
+}
+
+sub GetConstituencyFromAttachment {
+ my $self = shift;
+
+ # fetch value from X-RT-Mail-Extension field
+ my $attachments = $self->TransactionObj->Attachments;
+ $attachments->OrderByCols(
+ { FIELD => 'Created', ORDER => 'ASC' },
+ { FIELD => 'id', ORDER => 'ASC' },
+ );
+ $attachments->Columns( qw(id Parent TransactionId ContentType ContentEncoding Headers Subject Created) );
+ my $attachment = $attachments->First;
+ return undef unless $attachment;
+
+ my $value = $attachment->GetHeader('X-RT-Mail-Extension');
+ return undef unless $self->IsValidConstituency( $value );
+ return $value;
+}
+
+sub GetConstituencyFromParent {
+ my $self = shift;
+ my $parents = RT::Tickets->new( $RT::SystemUser );
+ $parents->FromSQL( "HasMember = ". $self->TicketObj->id );
+ return unless my $parent = $parents->First;
+ return $parent->FirstCustomFieldValue('_RTIR_Constituency');
+}
+
{ my %constituency;

sub IsValidConstituency {
_______________________________________________
Rt-commit mailing list
Rt-commit [at] lists
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-commit

Request Tracker commit RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.