[Rt-commit] r4434 - in rt/branches/3.5-TESTING:
html/REST/1.0/Forms/ticket
jesse at bestpractical.com
jesse at bestpractical.com
Mon Jan 23 08:59:21 EST 2006
Author: jesse
Date: Mon Jan 23 08:59:20 2006
New Revision: 4434
Modified:
rt/branches/3.5-TESTING/ (props changed)
rt/branches/3.5-TESTING/html/REST/1.0/Forms/ticket/default
Log:
r22883 at truegrounds: jesse | 2006-01-23 11:01:51 +0100
* CLI support for custom fields from lwang at Cluster FS
Modified: rt/branches/3.5-TESTING/html/REST/1.0/Forms/ticket/default
==============================================================================
--- rt/branches/3.5-TESTING/html/REST/1.0/Forms/ticket/default (original)
+++ rt/branches/3.5-TESTING/html/REST/1.0/Forms/ticket/default Mon Jan 23 08:59:20 2006
@@ -127,6 +127,18 @@
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};
}
@@ -190,6 +202,17 @@
push @data, [ $key => $val ];
}
+ # Display custom fields
+ my $CustomFields = $ticket->QueueObj->CustomFields();
+ while (my $cf = $CustomFields->Next()) {
+ 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 +294,20 @@
$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.";
More information about the Rt-commit
mailing list