2006-10-06 01:11:04 +04:00
|
|
|
#!/usr/bin/perl -wT
|
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
#
|
|
|
|
# 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 Testopia System.
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is Greg Hendricks.
|
2007-02-26 22:06:35 +03:00
|
|
|
# Portions created by Greg Hendricks are Copyright (C) 2006
|
|
|
|
# Novell. All Rights Reserved.
|
2006-10-06 01:11:04 +04:00
|
|
|
#
|
|
|
|
# Contributor(s): Greg Hendricks <ghendricks@novell.com>
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use lib ".";
|
|
|
|
|
|
|
|
use Bugzilla;
|
|
|
|
use Bugzilla::Constants;
|
|
|
|
use Bugzilla::Error;
|
|
|
|
use Bugzilla::Util;
|
|
|
|
use Bugzilla::Testopia::TestPlan;
|
|
|
|
use Bugzilla::Testopia::Util;
|
|
|
|
|
|
|
|
my $template = Bugzilla->template;
|
2007-02-26 22:06:35 +03:00
|
|
|
my $dbh = Bugzilla->dbh;
|
|
|
|
my $cgi = Bugzilla->cgi;
|
2006-10-06 01:11:04 +04:00
|
|
|
|
2007-02-26 22:06:35 +03:00
|
|
|
use vars qw($vars);
|
2006-10-06 01:11:04 +04:00
|
|
|
|
2007-02-26 22:06:35 +03:00
|
|
|
Bugzilla->login(LOGIN_REQUIRED);
|
2006-10-06 01:11:04 +04:00
|
|
|
|
2007-02-26 22:06:35 +03:00
|
|
|
print $cgi->header;
|
2007-03-15 18:49:26 +03:00
|
|
|
ThrowUserError("testopia-read-only") unless Bugzilla->user->in_group('admin');
|
2006-10-06 01:11:04 +04:00
|
|
|
|
2007-02-26 22:06:35 +03:00
|
|
|
my $plan = Bugzilla::Testopia::TestPlan->new({});
|
2006-10-06 01:11:04 +04:00
|
|
|
my $action = $cgi->param('action') || '';
|
|
|
|
my $item = $cgi->param('item') || '';
|
|
|
|
|
|
|
|
if ($item eq 'plan_type'){
|
|
|
|
if( $action eq 'edit'){
|
|
|
|
my $type_id = $cgi->param('type_id');
|
|
|
|
detaint_natural($type_id);
|
2007-02-16 00:46:15 +03:00
|
|
|
$vars->{'type'} = $plan->plan_type_ref($type_id)
|
2006-10-06 01:11:04 +04:00
|
|
|
|| ThrowUserError("invalid-test-id-non-existent", {'id' => $type_id, 'type' => 'Plan Type'});
|
|
|
|
$template->process("testopia/admin/plantypes/edit.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
|
|
|
}
|
|
|
|
elsif ($action eq 'doedit'){
|
|
|
|
my $type_id = $cgi->param('type_id');
|
|
|
|
my $type_name = $cgi->param('name') || '';
|
2007-02-16 00:46:15 +03:00
|
|
|
my $type_desc = $cgi->param('description') || '';
|
2006-10-06 01:11:04 +04:00
|
|
|
|
|
|
|
ThrowUserError('testopia-missing-required-field', {'field' => 'name'}) if $type_name eq '';
|
|
|
|
detaint_natural($type_id);
|
|
|
|
ThrowUserError("invalid-test-id-non-existent",
|
2007-02-16 00:46:15 +03:00
|
|
|
{'id' => $type_id, 'type' => 'Plan Type'}) unless $plan->plan_type_ref($type_id);
|
2006-10-06 01:11:04 +04:00
|
|
|
trick_taint($type_name);
|
2007-02-16 00:46:15 +03:00
|
|
|
trick_taint($type_desc);
|
2006-10-06 01:11:04 +04:00
|
|
|
|
2007-02-16 00:46:15 +03:00
|
|
|
$plan->update_plan_type($type_id, $type_name, $type_desc);
|
2006-10-06 01:11:04 +04:00
|
|
|
display();
|
|
|
|
}
|
|
|
|
elsif ($action eq 'add'){
|
|
|
|
$template->process("testopia/admin/plantypes/add.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
|
|
|
}
|
|
|
|
elsif ($action eq 'doadd'){
|
|
|
|
my $type_name = $cgi->param('name') || '';
|
2007-02-16 00:46:15 +03:00
|
|
|
my $type_desc = $cgi->param('description') || '';
|
2006-10-06 01:11:04 +04:00
|
|
|
|
|
|
|
ThrowUserError('testopia-missing-required-field', {'field' => 'name'}) if $type_name eq '';
|
|
|
|
trick_taint($type_name);
|
2007-02-16 00:46:15 +03:00
|
|
|
trick_taint($type_desc);
|
2006-10-06 01:11:04 +04:00
|
|
|
ThrowUserError('testopia-name-not-unique',
|
|
|
|
{'object' => 'Plan Type', 'name' => $type_name}) if $plan->check_plan_type($type_name);
|
|
|
|
|
2007-02-16 00:46:15 +03:00
|
|
|
$plan->add_plan_type($type_name, $type_desc);
|
2006-10-06 01:11:04 +04:00
|
|
|
display();
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
display();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
$template->process("testopia/admin/show.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
|
|
|
}
|
|
|
|
|
|
|
|
sub display {
|
|
|
|
$vars->{'plan'} = $plan;
|
|
|
|
$template->process("testopia/admin/plantypes/show.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
|
|
|
}
|