[Rt-commit] [svn] r1039 - in rt/branches/rt-3.1: html/Tools
lib/RT/Action
leira at pallas.eruditorum.org
leira at pallas.eruditorum.org
Wed Jun 9 11:56:32 EDT 2004
Author: leira
Date: Wed Jun 9 11:56:31 2004
New Revision: 1039
Modified:
rt/branches/rt-3.1/html/Tools/Offline.html
rt/branches/rt-3.1/lib/RT/Action/CreateTickets.pm
Log:
Support default Requestor when creating tickets (will be set if no Requestor is set in the template).
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 Wed Jun 9 11:56:31 2004
@@ -28,6 +28,9 @@
<& /Elements/ListActions, actions => \@results &>
+<& /Elements/Callback, Requestor => \$requestoraddress,
+ Queue => \$qname, %ARGS &>
+
<FORM ACTION="Offline.html" NAME="TicketUpdate"
METHOD=POST enctype="multipart/form-data">
<table>
@@ -40,6 +43,15 @@
<i><&|/l&>If no queue is specified, create tickets in this queue.</&></i>
</td>
</tr>
+<tr>
+<td class=label>
+<&|/l&>Default Requestor</&>:
+</td>
+<td>
+<input name=requestoraddress value=<%$requestoraddress%>>
+<i><&|/l&>If no Requestor is specified, create tickets with this requestor.</&></i>
+</td>
+</tr>
<tr><td class=labeltop>
<&|/l&>Template</&>:
</td>
@@ -69,6 +81,10 @@
my $action = new RT::Action::CreateTickets;
my $string;
+my $requestoraddress = $ARGS{'requestoraddress'};
+my $qname = $ARGS{'qname'};
+$RT::Logger->crit(" ********** requestor: " . $requestoraddress);
+
if ($ARGS{'Parse'} && $ARGS{'Template'}) {
$ARGS{'string'} = "";
my $cgi_object = $m->cgi_object;
@@ -79,7 +95,7 @@
while ( my $bytesread = read( $fh, $buffer, 4096 ) ) {
$template .= $buffer;
}
- $action->Parse($template, $ARGS{'qname'});
+ $action->Parse($template, $qname, $requestoraddress);
foreach (@{ $action->{'create_tickets'} }) {
my $id = $_;
$id =~ s/^create\-//;
@@ -89,7 +105,7 @@
$ARGS{'string'} = $string;
} elsif ($ARGS{'UpdateTickets'}) {
- $action->Parse($ARGS{string}, $ARGS{'qname'});
+ $action->Parse($ARGS{string}, $qname, $requestoraddress);
push @results, $action->CreateByTemplate();
push @results, $action->UpdateByTemplate();
$string = $ARGS{string};
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 Wed Jun 9 11:56:31 2004
@@ -619,10 +619,11 @@
my $self = shift;
my $content = shift;
my $qname = shift;
+ my $requestorname = shift;
my @template_order;
my $template_id;
- my $queue;
+ my ($queue, $requestor);
if (substr($content, 0, 3) eq '===') {
$RT::Logger->debug("Line: ===");
foreach my $line (split(/\n/, $content)) {
@@ -631,8 +632,11 @@
if ($line =~ /^===$/) {
if ($template_id && !$queue) {
$self->{'templates'}->{$template_id} .= "Queue: $qname\n";
+ } elsif ($template_id && !$requestor) {
+ $self->{'templates'}->{$template_id} .= "Requestor: $requestorname\n";
}
$queue = 0;
+ $requestor = 0;
}
if ($line =~ /^===Create-Ticket: (.*)$/) {
$template_id = "create-$1";
@@ -659,6 +663,16 @@
$line = "Queue: $value";
}
}
+ if ( $line =~ /^Requestor:(.*)/i) {
+ $requestor = 1;
+ my $value = $1;
+ $value =~ s/^\s//;
+ $value =~ s/\s$//;
+ if (!$value) {
+ $value = $requestorname;
+ $line = "Requestor: $value";
+ }
+ }
$self->{'templates'}->{$template_id} .= $line."\n";
}
}
@@ -724,6 +738,12 @@
$value = $qname;
}
}
+ if ( $field =~ /Requestor/i) {
+ $requestor = 1;
+ if (!$value) {
+ $value = $requestorname;
+ }
+ }
$self->{'templates'}->{$template_id} .= $field . ": ";
$self->{'templates'}->{$template_id} .= $value || "";
$self->{'templates'}->{$template_id} .= "\n";
@@ -735,6 +755,9 @@
if (!$queue) {
$self->{'templates'}->{$template_id} .= "Queue: $qname\n";
}
+ if (!$requestor) {
+ $self->{'templates'}->{$template_id} .= "Requestor: $requestorname\n";
+ }
}
}
}
@@ -797,8 +820,10 @@
}
} else {
# if it's not content, strip leading and trailing spaces
- $args{ $tag } =~ s/^\s+//g;
- $args{ $tag } =~ s/\s+$//g;
+ if ($args{ $tag }) {
+ $args{ $tag } =~ s/^\s+//g;
+ $args{ $tag } =~ s/\s+$//g;
+ }
}
}
}
More information about the Rt-commit
mailing list