From d811e671090c1acf8d0e3b9c5e432bd560ba2cfd Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Tue, 13 May 2014 12:56:48 -0700 Subject: [PATCH] Upload fields can be optional https://sourceforge.net/p/webadmin/bugs/4407/ --- custom/custom-lib.pl | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/custom/custom-lib.pl b/custom/custom-lib.pl index e00ccc871..a8454ee75 100755 --- a/custom/custom-lib.pl +++ b/custom/custom-lib.pl @@ -423,18 +423,23 @@ foreach my $a (@{$cmd->{'args'}}) { $rv = $setin->{$n}; } elsif ($a->{'type'} == 10) { - $setin->{$n} || &error($text{'run_eupload'}); - if ($setin->{$n."_filename"} =~ /([^\/\\]+$)/ && $1) { - $rv = &transname("$1"); + if ($setin->{$n}) { + if ($setin->{$n."_filename"} =~ /([^\/\\]+$)/ && $1) { + $rv = &transname("$1"); + } + else { + $rv = &transname(); + } + &open_tempfile(TEMP, ">$rv"); + &print_tempfile(TEMP, $setin->{$n}); + &close_tempfile(TEMP); + chown($uinfo->[2], $uinfo->[3], $rv); + push(@unlink, $rv); } else { - $rv = &transname(); + $a->{'must'} && &error($text{'run_eupload'}); + $rv = undef; } - &open_tempfile(TEMP, ">$rv"); - &print_tempfile(TEMP, $setin->{$n}); - &close_tempfile(TEMP); - chown($uinfo->[2], $uinfo->[3], $rv); - push(@unlink, $rv); } elsif ($a->{'type'} == 12 || $a->{'type'} == 13 || $a->{'type'} == 14) { local @vals;