2004-05-23 11:22:32 +04:00
|
|
|
#!/usr/bin/perl -wT
|
1999-10-13 03:00:35 +04:00
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
#
|
1999-11-02 02:33:56 +03:00
|
|
|
# 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 mozilla.org code.
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is Holger
|
|
|
|
# Schurig. Portions created by Holger Schurig are
|
|
|
|
# Copyright (C) 1999 Holger Schurig. All
|
|
|
|
# Rights Reserved.
|
|
|
|
#
|
|
|
|
# Contributor(s): Holger Schurig <holgerschurig@nikocity.de>
|
2005-01-16 16:48:25 +03:00
|
|
|
# Terry Weissman <terry@mozilla.org>
|
|
|
|
# Gavin Shelley <bugzilla@chimpychompy.org>
|
2006-06-21 04:44:48 +04:00
|
|
|
# Frédéric Buclin <LpSolit@gmail.com>
|
1999-10-13 03:00:35 +04:00
|
|
|
#
|
|
|
|
#
|
|
|
|
# Direct any questions on this source code to
|
|
|
|
#
|
|
|
|
# Holger Schurig <holgerschurig@nikocity.de>
|
|
|
|
|
|
|
|
use strict;
|
2002-04-29 23:32:29 +04:00
|
|
|
use lib ".";
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2006-06-20 11:55:39 +04:00
|
|
|
use Bugzilla;
|
2004-03-27 06:51:44 +03:00
|
|
|
use Bugzilla::Constants;
|
2006-06-21 04:44:48 +04:00
|
|
|
use Bugzilla::Util;
|
|
|
|
use Bugzilla::Error;
|
2005-07-19 04:05:11 +04:00
|
|
|
use Bugzilla::Product;
|
|
|
|
use Bugzilla::Version;
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2005-01-16 16:48:25 +03:00
|
|
|
my $cgi = Bugzilla->cgi;
|
2005-02-18 00:57:27 +03:00
|
|
|
my $dbh = Bugzilla->dbh;
|
2005-10-25 03:11:56 +04:00
|
|
|
my $template = Bugzilla->template;
|
|
|
|
my $vars = {};
|
2005-01-16 16:48:25 +03:00
|
|
|
|
1999-10-13 03:00:35 +04:00
|
|
|
#
|
|
|
|
# Preliminary checks:
|
|
|
|
#
|
|
|
|
|
2005-09-16 02:01:56 +04:00
|
|
|
my $user = Bugzilla->login(LOGIN_REQUIRED);
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2005-07-19 04:05:11 +04:00
|
|
|
print $cgi->header();
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2005-09-16 02:01:56 +04:00
|
|
|
$user->in_group('editcomponents')
|
2005-01-27 22:50:25 +03:00
|
|
|
|| ThrowUserError("auth_failure", {group => "editcomponents",
|
|
|
|
action => "edit",
|
|
|
|
object => "versions"});
|
1999-10-13 03:00:35 +04:00
|
|
|
|
|
|
|
#
|
|
|
|
# often used variables
|
|
|
|
#
|
2005-07-19 04:05:11 +04:00
|
|
|
my $product_name = trim($cgi->param('product') || '');
|
|
|
|
my $version_name = trim($cgi->param('version') || '');
|
|
|
|
my $action = trim($cgi->param('action') || '');
|
2005-09-28 02:08:14 +04:00
|
|
|
my $showbugcounts = (defined $cgi->param('showbugcounts'));
|
1999-10-13 03:00:35 +04:00
|
|
|
|
|
|
|
#
|
2005-07-19 04:05:11 +04:00
|
|
|
# product = '' -> Show nice list of products
|
1999-10-13 03:00:35 +04:00
|
|
|
#
|
|
|
|
|
2005-07-19 04:05:11 +04:00
|
|
|
unless ($product_name) {
|
2005-12-12 06:12:26 +03:00
|
|
|
$vars->{'products'} = $user->get_selectable_products;
|
2005-09-28 02:08:14 +04:00
|
|
|
$vars->{'showbugcounts'} = $showbugcounts;
|
2005-01-16 16:48:25 +03:00
|
|
|
|
2005-12-12 06:12:26 +03:00
|
|
|
$template->process("admin/versions/select-product.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
1999-10-13 03:00:35 +04:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2005-12-12 06:12:26 +03:00
|
|
|
# First make sure the product name is valid.
|
2005-07-19 04:05:11 +04:00
|
|
|
my $product = Bugzilla::Product::check_product($product_name);
|
|
|
|
|
2005-12-12 06:12:26 +03:00
|
|
|
# Then make sure the user is allowed to edit properties of this product.
|
|
|
|
$user->can_see_product($product->name)
|
|
|
|
|| ThrowUserError('product_access_denied', {product => $product->name});
|
|
|
|
|
|
|
|
|
1999-10-13 03:00:35 +04:00
|
|
|
#
|
|
|
|
# action='' -> Show nice list of versions
|
|
|
|
#
|
|
|
|
|
|
|
|
unless ($action) {
|
2005-09-28 02:08:14 +04:00
|
|
|
$vars->{'showbugcounts'} = $showbugcounts;
|
2006-03-02 01:10:24 +03:00
|
|
|
$vars->{'product'} = $product;
|
2006-07-19 03:50:32 +04:00
|
|
|
$template->process("admin/versions/list.html.tmpl", $vars)
|
2005-01-16 16:48:25 +03:00
|
|
|
|| ThrowTemplateError($template->error());
|
|
|
|
|
1999-10-13 03:00:35 +04:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# action='add' -> present form for parameters for new version
|
|
|
|
#
|
|
|
|
# (next action will be 'new')
|
|
|
|
#
|
|
|
|
|
|
|
|
if ($action eq 'add') {
|
2005-01-16 16:48:25 +03:00
|
|
|
|
2006-03-02 01:10:24 +03:00
|
|
|
$vars->{'product'} = $product;
|
2006-07-19 03:50:32 +04:00
|
|
|
$template->process("admin/versions/create.html.tmpl", $vars)
|
2005-01-16 16:48:25 +03:00
|
|
|
|| ThrowTemplateError($template->error());
|
1999-10-13 03:00:35 +04:00
|
|
|
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# action='new' -> add version entered in the 'action=add' screen
|
|
|
|
#
|
|
|
|
|
|
|
|
if ($action eq 'new') {
|
2005-01-16 16:48:25 +03:00
|
|
|
|
2006-07-19 03:50:32 +04:00
|
|
|
my $version = Bugzilla::Version::create($version_name, $product);
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2006-03-02 01:10:24 +03:00
|
|
|
$vars->{'version'} = $version;
|
|
|
|
$vars->{'product'} = $product;
|
2006-07-19 03:50:32 +04:00
|
|
|
$template->process("admin/versions/created.html.tmpl", $vars)
|
2005-01-16 16:48:25 +03:00
|
|
|
|| ThrowTemplateError($template->error());
|
|
|
|
|
1999-10-13 03:00:35 +04:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# action='del' -> ask if user really wants to delete
|
|
|
|
#
|
|
|
|
# (next action would be 'delete')
|
|
|
|
#
|
|
|
|
|
|
|
|
if ($action eq 'del') {
|
2005-01-16 16:48:25 +03:00
|
|
|
|
2006-07-19 03:50:32 +04:00
|
|
|
my $version = Bugzilla::Version::check_version($product, $version_name);
|
2005-01-16 16:48:25 +03:00
|
|
|
|
2006-03-02 01:10:24 +03:00
|
|
|
$vars->{'version'} = $version;
|
|
|
|
$vars->{'product'} = $product;
|
2006-07-19 03:50:32 +04:00
|
|
|
$template->process("admin/versions/confirm-delete.html.tmpl", $vars)
|
2005-01-16 16:48:25 +03:00
|
|
|
|| ThrowTemplateError($template->error());
|
1999-10-13 03:00:35 +04:00
|
|
|
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# action='delete' -> really delete the version
|
|
|
|
#
|
|
|
|
|
|
|
|
if ($action eq 'delete') {
|
|
|
|
|
2006-07-19 03:50:32 +04:00
|
|
|
my $version = Bugzilla::Version::check_version($product, $version_name);
|
|
|
|
$version->remove_from_db;
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2006-03-02 01:10:24 +03:00
|
|
|
$vars->{'version'} = $version;
|
|
|
|
$vars->{'product'} = $product;
|
2005-01-16 16:48:25 +03:00
|
|
|
|
2005-04-06 04:19:56 +04:00
|
|
|
$template->process("admin/versions/deleted.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
2006-07-19 03:50:32 +04:00
|
|
|
|
1999-10-13 03:00:35 +04:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# action='edit' -> present the edit version form
|
|
|
|
#
|
|
|
|
# (next action would be 'update')
|
|
|
|
#
|
|
|
|
|
|
|
|
if ($action eq 'edit') {
|
2005-01-16 16:48:25 +03:00
|
|
|
|
2006-07-19 03:50:32 +04:00
|
|
|
my $version = Bugzilla::Version::check_version($product, $version_name);
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2006-03-02 01:10:24 +03:00
|
|
|
$vars->{'version'} = $version;
|
|
|
|
$vars->{'product'} = $product;
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2006-07-19 03:50:32 +04:00
|
|
|
$template->process("admin/versions/edit.html.tmpl", $vars)
|
2005-01-16 16:48:25 +03:00
|
|
|
|| ThrowTemplateError($template->error());
|
1999-10-13 03:00:35 +04:00
|
|
|
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# action='update' -> update the version
|
|
|
|
#
|
|
|
|
|
|
|
|
if ($action eq 'update') {
|
|
|
|
|
2005-07-19 04:05:11 +04:00
|
|
|
my $version_old_name = trim($cgi->param('versionold') || '');
|
2006-07-19 03:50:32 +04:00
|
|
|
my $version =
|
|
|
|
Bugzilla::Version::check_version($product, $version_old_name);
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2006-03-31 14:27:26 +04:00
|
|
|
$dbh->bz_lock_tables('bugs WRITE', 'versions WRITE');
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2006-07-19 03:50:32 +04:00
|
|
|
$vars->{'updated'} = $version->update($version_name, $product);
|
|
|
|
|
|
|
|
$dbh->bz_unlock_tables();
|
2005-01-16 16:48:25 +03:00
|
|
|
|
2006-03-02 01:10:24 +03:00
|
|
|
$vars->{'version'} = $version;
|
|
|
|
$vars->{'product'} = $product;
|
2006-07-19 03:50:32 +04:00
|
|
|
$template->process("admin/versions/updated.html.tmpl", $vars)
|
2005-01-16 16:48:25 +03:00
|
|
|
|| ThrowTemplateError($template->error());
|
|
|
|
|
1999-10-13 03:00:35 +04:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# No valid action found
|
|
|
|
#
|
2005-02-16 19:35:54 +03:00
|
|
|
ThrowUserError('no_valid_action', {'field' => "version"});
|