summaryrefslogtreecommitdiffstats
path: root/editattachstatuses.cgi
diff options
context:
space:
mode:
authormyk%mozilla.org <>2002-03-13 01:05:33 +0100
committermyk%mozilla.org <>2002-03-13 01:05:33 +0100
commitcb6f229206bf8bf8f873e6d1c954139042655895 (patch)
treed92921de32049cb09b1f683feed6cc64c2c514d2 /editattachstatuses.cgi
parent496013d2cc0586cde9db0ace761292594fcae995 (diff)
downloadbugzilla-cb6f229206bf8bf8f873e6d1c954139042655895.tar.gz
bugzilla-cb6f229206bf8bf8f873e6d1c954139042655895.tar.xz
Fix for bug 97739: Confirms deletion of an attachment status in browsers with no-JS/JS-off.
Patch by Jeff Hedlund <jeff.hedlund@matrixsi.com>. r=myk,gerv
Diffstat (limited to 'editattachstatuses.cgi')
-rwxr-xr-xeditattachstatuses.cgi49
1 files changed, 43 insertions, 6 deletions
diff --git a/editattachstatuses.cgi b/editattachstatuses.cgi
index 0642d6bb8..61e1a15ae 100755
--- a/editattachstatuses.cgi
+++ b/editattachstatuses.cgi
@@ -87,11 +87,16 @@ elsif ($action eq "update")
validateSortKey();
update();
}
-elsif ($action eq "delete")
+elsif ($action eq "confirmdelete")
{
validateID();
- deleteStatus();
+ confirmDelete();
}
+elsif ($action eq "delete")
+{
+ validateID();
+ deleteStatus();
+}
else
{
DisplayError("I could not figure out what you wanted to do.")
@@ -174,14 +179,18 @@ sub list
# Retrieve a list of attachment status flags and create an array of hashes
# in which each hash contains the data for one flag.
- SendSQL("SELECT id, name, description, sortkey, product
- FROM attachstatusdefs ORDER BY sortkey");
+ SendSQL("SELECT id, name, description, sortkey, product, count(statusid)
+ FROM attachstatusdefs LEFT JOIN attachstatuses
+ ON attachstatusdefs.id=attachstatuses.statusid
+ GROUP BY id
+ ORDER BY sortkey");
my @statusdefs;
while ( MoreSQLData() )
{
- my ($id, $name, $description, $sortkey, $product) = FetchSQLData();
+ my ($id, $name, $description, $sortkey, $product, $attachcount) = FetchSQLData();
push @statusdefs, { 'id' => $id , 'name' => $name , 'description' => $description ,
- 'sortkey' => $sortkey , 'product' => $product };
+ 'sortkey' => $sortkey , 'product' => $product,
+ 'attachcount' => $attachcount };
}
# Define the variables and functions that will be passed to the UI template.
@@ -293,6 +302,34 @@ sub update
list("The attachment status has been updated.");
}
+sub confirmDelete
+{
+ # check if we need confirmation to delete:
+
+ SendSQL("SELECT COUNT(attach_id), name
+ FROM attachstatusdefs LEFT JOIN attachstatuses
+ ON attachstatuses.statusid=attachstatusdefs.id
+ WHERE statusid = $::FORM{'id'}
+ GROUP BY attachstatuses.statusid;");
+
+ my ($attachcount, $name) = FetchSQLData();
+
+ if ($attachcount > 0) {
+
+ $vars->{'id'} = $::FORM{'id'};
+ $vars->{'attachcount'} = $attachcount;
+ $vars->{'name'} = $name;
+
+ print "Content-type: text/html\n\n";
+
+ $template->process("attachstatus/delete.atml", $vars)
+ || DisplayError("Template process failed: " . & $template->error())
+ && exit;
+ }
+ else {
+ deleteStatus();
+ }
+}
sub deleteStatus
{