diff --git a/mozilla/webtools/bugzilla/editproducts.cgi b/mozilla/webtools/bugzilla/editproducts.cgi index 229aa64d274..9d81f176cf4 100755 --- a/mozilla/webtools/bugzilla/editproducts.cgi +++ b/mozilla/webtools/bugzilla/editproducts.cgi @@ -139,16 +139,21 @@ sub CheckClassificationProduct ($$) { my $cl = shift; my $prod = shift; + my $dbh = Bugzilla->dbh; CheckClassification($cl); CheckProduct($prod); - # does the classification exist? - SendSQL("SELECT products.name - FROM products,classifications - WHERE products.name=" . SqlQuote($prod) . - " AND classifications.name=" . SqlQuote($cl)); - my $res = FetchOneColumn(); + trick_taint($prod); + trick_taint($cl); + + my $query = q{SELECT products.name + FROM products + INNER JOIN classifications + ON products.classification_id = classifications.id + WHERE products.name = ? + AND classifications.name = ?}; + my $res = $dbh->selectrow_array($query, undef, ($prod, $cl)); unless ($res) { print "Sorry, classification->product '$cl'->'$prod' does not exist."; @@ -157,6 +162,26 @@ sub CheckClassificationProduct ($$) } } +sub CheckClassificationProductNew ($$) +{ + my ($cl, $prod) = @_; + my $dbh = Bugzilla->dbh; + + CheckClassificationNew($cl); + + my ($res) = $dbh->selectrow_array(q{ + SELECT products.name + FROM products + INNER JOIN classifications + ON products.classification_id = classifications.id + WHERE products.name = ? AND classifications.name = ?}, + undef, ($prod, $cl)); + + unless ($res) { + ThrowUserError('classification_doesnt_exist_for_product', + { product => $prod, classification => $cl }); + } +} # # Displays the form to edit a products parameters @@ -604,180 +629,93 @@ if ($action eq 'new') { # if ($action eq 'del') { - PutHeader("Delete product"); - CheckProduct($product); - my $classification_id=1; - if (Param('useclassification')) { - CheckClassificationProduct($classification,$product); - $classification_id = get_classification_id($classification); - } - - # display some data about the product - SendSQL("SELECT classifications.description, - products.id, products.description, milestoneurl, disallownew - FROM products,classifications - WHERE products.name=" . SqlQuote($product) . - " AND classifications.id=" . SqlQuote($classification_id)); - my ($class_description, $product_id, $prod_description, $milestoneurl, $disallownew) = FetchSQLData(); - my $milestonelink = $milestoneurl ? "$milestoneurl" - : "missing"; - $prod_description ||= "description missing"; - $class_description ||= "description missing"; - $disallownew = $disallownew ? 'closed' : 'open'; - print "
| Part | \n"; - print "Value | \n"; + if (!$product) { + ThrowUserError('product_not_specified'); + } + + my $product_id = get_product_id($product); + $product_id || ThrowUserError('product_doesnt_exist', + {product => $product}); + + my $classification_id = 1; if (Param('useclassification')) { - print "||
|---|---|---|---|
| Classification: | \n"; - print "$classification | \n"; - - print "||
| Description: | \n"; - print "$class_description | \n"; + CheckClassificationProductNew($classification, $product); + $classification_id = get_classification_id($classification); + $vars->{'classification'} = $classification; } - print "||
| Product: | \n"; - print "$product | \n"; + # Extract some data about the product + my $query = q{SELECT classifications.description, + products.description, + products.milestoneurl, + products.disallownew + FROM products + INNER JOIN classifications + ON products.classification_id = classifications.id + WHERE products.id = ?}; - print "||
| Description: | \n"; - print "$prod_description | \n"; + my ($class_description, + $prod_description, + $milestoneurl, + $disallownew) = $dbh->selectrow_array($query, undef, + $product_id); + $vars->{'class_description'} = $class_description; + $vars->{'product_id'} = $product_id; + $vars->{'prod_description'} = $prod_description; + $vars->{'milestoneurl'} = $milestoneurl; + $vars->{'disallownew'} = $disallownew; + $vars->{'product_name'} = $product; + + $vars->{'components'} = $dbh->selectall_arrayref(q{ + SELECT name, description FROM components + WHERE product_id = ? ORDER BY name}, {'Slice' => {}}, + $product_id); + + $vars->{'versions'} = $dbh->selectcol_arrayref(q{ + SELECT value FROM versions + WHERE product_id = ? ORDER BY value}, undef, + $product_id); + + # Adding listing for associated target milestones - + # matthew@zeroknowledge.com if (Param('usetargetmilestone')) { - print "||
| Milestone URL: | \n"; - print "$milestonelink | \n"; + $vars->{'milestones'} = $dbh->selectcol_arrayref(q{ + SELECT value FROM milestones + WHERE product_id = ? + ORDER BY sortkey, value}, undef, $product_id); } - - print "||
| Closed for bugs: | \n"; - print "$disallownew | \n"; - - print "||
| Components: | \n"; - print "";
- SendSQL("SELECT name,description
- FROM components
- WHERE product_id=$product_id");
- if (MoreSQLData()) {
- print "
| \n||
| Versions: | \n"; - print "";
- SendSQL("SELECT value
- FROM versions
- WHERE product_id=$product_id
- ORDER BY value");
- if (MoreSQLData()) {
- my $br = 0;
- while ( MoreSQLData() ) {
- my ($version) = FetchSQLData();
- print " " if $br; - print $version; - $br = 1; - } - } else { - print "missing"; - } - - # - # Adding listing for associated target milestones - matthew@zeroknowledge.com - # - if (Param('usetargetmilestone')) { - print " | \n||
| Edit milestones: | \n"; - print "";
- SendSQL("SELECT value
- FROM milestones
- WHERE product_id=$product_id
- ORDER BY sortkey,value");
- if(MoreSQLData()) {
- my $br = 0;
- while ( MoreSQLData() ) {
- my ($milestone) = FetchSQLData();
- print " " if $br; - print $milestone; - $br = 1; - } - } else { - print "missing"; - } - } - - print " | \n||
| Bugs: | \n"; - print ""; - SendSQL("SELECT count(bug_id), product_id - FROM bugs " . - $dbh->sql_group_by('product_id') . " - HAVING product_id = $product_id"); - my $bugs = FetchOneColumn(); - print $bugs || 'none'; - - - print " | \n
| \n", - "There are bugs entered for this product! When you delete this ", - "product, stored bugs and their history will be ", - "deleted too.\n", - " |
Do you really want to delete this product?
\n"; - print "
"; - - PutTrailer($localtrailer); + ($vars->{'bug_count'}) = $dbh->selectrow_array(q{ + SELECT COUNT(*) FROM bugs WHERE product_id = ?}, + undef, $product_id) || 0; + + $template->process("admin/products/confirm-delete.html.tmpl", $vars) + || ThrowTemplateError($template->error()); exit; } - - # # action='delete' -> really delete the product # if ($action eq 'delete') { - CheckProduct($product); - my $product_id = get_product_id($product); + + if (!$product) { + ThrowUserError('product_not_specified'); + } - my $bug_ids = - $dbh->selectcol_arrayref("SELECT bug_id FROM bugs WHERE product_id = ?", - undef, $product_id); + my $product_id = get_product_id($product); + $product_id || ThrowUserError('product_doesnt_exist', + {product => $product}); + + $vars->{'product'} = $product; + + my $bug_ids = $dbh->selectcol_arrayref(q{ + SELECT bug_id FROM bugs + WHERE product_id = ?}, undef, $product_id); my $nb_bugs = scalar(@$bug_ids); if ($nb_bugs) { @@ -790,47 +728,44 @@ if ($action eq 'delete') { else { ThrowUserError("product_has_bugs", { nb => $nb_bugs }); } + $vars->{'nb_bugs'} = $nb_bugs; } - PutHeader("Deleting product"); - print "All references to deleted bugs removed.\n" if $nb_bugs;
-
$dbh->bz_lock_tables('products WRITE', 'components WRITE',
'versions WRITE', 'milestones WRITE',
'group_control_map WRITE',
'flaginclusions WRITE', 'flagexclusions WRITE');
- $dbh->do("DELETE FROM components WHERE product_id = ?", undef, $product_id);
- print "Components deleted.
\n";
+ $dbh->do("DELETE FROM components WHERE product_id = ?",
+ undef, $product_id);
- $dbh->do("DELETE FROM versions WHERE product_id = ?", undef, $product_id);
- print "Versions deleted.
\n";
+ $dbh->do("DELETE FROM versions WHERE product_id = ?",
+ undef, $product_id);
- $dbh->do("DELETE FROM milestones WHERE product_id = ?", undef, $product_id);
- print "Milestones deleted.
\n";
+ $dbh->do("DELETE FROM milestones WHERE product_id = ?",
+ undef, $product_id);
$dbh->do("DELETE FROM group_control_map WHERE product_id = ?",
undef, $product_id);
- print "Group controls deleted.
\n";
$dbh->do("DELETE FROM flaginclusions WHERE product_id = ?",
undef, $product_id);
+
$dbh->do("DELETE FROM flagexclusions WHERE product_id = ?",
undef, $product_id);
- print "Flag inclusions and exclusions deleted.
\n"; - - $dbh->do("DELETE FROM products WHERE id = ?", undef, $product_id); - print "Product '$product' deleted.
\n";
+
+ $dbh->do("DELETE FROM products WHERE id = ?",
+ undef, $product_id);
$dbh->bz_unlock_tables();
unlink "$datadir/versioncache";
- PutTrailer($localtrailer);
+
+ $template->process("admin/products/deleted.html.tmpl", $vars)
+ || ThrowTemplateError($template->error());
exit;
}
-
-
#
# action='edit' -> present the 'edit product' form
# If a product is given with no action associated with it, then edit it.
diff --git a/mozilla/webtools/bugzilla/template/en/default/admin/products/confirm-delete.html.tmpl b/mozilla/webtools/bugzilla/template/en/default/admin/products/confirm-delete.html.tmpl
new file mode 100644
index 00000000000..672f345e9a5
--- /dev/null
+++ b/mozilla/webtools/bugzilla/template/en/default/admin/products/confirm-delete.html.tmpl
@@ -0,0 +1,282 @@
+[%# 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.
+ #
+ # Contributor(s): Gavin Shelley Do you really want to delete this product?
+
+
+ Components deleted.
+ Group controls deleted.
+ Product [% product FILTER html %] deleted.
+
+
+
+
+
+
+ [% IF Param('useclassification') %]
+ Field
+ Value
+
+
+ Classification:
+ [% classification FILTER html %]
+
+
+ [% END %]
+
+ Classification Description:
+ [%# descriptions are intentionally not filtered to allow html content %]
+ [% class_description FILTER none %]
+
+
+ Product:
+
+
+ [% product_name FILTER html %]
+
+
+
+
+
+ [% IF Param('usetargetmilestone') %]
+ Description:
+ [%# descriptions are intentionally not filtered to allow html content %]
+ [% prod_description FILTER none %]
+
+
+ [% END %]
+
+ Milestone URL:
+
+ [% IF milestoneurl %]
+
+ [%- milestoneurl FILTER html %]
+
+ [% ELSE %]
+ none
+ [% END %]
+
+
+
+
+ Closed for [% terms.bugs %]:
+ [% disallownew FILTER html %]
+
+
+
+
+ [% IF components.size > 0 %]
+
+ Components:
+
+ [% ELSE %]
+ Components:
+ [% END %]
+
+
+ [% IF components.size > 0 %]
+
+
+ [% FOREACH c = components %]
+
+ [% ELSE %]
+ none
+ [% END %]
+
+
+ [% END %]
+ [% c.name FILTER html %]:
+ [%# descriptions are intentionally not filtered to allow html content %]
+
+ [% IF c.description %]
+ [% c.description FILTER none %]
+ [% ELSE %]
+ missing
+ [% END %]
+
+
+
+
+
+ [% IF versions.size > 0 %]
+
+ Versions:
+
+ [% ELSE %]
+ Versions:
+ [% END %]
+
+ [% IF versions.size > 0 %]
+ [% FOREACH v = versions %]
+ [% v FILTER html %]
+
+ [% END %]
+ [% ELSE %]
+ none
+ [% END %]
+
+
+
+
+ [% IF milestones.size > 0 %]
+
+ Milestones:
+
+ [% ELSE %]
+ Milestones:
+ [% END %]
+
+
+ [% IF milestones.size > 0 %]
+ [% FOREACH m = milestones %]
+ [% m FILTER html %]
+
+ [% END %]
+ [% ELSE %]
+ none
+ [% END %]
+
+
+[% terms.Bugs %]:
+
+ [% IF bug_count %]
+
+ [% bug_count %]
+
+ [% ELSE %]
+ none
+ [% END %]
+
+ Confirmation
+
+[% IF bug_count %]
+
+ [% IF !Param("allowbugdeletion") %]
+
+ Sorry, there
+
+ [% IF bug_count > 1 %]
+ are [% bug_count %] [%+ terms.bugs %]
+ [% ELSE %]
+ is 1 [% terms.bug %]
+ [% END %]
+
+ outstanding for this product. You must reassign
+
+ [% IF bug_count > 1 %]
+ those [% terms.bugs %]
+ [% ELSE %]
+ that [% terms.bug %]
+ [% END %]
+
+ to another product before you can delete this one.
+
+ [% ELSE %]
+
+
+
+
+ [% END %]
+
+[% END %]
+
+[% IF bug_count == 0 || Param('allowbugdeletion') %]
+
+
+
+
+ There
+ [% IF bug_count > 1 %]
+ are [% bug_count %] [%+ terms.bugs %]
+ [% ELSE %]
+ is 1 [% terms.bug %]
+ [% END %]
+ entered for this product! When you delete this
+ product, stored [% terms.bugs %] and
+ their history will be deleted, too.
+
+
+ Versions deleted.
+ Milestones deleted.
+
+ Flag inclusions and exclusions deleted.
+