From b9c3dbad825ee0936d1687aff9fdf122d88d6dac Mon Sep 17 00:00:00 2001 From: "jocuri%softhome.net" <> Date: Sat, 10 Apr 2004 22:08:21 +0000 Subject: Patch for bug 87770: make attachment.cgi work with no parameters; patch by GavinS ; r=kiko; a=myk. --- attachment.cgi | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'attachment.cgi') diff --git a/attachment.cgi b/attachment.cgi index 61565f01f..d851e537e 100755 --- a/attachment.cgi +++ b/attachment.cgi @@ -68,17 +68,27 @@ my $cgi = Bugzilla->cgi; # Main Body Execution ################################################################################ -# All calls to this script should contain an "action" variable whose value -# determines what the user wants to do. The code below checks the value of -# that variable and runs the appropriate code. +# All calls to this script should contain an "action" variable whose +# value determines what the user wants to do. The code below checks +# the value of that variable and runs the appropriate code. If none is +# supplied, we default to 'view'. # Determine whether to use the action specified by the user or the default. my $action = $::FORM{'action'} || 'view'; +# Slight awkward extra checks for the case when we came here from the +# attachment/choose.html.tmpl page +if ($action eq 'View') { + $action = 'view'; +} +elsif ($action eq 'Edit') { + $action = 'edit'; +} + if ($action eq "view") -{ +{ validateID(); - view(); + view(); } elsif ($action eq "interdiff") { @@ -165,6 +175,17 @@ sub validateID { my $param = @_ ? $_[0] : 'id'; + # Only do this check for no 'id' parameter if we are trying to + # validate the 'id' parameter + if ($param eq 'id' && !$cgi->param('id')) { + + print Bugzilla->cgi->header(); + $template->process("attachment/choose.html.tmpl", $vars) || + ThrowTemplateError($template->error()); + exit; + + } + # Validate the value of the "id" form field, which must contain an # integer that is the ID of an existing attachment. -- cgit v1.2.3-24-g4f1b