[Rt-commit] [svn] r846 - in rt/branches/rt-3.1: html/Tools
lib/RT/Action
leira at pallas.eruditorum.org
leira at pallas.eruditorum.org
Thu May 6 17:00:20 EDT 2004
Author: leira
Date: Thu May 6 17:00:19 2004
New Revision: 846
Modified:
rt/branches/rt-3.1/html/Tools/Offline.html
rt/branches/rt-3.1/lib/RT/Action/CreateTickets.pm
Log:
- Allow selection of a default queue
- Be more generous about fields padded with spaces
- Be more generous about field names
- Put ENDOFCONTENT at the end of content
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 Thu May 6 17:00:19 2004
@@ -31,24 +31,32 @@
<FORM ACTION="Offline.html" NAME="TicketUpdate"
METHOD=POST enctype="multipart/form-data">
<table>
-<tr><td class=label>
-<&|/l&>Upload file</&>:
+<tr>
+<td>
+<&|/l&>Default Queue</&>:
</td>
<td>
-<input name="Template" type="file" value="foo">
-<INPUT TYPE=SUBMIT NAME="Parse" VALUE="<&|/l&>Parse</&>">
+<& /Elements/SelectQueue, Name => "qname", NamedValues => 1 &>
+<i><&|/l&>If no queue is specified, create tickets in this queue.</&></i>
</td>
</tr>
-<tr>
<tr><td class=labeltop>
<&|/l&>Template</&>:
</td>
-<td>
+<td colspan=2>
<textarea name=string cols=80 rows=30>
<%$string%>
</textarea>
</td>
</tr>
+<tr><td class=label>
+<&|/l&>Get template from file</&>:
+</td>
+<td>
+<input name="Template" type="file" value="foo">
+<INPUT TYPE=SUBMIT NAME="Parse" VALUE="<&|/l&>Go</&>">
+</td>
+</tr>
</table>
<& /Elements/Submit, Name => 'UpdateTickets', Label => loc('Upload'), Caption => loc("Upload your changes"), color => "#993333" &>
@@ -71,7 +79,7 @@
while ( my $bytesread = read( $fh, $buffer, 4096 ) ) {
$template .= $buffer;
}
- $action->Parse($template);
+ $action->Parse($template, $ARGS{'qname'});
foreach (@{ $action->{'create_tickets'} }) {
my $id = $_;
$id =~ s/^create\-//;
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 Thu May 6 17:00:19 2004
@@ -594,6 +594,7 @@
sub Parse {
my $self = shift;
my $content = shift;
+ my $qname = shift;
my @template_order;
my $template_id;
@@ -640,6 +641,7 @@
$content = substr($content, index($content, "\n") + 1);
$RT::Logger->debug("First: $first");
+ my $queue;
foreach my $line (split(/\n/, $content)) {
next unless $line;
$RT::Logger->debug("Line: $line");
@@ -648,20 +650,46 @@
my $template_id;
while ($line =~ /($justquoted|$delimited)/igx) {
if ($i == 0) {
+ $queue = 0;
$template_id = 'create-' . $1;
$RT::Logger->debug("template_id: $1");
push @{$self->{'create_tickets'}},$template_id;
} else {
- my $field = $1;
- if ($field =~ /$justquoted/) {
- $field =~ s/^\"|\'//;
- $field =~ s/\"|\'$//;
+ my $value = $1;
+ if ($value =~ /$justquoted/) {
+ $value =~ s/^\"|\'//;
+ $value =~ s/\"|\'$//;
}
- $self->{'templates'}->{$template_id} .= $fields[$i] . ": $field\n";
- $RT::Logger->debug($fields[$i] . ": $1");
+ my $field = $fields[$i];
+ next unless $field;
+ $field =~ s/^\s//;
+ $field =~ s/\s$//;
+ if ( $field =~ /Body/i || $field =~ /Data/i ||
+ $field =~ /Message/i) {
+ $field = 'Content';
+ }
+ if ( $field =~ /Summary/i) {
+ $field = 'Subject';
+ }
+ if ( $field =~ /Queue/i) {
+ $queue = 1;
+ $RT::Logger->debug("queue!!: |$field|\n");
+ if (!$value) {
+ $value = $qname;
+ }
+ }
+ $RT::Logger->debug("field: |$field|\n");
+ $self->{'templates'}->{$template_id} .= $field . ": ";
+ $self->{'templates'}->{$template_id} .= $value || "";
+ $self->{'templates'}->{$template_id} .= "\n";
+ $self->{'templates'}->{$template_id} .= "ENDOFCONTENT\n" if $field =~ /content/i;
+ $RT::Logger->debug($field . ": $1");
}
$i++;
}
+ if (!$queue) {
+ $self->{'templates'}->{$template_id} .= "Queue: $qname\n";
+ }
}
}
}
More information about the Rt-commit
mailing list