Mailing List Archive

[svn] r1721 - in rt: . branches branches/3.3-TESTING/bin branches/3.3-TESTING/html/Search branches/3.3-TESTING/lib/RT branches/3.3-TESTING/lib/RT/Interface
Author: autrijus
Date: Fri Nov 5 06:43:18 2004
New Revision: 1721

Modified:
rt/ (props changed)
rt/branches/ (props changed)
rt/branches/3.3-TESTING/bin/standalone_httpd.in
rt/branches/3.3-TESTING/html/Search/Bulk.html
rt/branches/3.3-TESTING/lib/RT/Interface/Web.pm
rt/branches/3.3-TESTING/lib/RT/Ticket_Overlay.pm
Log:
r10186@not (orig r1718): autrijus | 2004-11-05T08:56:10.440277Z
* Log::Dispatch wants ->warning, not ->warn.

r10196@not: autrijus | 2004-11-05T11:41:58.476189Z
* Fixes to standalone_httpd: 'protocol' was not defined, and query_string
may be undefined too. (Supposedly fixed in HTTP::Server::Simple.)

r10197@not: autrijus | 2004-11-05T11:42:20.621065Z
* Remove outdated comment.

r10198@not: autrijus | 2004-11-05T11:43:55.045510Z
* Refactor getting-an-uploaded-file-into-cf into _UploadFile call
in Interface::Web; this unbreaks uploading a file cf on ticket creation.
* The "CustomField-x" keys in $Ticket->Create now take hash references
that contain CFV fields, eg. LargeContent, ContentType, Value.




Modified: rt/branches/3.3-TESTING/bin/standalone_httpd.in
==============================================================================
--- rt/branches/3.3-TESTING/bin/standalone_httpd.in (original)
+++ rt/branches/3.3-TESTING/bin/standalone_httpd.in Fri Nov 5 06:43:18 2004
@@ -108,10 +108,12 @@

last if ( $method !~ /^(GET|POST|HEAD)$/ );

+ $query_string = '' if !defined $query_string;
+
build_cgi_env( method => $method,
query_string => $query_string,
path => $file,
- method => $method,
+ protocol => $proto,
port => $port,
peername => $peername,
peeraddr => $peeraddr,

Modified: rt/branches/3.3-TESTING/html/Search/Bulk.html
==============================================================================
--- rt/branches/3.3-TESTING/html/Search/Bulk.html (original)
+++ rt/branches/3.3-TESTING/html/Search/Bulk.html Fri Nov 5 06:43:18 2004
@@ -76,7 +76,6 @@
</%PERL>
<TR bgcolor="<%$bgcolor%>">
<TD><input type=checkbox name="UpdateTicket<%$Ticket->Id%>" CHECKED></TD>
-%# The ticket view is controlled by config.pm, WebOptions
%foreach my $col (@cols) {
<TD>
% if ($col eq 'id') {

Modified: rt/branches/3.3-TESTING/lib/RT/Interface/Web.pm
==============================================================================
--- rt/branches/3.3-TESTING/lib/RT/Interface/Web.pm (original)
+++ rt/branches/3.3-TESTING/lib/RT/Interface/Web.pm Fri Nov 5 06:43:18 2004
@@ -326,7 +326,12 @@
$ARGS{$arg} = [split('\n', $ARGS{$arg})];
}

- $create_args{"CustomField-".$cfid} = $ARGS{"$arg"};
+ if ( $arg =~ /-Upload$/ ) {
+ $create_args{"CustomField-".$cfid} = _UploadedFile($arg);
+ }
+ else {
+ $create_args{"CustomField-".$cfid} = $ARGS{"$arg"};
+ }
}
}

@@ -825,19 +830,6 @@

# }}}

-# {{{ sub Config
-# TODO: This might eventually read the cookies, user configuration
-# information from the DB, queue configuration information from the
-# DB, etc.
-
-sub Config {
- my $args = shift;
- my $key = shift;
- return $args->{$key} || $RT::WebOptions{$key};
-}
-
-# }}}
-
# {{{ sub ProcessACLChanges

sub ProcessACLChanges {
@@ -1149,16 +1141,11 @@
}
}
elsif ( $arg =~ /-Upload$/ ) {
- my $cgi_object = $m->cgi_object;
- my $fh = $cgi_object->upload($arg) or next;
- my $upload_info = $cgi_object->uploadInfo($fh);
- my $filename = "$fh";
- $filename =~ s#^.*[\\/]##;
+ my $value_hash = _UploadedFile($arg) or next;
+
my ( $val, $msg ) = $Object->AddCustomFieldValue(
- Field => $cf,
- Value => $filename,
- LargeContent => do { local $/; scalar <$fh> },
- ContentType => $upload_info->{'Content-Type'},
+ %$value_hash,
+ Field => $cf,
);
push ( @results, $msg );
}
@@ -1468,6 +1455,35 @@
return (@results);
}

+# {{{ sub _UploadedFile
+
+=head2 _UploadedFile ( $arg );
+
+Takes a CGI parameter name; if a file is uploaded under that name,
+return a hash reference suitable for AddCustomFieldValue's use:
+C<( Value => $filename, LargeContent => $content, ContentType => $type )>.
+
+Returns C<undef> if no files were uploaded in the C<$arg> field.
+
+=cut
+
+sub _UploadedFile {
+ my $arg = shift;
+ my $cgi_object = $m->cgi_object;
+ my $fh = $cgi_object->upload($arg) or return undef;
+ my $upload_info = $cgi_object->uploadInfo($fh);
+
+ my $filename = "$fh";
+ $filename =~ s#^.*[\\/]##;
+ binmode($fh);
+
+ return {
+ Value => $filename,
+ LargeContent => do { local $/; scalar <$fh> },
+ ContentType => $upload_info->{'Content-Type'},
+ };
+}
+
eval "require RT::Interface::Web_Vendor";
die $@ if ($@ && $@ !~ qr{^Can't locate RT/Interface/Web_Vendor.pm});
eval "require RT::Interface::Web_Local";

Modified: rt/branches/3.3-TESTING/lib/RT/Ticket_Overlay.pm
==============================================================================
--- rt/branches/3.3-TESTING/lib/RT/Ticket_Overlay.pm (original)
+++ rt/branches/3.3-TESTING/lib/RT/Ticket_Overlay.pm Fri Nov 5 06:43:18 2004
@@ -692,10 +692,15 @@
my $value ( UNIVERSAL::isa( $args{$arg} => 'ARRAY' ) ? @{ $args{$arg} } : ( $args{$arg} ) )
{
next unless ( length($value) );
+
+ # Allow passing in uploaded LargeContent etc by hash reference
$self->_AddCustomFieldValue(
+ (UNIVERSAL::isa( $value => 'HASH' )
+ ? %$value
+ : (Value => $value)
+ ),
Field => $cfid,
- Value => $value,
- RecordTransaction => 0
+ RecordTransaction => 0,
);
}
}
_______________________________________________
Rt-commit mailing list
Rt-commit@lists.bestpractical.com
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-commit