]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Patch for bug 87770: make attachment.cgi work with no parameters; patch by GavinS...
authorjocuri%softhome.net <>
Sat, 10 Apr 2004 22:08:21 +0000 (22:08 +0000)
committerjocuri%softhome.net <>
Sat, 10 Apr 2004 22:08:21 +0000 (22:08 +0000)
attachment.cgi
show_bug.cgi
template/en/default/attachment/choose.html.tmpl [new file with mode: 0644]

index 61565f01f6a6ec93f9cafd3568d572119ebc9669..d851e537ee07cdc9a88fdc8de227e541cae626c1 100755 (executable)
@@ -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.
 
index 9093550ef33b5fc0d51c836f24e05eb075a70d0c..7a568e3f54ec23dc53b69f66f1cff40e72776cb4 100755 (executable)
@@ -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 (file)
index 0000000..b486646
--- /dev/null
@@ -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 <bugzilla@chimpychompy.org>
+  #%]
+
+[% PROCESS global/variables.none.tmpl %]
+
+[% PROCESS global/header.html.tmpl
+   title = "Locate attachment"
+ %]
+
+<form method="get" action="attachment.cgi">
+  <p>Access an attachment by entering its ID into the form below:</p>
+  <p>Attachment ID: <input name="id" size="6">
+  <input type="submit" name="action" value="Edit">
+  <input type="submit" name="action" value="View">
+  </p>
+</form>
+
+<form method="get" action="show_bug.cgi">
+  <p>Or, access it from the list of attachments in its associated [% terms.bug %] report:</p>
+  <p>[% terms.Bug %] ID: <input name="id" size="6">
+  <input type="submit" name="action" value="View">
+  </p>
+</form>
+
+[% PROCESS global/footer.html.tmpl %]