]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 163114 - Templatise all calls to DisplayError. Patch C. Patch by gerv; r=burnus.
authorgerv%gerv.net <>
Wed, 2 Oct 2002 05:41:03 +0000 (05:41 +0000)
committergerv%gerv.net <>
Wed, 2 Oct 2002 05:41:03 +0000 (05:41 +0000)
createaccount.cgi
enter_bug.cgi
post_bug.cgi
process_bug.cgi
quips.cgi
template/en/default/global/code-error.html.tmpl
template/en/default/global/user-error.html.tmpl

index 13256f47b70c09241722f6bc11ed2c78823cd045..37776a7800da45315dda92f2016db33e76089dc0 100755 (executable)
@@ -44,11 +44,7 @@ if(Param('useLDAP')) {
   # Just in case someone already has an account, let them get the correct
   # footer on the error message
   quietly_check_login();
-  DisplayError("This site is using LDAP for authentication.  Please contact 
-                an LDAP administrator to get a new account created.",
-               "Can't create LDAP accounts");
-  PutFooter();
-  exit;
+  ThrowUserError("ldap_cant_create_account");
 }
 
 # Clear out the login cookies.  Make people log in again if they create an
index f53c63dd661f1a84851808147b0c0acd98b1557a..ab3e1512d46a04a64c97e905d4a301bd6178da1c 100755 (executable)
@@ -79,9 +79,7 @@ if (!defined $::FORM{'product'}) {
  
     my $prodsize = scalar(keys %products);
     if ($prodsize == 0) {
-        DisplayError("Either no products have been defined to enter bugs ".
-                     "against or you have not been given access to any.\n");
-        exit;
+        ThrowUserError("no_products");
     } 
     elsif ($prodsize > 1) {
         $vars->{'proddesc'} = \%products;
@@ -225,34 +223,19 @@ if(Param("usebuggroupsentry")
    && GroupExists($product) 
    && !UserInGroup($product)) 
 {
-    DisplayError("Sorry; you do not have the permissions necessary to " .
-                 "enter a bug against this product.\n");         
-    exit;
+    ThrowUserError("entry_access_denied", { product => $product});         
 }
 
 GetVersionTable();
 
 if (lsearch(\@::enterable_products, $product) == -1) {
-    DisplayError("'" . html_quote($product) . "' is not a valid product.");
-    exit;
+    ThrowUserError("invalid_product_name", { product => $product});
 }
 
 my $product_id = get_product_id($product);
 
-if (0 == @{$::components{$product}}) {
-    my $error = "Sorry; there needs to be at least one component for this " .
-                "product in order to create a new bug. ";
-    if (UserInGroup('editcomponents')) {
-        $error .= "<a href=\"editcomponents.cgi\">" . 
-                  "Create a new component</a>\n";
-    }
-    else {              
-        $error .= "Please contact " . Param("maintainer") . ", detailing " .
-                  "the product in which you tried to create a new bug.\n";
-    }
-        
-    DisplayError($error);   
-    exit;
+if (0 == @{$::components{$product}}) {        
+    ThrowUserError("no_components");   
 } 
 elsif (1 == @{$::components{$product}}) {
     # Only one component; just pick it.
index 206c75c57487ab95cfd1fb1ffca6b36f5198019a..c07d07d99ef768e008b946236f7dc9de56c00905 100755 (executable)
@@ -94,23 +94,15 @@ umask 0;
 
 # Some sanity checking
 if(Param("usebuggroupsentry") && GroupExists($product)) {
-    if(!UserInGroup($product)) {
-        DisplayError("Sorry; you do not have the permissions necessary to enter
-                      a bug against this product.", "Permission Denied");
-        exit;
-    }
+    UserInGroup($product) || 
+      ThrowUserError("entry_access_denied", {product => $product});
 }
 
 my $component_id = get_component_id($product_id, $::FORM{component});
-if (!$component_id) {
-    DisplayError("You must choose a component that corresponds to this bug.
-                  If necessary, just guess.");
-    exit;
-}
+$component_id || ThrowUserError("require_component");
 
 if (!defined $::FORM{'short_desc'} || trim($::FORM{'short_desc'}) eq "") {
-    DisplayError("You must enter a summary for this bug.");
-    exit;
+    ThrowUserError("require_summary");
 }
 
 # If bug_file_loc is "http://", the default, strip it out and use an empty
index 4fb42d8b0d7cabe4462eb0f49a81c9b6abca44c8..1e4fd28b7ebf208d347dfae1cd52c3b0a64717e5 100755 (executable)
@@ -84,9 +84,7 @@ if (defined $::FORM{'id'}) {
 }
 
 # Make sure there are bugs to process.
-scalar(@idlist)
-  || DisplayError("You did not select any bugs to modify.")
-  && exit;
+scalar(@idlist) || ThrowUserError("no_bugs_chosen");
 
 # If we are duping bugs, let's also make sure that we can change 
 # the original.  This takes care of issue A on bug 96085.
@@ -616,11 +614,9 @@ foreach my $field ("rep_platform", "priority", "bug_severity",
 my $prod_id; # Remember, can't use this for mass changes
 if ($::FORM{'product'} ne $::dontchange) {
     $prod_id = get_product_id($::FORM{'product'});
-    if (! $prod_id) {
-        DisplayError("The <tt>" . html_quote($::FORM{'product'}) .
-                     "</tt> product doesn't exist.");
-        exit;
-    }
+    $prod_id ||
+      ThrowUserError("invalid_product_name", {product => $::FORM{'product'});
+      
     DoComma();
     $::query .= "product_id = $prod_id";
 } else {
@@ -637,12 +633,10 @@ if ($::FORM{'component'} ne $::dontchange) {
     }
     $comp_id = get_component_id($prod_id,
                                 $::FORM{'component'});
-    if (! $comp_id) {
-        DisplayError("The <tt>" . html_quote($::FORM{'component'}) .
-                     "</tt> component doesn't exist in the <tt>" .
-                     html_quote($::FORM{'product'}) . "</tt> product");
-        exit;
-    }
+    $comp_id || ThrowCodeError("invalid_component", 
+                               {component => $::FORM{'component'},
+                                product => $::FORM{'product'}});
+    
     DoComma();
     $::query .= "component_id = $comp_id";
 }
index f120e5a24dfc81f553cf87cfc3c25cc43490f520..c36a09b6c95970bb081e8c713664e4b326543a22 100755 (executable)
--- a/quips.cgi
+++ b/quips.cgi
@@ -55,24 +55,12 @@ if ($action eq "show") {
 }
 
 if ($action eq "add") {
+    (Param('enablequips') eq "on") || ThrowUserError("no_new_quips");
+    
     # Add the quip 
     my $comment = $::FORM{"quip"};
-    if (!$comment) {
-        DisplayError("Please enter a quip in the text field.");
-        exit();
-    }
-
-    if (Param('enablequips') ne "on") {
-        ThrowUserError("no_new_quips");
-        exit();
-    }
-    
-
-    if ($comment =~ m/</) {
-        DisplayError("Sorry - for security reasons, support for HTML tags has 
-                      been turned off in quips.");
-        exit();
-    }
+    $comment || ThrowUserError("need_quip");
+    $comment !~ m/</ || ThrowUserError("no_html_in_quips");
 
     SendSQL("INSERT INTO quips (userid, quip) VALUES (". $userid . ", " . SqlQuote($comment) . ")");
 
index 0f767ded8e01f761ff6329f82424e5e9037e30cb..ecc22248432454f4e9335f1e3a3aa38ffa012225 100644 (file)
      The custom sort order specified in your form submission contains an
      invalid column name <em>[% fragment FILTER html %]</em>.
          
+  [% ELSIF error == "invalid_component" %]
+    [% title = "Invalid Component" %]
+    The [% component FILTER html %] component doesn't exist in the 
+    [% product FILTER html %] product.
+    
   [% ELSIF error == "mismatched_bug_ids_on_obsolete" %]
     Attachment [% attach_id FILTER html %] ([% description FILTER html %]) 
     is attached to bug [% attach_bug_id FILTER html %], but you tried to 
index 10c50cc9e04533c88e3f861a36cdb0025e51f75e..fd9ffe09bdadba685f81fb1c9f62e4f6454eb9c9 100644 (file)
     [% title = "Email Address Email Address Confirmation Failed" %]
     Email address confirmation failed.
 
+  [% ELSIF error == "entry_access_denied" %]
+    [% title = "Permission Denied" %]
+     Sorry; you do not have the permissions necessary to enter a bug against
+     the [% product FILTER html %] product.
+     
   [% ELSIF error == "file_not_specified" %]
     [% title = "No File Specified" %]
     You did not specify a file to attach.
     [% title = "Invalid Username Or Password" %]
     The username or password you entered is not valid.
                     
+  [% ELSIF error == "ldap_cant_create_account" %]
+    [% title = "Can't create LDAP accounts" %]
+     This site is using LDAP for authentication.  Please contact 
+     an LDAP administrator to get a new account created.
+     
   [% ELSIF error == "login_needed_for_password_change" %]
     [% title = "Login Name Required" %]
     You must enter a login name when requesting to change your password.
         
   [% ELSIF error == "need_component" %]
     [% title = "Component Required" %]
-    You must specify a component to help determine the new owner of these bugs.                            
+    You must specify a component to help determine the new owner of these bugs.
+                  
   [% ELSIF error == "need_product" %]
     [% title = "Product Required" %]
-    You must specify a product to help determine the new owner of these bugs.                 
+    You must specify a product to help determine the new owner of these bugs.
+    
+  [% ELSIF error == "need_quip" %]
+    [% title = "Quip Required" %]
+    Please enter a quip in the text field.
+    
   [% ELSIF error == "no_bugs_chosen" %]
     [% title = "No Bugs Chosen" %]
     You apparently didn't choose any bugs to modify.
     You cannot change the component for a list of bugs covering more than 
     one product.
                        
+  [% ELSIF error == "no_components" %]
+    [% title = "No Components" %]
+    Sorry; there needs to be at least one component for this product in order 
+    to create a new bug.
+    [% IF UserInGroup("editcomponents") %]
+      <a href="editcomponents.cgi">Create a new component</a>.      
+    [% ELSE %]
+       Please contact [% Param("maintainer") %], giving the name of 
+       the product in which you tried to create a new bug.      
+    [% END %]
+                            
   [% ELSIF error == "no_dupe_stats" %]
     [% title = "Cannot Find Duplicate Statistics" %]
     There are no duplicate statistics for today ([% today %]) or yesterday.
     There are no duplicate statistics for today ([% today %]), and an error
     occurred opening yesterday's dupes file: [% error_msg FILTER html %].
     
+  [% ELSIF error == "no_html_in_quips" %]
+    [% title = "No HTML In Quips" %]
+     Sorry - for security reasons, support for HTML tags has been turned off 
+     in quips.
+         
   [% ELSIF error == "no_new_quips" %]
     [% title = "No New Quips" %]
     This site does not permit the addition of new quips.
     [% title = "No Page Specified" %]
     You did not specify the id of a page to display.
 
+  [% ELSIF error == "no_products" %]
+    [% title = "No Products" %]
+     Either no products have been defined to enter bugs against or you have not
+     been given access to any.
+     
   [% ELSIF error == "patch_too_large" %]
     [% title = "File Too Large" %]
     The file you are trying to attach is [% filesize %] kilobytes (KB) in size.
       100 users.  Enter more of the name to bring the number of matches 
       down to a reasonable amount.
   
+  [% ELSIF error == "require_component" %]
+    [% title = "Component Needed" %]
+    You must choose a component to file this bug in. If necessary, 
+    just guess.
+    
   [% ELSIF error == "require_new_password" %]
      [% title = "New Password Needed" %]
      You cannot change your password without submitting a new one.
 
+  [% ELSIF error == "require_summary" %]
+     [% title = "Summary Needed" %]
+     You must enter a summary for this bug.
+
   [% ELSIF error == "token_inexistent" %]
      [% title = "Token Does Not Exist" %]
      The token you submitted does not exist, has expired, or has