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 +++++++++++++++--- show_bug.cgi | 2 +- template/en/default/attachment/choose.html.tmpl | 43 +++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 template/en/default/attachment/choose.html.tmpl 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. diff --git a/show_bug.cgi b/show_bug.cgi index 9093550ef..7a568e3f5 100755 --- a/show_bug.cgi +++ b/show_bug.cgi @@ -46,7 +46,7 @@ my $single = !$cgi->param('format') && (!$cgi->param('ctype') || $cgi->param('ctype') eq 'html'); # If we don't have an ID, _AND_ we're only doing a single bug, then prompt -if (!defined $cgi->param('id') && $single) { +if (!$cgi->param('id') && $single) { print Bugzilla->cgi->header(); $template->process("bug/choose.html.tmpl", $vars) || ThrowTemplateError($template->error()); diff --git a/template/en/default/attachment/choose.html.tmpl b/template/en/default/attachment/choose.html.tmpl new file mode 100644 index 000000000..b48664653 --- /dev/null +++ b/template/en/default/attachment/choose.html.tmpl @@ -0,0 +1,43 @@ +[%# 1.0@bugzilla.org %] +[%# The contents of this file are subject to the Mozilla Public + # License Version 1.1 (the "License"); you may not use this file + # except in compliance with the License. You may obtain a copy of + # the License at http://www.mozilla.org/MPL/ + # + # Software distributed under the License is distributed on an "AS + # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + # implied. See the License for the specific language governing + # rights and limitations under the License. + # + # The Original Code is the Bugzilla Bug Tracking System. + # + # The Initial Developer of the Original Code is Netscape Communications + # Corporation. Portions created by Netscape are + # Copyright (C) 1998 Netscape Communications Corporation. All + # Rights Reserved. + # + # Contributor(s): Gavin Shelley + #%] + +[% PROCESS global/variables.none.tmpl %] + +[% PROCESS global/header.html.tmpl + title = "Locate attachment" + %] + +
+

Access an attachment by entering its ID into the form below:

+

Attachment ID: + + +

+
+ +
+

Or, access it from the list of attachments in its associated [% terms.bug %] report:

+

[% terms.Bug %] ID: + +

+
+ +[% PROCESS global/footer.html.tmpl %] -- cgit v1.2.3-24-g4f1b