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/
1999-10-13 03:00:35 +04:00
#
1999-11-02 02:33:56 +03:00
# 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>
# Terry Weissman <terry@mozilla.org>
# Dawn Endico <endico@mozilla.org>
2000-03-10 19:25:03 +03:00
# Joe Robins <jmrobins@tgix.com>
2005-02-16 21:05:06 +03:00
# Gavin Shelley <bugzilla@chimpychompy.org>
2005-04-06 04:19:56 +04:00
# Fr<46> d<EFBFBD> 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 ".";
2002-11-24 22:56:34 +03:00
use vars qw ($template $vars);
use Bugzilla::Constants;
1999-10-13 03:00:35 +04:00
require "CGI.pl";
require "globals.pl";
2005-04-16 21:17:06 +04:00
use Bugzilla::Bug;
2003-06-26 03:23:13 +04:00
use Bugzilla::Series;
2005-03-16 01:10:14 +03:00
use Bugzilla::User;
2003-11-22 06:50:42 +03:00
use Bugzilla::Config qw(:DEFAULT $datadir);
2000-02-17 08:15:23 +03:00
# Shut up misguided -w warnings about "used only once". "use vars" just
# doesn't work for me.
2003-06-26 03:23:13 +04:00
use vars qw(@legal_bug_status @legal_resolution);
1999-10-13 03:00:35 +04:00
2002-11-24 22:56:34 +03:00
my %ctl = (
&::CONTROLMAPNA => 'NA',
&::CONTROLMAPSHOWN => 'Shown',
&::CONTROLMAPDEFAULT => 'Default',
&::CONTROLMAPMANDATORY => 'Mandatory'
);
1999-10-13 03:00:35 +04:00
# TestProduct: just returns if the specified product does exists
# CheckProduct: same check, optionally emit an error text
sub TestProduct ($)
{
my $prod = shift;
# does the product exist?
2002-08-12 09:43:05 +04:00
SendSQL("SELECT name
1999-10-13 03:00:35 +04:00
FROM products
2002-08-12 09:43:05 +04:00
WHERE name=" . SqlQuote($prod));
1999-10-13 03:00:35 +04:00
return FetchOneColumn();
}
sub CheckProduct ($)
{
my $prod = shift;
# do we have a product?
unless ($prod) {
print "Sorry, you haven't specified a product.";
PutTrailer();
exit;
}
unless (TestProduct $prod) {
print "Sorry, product '$prod' does not exist.";
PutTrailer();
exit;
}
}
2004-08-21 01:49:20 +04:00
# TestClassification: just returns if the specified classification does exists
# CheckClassification: same check, optionally emit an error text
sub TestClassification ($)
{
my $cl = shift;
# does the classification exist?
SendSQL("SELECT name
FROM classifications
WHERE name=" . SqlQuote($cl));
return FetchOneColumn();
}
sub CheckClassification ($)
{
my $cl = shift;
# do we have a classification?
unless ($cl) {
print "Sorry, you haven't specified a classification.";
PutTrailer();
exit;
}
unless (TestClassification $cl) {
print "Sorry, classification '$cl' does not exist.";
PutTrailer();
exit;
}
}
2005-02-16 21:05:06 +03:00
# For the transition period, as this file is templatised bit by bit,
# we need this routine, which does things properly, and will
# eventually be the only version. (The older versions assume a
# PutHeader() call has been made)
sub CheckClassificationNew ($)
{
my $cl = shift;
# do we have a classification?
unless ($cl) {
ThrowUserError('classification_not_specified');
}
unless (TestClassification $cl) {
ThrowUserError('classification_doesnt_exist',
{'name' => $cl});
}
}
2004-08-21 01:49:20 +04:00
sub CheckClassificationProduct ($$)
{
my $cl = shift;
my $prod = shift;
CheckClassification($cl);
CheckProduct($prod);
# does the classification exist?
SendSQL("SELECT products.name
FROM products,classifications
WHERE products.name=" . SqlQuote($prod) .
" AND classifications.name=" . SqlQuote($cl));
my $res = FetchOneColumn();
unless ($res) {
print "Sorry, classification->product '$cl'->'$prod' does not exist.";
PutTrailer();
exit;
}
}
1999-10-13 03:00:35 +04:00
#
# Displays the form to edit a products parameters
#
2004-08-21 01:49:20 +04:00
sub EmitFormElements ($$$$$$$$$)
1999-10-13 03:00:35 +04:00
{
2004-08-21 01:49:20 +04:00
my ($classification, $product, $description, $milestoneurl, $disallownew,
2000-03-23 21:23:14 +03:00
$votesperuser, $maxvotesperbug, $votestoconfirm, $defaultmilestone)
= @_;
1999-10-13 03:00:35 +04:00
1999-10-20 01:27:41 +04:00
$product = value_quote($product);
$description = value_quote($description);
2004-08-21 01:49:20 +04:00
if (Param('useclassification')) {
print " <TH ALIGN=\"right\">Classification:</TH>\n";
print " <TD><b>",html_quote($classification),"</b></TD>\n";
print "</TR><TR>\n";
}
1999-10-13 03:00:35 +04:00
print " <TH ALIGN=\"right\">Product:</TH>\n";
print " <TD><INPUT SIZE=64 MAXLENGTH=64 NAME=\"product\" VALUE=\"$product\"></TD>\n";
print "</TR><TR>\n";
print " <TH ALIGN=\"right\">Description:</TH>\n";
print " <TD><TEXTAREA ROWS=4 COLS=64 WRAP=VIRTUAL NAME=\"description\">$description</TEXTAREA></TD>\n";
2000-03-23 21:23:14 +03:00
$defaultmilestone = value_quote($defaultmilestone);
1999-10-13 03:00:35 +04:00
if (Param('usetargetmilestone')) {
1999-10-20 01:27:41 +04:00
$milestoneurl = value_quote($milestoneurl);
1999-10-13 03:00:35 +04:00
print "</TR><TR>\n";
2001-11-22 18:46:27 +03:00
print " <TH ALIGN=\"right\">URL describing milestones for this product:</TH>\n";
1999-10-13 03:00:35 +04:00
print " <TD><INPUT TYPE=TEXT SIZE=64 MAXLENGTH=255 NAME=\"milestoneurl\" VALUE=\"$milestoneurl\"></TD>\n";
2000-03-23 21:23:14 +03:00
print "</TR><TR>\n";
print " <TH ALIGN=\"right\">Default milestone:</TH>\n";
print " <TD><INPUT TYPE=TEXT SIZE=20 MAXLENGTH=20 NAME=\"defaultmilestone\" VALUE=\"$defaultmilestone\"></TD>\n";
} else {
print qq{<INPUT TYPE=HIDDEN NAME="defaultmilestone" VALUE="$defaultmilestone">\n};
1999-10-13 03:00:35 +04:00
}
2000-03-10 19:25:03 +03:00
1999-10-13 03:00:35 +04:00
print "</TR><TR>\n";
print " <TH ALIGN=\"right\">Closed for bug entry:</TH>\n";
my $closed = $disallownew ? "CHECKED" : "";
print " <TD><INPUT TYPE=CHECKBOX NAME=\"disallownew\" $closed VALUE=\"1\"></TD>\n";
2000-01-05 00:29:51 +03:00
print "</TR><TR>\n";
print " <TH ALIGN=\"right\">Maximum votes per person:</TH>\n";
print " <TD><INPUT SIZE=5 MAXLENGTH=5 NAME=\"votesperuser\" VALUE=\"$votesperuser\"></TD>\n";
2000-02-17 08:15:23 +03:00
print "</TR><TR>\n";
print " <TH ALIGN=\"right\">Maximum votes a person can put on a single bug:</TH>\n";
print " <TD><INPUT SIZE=5 MAXLENGTH=5 NAME=\"maxvotesperbug\" VALUE=\"$maxvotesperbug\"></TD>\n";
print "</TR><TR>\n";
2004-03-08 02:27:32 +03:00
print " <TH ALIGN=\"right\">Number of votes a bug in this product needs to automatically get out of the <A HREF=\"page.cgi?id=fields.html#status\">UNCONFIRMED</A> state:</TH>\n";
2000-02-17 08:15:23 +03:00
print " <TD><INPUT SIZE=5 MAXLENGTH=5 NAME=\"votestoconfirm\" VALUE=\"$votestoconfirm\"></TD>\n";
1999-10-13 03:00:35 +04:00
}
#
# Displays a text like "a.", "a or b.", "a, b or c.", "a, b, c or d."
#
sub PutTrailer (@)
{
my (@links) = ("Back to the <A HREF=\"query.cgi\">query page</A>", @_);
my $count = $#links;
my $num = 0;
print "<P>\n";
foreach (@links) {
print $_;
if ($num == $count) {
print ".\n";
}
elsif ($num == $count-1) {
print " or ";
}
else {
print ", ";
}
$num++;
}
2000-01-15 01:35:49 +03:00
PutFooter();
1999-10-13 03:00:35 +04:00
}
#
# Preliminary checks:
#
2005-04-06 04:19:56 +04:00
my $user = Bugzilla->login(LOGIN_REQUIRED);
my $whoid = $user->id;
1999-10-13 03:00:35 +04:00
2005-04-09 03:51:02 +04:00
my $cgi = Bugzilla->cgi;
print $cgi->header();
1999-10-13 03:00:35 +04:00
2005-01-16 17:07:31 +03:00
UserInGroup("editcomponents")
|| ThrowUserError("auth_failure", {group => "editcomponents",
action => "edit",
object => "products"});
1999-10-13 03:00:35 +04:00
#
# often used variables
#
2005-04-09 03:51:02 +04:00
my $classification = trim($cgi->param('classification') || '');
my $product = trim($cgi->param('product') || '');
my $action = trim($cgi->param('action') || '');
2002-11-24 22:56:34 +03:00
my $headerdone = 0;
1999-10-13 03:00:35 +04:00
my $localtrailer = "<A HREF=\"editproducts.cgi\">edit</A> more products";
2004-08-21 01:49:20 +04:00
my $classhtmlvarstart = "";
my $classhtmlvar = "";
2005-02-18 00:57:27 +03:00
my $dbh = Bugzilla->dbh;
2004-08-21 01:49:20 +04:00
#
2005-03-17 17:47:06 +03:00
# product = '' -> Show nice list of classifications (if
# classifications enabled)
2004-08-21 01:49:20 +04:00
#
if (Param('useclassification')) {
2005-03-24 00:24:19 +03:00
if ($classification) {
$classhtmlvar = "&classification=" . url_quote($classification);
$classhtmlvarstart = "?classification=" . url_quote($classification);
$localtrailer .= ", <A HREF=\"editproducts.cgi" . $classhtmlvarstart . "\">edit</A> in this classification";
}
elsif (!$product) {
2005-03-17 17:47:06 +03:00
my $query =
"SELECT classifications.name, classifications.description,
COUNT(classification_id) AS product_count
2004-08-21 01:49:20 +04:00
FROM classifications
2005-03-16 03:27:15 +03:00
LEFT JOIN products
2005-03-17 17:47:06 +03:00
ON classifications.id = products.classification_id " .
$dbh->sql_group_by('classifications.id',
'classifications.name,
classifications.description') . "
ORDER BY name";
$vars->{'classifications'} = $dbh->selectall_arrayref($query,
{'Slice' => {}});
$template->process("admin/products/list-classifications.html.tmpl",
$vars)
|| ThrowTemplateError($template->error());
2004-08-21 01:49:20 +04:00
exit;
}
}
1999-10-13 03:00:35 +04:00
#
2005-03-24 00:24:19 +03:00
# action = '' -> Show a nice list of products, unless a product
# is already specified (then edit it)
1999-10-13 03:00:35 +04:00
#
2005-03-24 00:24:19 +03:00
if (!$action && !$product) {
2005-02-16 21:05:06 +03:00
2004-08-21 01:49:20 +04:00
if (Param('useclassification')) {
2005-02-16 21:05:06 +03:00
CheckClassificationNew($classification);
2004-08-21 01:49:20 +04:00
}
1999-10-13 03:00:35 +04:00
2005-02-16 21:05:06 +03:00
my @execute_params = ();
my @products = ();
my $query = "SELECT products.name,
COALESCE(products.description,'') AS description,
2005-03-11 22:06:11 +03:00
disallownew = 0 AS status,
2005-02-16 21:05:06 +03:00
votesperuser, maxvotesperbug, votestoconfirm,
COUNT(bug_id) AS bug_count
FROM products";
2004-08-21 01:49:20 +04:00
if (Param('useclassification')) {
2005-05-02 22:52:02 +04:00
$query .= " INNER JOIN classifications " .
"ON classifications.id = products.classification_id";
2004-08-21 01:49:20 +04:00
}
2005-02-16 21:05:06 +03:00
2004-08-21 01:49:20 +04:00
$query .= " LEFT JOIN bugs ON products.id = bugs.product_id";
2005-02-16 21:05:06 +03:00
2004-08-21 01:49:20 +04:00
if (Param('useclassification')) {
2005-05-02 22:52:02 +04:00
$query .= " WHERE classifications.name = ? ";
2005-02-16 21:05:06 +03:00
# trick_taint is OK because we use this in a placeholder in a SELECT
trick_taint($classification);
push(@execute_params,
$classification);
2004-08-21 01:49:20 +04:00
}
2005-02-16 21:05:06 +03:00
2005-03-16 03:27:15 +03:00
$query .= " " . $dbh->sql_group_by('products.name',
'products.description, disallownew,
votesperuser, maxvotesperbug,
votestoconfirm');
$query .= " ORDER BY products.name";
1999-10-13 03:00:35 +04:00
2005-02-16 21:05:06 +03:00
$vars->{'products'} = $dbh->selectall_arrayref($query,
{'Slice' => {}},
@execute_params);
$vars->{'classification'} = $classification;
$template->process("admin/products/list.html.tmpl",
$vars)
|| ThrowTemplateError($template->error());
1999-10-13 03:00:35 +04:00
exit;
}
#
# action='add' -> present form for parameters for new product
#
# (next action will be 'new')
#
if ($action eq 'add') {
PutHeader("Add product");
2004-08-21 01:49:20 +04:00
if (Param('useclassification')) {
CheckClassification($classification);
}
1999-10-13 03:00:35 +04:00
#print "This page lets you add a new product to bugzilla.\n";
print "<FORM METHOD=POST ACTION=editproducts.cgi>\n";
print "<TABLE BORDER=0 CELLPADDING=4 CELLSPACING=0><TR>\n";
2004-08-21 01:49:20 +04:00
EmitFormElements($classification,'', '', '', 0, 0, 10000, 0, "---");
1999-10-13 03:00:35 +04:00
print "</TR><TR>\n";
print " <TH ALIGN=\"right\">Version:</TH>\n";
print " <TD><INPUT SIZE=64 MAXLENGTH=255 NAME=\"version\" VALUE=\"unspecified\"></TD>\n";
2004-07-06 05:12:29 +04:00
print "</TR><TR>\n";
print " <TH ALIGN=\"right\">Create chart datasets for this product:</TH>\n";
print " <TD><INPUT TYPE=CHECKBOX NAME=\"createseries\" VALUE=1></TD>";
print "</TR>\n";
1999-10-13 03:00:35 +04:00
print "</TABLE>\n<HR>\n";
print "<INPUT TYPE=SUBMIT VALUE=\"Add\">\n";
print "<INPUT TYPE=HIDDEN NAME=\"action\" VALUE=\"new\">\n";
2003-06-26 03:23:13 +04:00
print "<INPUT TYPE=HIDDEN NAME='subcategory' VALUE='-All-'>\n";
print "<INPUT TYPE=HIDDEN NAME='open_name' VALUE='All Open'>\n";
2004-08-21 01:49:20 +04:00
print "<INPUT TYPE=HIDDEN NAME='classification' VALUE='",html_quote($classification),"'>\n";
1999-10-13 03:00:35 +04:00
print "</FORM>";
my $other = $localtrailer;
$other =~ s/more/other/;
PutTrailer($other);
exit;
}
#
# action='new' -> add product entered in the 'action=add' screen
#
if ($action eq 'new') {
PutHeader("Adding new product");
2000-03-10 19:25:03 +03:00
# Cleanups and validity checks
1999-10-13 03:00:35 +04:00
2005-05-03 22:32:58 +04:00
my $classification_id = 1;
if (Param('useclassification')) {
CheckClassification($classification);
$classification_id = get_classification_id($classification);
}
1999-10-13 03:00:35 +04:00
unless ($product) {
print "You must enter a name for the new product. Please press\n";
print "<b>Back</b> and try again.\n";
PutTrailer($localtrailer);
exit;
}
2004-07-20 09:06:18 +04:00
my $existing_product = TestProduct($product);
2004-09-09 02:53:39 +04:00
if ($existing_product) {
# Check for exact case sensitive match:
if ($existing_product eq $product) {
print "The product '$product' already exists. Please press\n";
print "<b>Back</b> and try again.\n";
PutTrailer($localtrailer);
exit;
}
1999-10-13 03:00:35 +04:00
2004-09-09 02:53:39 +04:00
# Next check for a case-insensitive match:
if (lc($existing_product) eq lc($product)) {
print "The new product '$product' differs from existing product ";
print "'$existing_product' only in case. Please press\n";
print "<b>Back</b> and try again.\n";
PutTrailer($localtrailer);
exit;
}
2004-07-20 09:06:18 +04:00
}
2005-04-09 03:51:02 +04:00
my $version = trim($cgi->param('version') || '');
1999-10-13 03:00:35 +04:00
if ($version eq '') {
print "You must enter a version for product '$product'. Please press\n";
print "<b>Back</b> and try again.\n";
PutTrailer($localtrailer);
exit;
}
2005-04-09 03:51:02 +04:00
my $description = trim($cgi->param('description') || '');
my $milestoneurl = trim($cgi->param('milestoneurl') || '');
1999-10-13 03:00:35 +04:00
my $disallownew = 0;
2005-04-09 03:51:02 +04:00
$disallownew = 1 if $cgi->param('disallownew');
my $votesperuser = $cgi->param('votesperuser');
2000-01-05 00:29:51 +03:00
$votesperuser ||= 0;
2005-04-09 03:51:02 +04:00
my $maxvotesperbug = $cgi->param('maxvotesperbug');
2000-02-17 08:15:23 +03:00
$maxvotesperbug = 10000 if !defined $maxvotesperbug;
2005-04-09 03:51:02 +04:00
my $votestoconfirm = $cgi->param('votestoconfirm');
2000-02-17 08:15:23 +03:00
$votestoconfirm ||= 0;
2005-04-09 03:51:02 +04:00
my $defaultmilestone = $cgi->param('defaultmilestone') || "---";
1999-10-13 03:00:35 +04:00
# Add the new product.
SendSQL("INSERT INTO products ( " .
2002-08-12 09:43:05 +04:00
"name, description, milestoneurl, disallownew, votesperuser, " .
2004-08-21 01:49:20 +04:00
"maxvotesperbug, votestoconfirm, defaultmilestone, classification_id" .
2000-03-23 21:23:14 +03:00
" ) VALUES ( " .
SqlQuote($product) . "," .
SqlQuote($description) . "," .
SqlQuote($milestoneurl) . "," .
2003-10-26 05:37:48 +03:00
# had tainting issues under cygwin, IIS 5.0, perl -T %s %s
# see bug 208647. http://bugzilla.mozilla.org/show_bug.cgi?id=208647
# had to de-taint $disallownew, $votesperuser, $maxvotesperbug,
# and $votestoconfirm w/ SqlQuote()
# - jpyeron@pyerotechnics.com
SqlQuote($disallownew) . "," .
SqlQuote($votesperuser) . "," .
SqlQuote($maxvotesperbug) . "," .
SqlQuote($votestoconfirm) . "," .
2004-08-21 01:49:20 +04:00
SqlQuote($defaultmilestone) . "," .
SqlQuote($classification_id) . ")");
2005-02-18 19:01:48 +03:00
my $product_id = $dbh->bz_last_key('products', 'id');
2004-08-21 01:49:20 +04:00
1999-10-13 03:00:35 +04:00
SendSQL("INSERT INTO versions ( " .
2002-08-12 09:43:05 +04:00
"value, product_id" .
1999-10-13 03:00:35 +04:00
" ) VALUES ( " .
SqlQuote($version) . "," .
2002-08-12 09:43:05 +04:00
$product_id . ")" );
1999-10-13 03:00:35 +04:00
2002-08-12 09:43:05 +04:00
SendSQL("INSERT INTO milestones (product_id, value) VALUES (" .
$product_id . ", " . SqlQuote($defaultmilestone) . ")");
2000-03-23 21:23:14 +03:00
2000-03-10 19:25:03 +03:00
# If we're using bug groups, then we need to create a group for this
# product as well. -JMR, 2/16/00
2003-06-26 03:23:13 +04:00
if (Param("makeproductgroups")) {
2000-03-10 19:25:03 +03:00
# Next we insert into the groups table
2004-05-12 03:17:05 +04:00
my $productgroup = $product;
while (GroupExists($productgroup)) {
$productgroup .= '_';
}
2000-03-10 19:25:03 +03:00
SendSQL("INSERT INTO groups " .
2002-09-22 21:15:13 +04:00
"(name, description, isbuggroup, last_changed) " .
2000-03-10 19:25:03 +03:00
"VALUES (" .
2004-05-12 03:17:05 +04:00
SqlQuote($productgroup) . ", " .
2002-09-22 21:15:13 +04:00
SqlQuote("Access to bugs in the $product product") . ", 1, NOW())");
2005-02-18 19:01:48 +03:00
my $gid = $dbh->bz_last_key('groups', 'id');
2002-09-22 21:15:13 +04:00
my $admin = GroupNameToId('admin');
2004-07-27 20:33:41 +04:00
# If we created a new group, give the "admin" group priviledges
# initially.
SendSQL("INSERT INTO group_group_map (member_id, grantor_id, grant_type)
VALUES ($admin, $gid," . GROUP_MEMBERSHIP .")");
SendSQL("INSERT INTO group_group_map (member_id, grantor_id, grant_type)
VALUES ($admin, $gid," . GROUP_BLESS .")");
SendSQL("INSERT INTO group_group_map (member_id, grantor_id, grant_type)
VALUES ($admin, $gid," . GROUP_VISIBLE .")");
2002-11-24 22:56:34 +03:00
# Associate the new group and new product.
SendSQL("INSERT INTO group_control_map " .
"(group_id, product_id, entry, " .
"membercontrol, othercontrol, canedit) VALUES " .
"($gid, $product_id, " . Param("useentrygroupdefault") .
", " . CONTROLMAPDEFAULT . ", " .
CONTROLMAPNA . ", 0)");
2003-06-26 03:23:13 +04:00
}
2002-11-24 22:56:34 +03:00
2005-04-09 03:51:02 +04:00
if ($cgi->param('createseries')) {
2004-07-06 05:12:29 +04:00
# Insert default charting queries for this product.
# If they aren't using charting, this won't do any harm.
GetVersionTable();
2004-07-17 05:55:37 +04:00
2005-04-09 03:51:02 +04:00
# $open_name and $product are sqlquoted by the series code
# and never used again here, so we can trick_taint them.
my $open_name = $cgi->param('open_name');
trick_taint($open_name);
2004-07-17 05:55:37 +04:00
trick_taint($product);
2004-07-06 05:12:29 +04:00
my @series;
# We do every status, every resolution, and an "opened" one as well.
foreach my $bug_status (@::legal_bug_status) {
2004-08-30 01:29:36 +04:00
push(@series, [$bug_status,
"bug_status=" . url_quote($bug_status)]);
2004-07-06 05:12:29 +04:00
}
2003-06-26 03:23:13 +04:00
2004-07-06 05:12:29 +04:00
foreach my $resolution (@::legal_resolution) {
next if !$resolution;
2004-08-30 01:29:36 +04:00
push(@series, [$resolution, "resolution=" .url_quote($resolution)]);
2004-07-06 05:12:29 +04:00
}
2003-06-26 03:23:13 +04:00
2004-07-06 05:12:29 +04:00
# For localisation reasons, we get the name of the "global" subcategory
# and the title of the "open" query from the submitted form.
2004-08-30 01:29:36 +04:00
my @openedstatuses = OpenStates();
my $query =
join("&", map { "bug_status=" . url_quote($_) } @openedstatuses);
2005-04-09 03:51:02 +04:00
push(@series, [$open_name, $query]);
2004-07-06 05:12:29 +04:00
foreach my $sdata (@series) {
my $series = new Bugzilla::Series(undef, $product,
2005-04-09 03:51:02 +04:00
scalar $cgi->param('subcategory'),
2004-08-30 01:29:36 +04:00
$sdata->[0], $::userid, 1,
$sdata->[1] . "&product=" . url_quote($product), 1);
2004-07-06 05:12:29 +04:00
$series->writeToDatabase();
}
2000-03-10 19:25:03 +03:00
}
1999-10-13 03:00:35 +04:00
# Make versioncache flush
2003-11-22 06:50:42 +03:00
unlink "$datadir/versioncache";
1999-10-13 03:00:35 +04:00
print "OK, done.<p>\n";
2003-09-27 03:47:07 +04:00
PutTrailer($localtrailer,
2003-11-16 12:30:07 +03:00
"<a href=\"editproducts.cgi?action=add\">add</a> a new product",
2003-09-27 03:47:07 +04:00
"<a href=\"editcomponents.cgi?action=add&product=" .
2004-08-21 01:49:20 +04:00
url_quote($product) . $classhtmlvar .
"\">add</a> components to this new product");
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') {
PutHeader("Delete product");
CheckProduct($product);
2004-08-21 01:49:20 +04:00
my $classification_id=1;
if (Param('useclassification')) {
CheckClassificationProduct($classification,$product);
$classification_id = get_classification_id($classification);
}
1999-10-13 03:00:35 +04:00
# display some data about the product
2004-08-21 01:49:20 +04:00
SendSQL("SELECT classifications.description,
products.id, products.description, milestoneurl, disallownew
FROM products,classifications
WHERE products.name=" . SqlQuote($product) .
" AND classifications.id=" . SqlQuote($classification_id));
my ($class_description, $product_id, $prod_description, $milestoneurl, $disallownew) = FetchSQLData();
2001-09-28 03:49:07 +04:00
my $milestonelink = $milestoneurl ? "<a href=\"$milestoneurl\">$milestoneurl</a>"
: "<font color=\"red\">missing</font>";
2004-08-21 01:49:20 +04:00
$prod_description ||= "<FONT COLOR=\"red\">description missing</FONT>";
$class_description ||= "<FONT COLOR=\"red\">description missing</FONT>";
1999-10-13 03:00:35 +04:00
$disallownew = $disallownew ? 'closed' : 'open';
print "<TABLE BORDER=1 CELLPADDING=4 CELLSPACING=0>\n";
print "<TR BGCOLOR=\"#6666FF\">\n";
print " <TH VALIGN=\"top\" ALIGN=\"left\">Part</TH>\n";
print " <TH VALIGN=\"top\" ALIGN=\"left\">Value</TH>\n";
2004-08-21 01:49:20 +04:00
if (Param('useclassification')) {
print "</TR><TR>\n";
print " <TD VALIGN=\"top\">Classification:</TD>\n";
print " <TD VALIGN=\"top\">$classification</TD>\n";
print "</TR><TR>\n";
print " <TD VALIGN=\"top\">Description:</TD>\n";
print " <TD VALIGN=\"top\">$class_description</TD>\n";
}
1999-10-13 03:00:35 +04:00
print "</TR><TR>\n";
print " <TD VALIGN=\"top\">Product:</TD>\n";
print " <TD VALIGN=\"top\">$product</TD>\n";
print "</TR><TR>\n";
print " <TD VALIGN=\"top\">Description:</TD>\n";
2004-08-21 01:49:20 +04:00
print " <TD VALIGN=\"top\">$prod_description</TD>\n";
1999-10-13 03:00:35 +04:00
if (Param('usetargetmilestone')) {
print "</TR><TR>\n";
print " <TD VALIGN=\"top\">Milestone URL:</TD>\n";
2001-09-28 03:49:07 +04:00
print " <TD VALIGN=\"top\">$milestonelink</TD>\n";
1999-10-13 03:00:35 +04:00
}
2000-03-10 19:25:03 +03:00
1999-10-13 03:00:35 +04:00
print "</TR><TR>\n";
print " <TD VALIGN=\"top\">Closed for bugs:</TD>\n";
print " <TD VALIGN=\"top\">$disallownew</TD>\n";
print "</TR><TR>\n";
print " <TD VALIGN=\"top\">Components:</TD>\n";
print " <TD VALIGN=\"top\">";
2002-08-12 09:43:05 +04:00
SendSQL("SELECT name,description
1999-10-13 03:00:35 +04:00
FROM components
2002-08-12 09:43:05 +04:00
WHERE product_id=$product_id");
1999-10-13 03:00:35 +04:00
if (MoreSQLData()) {
print "<table>";
while ( MoreSQLData() ) {
my ($component, $description) = FetchSQLData();
$description ||= "<FONT COLOR=\"red\">description missing</FONT>";
print "<tr><th align=right valign=top>$component:</th>";
print "<td valign=top>$description</td></tr>\n";
}
print "</table>\n";
} else {
print "<FONT COLOR=\"red\">missing</FONT>";
}
print "</TD>\n</TR><TR>\n";
print " <TD VALIGN=\"top\">Versions:</TD>\n";
print " <TD VALIGN=\"top\">";
SendSQL("SELECT value
FROM versions
2002-08-12 09:43:05 +04:00
WHERE product_id=$product_id
1999-10-13 03:00:35 +04:00
ORDER BY value");
if (MoreSQLData()) {
my $br = 0;
while ( MoreSQLData() ) {
my ($version) = FetchSQLData();
print "<BR>" if $br;
print $version;
$br = 1;
}
} else {
print "<FONT COLOR=\"red\">missing</FONT>";
}
2000-03-21 19:47:06 +03:00
#
# Adding listing for associated target milestones - matthew@zeroknowledge.com
#
if (Param('usetargetmilestone')) {
print "</TD>\n</TR><TR>\n";
2004-08-21 01:49:20 +04:00
print " <TH ALIGN=\"right\" VALIGN=\"top\"><A HREF=\"editmilestones.cgi?product=", url_quote($product), $classhtmlvar, "\">Edit milestones:</A></TH>\n";
2000-03-21 19:47:06 +03:00
print " <TD>";
SendSQL("SELECT value
FROM milestones
2002-08-12 09:43:05 +04:00
WHERE product_id=$product_id
2000-03-21 19:47:06 +03:00
ORDER BY sortkey,value");
if(MoreSQLData()) {
my $br = 0;
while ( MoreSQLData() ) {
my ($milestone) = FetchSQLData();
print "<BR>" if $br;
print $milestone;
$br = 1;
}
} else {
print "<FONT COLOR=\"red\">missing</FONT>";
}
}
1999-10-13 03:00:35 +04:00
print "</TD>\n</TR><TR>\n";
print " <TD VALIGN=\"top\">Bugs:</TD>\n";
print " <TD VALIGN=\"top\">";
2005-03-16 03:27:15 +03:00
SendSQL("SELECT count(bug_id), product_id
FROM bugs " .
$dbh->sql_group_by('product_id') . "
HAVING product_id = $product_id");
1999-10-13 03:00:35 +04:00
my $bugs = FetchOneColumn();
print $bugs || 'none';
print "</TD>\n</TR></TABLE>";
print "<H2>Confirmation</H2>\n";
if ($bugs) {
if (!Param("allowbugdeletion")) {
print "Sorry, there are $bugs bugs outstanding for this product.
You must reassign those bugs to another product before you can delete this
one.";
PutTrailer($localtrailer);
exit;
}
print "<TABLE BORDER=0 CELLPADDING=20 WIDTH=\"70%\" BGCOLOR=\"red\"><TR><TD>\n",
"There are bugs entered for this product! When you delete this ",
2005-05-17 03:39:17 +04:00
"product, <B><BLINK>ALL</BLINK></B> stored bugs and their history will be ",
"deleted too.\n",
1999-10-13 03:00:35 +04:00
"</TD></TR></TABLE>\n";
}
print "<P>Do you really want to delete this product?<P>\n";
print "<FORM METHOD=POST ACTION=editproducts.cgi>\n";
print "<INPUT TYPE=SUBMIT VALUE=\"Yes, delete\">\n";
print "<INPUT TYPE=HIDDEN NAME=\"action\" VALUE=\"delete\">\n";
1999-10-20 01:27:41 +04:00
print "<INPUT TYPE=HIDDEN NAME=\"product\" VALUE=\"" .
2002-11-24 22:56:34 +03:00
html_quote($product) . "\">\n";
2004-08-21 01:49:20 +04:00
print "<INPUT TYPE=HIDDEN NAME=\"classification\" VALUE=\"" .
html_quote($classification) . "\">\n";
1999-10-13 03:00:35 +04:00
print "</FORM>";
PutTrailer($localtrailer);
exit;
}
#
# action='delete' -> really delete the product
#
if ($action eq 'delete') {
CheckProduct($product);
2002-08-12 09:43:05 +04:00
my $product_id = get_product_id($product);
1999-10-13 03:00:35 +04:00
2005-04-06 04:19:56 +04:00
my $bug_ids =
$dbh->selectcol_arrayref("SELECT bug_id FROM bugs WHERE product_id = ?",
undef, $product_id);
1999-10-13 03:00:35 +04:00
2005-04-06 04:19:56 +04:00
my $nb_bugs = scalar(@$bug_ids);
if ($nb_bugs) {
if (Param("allowbugdeletion")) {
foreach my $bug_id (@$bug_ids) {
my $bug = new Bugzilla::Bug($bug_id, $whoid);
$bug->remove_from_db();
}
1999-12-17 06:41:13 +03:00
}
2005-04-06 04:19:56 +04:00
else {
ThrowUserError("product_has_bugs", { nb => $nb_bugs });
}
}
1999-10-13 03:00:35 +04:00
2005-04-06 04:19:56 +04:00
PutHeader("Deleting product");
print "All references to deleted bugs removed.<P>\n" if $nb_bugs;
1999-10-13 03:00:35 +04:00
2005-04-06 04:19:56 +04:00
$dbh->bz_lock_tables('products WRITE', 'components WRITE',
'versions WRITE', 'milestones WRITE',
'group_control_map WRITE',
'flaginclusions WRITE', 'flagexclusions WRITE');
1999-10-13 03:00:35 +04:00
2005-04-06 04:19:56 +04:00
$dbh->do("DELETE FROM components WHERE product_id = ?", undef, $product_id);
1999-10-13 03:00:35 +04:00
print "Components deleted.<BR>\n";
2005-04-06 04:19:56 +04:00
$dbh->do("DELETE FROM versions WHERE product_id = ?", undef, $product_id);
print "Versions deleted.<BR>\n";
1999-10-13 03:00:35 +04:00
2005-04-06 04:19:56 +04:00
$dbh->do("DELETE FROM milestones WHERE product_id = ?", undef, $product_id);
print "Milestones deleted.<P>\n";
2000-03-21 19:47:06 +03:00
2005-04-06 04:19:56 +04:00
$dbh->do("DELETE FROM group_control_map WHERE product_id = ?",
undef, $product_id);
2002-11-24 22:56:34 +03:00
print "Group controls deleted.<BR>\n";
2005-04-06 04:19:56 +04:00
$dbh->do("DELETE FROM flaginclusions WHERE product_id = ?",
undef, $product_id);
$dbh->do("DELETE FROM flagexclusions WHERE product_id = ?",
undef, $product_id);
print "Flag inclusions and exclusions deleted.<P>\n";
2002-09-28 22:42:54 +04:00
2005-04-06 04:19:56 +04:00
$dbh->do("DELETE FROM products WHERE id = ?", undef, $product_id);
print "Product '$product' deleted.<P>\n";
2000-03-10 19:25:03 +03:00
2005-02-18 00:57:27 +03:00
$dbh->bz_unlock_tables();
2003-11-22 06:50:42 +03:00
unlink "$datadir/versioncache";
1999-10-13 03:00:35 +04:00
PutTrailer($localtrailer);
exit;
}
#
2005-03-24 00:24:19 +03:00
# action='edit' -> present the 'edit product' form
# If a product is given with no action associated with it, then edit it.
1999-10-13 03:00:35 +04:00
#
# (next action would be 'update')
#
2005-03-24 00:24:19 +03:00
if ($action eq 'edit' || (!$action && $product)) {
1999-10-13 03:00:35 +04:00
PutHeader("Edit product");
CheckProduct($product);
2004-08-21 01:49:20 +04:00
my $classification_id=1;
if (Param('useclassification')) {
2005-03-24 00:24:19 +03:00
# If a product has been given with no classification associated
# with it, take this information from the DB
if ($classification) {
CheckClassificationProduct($classification, $product);
} else {
trick_taint($product);
$classification =
$dbh->selectrow_array("SELECT classifications.name
FROM products, classifications
WHERE products.name = ?
AND classifications.id = products.classification_id",
undef, $product);
}
2004-08-21 01:49:20 +04:00
$classification_id = get_classification_id($classification);
}
1999-10-13 03:00:35 +04:00
# get data of product
2004-08-21 01:49:20 +04:00
SendSQL("SELECT classifications.description,
products.id,products.description,milestoneurl,disallownew,
2000-03-23 21:23:14 +03:00
votesperuser,maxvotesperbug,votestoconfirm,defaultmilestone
2004-08-21 01:49:20 +04:00
FROM products,classifications
WHERE products.name=" . SqlQuote($product) .
" AND classifications.id=" . SqlQuote($classification_id));
my ($class_description, $product_id,$prod_description, $milestoneurl, $disallownew,
2000-03-23 21:23:14 +03:00
$votesperuser, $maxvotesperbug, $votestoconfirm, $defaultmilestone) =
2000-01-05 00:29:51 +03:00
FetchSQLData();
1999-10-13 03:00:35 +04:00
print "<FORM METHOD=POST ACTION=editproducts.cgi>\n";
1999-10-20 01:26:39 +04:00
print "<TABLE BORDER=0 CELLPADDING=4 CELLSPACING=0><TR>\n";
1999-10-13 03:00:35 +04:00
2004-08-21 01:49:20 +04:00
EmitFormElements($classification, $product, $prod_description, $milestoneurl,
2000-03-10 19:25:03 +03:00
$disallownew, $votesperuser, $maxvotesperbug,
2000-03-23 21:23:14 +03:00
$votestoconfirm, $defaultmilestone);
1999-10-13 03:00:35 +04:00
1999-10-20 01:26:39 +04:00
print "</TR><TR VALIGN=top>\n";
2004-08-21 01:49:20 +04:00
print " <TH ALIGN=\"right\"><A HREF=\"editcomponents.cgi?product=", url_quote($product), $classhtmlvar, "\">Edit components:</A></TH>\n";
1999-10-13 03:00:35 +04:00
print " <TD>";
2002-08-12 09:43:05 +04:00
SendSQL("SELECT name,description
1999-10-13 03:00:35 +04:00
FROM components
2002-08-12 09:43:05 +04:00
WHERE product_id=$product_id");
1999-10-13 03:00:35 +04:00
if (MoreSQLData()) {
print "<table>";
while ( MoreSQLData() ) {
my ($component, $description) = FetchSQLData();
$description ||= "<FONT COLOR=\"red\">description missing</FONT>";
print "<tr><th align=right valign=top>$component:</th>";
print "<td valign=top>$description</td></tr>\n";
}
print "</table>\n";
} else {
print "<FONT COLOR=\"red\">missing</FONT>";
}
print "</TD>\n</TR><TR>\n";
2004-08-21 01:49:20 +04:00
print " <TH ALIGN=\"right\" VALIGN=\"top\"><A HREF=\"editversions.cgi?product=", url_quote($product), $classhtmlvar, "\">Edit versions:</A></TH>\n";
1999-10-13 03:00:35 +04:00
print " <TD>";
SendSQL("SELECT value
FROM versions
2002-08-12 09:43:05 +04:00
WHERE product_id=$product_id
1999-10-13 03:00:35 +04:00
ORDER BY value");
if (MoreSQLData()) {
my $br = 0;
while ( MoreSQLData() ) {
my ($version) = FetchSQLData();
print "<BR>" if $br;
print $version;
$br = 1;
}
} else {
print "<FONT COLOR=\"red\">missing</FONT>";
}
2000-03-21 19:47:06 +03:00
#
# Adding listing for associated target milestones - matthew@zeroknowledge.com
#
if (Param('usetargetmilestone')) {
print "</TD>\n</TR><TR>\n";
2004-08-21 01:49:20 +04:00
print " <TH ALIGN=\"right\" VALIGN=\"top\"><A HREF=\"editmilestones.cgi?product=", url_quote($product), $classhtmlvar, "\">Edit milestones:</A></TH>\n";
2000-03-21 19:47:06 +03:00
print " <TD>";
SendSQL("SELECT value
FROM milestones
2002-08-12 09:43:05 +04:00
WHERE product_id=$product_id
2000-03-21 19:47:06 +03:00
ORDER BY sortkey,value");
if(MoreSQLData()) {
my $br = 0;
while ( MoreSQLData() ) {
my ($milestone) = FetchSQLData();
print "<BR>" if $br;
print $milestone;
$br = 1;
}
} else {
print "<FONT COLOR=\"red\">missing</FONT>";
}
}
1999-10-13 03:00:35 +04:00
2002-11-24 22:56:34 +03:00
print "</TD>\n</TR><TR>\n";
2004-08-21 01:49:20 +04:00
print " <TH ALIGN=\"right\" VALIGN=\"top\"><A HREF=\"editproducts.cgi?action=editgroupcontrols&product=", url_quote($product), $classhtmlvar,"\">Edit Group Access Controls</A></TH>\n";
2002-11-24 22:56:34 +03:00
print "<TD>\n";
SendSQL("SELECT id, name, isactive, entry, membercontrol, othercontrol, canedit " .
"FROM groups, " .
"group_control_map " .
"WHERE group_control_map.group_id = id AND product_id = $product_id " .
"AND isbuggroup != 0 ORDER BY name");
while (MoreSQLData()) {
my ($id, $name, $isactive, $entry, $membercontrol, $othercontrol, $canedit)
= FetchSQLData();
print "<B>" . html_quote($name) . ":</B> ";
if ($isactive) {
print $ctl{$membercontrol} . "/" . $ctl{$othercontrol};
print ", ENTRY" if $entry;
print ", CANEDIT" if $canedit;
} else {
print "DISABLED";
}
print "<BR>\n";
}
1999-10-13 03:00:35 +04:00
print "</TD>\n</TR><TR>\n";
print " <TH ALIGN=\"right\">Bugs:</TH>\n";
print " <TD>";
2005-03-16 03:27:15 +03:00
SendSQL("SELECT count(bug_id), product_id
FROM bugs " .
$dbh->sql_group_by('product_id') . "
HAVING product_id = $product_id");
1999-10-13 03:00:35 +04:00
my $bugs = '';
$bugs = FetchOneColumn() if MoreSQLData();
print $bugs || 'none';
print "</TD>\n</TR></TABLE>\n";
2004-08-21 01:49:20 +04:00
print "<INPUT TYPE=HIDDEN NAME=\"classification\" VALUE=\"" .
html_quote($classification) . "\">\n";
1999-10-20 01:27:41 +04:00
print "<INPUT TYPE=HIDDEN NAME=\"productold\" VALUE=\"" .
2002-11-24 22:56:34 +03:00
html_quote($product) . "\">\n";
1999-10-20 01:27:41 +04:00
print "<INPUT TYPE=HIDDEN NAME=\"descriptionold\" VALUE=\"" .
2004-08-21 01:49:20 +04:00
html_quote($prod_description) . "\">\n";
1999-10-20 01:27:41 +04:00
print "<INPUT TYPE=HIDDEN NAME=\"milestoneurlold\" VALUE=\"" .
2002-11-24 22:56:34 +03:00
html_quote($milestoneurl) . "\">\n";
1999-10-13 03:00:35 +04:00
print "<INPUT TYPE=HIDDEN NAME=\"disallownewold\" VALUE=\"$disallownew\">\n";
2000-01-05 00:29:51 +03:00
print "<INPUT TYPE=HIDDEN NAME=\"votesperuserold\" VALUE=\"$votesperuser\">\n";
2000-02-17 08:15:23 +03:00
print "<INPUT TYPE=HIDDEN NAME=\"maxvotesperbugold\" VALUE=\"$maxvotesperbug\">\n";
print "<INPUT TYPE=HIDDEN NAME=\"votestoconfirmold\" VALUE=\"$votestoconfirm\">\n";
2000-03-23 21:23:14 +03:00
$defaultmilestone = value_quote($defaultmilestone);
print "<INPUT TYPE=HIDDEN NAME=\"defaultmilestoneold\" VALUE=\"$defaultmilestone\">\n";
1999-10-13 03:00:35 +04:00
print "<INPUT TYPE=HIDDEN NAME=\"action\" VALUE=\"update\">\n";
print "<INPUT TYPE=SUBMIT VALUE=\"Update\">\n";
print "</FORM>";
my $x = $localtrailer;
$x =~ s/more/other/;
PutTrailer($x);
exit;
}
2002-11-24 22:56:34 +03:00
#
# action='updategroupcontrols' -> update the product
#
if ($action eq 'updategroupcontrols') {
my $product_id = get_product_id($product);
my @now_na = ();
my @now_mandatory = ();
2005-04-09 03:51:02 +04:00
foreach my $f ($cgi->param()) {
2002-11-24 22:56:34 +03:00
if ($f =~ /^membercontrol_(\d+)$/) {
my $id = $1;
2005-04-09 03:51:02 +04:00
if ($cgi->param($f) == CONTROLMAPNA) {
2002-11-24 22:56:34 +03:00
push @now_na,$id;
2005-04-09 03:51:02 +04:00
} elsif ($cgi->param($f) == CONTROLMAPMANDATORY) {
2002-11-24 22:56:34 +03:00
push @now_mandatory,$id;
}
}
}
2005-04-09 03:51:02 +04:00
if (!defined $cgi->param('confirmed')) {
2002-11-24 22:56:34 +03:00
my @na_groups = ();
if (@now_na) {
SendSQL("SELECT groups.name, COUNT(bugs.bug_id)
FROM bugs, bug_group_map, groups
2005-03-16 03:27:15 +03:00
WHERE groups.id IN(" . join(', ', @now_na) . ")
2002-11-24 22:56:34 +03:00
AND bug_group_map.group_id = groups.id
AND bug_group_map.bug_id = bugs.bug_id
2005-03-16 03:27:15 +03:00
AND bugs.product_id = $product_id " .
$dbh->sql_group_by('groups.name'));
2002-11-24 22:56:34 +03:00
while (MoreSQLData()) {
my ($groupname, $bugcount) = FetchSQLData();
my %g = ();
$g{'name'} = $groupname;
$g{'count'} = $bugcount;
push @na_groups,\%g;
}
}
my @mandatory_groups = ();
if (@now_mandatory) {
SendSQL("SELECT groups.name, COUNT(bugs.bug_id)
2005-05-02 22:52:02 +04:00
FROM bugs
LEFT JOIN bug_group_map
ON bug_group_map.bug_id = bugs.bug_id
INNER JOIN groups
ON bug_group_map.group_id = groups.id
WHERE groups.id IN(" . join(', ', @now_mandatory) . ")
AND bugs.product_id = $product_id
AND bug_group_map.bug_id IS NULL " .
$dbh->sql_group_by('groups.name'));
2002-11-24 22:56:34 +03:00
while (MoreSQLData()) {
my ($groupname, $bugcount) = FetchSQLData();
my %g = ();
$g{'name'} = $groupname;
$g{'count'} = $bugcount;
push @mandatory_groups,\%g;
}
}
if ((@na_groups) || (@mandatory_groups)) {
$vars->{'product'} = $product;
$vars->{'na_groups'} = \@na_groups;
$vars->{'mandatory_groups'} = \@mandatory_groups;
$template->process("admin/products/groupcontrol/confirm-edit.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
}
}
PutHeader("Update group access controls for product \"$product\"");
$headerdone = 1;
SendSQL("SELECT id, name FROM groups " .
"WHERE isbuggroup != 0 AND isactive != 0");
while (MoreSQLData()){
my ($groupid, $groupname) = FetchSQLData();
2005-04-09 03:51:02 +04:00
my $newmembercontrol = $cgi->param("membercontrol_$groupid") || 0;
my $newothercontrol = $cgi->param("othercontrol_$groupid") || 0;
2002-11-24 22:56:34 +03:00
# Legality of control combination is a function of
# membercontrol\othercontrol
# NA SH DE MA
# NA + - - -
# SH + + + +
# DE + - + +
# MA - - - +
unless (($newmembercontrol == $newothercontrol)
|| ($newmembercontrol == CONTROLMAPSHOWN)
|| (($newmembercontrol == CONTROLMAPDEFAULT)
&& ($newothercontrol != CONTROLMAPSHOWN))) {
ThrowUserError('illegal_group_control_combination',
{groupname => $groupname,
header_done => 1});
}
}
2005-02-18 00:57:27 +03:00
$dbh->bz_lock_tables('groups READ',
'group_control_map WRITE',
'bugs WRITE',
'bugs_activity WRITE',
'bug_group_map WRITE',
'fielddefs READ');
2002-11-24 22:56:34 +03:00
SendSQL("SELECT id, name, entry, membercontrol, othercontrol, canedit " .
"FROM groups " .
"LEFT JOIN group_control_map " .
"ON group_control_map.group_id = id AND product_id = $product_id " .
"WHERE isbuggroup != 0 AND isactive != 0");
while (MoreSQLData()) {
my ($groupid, $groupname, $entry, $membercontrol,
$othercontrol, $canedit) = FetchSQLData();
2005-04-09 03:51:02 +04:00
my $newentry = $cgi->param("entry_$groupid") || 0;
my $newmembercontrol = $cgi->param("membercontrol_$groupid") || 0;
my $newothercontrol = $cgi->param("othercontrol_$groupid") || 0;
my $newcanedit = $cgi->param("canedit_$groupid") || 0;
2002-11-24 22:56:34 +03:00
my $oldentry = $entry;
$entry = $entry || 0;
$membercontrol = $membercontrol || 0;
$othercontrol = $othercontrol || 0;
$canedit = $canedit || 0;
detaint_natural($newentry);
detaint_natural($newothercontrol);
detaint_natural($newmembercontrol);
detaint_natural($newcanedit);
if ((!defined($oldentry)) &&
(($newentry) || ($newmembercontrol) || ($newcanedit))) {
PushGlobalSQLState();
SendSQL("INSERT INTO group_control_map " .
"(group_id, product_id, entry, " .
"membercontrol, othercontrol, canedit) " .
"VALUES " .
"($groupid, $product_id, $newentry, " .
"$newmembercontrol, $newothercontrol, $newcanedit)");
PopGlobalSQLState();
} elsif (($newentry != $entry)
|| ($newmembercontrol != $membercontrol)
|| ($newothercontrol != $othercontrol)
|| ($newcanedit != $canedit)) {
PushGlobalSQLState();
SendSQL("UPDATE group_control_map " .
"SET entry = $newentry, " .
"membercontrol = $newmembercontrol, " .
"othercontrol = $newothercontrol, " .
"canedit = $newcanedit " .
"WHERE group_id = $groupid " .
"AND product_id = $product_id");
PopGlobalSQLState();
}
if (($newentry == 0) && ($newmembercontrol == 0)
&& ($newothercontrol == 0) && ($newcanedit == 0)) {
PushGlobalSQLState();
SendSQL("DELETE FROM group_control_map " .
"WHERE group_id = $groupid " .
"AND product_id = $product_id");
PopGlobalSQLState();
}
}
foreach my $groupid (@now_na) {
print "Removing bugs from NA group "
. html_quote(GroupIdToName($groupid)) . "<P>\n";
my $count = 0;
SendSQL("SELECT bugs.bug_id,
(lastdiffed >= delta_ts)
FROM bugs, bug_group_map
WHERE group_id = $groupid
AND bug_group_map.bug_id = bugs.bug_id
AND bugs.product_id = $product_id
ORDER BY bugs.bug_id");
while (MoreSQLData()) {
my ($bugid, $mailiscurrent) = FetchSQLData();
PushGlobalSQLState();
SendSQL("DELETE FROM bug_group_map WHERE
bug_id = $bugid AND group_id = $groupid");
SendSQL("SELECT name, NOW() FROM groups WHERE id = $groupid");
my ($removed, $timestamp) = FetchSQLData();
LogActivityEntry($bugid, "bug_group", $removed, "",
$::userid, $timestamp);
2005-02-08 19:51:03 +03:00
my $diffed = "";
2005-03-11 22:45:03 +03:00
if ($mailiscurrent) {
2005-02-08 19:51:03 +03:00
$diffed = ", lastdiffed = " . SqlQuote($timestamp);
2002-11-24 22:56:34 +03:00
}
2005-02-08 19:51:03 +03:00
SendSQL("UPDATE bugs SET delta_ts = " . SqlQuote($timestamp) .
$diffed . " WHERE bug_id = $bugid");
2002-11-24 22:56:34 +03:00
PopGlobalSQLState();
$count++;
}
print "dropped $count bugs<p>\n";
}
foreach my $groupid (@now_mandatory) {
print "Adding bugs to Mandatory group "
. html_quote(GroupIdToName($groupid)) . "<P>\n";
my $count = 0;
SendSQL("SELECT bugs.bug_id,
(lastdiffed >= delta_ts)
FROM bugs
LEFT JOIN bug_group_map
ON bug_group_map.bug_id = bugs.bug_id
AND group_id = $groupid
WHERE bugs.product_id = $product_id
AND bug_group_map.bug_id IS NULL
ORDER BY bugs.bug_id");
while (MoreSQLData()) {
my ($bugid, $mailiscurrent) = FetchSQLData();
PushGlobalSQLState();
SendSQL("INSERT INTO bug_group_map (bug_id, group_id)
VALUES ($bugid, $groupid)");
SendSQL("SELECT name, NOW() FROM groups WHERE id = $groupid");
my ($added, $timestamp) = FetchSQLData();
LogActivityEntry($bugid, "bug_group", "", $added,
$::userid, $timestamp);
2005-02-08 19:51:03 +03:00
my $diffed = "";
2005-03-11 22:45:03 +03:00
if ($mailiscurrent) {
2005-02-08 19:51:03 +03:00
$diffed = ", lastdiffed = " . SqlQuote($timestamp);
2002-11-24 22:56:34 +03:00
}
2005-02-08 19:51:03 +03:00
SendSQL("UPDATE bugs SET delta_ts = " . SqlQuote($timestamp) .
$diffed . " WHERE bug_id = $bugid");
2002-11-24 22:56:34 +03:00
PopGlobalSQLState();
$count++;
}
print "added $count bugs<p>\n";
}
2005-02-18 00:57:27 +03:00
$dbh->bz_unlock_tables();
2002-11-24 22:56:34 +03:00
print "Group control updates done<P>\n";
PutTrailer($localtrailer);
exit;
}
1999-10-13 03:00:35 +04:00
#
# action='update' -> update the product
#
if ($action eq 'update') {
PutHeader("Update product");
2005-04-09 03:51:02 +04:00
my $productold = trim($cgi->param('productold') || '');
my $description = trim($cgi->param('description') || '');
my $descriptionold = trim($cgi->param('descriptionold') || '');
my $disallownew = trim($cgi->param('disallownew') || '');
my $disallownewold = trim($cgi->param('disallownewold') || '');
my $milestoneurl = trim($cgi->param('milestoneurl') || '');
my $milestoneurlold = trim($cgi->param('milestoneurlold') || '');
my $votesperuser = trim($cgi->param('votesperuser') || 0);
my $votesperuserold = trim($cgi->param('votesperuserold') || 0);
my $maxvotesperbug = trim($cgi->param('maxvotesperbug') || 0);
my $maxvotesperbugold = trim($cgi->param('maxvotesperbugold') || 0);
my $votestoconfirm = trim($cgi->param('votestoconfirm') || 0);
my $votestoconfirmold = trim($cgi->param('votestoconfirmold') || 0);
my $defaultmilestone = trim($cgi->param('defaultmilestone') || '---');
my $defaultmilestoneold = trim($cgi->param('defaultmilestoneold') || '---');
2000-02-17 08:15:23 +03:00
my $checkvotes = 0;
1999-10-13 03:00:35 +04:00
CheckProduct($productold);
2002-08-12 09:43:05 +04:00
my $product_id = get_product_id($productold);
1999-10-13 03:00:35 +04:00
2004-07-09 00:08:55 +04:00
if (!detaint_natural($maxvotesperbug) || $maxvotesperbug == 0) {
2000-02-17 08:15:23 +03:00
print "Sorry, the max votes per bug must be a positive integer.";
PutTrailer($localtrailer);
exit;
}
2004-07-09 00:08:55 +04:00
if (!detaint_natural($votesperuser)) {
print "Sorry, the votes per user must be an integer >= 0.";
PutTrailer($localtrailer);
exit;
}
if (!detaint_natural($votestoconfirm)) {
print "Sorry, the votes to confirm must be an integer >= 0.";
PutTrailer($localtrailer);
exit;
}
2002-08-12 09:43:05 +04:00
# Note that we got the $product_id using $productold above so it will
# remain static even after we rename the product in the database.
1999-10-13 03:00:35 +04:00
2005-02-18 00:57:27 +03:00
$dbh->bz_lock_tables('products WRITE',
'versions READ',
'groups WRITE',
'group_control_map WRITE',
'profiles WRITE',
'milestones READ');
1999-10-13 03:00:35 +04:00
2000-01-11 01:17:10 +03:00
if ($disallownew ne $disallownewold) {
2004-07-08 03:49:41 +04:00
$disallownew = $disallownew ? 1 : 0;
1999-10-13 03:00:35 +04:00
SendSQL("UPDATE products
SET disallownew=$disallownew
2002-08-12 09:43:05 +04:00
WHERE id=$product_id");
1999-10-13 03:00:35 +04:00
print "Updated bug submit status.<BR>\n";
}
if ($description ne $descriptionold) {
unless ($description) {
print "Sorry, I can't delete the description.";
2005-02-18 00:57:27 +03:00
$dbh->bz_unlock_tables(UNLOCK_ABORT);
2000-01-15 01:35:49 +03:00
PutTrailer($localtrailer);
1999-10-13 03:00:35 +04:00
exit;
}
SendSQL("UPDATE products
SET description=" . SqlQuote($description) . "
2002-08-12 09:43:05 +04:00
WHERE id=$product_id");
1999-10-13 03:00:35 +04:00
print "Updated description.<BR>\n";
}
if (Param('usetargetmilestone') && $milestoneurl ne $milestoneurlold) {
SendSQL("UPDATE products
SET milestoneurl=" . SqlQuote($milestoneurl) . "
2002-08-12 09:43:05 +04:00
WHERE id=$product_id");
1999-10-13 03:00:35 +04:00
print "Updated mile stone URL.<BR>\n";
}
2000-03-10 19:25:03 +03:00
2000-01-05 00:29:51 +03:00
if ($votesperuser ne $votesperuserold) {
SendSQL("UPDATE products
SET votesperuser=$votesperuser
2002-08-12 09:43:05 +04:00
WHERE id=$product_id");
2000-03-10 19:25:03 +03:00
print "Updated votes per user.<BR>\n";
2000-02-17 08:15:23 +03:00
$checkvotes = 1;
2000-01-05 00:29:51 +03:00
}
1999-10-13 03:00:35 +04:00
2000-02-17 08:15:23 +03:00
if ($maxvotesperbug ne $maxvotesperbugold) {
SendSQL("UPDATE products
SET maxvotesperbug=$maxvotesperbug
2002-08-12 09:43:05 +04:00
WHERE id=$product_id");
2000-03-10 19:25:03 +03:00
print "Updated max votes per bug.<BR>\n";
2000-02-17 08:15:23 +03:00
$checkvotes = 1;
}
if ($votestoconfirm ne $votestoconfirmold) {
SendSQL("UPDATE products
SET votestoconfirm=$votestoconfirm
2002-08-12 09:43:05 +04:00
WHERE id=$product_id");
2000-03-10 19:25:03 +03:00
print "Updated votes to confirm.<BR>\n";
2000-02-17 08:15:23 +03:00
$checkvotes = 1;
}
2000-03-23 21:23:14 +03:00
if ($defaultmilestone ne $defaultmilestoneold) {
SendSQL("SELECT value FROM milestones " .
"WHERE value = " . SqlQuote($defaultmilestone) .
2002-08-12 09:43:05 +04:00
" AND product_id = $product_id");
2000-03-23 21:23:14 +03:00
if (!FetchOneColumn()) {
print "Sorry, the milestone $defaultmilestone must be defined first.";
2005-02-18 00:57:27 +03:00
$dbh->bz_unlock_tables(UNLOCK_ABORT);
2000-03-23 21:23:14 +03:00
PutTrailer($localtrailer);
exit;
}
SendSQL("UPDATE products " .
"SET defaultmilestone = " . SqlQuote($defaultmilestone) .
2002-08-12 09:43:05 +04:00
"WHERE id=$product_id");
2000-03-23 21:23:14 +03:00
print "Updated default milestone.<BR>\n";
}
2000-02-17 08:15:23 +03:00
my $qp = SqlQuote($product);
my $qpold = SqlQuote($productold);
1999-10-13 03:00:35 +04:00
if ($product ne $productold) {
unless ($product) {
print "Sorry, I can't delete the product name.";
2005-02-18 00:57:27 +03:00
$dbh->bz_unlock_tables(UNLOCK_ABORT);
2000-01-15 01:35:49 +03:00
PutTrailer($localtrailer);
1999-10-13 03:00:35 +04:00
exit;
}
2004-07-20 09:06:18 +04:00
if (lc($product) ne lc($productold) &&
TestProduct($product)) {
1999-10-13 03:00:35 +04:00
print "Sorry, product name '$product' is already in use.";
2005-02-18 00:57:27 +03:00
$dbh->bz_unlock_tables(UNLOCK_ABORT);
2000-01-15 01:35:49 +03:00
PutTrailer($localtrailer);
1999-10-13 03:00:35 +04:00
exit;
}
2002-08-12 09:43:05 +04:00
SendSQL("UPDATE products SET name=$qp WHERE id=$product_id");
1999-10-13 03:00:35 +04:00
print "Updated product name.<BR>\n";
}
2005-02-18 00:57:27 +03:00
$dbh->bz_unlock_tables();
2003-11-22 06:50:42 +03:00
unlink "$datadir/versioncache";
1999-10-13 03:00:35 +04:00
2000-02-17 08:15:23 +03:00
if ($checkvotes) {
2004-12-11 16:33:27 +03:00
# 1. too many votes for a single user on a single bug.
2000-02-17 08:15:23 +03:00
if ($maxvotesperbug < $votesperuser) {
2004-12-11 16:33:27 +03:00
print "<br>Checking existing votes in this product for anybody who now has too many votes for a single bug.";
2000-02-17 08:15:23 +03:00
SendSQL("SELECT votes.who, votes.bug_id " .
"FROM votes, bugs " .
"WHERE bugs.bug_id = votes.bug_id " .
2002-08-12 09:43:05 +04:00
" AND bugs.product_id = $product_id " .
2003-04-27 11:20:39 +04:00
" AND votes.vote_count > $maxvotesperbug");
2000-02-17 08:15:23 +03:00
my @list;
while (MoreSQLData()) {
my ($who, $id) = (FetchSQLData());
push(@list, [$who, $id]);
}
foreach my $ref (@list) {
my ($who, $id) = (@$ref);
RemoveVotes($id, $who, "The rules for voting on this product has changed;\nyou had too many votes for a single bug.");
my $name = DBID_to_name($who);
print qq{<br>Removed votes for bug <A HREF="show_bug.cgi?id=$id">$id</A> from $name\n};
}
}
2004-12-11 16:33:27 +03:00
# 2. too many total votes for a single user.
# This part doesn't work in the general case because RemoveVotes
# doesn't enforce votesperuser (except per-bug when it's less
# than maxvotesperbug). See RemoveVotes in globals.pl.
print "<br>Checking existing votes in this product for anybody who now has too many total votes.";
2003-04-27 11:20:39 +04:00
SendSQL("SELECT votes.who, votes.vote_count FROM votes, bugs " .
2000-02-17 08:15:23 +03:00
"WHERE bugs.bug_id = votes.bug_id " .
2002-08-12 09:43:05 +04:00
" AND bugs.product_id = $product_id");
2000-02-17 08:15:23 +03:00
my %counts;
while (MoreSQLData()) {
my ($who, $count) = (FetchSQLData());
if (!defined $counts{$who}) {
$counts{$who} = $count;
} else {
$counts{$who} += $count;
}
}
foreach my $who (keys(%counts)) {
if ($counts{$who} > $votesperuser) {
SendSQL("SELECT votes.bug_id FROM votes, bugs " .
"WHERE bugs.bug_id = votes.bug_id " .
2002-08-12 09:43:05 +04:00
" AND bugs.product_id = $product_id " .
2000-02-17 08:15:23 +03:00
" AND votes.who = $who");
while (MoreSQLData()) {
2004-12-11 16:33:27 +03:00
my ($id) = FetchSQLData();
2000-02-17 08:15:23 +03:00
RemoveVotes($id, $who,
"The rules for voting on this product has changed; you had too many\ntotal votes, so all votes have been removed.");
my $name = DBID_to_name($who);
print qq{<br>Removed votes for bug <A HREF="show_bug.cgi?id=$id">$id</A> from $name\n};
}
}
}
2004-12-11 16:33:27 +03:00
# 3. enough votes to confirm
2000-02-17 08:15:23 +03:00
SendSQL("SELECT bug_id FROM bugs " .
2002-08-12 09:43:05 +04:00
"WHERE product_id = $product_id " .
2005-02-08 19:22:26 +03:00
" AND bug_status = 'UNCONFIRMED' " .
2000-02-17 08:15:23 +03:00
" AND votes >= $votestoconfirm");
2004-12-11 16:33:27 +03:00
if (MoreSQLData()) {
print "<br>Checking unconfirmed bugs in this product for any which now have sufficient votes.";
2000-02-17 08:15:23 +03:00
}
2004-12-11 16:33:27 +03:00
while (MoreSQLData()) {
# The user id below is used for activity log purposes
CheckIfVotedConfirmed(FetchOneColumn(), Bugzilla->user->id);
2000-02-17 08:15:23 +03:00
}
}
1999-10-13 03:00:35 +04:00
PutTrailer($localtrailer);
exit;
}
2002-11-24 22:56:34 +03:00
#
# action='editgroupcontrols' -> update product group controls
#
if ($action eq 'editgroupcontrols') {
my $product_id = get_product_id($product);
2005-01-08 21:15:46 +03:00
$product_id
|| ThrowUserError("invalid_product_name", { product => $product });
2002-11-24 22:56:34 +03:00
# Display a group if it is either enabled or has bugs for this product.
SendSQL("SELECT id, name, entry, membercontrol, othercontrol, canedit, " .
"isactive, COUNT(bugs.bug_id) " .
"FROM groups " .
"LEFT JOIN group_control_map " .
"ON group_control_map.group_id = id " .
"AND group_control_map.product_id = $product_id " .
"LEFT JOIN bug_group_map " .
"ON bug_group_map.group_id = groups.id " .
"LEFT JOIN bugs " .
"ON bugs.bug_id = bug_group_map.bug_id " .
"AND bugs.product_id = $product_id " .
"WHERE isbuggroup != 0 " .
"AND (isactive != 0 OR entry IS NOT NULL " .
"OR bugs.bug_id IS NOT NULL) " .
2005-03-16 03:27:15 +03:00
$dbh->sql_group_by('name', 'id, entry, membercontrol,
othercontrol, canedit, isactive'));
2002-11-24 22:56:34 +03:00
my @groups = ();
while (MoreSQLData()) {
my %group = ();
my ($groupid, $groupname, $entry, $membercontrol, $othercontrol,
$canedit, $isactive, $bugcount) = FetchSQLData();
$group{'id'} = $groupid;
$group{'name'} = $groupname;
$group{'entry'} = $entry;
$group{'membercontrol'} = $membercontrol;
$group{'othercontrol'} = $othercontrol;
$group{'canedit'} = $canedit;
$group{'isactive'} = $isactive;
$group{'bugcount'} = $bugcount;
push @groups,\%group;
}
$vars->{'header_done'} = $headerdone;
$vars->{'product'} = $product;
2004-08-21 01:49:20 +04:00
$vars->{'classification'} = $classification;
2002-11-24 22:56:34 +03:00
$vars->{'groups'} = \@groups;
$vars->{'const'} = {
'CONTROLMAPNA' => CONTROLMAPNA,
'CONTROLMAPSHOWN' => CONTROLMAPSHOWN,
'CONTROLMAPDEFAULT' => CONTROLMAPDEFAULT,
'CONTROLMAPMANDATORY' => CONTROLMAPMANDATORY,
};
$template->process("admin/products/groupcontrol/edit.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
print "<!-- \n";
print "<script type=\"text/javascript\">\n";
print "function hide(id) {\n";
print " id.visibility = 0\n";
print " alert(id)\n";
print "}\n";
print "</script>";
print " -->\n";
print "<STYLE type=\"text/css\">\n";
print " .hstyle { visibility: visible; color: red; }\n";
print "</STYLE>\n";
print "<FORM METHOD=POST ACTION=editproducts.cgi>\n";
print "<TABLE BORDER=1 CELLPADDING=4 CELLSPACING=0><TR BGCOLOR=\"#6666FF\">\n";
print " <TH ALIGN=\"left\">Group</TH>\n";
print " <TH ALIGN=\"left\">Entry</TH>\n";
print " <TH ALIGN=\"left\">MemberControl</TH>\n";
print " <TH ALIGN=\"left\">OtherControl</TH>\n";
print " <TH ALIGN=\"left\">Canedit</TH>\n";
while (MoreSQLData()) {
print "</TR>\n";
my ($groupid, $groupname, $entry, $membercontrol, $othercontrol,
$canedit) = FetchSQLData();
print "<TR id=\"row_$groupname\" class=\"hstyle\" ";
print "onload=\"document.row.row_$groupname.color=green\">\n";
print " <TD>\n";
print " $groupname\n";
print " </TD><TD>\n";
$entry |= 0;
print " <INPUT TYPE=CHECKBOX NAME=\"entry_$groupid\" VALUE=1";
print " CHECKED " if $entry;
print ">\n";
print " </TD><TD>\n";
$membercontrol |= 0;
$othercontrol |= 0;
print " <SELECT NAME=\"membercontrol_$groupid\">\n";
print " <OPTION VALUE=" . CONTROLMAPNA;
print " selected=\"selected\"" if ($membercontrol == CONTROLMAPNA);
print ">NA</OPTION>\n";
print " <OPTION VALUE=" . CONTROLMAPSHOWN;
print " selected=\"selected\"" if ($membercontrol == CONTROLMAPSHOWN);
print ">Shown</OPTION>\n";
print " <OPTION VALUE=" . CONTROLMAPDEFAULT;
print " selected=\"selected\"" if ($membercontrol == CONTROLMAPDEFAULT);
print ">Default</OPTION>\n";
print " <OPTION VALUE=" . CONTROLMAPMANDATORY;
print " selected=\"selected\"" if ($membercontrol == CONTROLMAPMANDATORY);
print ">Mandatory</OPTION>\n";
print "</SELECT>\n";
print " </TD><TD>\n";
print " <SELECT NAME=\"othercontrol_$groupid\">\n";
print " <OPTION VALUE=" . CONTROLMAPNA;
print " selected=\"selected\"" if ($othercontrol == CONTROLMAPNA);
print ">NA</OPTION>\n";
print " <OPTION VALUE=" . CONTROLMAPSHOWN;
print " selected=\"selected\"" if ($othercontrol == CONTROLMAPSHOWN);
print ">Shown</OPTION>\n";
print " <OPTION VALUE=" . CONTROLMAPDEFAULT;
print " selected=\"selected\"" if ($othercontrol == CONTROLMAPDEFAULT);
print ">Default</OPTION>\n";
print " <OPTION VALUE=" . CONTROLMAPMANDATORY;
print " selected=\"selected\"" if ($othercontrol == CONTROLMAPMANDATORY);
print ">Mandatory</OPTION>\n";
print "</SELECT>\n";
print " </TD><TD>\n";
$canedit |= 0;
print " <INPUT TYPE=CHECKBOX NAME=\"canedit_$groupid\" VALUE=1";
print " CHECKED " if $canedit;
print ">\n";
}
print "</TR>\n";
print "</TABLE><BR>";
print "Add controls to the panel above:<BR>\n";
print "<SELECT NAME=\"newgroups\" SIZE=\"10\" MULTIPLE=\"MULTIPLE\">\n";
SendSQL("SELECT id, name " .
"FROM groups " .
"LEFT JOIN group_control_map " .
"ON group_control_map.group_id = id AND product_id = $product_id " .
"WHERE canedit IS NULL AND isbuggroup != 0 AND isactive != 0 " .
"ORDER BY name");
while (MoreSQLData()) {
my ($groupid, $groupname) = FetchSQLData();
print "<OPTION VALUE=\"$groupid\">$groupname</OPTION>\n";
}
print "</SELECT><BR><BR>\n";
print "<INPUT TYPE=SUBMIT VALUE=\"Update\">\n";
print "<INPUT TYPE=RESET>\n";
print "<INPUT TYPE=HIDDEN NAME=\"action\" VALUE=\"updategroupcontrols\">\n";
print "<INPUT TYPE=HIDDEN NAME=\"product\" VALUE=\"$product\">\n";
print "</FORM>\n";
print "<P>note: Any group controls Set to NA/NA with no other checkboxes ";
print "will automatically be removed from the panel the next time ";
print "update is clicked.\n";
print "<P>These settings control the relationship of the groups to this ";
print "product.\n";
print "<P>If any group has <B>Entry</B> selected, then this product will ";
print "restrict bug entry to only those users who are members of all the ";
print "groups with entry selected.\n";
print "<P>If any group has <B>Canedit</B> selected, then this product ";
print "will be read-only for any users who are not members of all of ";
print "the groups with Canedit selected. ONLY users who are members of ";
print "all the canedit groups will be able to edit. This is an additional ";
print "restriction that further restricts what can be edited by a user.\n";
print "<P>The <B>MemberControl</B> and <B>OtherControl</B> fields ";
print "indicate which bugs will be placed in ";
print "this group according to the following definitions.\n";
print "<BR><TABLE BORDER=1>";
print "<TR>";
print "<TH>MemberControl</TH><TH>OtherControl</TH><TH>Interpretation</TH>";
print "</TR><TR>";
print "<TD>NA</TD>\n";
print "<TD>NA</TD>\n";
print "<TD>Bugs in this product are never associated with this group.</TD>\n";
print "</TR><TR>";
print "<TD>Shown</TD>\n";
print "<TD>NA</TD>\n";
print "<TD>Bugs in this product are permitted to be restricted to this ";
2004-06-02 01:30:29 +04:00
print "group. Users who are members of this group will be able ";
2002-11-24 22:56:34 +03:00
print "to place bugs in this group.</TD>\n";
print "</TR><TR>";
print "<TD>Shown</TD>\n";
print "<TD>Shown</TD>\n";
print "<TD>Bugs in this product can be placed in this group by anyone ";
print "with permission to edit the bug even if they are not a member ";
print "of this group.</TD>\n";
print "</TR><TR>";
print "<TD>Shown</TD>\n";
print "<TD>Default</TD>\n";
print "<TD>Bugs in this product can be placed in this group by anyone ";
print "with permission to edit the bug even if they are not a member ";
print "of this group. Non-members place bugs in this group by default.";
print "</TD>\n";
print "</TR><TR>";
print "<TD>Shown</TD>\n";
print "<TD>Mandatory</TD>\n";
print "<TD>Bugs in this product are permitted to be restricted to this ";
2004-06-02 01:30:29 +04:00
print "group. Users who are members of this group will be able ";
2002-11-24 22:56:34 +03:00
print "to place bugs in this group.";
print "Non-members will be forced to restrict bugs to this group ";
print "when they initially enter a bug in this product.";
print "</TD>\n";
print "</TR><TR>";
print "<TD>Default</TD>\n";
print "<TD>NA</TD>\n";
print "<TD>Bugs in this product are permitted to be restricted to this ";
print "group and are placed in this group by default.";
2004-06-02 01:30:29 +04:00
print "Users who are members of this group will be able ";
2002-11-24 22:56:34 +03:00
print "to place bugs in this group.</TD>\n";
print "</TR><TR>";
print "<TD>Default</TD>\n";
print "<TD>Default</TD>\n";
print "<TD>Bugs in this product are permitted to be restricted to this ";
print "group and are placed in this group by default.";
2004-06-02 01:30:29 +04:00
print "Users who are members of this group will be able ";
2002-11-24 22:56:34 +03:00
print "to place bugs in this group. Non-members will be able to ";
print "restrict bugs to this group on entry and will do so by default ";
print "</TD>\n";
print "</TR><TR>";
print "<TD>Default</TD>\n";
print "<TD>Mandatory</TD>\n";
print "<TD>Bugs in this product are permitted to be restricted to this ";
print "group and are placed in this group by default.";
2004-06-02 01:30:29 +04:00
print "Users who are members of this group will be able ";
2002-11-24 22:56:34 +03:00
print "to place bugs in this group. Non-members will be forced ";
print "to place bugs in this group on entry.";
print "</TR><TR>";
print "<TD>Mandatory</TD>\n";
print "<TD>Mandatory</TD>\n";
print "<TD>Bugs in this product are required to be restricted to this ";
print "group. Users are not given any option.</TD>\n";
print "</TABLE>";
PutTrailer($localtrailer);
exit;
}
1999-10-13 03:00:35 +04:00
#
# No valid action found
#
PutHeader("Error");
print "I don't have a clue what you want.<BR>\n";