summaryrefslogtreecommitdiffstats
path: root/editmilestones.cgi
diff options
context:
space:
mode:
Diffstat (limited to 'editmilestones.cgi')
-rwxr-xr-xeditmilestones.cgi54
1 files changed, 30 insertions, 24 deletions
diff --git a/editmilestones.cgi b/editmilestones.cgi
index fccf72533..67d84fcce 100755
--- a/editmilestones.cgi
+++ b/editmilestones.cgi
@@ -33,9 +33,9 @@ sub TestProduct ($)
my $prod = shift;
# does the product exist?
- SendSQL("SELECT product
+ SendSQL("SELECT name
FROM products
- WHERE product=" . SqlQuote($prod));
+ WHERE name=" . SqlQuote($prod));
return FetchOneColumn();
}
@@ -62,9 +62,9 @@ sub TestMilestone ($$)
my ($prod,$mile) = @_;
# does the product exist?
- SendSQL("SELECT product,value
- FROM milestones
- WHERE product=" . SqlQuote($prod) . " and value=" . SqlQuote($mile));
+ SendSQL("SELECT products.name, value
+ FROM milestones, products
+ WHERE milestones.product_id=products.id AND products.name=" . SqlQuote($prod) . " and value=" . SqlQuote($mile));
return FetchOneColumn();
}
@@ -183,10 +183,10 @@ if ($milestone) {
unless ($product) {
PutHeader("Select product");
- SendSQL("SELECT products.product,products.description,'xyzzy'
+ SendSQL("SELECT products.name,products.description,'xyzzy'
FROM products
- GROUP BY products.product
- ORDER BY products.product");
+ GROUP BY products.name
+ ORDER BY products.name");
print "<TABLE BORDER=1 CELLPADDING=4 CELLSPACING=0><TR BGCOLOR=\"#6666FF\">\n";
print " <TH ALIGN=\"left\">Edit milestones of ...</TH>\n";
print " <TH ALIGN=\"left\">Description</TH>\n";
@@ -216,10 +216,11 @@ unless ($product) {
unless ($action) {
PutHeader("Select milestone for $product");
CheckProduct($product);
+ my $product_id = get_product_id($product);
SendSQL("SELECT value,sortkey
FROM milestones
- WHERE product=" . SqlQuote($product) . "
+ WHERE product_id=$product_id
ORDER BY sortkey,value");
print "<TABLE BORDER=1 CELLPADDING=4 CELLSPACING=0><TR BGCOLOR=\"#6666FF\">\n";
@@ -259,6 +260,7 @@ unless ($action) {
if ($action eq 'add') {
PutHeader("Add milestone for $product");
CheckProduct($product);
+ my $product_id = get_product_id($product);
#print "This page lets you add a new milestone to a $::bugzilla_name tracked product.\n";
@@ -287,6 +289,7 @@ if ($action eq 'add') {
if ($action eq 'new') {
PutHeader("Adding new milestone for $product");
CheckProduct($product);
+ my $product_id = get_product_id($product);
# Cleanups and valididy checks
@@ -305,10 +308,9 @@ if ($action eq 'new') {
# Add the new milestone
SendSQL("INSERT INTO milestones ( " .
- "value, product, sortkey" .
+ "value, product_id, sortkey" .
" ) VALUES ( " .
- SqlQuote($milestone) . "," .
- SqlQuote($product) . ", $sortkey)");
+ SqlQuote($milestone) . ", $product_id, $sortkey)");
# Make versioncache flush
unlink "data/versioncache";
@@ -330,16 +332,17 @@ if ($action eq 'new') {
if ($action eq 'del') {
PutHeader("Delete milestone of $product");
CheckMilestone($product, $milestone);
+ my $product_id = get_product_id($product);
- SendSQL("SELECT count(bug_id),product,target_milestone
+ SendSQL("SELECT count(bug_id), product_id, target_milestone
FROM bugs
- GROUP BY product,target_milestone
- HAVING product=" . SqlQuote($product) . "
+ GROUP BY product_id, target_milestone
+ HAVING product_id=$product_id
AND target_milestone=" . SqlQuote($milestone));
my $bugs = FetchOneColumn();
SendSQL("SELECT defaultmilestone FROM products " .
- "WHERE product=" . SqlQuote($product));
+ "WHERE id=$product_id");
my $defaultmilestone = FetchOneColumn();
print "<TABLE BORDER=1 CELLPADDING=4 CELLSPACING=0>\n";
@@ -405,6 +408,7 @@ one.";
if ($action eq 'delete') {
PutHeader("Deleting milestone of $product");
CheckMilestone($product,$milestone);
+ my $product_id = get_product_id($product);
# lock the tables before we start to change everything:
@@ -422,7 +426,7 @@ if ($action eq 'delete') {
SendSQL("SELECT bug_id
FROM bugs
- WHERE product=" . SqlQuote($product) . "
+ WHERE product_id=$product_id
AND target_milestone=" . SqlQuote($milestone));
while (MoreSQLData()) {
my $bugid = FetchOneColumn();
@@ -439,13 +443,13 @@ if ($action eq 'delete') {
# Deleting the rest is easier:
SendSQL("DELETE FROM bugs
- WHERE product=" . SqlQuote($product) . "
+ WHERE product_id=$product_id
AND target_milestone=" . SqlQuote($milestone));
print "Bugs deleted.<BR>\n";
}
SendSQL("DELETE FROM milestones
- WHERE product=" . SqlQuote($product) . "
+ WHERE product_id=$product_id
AND value=" . SqlQuote($milestone));
print "Milestone deleted.<P>\n";
SendSQL("UNLOCK TABLES");
@@ -466,9 +470,10 @@ if ($action eq 'delete') {
if ($action eq 'edit') {
PutHeader("Edit milestone of $product");
CheckMilestone($product,$milestone);
+ my $product_id = get_product_id($product);
- SendSQL("SELECT sortkey FROM milestones WHERE product=" .
- SqlQuote($product) . " AND value = " . SqlQuote($milestone));
+ SendSQL("SELECT sortkey FROM milestones WHERE product_id=$product_id " .
+ " AND value = " . SqlQuote($milestone));
my $sortkey = FetchOneColumn();
print "<FORM METHOD=POST ACTION=editmilestones.cgi>\n";
@@ -506,6 +511,7 @@ if ($action eq 'update') {
my $sortkeyold = trim($::FORM{sortkeyold} || '0');
CheckMilestone($product,$milestoneold);
+ my $product_id = get_product_id($product);
SendSQL("LOCK TABLES bugs WRITE,
milestones WRITE,
@@ -535,14 +541,14 @@ if ($action eq 'update') {
SET target_milestone=" . SqlQuote($milestone) . ",
delta_ts=delta_ts
WHERE target_milestone=" . SqlQuote($milestoneold) . "
- AND product=" . SqlQuote($product));
+ AND product_id=$product_id");
SendSQL("UPDATE milestones
SET value=" . SqlQuote($milestone) . "
- WHERE product=" . SqlQuote($product) . "
+ WHERE product_id=$product_id
AND value=" . SqlQuote($milestoneold));
SendSQL("UPDATE products " .
"SET defaultmilestone = " . SqlQuote($milestone) .
- "WHERE product = " . SqlQuote($product) .
+ " WHERE id = $product_id" .
" AND defaultmilestone = " . SqlQuote($milestoneold));
unlink "data/versioncache";
print "Updated milestone.<BR>\n";