aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'editkeywords.cgi')
-rwxr-xr-xeditkeywords.cgi62
1 files changed, 5 insertions, 57 deletions
diff --git a/editkeywords.cgi b/editkeywords.cgi
index 7b906c30b..7b94dbbe3 100755
--- a/editkeywords.cgi
+++ b/editkeywords.cgi
@@ -34,25 +34,6 @@ my $dbh = Bugzilla->dbh;
my $template = Bugzilla->template;
my $vars = {};
-sub Validate {
- my ($name, $description) = @_;
- if ($name eq "") {
- ThrowUserError("keyword_blank_name");
- }
- if ($name =~ /[\s,]/) {
- ThrowUserError("keyword_invalid_name");
- }
- if ($description eq "") {
- ThrowUserError("keyword_blank_description");
- }
- # It is safe to detaint these values as they are only
- # used in placeholders.
- trick_taint($name);
- $_[0] = $name;
- trick_taint($description);
- $_[1] = $description;
-}
-
sub ValidateKeyID {
my $id = shift;
@@ -102,49 +83,16 @@ if ($action eq 'add') {
#
# action='new' -> add keyword entered in the 'action=add' screen
#
-
if ($action eq 'new') {
- # Cleanups and validity checks
-
- my $name = trim($cgi->param('name') || '');
- my $description = trim($cgi->param('description') || '');
-
- Validate($name, $description);
-
- my $id = $dbh->selectrow_array('SELECT id FROM keyworddefs
- WHERE name = ?', undef, $name);
-
- if ($id) {
- $vars->{'name'} = $name;
- ThrowUserError("keyword_already_exists", $vars);
- }
-
-
- # Pick an unused number. Be sure to recycle numbers that may have been
- # deleted in the past. This code is potentially slow, but it happens
- # rarely enough, and there really aren't ever going to be that many
- # keywords anyway.
-
- my $existing_ids =
- $dbh->selectcol_arrayref('SELECT id FROM keyworddefs ORDER BY id');
+ my $name = $cgi->param('name') || '';
+ my $desc = $cgi->param('description') || '';
- my $newid = 1;
-
- foreach my $oldid (@$existing_ids) {
- if ($oldid > $newid) {
- last;
- }
- $newid = $oldid + 1;
- }
-
- # Add the new keyword.
- $dbh->do('INSERT INTO keyworddefs
- (id, name, description) VALUES (?, ?, ?)',
- undef, ($newid, $name, $description));
+ my $keyword = Bugzilla::Keyword->create(
+ { name => $name, description => $desc });
print $cgi->header();
- $vars->{'name'} = $name;
+ $vars->{'name'} = $keyword->name;
$template->process("admin/keywords/created.html.tmpl", $vars)
|| ThrowTemplateError($template->error());