summaryrefslogtreecommitdiff
path: root/rt/html/REST/1.0/Forms/ticket/default
diff options
context:
space:
mode:
authorivan <ivan>2008-03-02 04:11:51 +0000
committerivan <ivan>2008-03-02 04:11:51 +0000
commit8103c1fc1b2c27a6855feadf26f91b980a54bc52 (patch)
tree631dd45606c37c00d9026e14ecc3ee3700b4b51c /rt/html/REST/1.0/Forms/ticket/default
parent9c68254528b6f2c7d8c1921b452fa56064783782 (diff)
import rt 3.6.6
Diffstat (limited to 'rt/html/REST/1.0/Forms/ticket/default')
-rw-r--r--rt/html/REST/1.0/Forms/ticket/default71
1 files changed, 59 insertions, 12 deletions
diff --git a/rt/html/REST/1.0/Forms/ticket/default b/rt/html/REST/1.0/Forms/ticket/default
index 7d515e5..2bfc43d 100644
--- a/rt/html/REST/1.0/Forms/ticket/default
+++ b/rt/html/REST/1.0/Forms/ticket/default
@@ -2,7 +2,7 @@
%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
%# <jesse@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
@@ -22,7 +22,9 @@
%#
%# You should have received a copy of the GNU General Public License
%# along with this program; if not, write to the Free Software
-%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/copyleft/gpl.html.
%#
%#
%# CONTRIBUTION SUBMISSION POLICY:
@@ -49,8 +51,9 @@
$id
$changes => {}
$fields => undef
+$args => undef
</%ARGS>
-<%perl>
+<%INIT>
use MIME::Entity;
my @comments;
@@ -83,7 +86,7 @@ if ($id ne 'new') {
}
}
else {
- if (%data == 0) {
+ if (!keys(%data)) {
# GET ticket/new: Return a suitable default form.
# We get defaults from queue/1 (XXX: What if it isn't there?).
my $due = new RT::Date $session{CurrentUser};
@@ -127,11 +130,26 @@ else {
if (exists $create{lc $k}) {
$v{$create{lc $k}} = delete $data{$k};
}
+ # Set custom field
+ elsif ($k =~ /^CF-/i) {
+ my $cf = RT::CustomField->new( $RT::SystemUser );
+ my $cfk = $k;
+ $cfk =~ s/^CF-//i;
+ unless($cf->LoadByName( Name => $cfk )) {
+ push @comments, "# Invalid custom field name ($cfk)";
+ delete $data{$k};
+ next;
+ }
+ $v{"CustomField-".$cf->Id()} = delete $data{$k};
+ }
elsif (lc $k eq 'text') {
$text = delete $data{$k};
}
}
+ # people fields allow multiple values
+ $v{$_} = vsplit($v{$_}) foreach ( grep $create{lc $_}, @people );
+
if ($text) {
$v{MIMEObj} =
MIME::Entity->build(
@@ -141,20 +159,23 @@ else {
);
}
- $ticket->Create(%v);
- unless ($ticket->Id) {
- return [ "# Could not create ticket.", [], {}, 1 ];
+ my($tid,$trid,$terr) = $ticket->Create(%v);
+ unless ($tid) {
+ push(@comments, "# Could not create ticket.");
+ push(@comments, "# " . $terr);
+ goto DONE;
}
delete $data{id};
$id = $ticket->Id;
push(@comments, "# Ticket $id created.");
- goto DONE if %data == 0;
+ # see if the hash is empty
+ goto DONE if ! keys(%data);
}
}
# Now we know we're dealing with an existing ticket.
-if (%data == 0) {
+if (!keys(%data)) {
my ($time, $key, $val, @data);
push @data, [ id => "ticket/".$ticket->Id ];
@@ -171,7 +192,7 @@ if (%data == 0) {
}
foreach $key (@people) {
- next unless (!%$fields || (exists $fields->{lc $key}));
+ next unless (!%$fields || (exists $fields->{lc $key}));
push @data, [ $key => [ $ticket->$key->MemberEmailAddresses ] ];
}
@@ -186,10 +207,22 @@ if (%data == 0) {
foreach $key (qw(TimeEstimated TimeWorked TimeLeft)) {
next unless (!%$fields || (exists $fields->{lc $key}));
$val = $ticket->$key || 0;
- $val = $time->DurationAsString($val*60) if $val;
+ $val = "$val minutes" if $val;
push @data, [ $key => $val ];
}
+ # Display custom fields
+ my $CustomFields = $ticket->QueueObj->TicketCustomFields();
+ while (my $cf = $CustomFields->Next()) {
+ next unless (!%$fields || (exists $fields->{"cf-".lc $cf->Name}));
+ my $vals = $ticket->CustomFieldValues($cf->Id());
+ my @out = ();
+ while (my $v = $vals->Next()) {
+ push @out, $v->Content;
+ }
+ push @data, [ 'CF-' . $cf->Name => join ',', @out ];
+ }
+
my %k = map {@$_} @data;
$o = [ map {$_->[0]} @data ];
$k = \%k;
@@ -271,6 +304,20 @@ else {
$s =~ s/^# //;
}
}
+ # Set custom field
+ elsif ($key =~ /^CF-/i) {
+ my $cf = RT::CustomField->new( $RT::SystemUser );
+ $key =~ s/^CF-//i;
+ if (not $cf->LoadByName( Name => $key )) {
+ $n = 0;
+ $s = "Unknown custom field.";
+ }
+ else {
+ ($n, $s) = $ticket->AddCustomFieldValue(
+ Field => $cf, Value => $val );
+ $s =~ s/^# // if defined $s;
+ }
+ }
elsif ($key ne 'id' && $key ne 'type' && $key ne 'creator') {
$n = 0;
$s = "Unknown field.";
@@ -295,4 +342,4 @@ DONE:
$c ||= join("\n", @comments) if @comments;
return [$c, $o, $k, $e];
-</%perl>
+</%INIT>