Commit afe02a6e authored by jocuri%softhome.net's avatar jocuri%softhome.net

Bug 225703: Partial templatization for editkeywords.cgi; r=jouni; r=gerv; a=justdave.

parent 07fc6c82
...@@ -25,6 +25,8 @@ use lib "."; ...@@ -25,6 +25,8 @@ use lib ".";
require "CGI.pl"; require "CGI.pl";
use vars qw($template $vars);
my $localtrailer = "<A HREF=\"editkeywords.cgi\">edit</A> more keywords"; my $localtrailer = "<A HREF=\"editkeywords.cgi\">edit</A> more keywords";
...@@ -126,6 +128,8 @@ unless (UserInGroup("editkeywords")) { ...@@ -126,6 +128,8 @@ unless (UserInGroup("editkeywords")) {
my $action = trim($::FORM{action} || ''); my $action = trim($::FORM{action} || '');
$vars->{'action'} = $action;
detaint_natural($::FORM{id}); detaint_natural($::FORM{id});
...@@ -180,20 +184,12 @@ if ($action eq "") { ...@@ -180,20 +184,12 @@ if ($action eq "") {
if ($action eq 'add') { if ($action eq 'add') {
PutHeader("Add keyword"); print Bugzilla->cgi->header();
print "<FORM METHOD=POST ACTION=editkeywords.cgi>\n";
print "<TABLE BORDER=0 CELLPADDING=4 CELLSPACING=0>\n";
EmitFormElements(-1, '', ''); $template->process("admin/keywords/create.html.tmpl",
$vars)
|| ThrowTemplateError($template->error());
print "</TABLE>\n<HR>\n";
print "<INPUT TYPE=SUBMIT VALUE=\"Add\">\n";
print "<INPUT TYPE=HIDDEN NAME=\"action\" VALUE=\"new\">\n";
print "</FORM>";
my $other = $localtrailer;
$other =~ s/more/other/;
PutTrailer($other);
exit; exit;
} }
...@@ -308,8 +304,6 @@ if ($action eq 'edit') { ...@@ -308,8 +304,6 @@ if ($action eq 'edit') {
# #
if ($action eq 'update') { if ($action eq 'update') {
PutHeader("Update keyword");
my $id = $::FORM{id}; my $id = $::FORM{id};
my $name = trim($::FORM{name} || ''); my $name = trim($::FORM{name} || '');
my $description = trim($::FORM{description} || ''); my $description = trim($::FORM{description} || '');
...@@ -321,6 +315,8 @@ if ($action eq 'update') { ...@@ -321,6 +315,8 @@ if ($action eq 'update') {
my $tmp = FetchOneColumn(); my $tmp = FetchOneColumn();
if ($tmp && $tmp != $id) { if ($tmp && $tmp != $id) {
PutHeader("Update keyword");
print "The keyword '$name' already exists. Please press\n"; print "The keyword '$name' already exists. Please press\n";
print "<b>Back</b> and try again.\n"; print "<b>Back</b> and try again.\n";
PutTrailer($localtrailer); PutTrailer($localtrailer);
...@@ -331,26 +327,27 @@ if ($action eq 'update') { ...@@ -331,26 +327,27 @@ if ($action eq 'update') {
", description = " . SqlQuote($description) . ", description = " . SqlQuote($description) .
" WHERE id = $id"); " WHERE id = $id");
print "Keyword updated.<BR>\n";
&RebuildCacheWarning;
# Make versioncache flush # Make versioncache flush
unlink "data/versioncache"; unlink "data/versioncache";
PutTrailer($localtrailer); print Bugzilla->cgi->header();
$vars->{'name'} = $name;
$template->process("admin/keywords/rebuild-cache.html.tmpl",
$vars)
|| ThrowTemplateError($template->error());
exit; exit;
} }
if ($action eq 'delete') { if ($action eq 'delete') {
PutHeader("Delete keyword");
my $id = $::FORM{id}; my $id = $::FORM{id};
SendSQL("SELECT name FROM keyworddefs WHERE id=$id"); SendSQL("SELECT name FROM keyworddefs WHERE id=$id");
my $name = FetchOneColumn(); my $name = FetchOneColumn();
if (!$::FORM{reallydelete}) { if (!$::FORM{reallydelete}) {
SendSQL("SELECT count(*) SendSQL("SELECT count(*)
FROM keywords FROM keywords
WHERE keywordid = $id"); WHERE keywordid = $id");
...@@ -358,21 +355,16 @@ if ($action eq 'delete') { ...@@ -358,21 +355,16 @@ if ($action eq 'delete') {
my $bugs = FetchOneColumn(); my $bugs = FetchOneColumn();
if ($bugs) { if ($bugs) {
$vars->{'bug_count'} = $bugs;
$vars->{'keyword_id'} = $id;
$vars->{'name'} = $name;
print Bugzilla->cgi->header();
print qq{ $template->process("admin/keywords/confirm-delete.html.tmpl",
There are $bugs bugs which have this keyword set. Are you <b>sure</b> you want $vars)
to delete the <code>$name</code> keyword? || ThrowTemplateError($template->error());
<FORM METHOD=POST ACTION=editkeywords.cgi>
<INPUT TYPE=HIDDEN NAME="id" VALUE="$id">
<INPUT TYPE=HIDDEN NAME="action" VALUE="delete">
<INPUT TYPE=HIDDEN NAME="reallydelete" VALUE="1">
<INPUT TYPE=SUBMIT VALUE="Yes, really delete the keyword">
</FORM>
};
PutTrailer($localtrailer);
exit; exit;
} }
} }
...@@ -380,31 +372,17 @@ to delete the <code>$name</code> keyword? ...@@ -380,31 +372,17 @@ to delete the <code>$name</code> keyword?
SendSQL("DELETE FROM keywords WHERE keywordid = $id"); SendSQL("DELETE FROM keywords WHERE keywordid = $id");
SendSQL("DELETE FROM keyworddefs WHERE id = $id"); SendSQL("DELETE FROM keyworddefs WHERE id = $id");
print "Keyword $name deleted.\n";
&RebuildCacheWarning;
# Make versioncache flush # Make versioncache flush
unlink "data/versioncache"; unlink "data/versioncache";
PutTrailer($localtrailer); print Bugzilla->cgi->header();
exit;
}
PutHeader("Error"); $vars->{'name'} = $name;
print "I don't have a clue what you want.<BR>\n"; $template->process("admin/keywords/rebuild-cache.html.tmpl",
$vars)
foreach ( sort keys %::FORM) { || ThrowTemplateError($template->error());
print "$_: $::FORM{$_}<BR>\n";
}
sub RebuildCacheWarning {
print "<BR><BR><B>You have deleted or modified a keyword. You must rebuild the keyword cache!<BR></B>";
print "You can rebuild the cache using sanitycheck.cgi. On very large installations of Bugzilla,<BR>";
print "This can take several minutes.<BR><BR><B><A HREF=\"sanitycheck.cgi?rebuildkeywordcache=1\">Rebuild cache</A><BR></B>";
exit;
} }
ThrowCodeError("action_unrecognized", $vars);
<!-- 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.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Terry Weissman <terry@mozilla.org>
# Vlad Dascalu <jocuri@softhome.net>
#%]
[%# INTERFACE:
# name: string. The name of the keyword.
# keyword_id: number. The ID of the keyword.
# bug_count: number. The number of bugs with the keyword.
#%]
[% PROCESS global/header.html.tmpl
title = "Delete Keyword"
%]
<p>
[% IF bug_count == 1 %]
There is one [% terms.bug %] with this keyword set.
[% ELSE %]
There are [% bug_count %] [%+terms.bugs %] with
this keyword set.
[% END %]
Are you <b>sure</b> you want to delete
the <code>[% name FILTER html %]</code> keyword?
</p>
<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="submit" value="Yes, really delete the keyword">
</form>
<p>Go back to the <a href="query.cgi">query page</a>
or <a href="editkeywords.cgi">edit other keywords</a>.</p>
[% PROCESS global/footer.html.tmpl %]
<!-- 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.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Terry Weissman <terry@mozilla.org>
# Vlad Dascalu <jocuri@softhome.net>
#%]
[%# INTERFACE:
# none
#%]
[% PROCESS global/header.html.tmpl
title = "Add keyword"
h2 = "This page allows you to add a new keyword."
%]
<form method="post" action="editkeywords.cgi">
<table border="0" cellpadding="4" cellspacing="0">
<input type="hidden" name="id" value="-1">
<tr>
<th align="right">Name:</th>
<td><input size="64" maxlength="64" name="name" value=""></td>
</tr>
<tr>
<th align="right">Description:</th>
<td>
<textarea rows="4" cols="64" wrap="virtual"
name="description"></textarea>
</td>
</tr>
</table>
<hr>
<input type="submit" value="Add">
<input type="hidden" name="action" value="new">
</form>
<p>Go back to the <a href="query.cgi">query page</a>
or <a href="editkeywords.cgi">edit other keywords</a>.</p>
[% PROCESS global/footer.html.tmpl %]
<!-- 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.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Terry Weissman <terry@mozilla.org>
# Vlad Dascalu <jocuri@softhome.net>
#%]
[%# INTERFACE:
# action: string. Contains the current action (either "update" or "delete").
# name: string. Contains the name of the current keyword.
#%]
[% IF action == "update" %]
[% title = "Update keyword"%]
[% status = "updated" %]
[% ELSIF action == "delete" %]
[% title = "Delete keyword" %]
[% status = "deleted" %]
[% END %]
[% PROCESS global/header.html.tmpl %]
Keyword [% name FILTER html %] [%+status FILTER html %].
<p>
<b>After you have finished deleting or modifying keywords,
you need to rebuild the keyword cache.</b><br>
Warning: on a very large installation of [% terms.Bugzilla %],
this can take several minutes.
</p>
<p>
<b><a href="sanitycheck.cgi?rebuildkeywordcache=1">Rebuild
keyword cache</a></b>
</p>
<p>Go back to the <a href="query.cgi">query page</a> or
<a href="editkeywords.cgi">edit more keywords</a>.</p>
[% PROCESS global/footer.html.tmpl %]
...@@ -491,6 +491,11 @@ ...@@ -491,6 +491,11 @@
'const.CONTROLMAPMANDATORY', 'const.CONTROLMAPMANDATORY',
], ],
'admin/keywords/confirm-delete.html.tmpl' => [
'keyword_id',
'bug_count',
],
'admin/flag-type/confirm-delete.html.tmpl' => [ 'admin/flag-type/confirm-delete.html.tmpl' => [
'flag_count', 'flag_count',
'flag_type.id', 'flag_type.id',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment