}
-sub confirmDelete
-{
- my $id = validateID();
-
- # check if we need confirmation to delete:
-
- my $count = Bugzilla::Flag::count({ 'type_id' => $id,
- 'is_active' => 1 });
-
- if ($count > 0) {
+sub confirmDelete {
+ my $id = validateID();
+
+ # check if we need confirmation to delete:
+ my $count = Bugzilla::Flag::count({ 'type_id' => $id,
+ 'is_active' => 1 });
+
$vars->{'flag_type'} = Bugzilla::FlagType::get($id);
$vars->{'flag_count'} = scalar($count);
$vars->{'token'} = issue_session_token('delete_flagtype');
# Generate and return the UI (HTML page) from the appropriate template.
$template->process("admin/flag-type/confirm-delete.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
- }
- else {
- my $token = issue_session_token('delete_flagtype');
- deleteType($token);
- }
}
}
-if ($action eq 'delete') {
+if ($action eq 'del') {
my $id = ValidateKeyID(scalar $cgi->param('id'));
my $name = $dbh->selectrow_array('SELECT name FROM keyworddefs
WHERE id= ?', undef, $id);
- if (!$cgi->param('reallydelete')) {
- my $bugs = $dbh->selectrow_array('SELECT COUNT(*) FROM keywords
- WHERE keywordid = ?',
- undef, $id);
-
- # We need this token even if there is no bug using this keyword.
- $token = issue_session_token('delete_keyword');
+ my $bugs = $dbh->selectrow_array('SELECT COUNT(*) FROM keywords
+ WHERE keywordid = ?',
+ undef, $id);
- if ($bugs) {
- $vars->{'bug_count'} = $bugs;
- $vars->{'keyword_id'} = $id;
- $vars->{'name'} = $name;
- $vars->{'token'} = $token;
+ $vars->{'bug_count'} = $bugs;
+ $vars->{'keyword_id'} = $id;
+ $vars->{'name'} = $name;
+ $vars->{'token'} = issue_session_token('delete_keyword');
- print $cgi->header();
+ print $cgi->header();
- $template->process("admin/keywords/confirm-delete.html.tmpl", $vars)
- || ThrowTemplateError($template->error());
+ $template->process("admin/keywords/confirm-delete.html.tmpl", $vars)
+ || ThrowTemplateError($template->error());
+ exit;
+}
- exit;
- }
- }
- # We cannot do this check earlier as we have to check 'reallydelete' first.
+if ($action eq 'delete') {
check_token_data($token, 'delete_keyword');
+ my $id = ValidateKeyID(scalar $cgi->param('id'));
+
+ my $name = $dbh->selectrow_array('SELECT name FROM keyworddefs
+ WHERE id= ?', undef, $id);
$dbh->do('DELETE FROM keywords WHERE keywordid = ?', undef, $id);
$dbh->do('DELETE FROM keyworddefs WHERE id = ?', undef, $id);
[% PROCESS global/header.html.tmpl title = title %]
<p>
- There are [% flag_count %] flags of type [% flag_type.name FILTER html %].
- If you delete this type, those flags will also be deleted. Note that
- instead of deleting the type you can
+ [% IF flag_count %]
+ There are [% flag_count %] flags of type [% flag_type.name FILTER html %].
+ If you delete this type, those flags will also be deleted.
+ [% END %]
+
+ Note that instead of deleting the type you can
<a href="editflagtypes.cgi?action=deactivate&id=[% flag_type.id %]&token=
[%- token FILTER html %]">deactivate it</a>,
- in which case the type and its flags will remain in the database
- but will not appear in the [% terms.Bugzilla %] UI.
+ in which case the type [% IF flag_count %] and its flags [% END %] will remain
+ in the database but will not appear in the [% terms.Bugzilla %] UI.
</p>
<table>
<p>
[% IF bug_count == 1 %]
There is one [% terms.bug %] with this keyword set.
- [% ELSE %]
+ [% ELSIF bug_count > 1 %]
There are [% bug_count %] [%+terms.bugs %] with
this keyword set.
[% END %]
<form method="post" action="editkeywords.cgi">
<input type="hidden" name="id" value="[% keyword_id %]">
<input type="hidden" name="action" value="delete">
- <input type="hidden" name="reallydelete" value="1">
<input type="hidden" name="token" value="[% token FILTER html %]">
<input type="submit" value="Yes, really delete the keyword">
</form>
{
heading => "Action"
content => "Delete"
- contentlink => "editkeywords.cgi?action=delete&id=%%id%%"
+ contentlink => "editkeywords.cgi?action=del&id=%%id%%"
}
]
%]