[Rt-commit] [svn] r1203 - in rt/branches/rt-3.1: . html/Tools
lib/RT lib/RT/Action lib/RT/Condition
jesse at pallas.eruditorum.org
jesse at pallas.eruditorum.org
Mon Jul 12 02:13:42 EDT 2004
Author: jesse
Date: Mon Jul 12 02:13:41 2004
New Revision: 1203
Modified:
rt/branches/rt-3.1/ (props changed)
rt/branches/rt-3.1/html/Tools/Offline.html
rt/branches/rt-3.1/lib/RT/Action/CreateTickets.pm
rt/branches/rt-3.1/lib/RT/Action/Generic.pm
rt/branches/rt-3.1/lib/RT/Condition/Generic.pm
rt/branches/rt-3.1/lib/RT/ScripAction_Overlay.pm
rt/branches/rt-3.1/lib/RT/ScripCondition_Overlay.pm
rt/branches/rt-3.1/lib/RT/Ticket_Overlay.pm
Log:
----------------------------------------------------------------------
r2125 at tinbook: jesse | 2004-07-12T05:19:50.016366Z
A bunch more work to prepare for roundtrippable comma-delimited files (vitix)
----------------------------------------------------------------------
Modified: rt/branches/rt-3.1/html/Tools/Offline.html
==============================================================================
--- rt/branches/rt-3.1/html/Tools/Offline.html (original)
+++ rt/branches/rt-3.1/html/Tools/Offline.html Mon Jul 12 02:13:41 2004
@@ -73,42 +73,46 @@
<& /Elements/Submit, Name => 'UpdateTickets', Label => loc('Upload'), Caption => loc("Upload your changes"), color => "#993333" &>
</FORM>
-
+<%args>
+$requestoraddress => undef
+$qname => undef
+$string => undef
+</%args>
<%INIT>
my @results;
use RT::Action::CreateTickets;
-my $action = new RT::Action::CreateTickets;
-my $string;
-
-my $requestoraddress = $ARGS{'requestoraddress'};
-my $qname = $ARGS{'qname'};
-
+my $action = RT::Action::CreateTickets->new(CurrentUser => $session{'CurrentUser'});
+;
if ($ARGS{'Parse'} && $ARGS{'Template'}) {
- $ARGS{'string'} = "";
my $cgi_object = $m->cgi_object;
my $fh = $cgi_object->upload('Template');
my $filename = "$fh";
my ($buffer, $template);
while ( my $bytesread = read( $fh, $buffer, 4096 ) ) {
- $template .= $buffer;
+ $template .= $buffer;
}
$template =~ s/\r\n/\n/gs;
$action->Parse(Content => $template, Queue => $qname, Requestor => $requestoraddress);
- foreach (@{ $action->{'create_tickets'} }) {
- my $id = $_;
- $id =~ s/^create\-//;
- $string .= "===Create-Ticket: $id\n";
- $string .= $action->{'templates'}->{$_} . "\n";
+ foreach ( @{ $action->{'create_tickets'} } ) {
+ my $id = $_;
+ $id =~ s/^create\-//;
+ $string .= "===Create-Ticket: $id\n";
+ $string .= $action->{'templates'}->{$_} . "\n";
}
+ foreach ( @{ $action->{'update_tickets'} } ) {
+ my $id = $_;
+ $id =~ s/^update\-//;
+ $string .= "===Update-Ticket: $id\n";
+ $string .= $action->{'templates'}->{$_} . "\n";
+ }
+
- $ARGS{'string'} = $string;
} elsif ($ARGS{'UpdateTickets'}) {
$action->Parse(Content => $ARGS{string}, Queue => $qname, Requestor=> $requestoraddress);
push @results, $action->CreateByTemplate();
push @results, $action->UpdateByTemplate();
- $string = $ARGS{string};
} else {
if ($ARGS{'Query'}) {
my $Tickets = RT::Tickets->new($session{'CurrentUser'});
Modified: rt/branches/rt-3.1/lib/RT/Action/CreateTickets.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Action/CreateTickets.pm (original)
+++ rt/branches/rt-3.1/lib/RT/Action/CreateTickets.pm Mon Jul 12 02:13:41 2004
@@ -280,7 +280,7 @@
is ($t->ReferredToBy->Count,1, "It's only referred to by one other ticket");
is ($t->ReferredToBy->First->BaseObj->Id,$t->DependsOn->First->TargetObj->Id, "The same ticket that depends on it refers to it.");
use RT::Action::CreateTickets;
-my $action = new RT::Action::CreateTickets;
+my $action = RT::Action::CreateTickets->new( CurrentUser => $RT::SystemUser);;
# comma-delimited templates
my $commas = <<"EOF";
@@ -655,18 +655,20 @@
$template_id =~ m/^update-(.*)/;
my $base_id = "base-$1";
my $base = $self->{'templates'}->{$base_id};
+ if ($base) {
$base =~ s/\r//g;
$base =~ s/\n+$//;
$current =~ s/\n+$//;
- if ( $base ne $current ) {
+ # If we have no base template, set what we can.
+ if ($base ne $current) {
push @results,
"Could not update ticket "
. $T::Tickets{$template_id}->Id
. ": Ticket has changed";
next;
}
-
+ }
push @results, $T::Tickets{$template_id}->Update(
AttributesRef => \@attribs,
ARGSRef => $ticketargs
@@ -783,7 +785,7 @@
my $value = $1;
$value =~ s/^\s//;
$value =~ s/\s$//;
- if ( !$value ) {
+ if ( !$value && $args{'Queue'}) {
$value = $args{'Queue'};
$line = "Queue: $value";
}
@@ -793,7 +795,7 @@
my $value = $1;
$value =~ s/^\s//;
$value =~ s/\s$//;
- if ( !$value ) {
+ if ( !$value && $args{'Requestor'}) {
$value = $args{'Requestor'};
$line = "Requestor: $value";
}
@@ -843,9 +845,22 @@
$tid =~ s/^\s//;
$tid =~ s/\s$//;
next unless $tid;
- $template_id = 'create-' . $tid;
+
+
+ if ($tid =~ /^\d+$/) {
+ $template_id = 'update-' . $tid;
+ push @{ $self->{'update_tickets'} }, $template_id;
+
+ } elsif ($tid =~ /^#base-(\d+)$/) {
+
+ $template_id = 'base-' . $1;
+ push @{ $self->{'base_tickets'} }, $template_id;
+
+ } else {
+ $template_id = 'create-' . $tid;
+ push @{ $self->{'create_tickets'} }, $template_id;
+ }
$RT::Logger->debug("template_id: $tid");
- push @{ $self->{'create_tickets'} }, $template_id;
}
else {
my $value = $1;
@@ -869,13 +884,13 @@
}
if ( $field =~ /Queue/i ) {
$queue = 1;
- if ( !$value ) {
+ if ( !$value && $args{'Queue'} ) {
$value = $args{'Queue'};
}
}
if ( $field =~ /Requestor/i ) {
$requestor = 1;
- if ( !$value ) {
+ if ( !$value && $args{'Requestor'} ) {
$value = $args{'Requestor'};
}
}
@@ -938,12 +953,12 @@
}
}
- my $TicketObj ||= RT::Ticket->new($RT::SystemUser);
+ my $TicketObj ||= RT::Ticket->new($self->CurrentUser);
my %args;
my @lines = ( split( /\n/, $content ) );
while ( defined( my $line = shift @lines ) ) {
- if ( $line =~ /^(.*?):(?:\s+(.*))?$/ ) {
+ if ( $line =~ /^(.*?):(?:\s+)(.*?)(?:\s*)$/ ) {
my $value = $2;
my $tag = lc($1);
$tag =~ s/-//g;
@@ -980,7 +995,7 @@
}
foreach my $date qw(due starts started resolved) {
- my $dateobj = RT::Date->new($RT::SystemUser);
+ my $dateobj = RT::Date->new($self->CurrentUser);
next unless $args{$date};
if ( $args{$date} =~ /^\d+$/ ) {
$dateobj->Set( Format => 'unix', Value => $args{$date} );
@@ -1191,6 +1206,10 @@
foreach my $type qw(Requestor Cc AdminCc) {
my $method = $type . 'Addresses';
my $oldaddr = $ticket->$method;
+
+
+ # Skip unless we have a defined field
+ next unless defined $args->{$type};
my $newaddr = $args->{$type};
my @old = split( ', ', $oldaddr );
Modified: rt/branches/rt-3.1/lib/RT/Action/Generic.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Action/Generic.pm (original)
+++ rt/branches/rt-3.1/lib/RT/Action/Generic.pm Mon Jul 12 02:13:41 2004
@@ -46,6 +46,8 @@
use strict;
use Scalar::Util;
+use base qw/RT::Base/;
+
# {{{ sub new
sub new {
my $proto = shift;
@@ -57,13 +59,6 @@
}
# }}}
-# {{{ sub new
-sub loc {
- my $self = shift;
- return $self->{'ScripObj'}->loc(@_);
-}
-# }}}
-
# {{{ sub _Init
sub _Init {
my $self = shift;
@@ -73,6 +68,7 @@
TemplateObj => undef,
Argument => undef,
Type => undef,
+ CurrentUser => undef,
@_ );
@@ -82,6 +78,7 @@
$self->{'TransactionObj'} = $args{'TransactionObj'};
$self->{'TemplateObj'} = $args{'TemplateObj'};
$self->{'Type'} = $args{'Type'};
+ $self->CurrentUser( $args{'CurrentUser'});
Scalar::Util::weaken($self->{'ScripObj'});
Scalar::Util::weaken($self->{'TicketObj'});
Scalar::Util::weaken($self->{'TemplateObj'});
Modified: rt/branches/rt-3.1/lib/RT/Condition/Generic.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Condition/Generic.pm (original)
+++ rt/branches/rt-3.1/lib/RT/Condition/Generic.pm Mon Jul 12 02:13:41 2004
@@ -21,6 +21,7 @@
#
#
# END LICENSE BLOCK
+
=head1 NAME
RT::Condition::Generic - ;
@@ -57,10 +58,8 @@
package RT::Condition::Generic;
-use RT::Base;
use strict;
-use vars qw/@ISA/;
- at ISA = qw(RT::Base);
+use base qw/RT::Base/;
# {{{ sub new
sub new {
@@ -82,6 +81,7 @@
TemplateObj => undef,
Argument => undef,
ApplicableTransTypes => undef,
+ CurrentUser => undef,
@_ );
$self->{'Argument'} = $args{'Argument'};
@@ -89,6 +89,7 @@
$self->{'TicketObj'} = $args{'TicketObj'};
$self->{'TransactionObj'} = $args{'TransactionObj'};
$self->{'ApplicableTransTypes'} = $args{'ApplicableTransTypes'};
+ $self->CurrentUser($args{'CurrentUser'});
}
# }}}
Modified: rt/branches/rt-3.1/lib/RT/ScripAction_Overlay.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/ScripAction_Overlay.pm (original)
+++ rt/branches/rt-3.1/lib/RT/ScripAction_Overlay.pm Mon Jul 12 02:13:41 2004
@@ -144,6 +144,7 @@
TransactionObj => $args{'TransactionObj'},
TemplateObj => $self->TemplateObj,
Argument => $self->Argument,
+ CurrentUser => $self->CurrentUser
);
}
# }}}
Modified: rt/branches/rt-3.1/lib/RT/ScripCondition_Overlay.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/ScripCondition_Overlay.pm (original)
+++ rt/branches/rt-3.1/lib/RT/ScripCondition_Overlay.pm Mon Jul 12 02:13:41 2004
@@ -157,7 +157,8 @@
'ScripObj' => $args{'ScripObj'},
'TransactionObj' => $args{'TransactionObj'},
'Argument' => $self->Argument,
- 'ApplicableTransTypes' => $self->ApplicableTransTypes,
+ 'ApplicableTransTypes' => $self->ApplicableTransTypes,
+ CurrentUser => $self->CurrentUser
);
}
# }}}
Modified: rt/branches/rt-3.1/lib/RT/Ticket_Overlay.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Ticket_Overlay.pm (original)
+++ rt/branches/rt-3.1/lib/RT/Ticket_Overlay.pm Mon Jul 12 02:13:41 2004
@@ -2128,6 +2128,18 @@
return ($queue_obj);
}
+=head2 Queue
+
+Returns the name of this ticket's queue, rather than its id.
+
+=cut
+
+sub Queue {
+ my $self = shift;
+ return $self->QueueObj->Name;
+}
+
+
# }}}
# }}}
More information about the Rt-commit
mailing list