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>
|
2006-02-25 01:53:32 +03:00
|
|
|
# Frédéric Buclin <LpSolit@gmail.com>
|
2005-08-27 00:08:46 +04:00
|
|
|
# Greg Hendricks <ghendricks@novell.com>
|
2005-10-24 23:21:05 +04:00
|
|
|
# Lance Larsh <lance.larsh@oracle.com>
|
1999-10-13 03:00:35 +04:00
|
|
|
#
|
|
|
|
# Direct any questions on this source code to
|
|
|
|
#
|
|
|
|
# Holger Schurig <holgerschurig@nikocity.de>
|
|
|
|
|
|
|
|
use strict;
|
2007-10-19 10:46:19 +04:00
|
|
|
use lib qw(. lib);
|
2006-06-21 04:44:48 +04:00
|
|
|
|
2006-02-21 16:08:24 +03:00
|
|
|
use Bugzilla;
|
2002-11-24 22:56:34 +03:00
|
|
|
use Bugzilla::Constants;
|
2006-06-21 04:44:48 +04:00
|
|
|
use Bugzilla::Util;
|
|
|
|
use Bugzilla::Error;
|
2005-04-16 21:17:06 +04:00
|
|
|
use Bugzilla::Bug;
|
2003-06-26 03:23:13 +04:00
|
|
|
use Bugzilla::Series;
|
2006-06-02 14:50:15 +04:00
|
|
|
use Bugzilla::Mailer;
|
2005-10-18 01:43:42 +04:00
|
|
|
use Bugzilla::Product;
|
|
|
|
use Bugzilla::Classification;
|
|
|
|
use Bugzilla::Milestone;
|
2006-03-02 00:33:01 +03:00
|
|
|
use Bugzilla::Group;
|
2006-06-19 21:30:24 +04:00
|
|
|
use Bugzilla::User;
|
2006-06-20 00:15:18 +04:00
|
|
|
use Bugzilla::Field;
|
2006-10-15 02:02:13 +04:00
|
|
|
use Bugzilla::Token;
|
2007-10-09 14:35:01 +04:00
|
|
|
use Bugzilla::Status;
|
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-10-31 00:42:13 +03:00
|
|
|
my $dbh = Bugzilla->dbh;
|
2005-04-09 03:51:02 +04:00
|
|
|
my $cgi = Bugzilla->cgi;
|
2005-10-25 03:11:56 +04:00
|
|
|
my $template = Bugzilla->template;
|
|
|
|
my $vars = {};
|
2007-10-23 01:42:01 +04:00
|
|
|
# Remove this as soon as the documentation about products has been
|
|
|
|
# improved and each action has its own section.
|
|
|
|
$vars->{'doc_section'} = 'products.html';
|
2005-10-25 03:11:56 +04:00
|
|
|
|
2005-04-09 03:51:02 +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')
|
2006-11-10 19:51:30 +03:00
|
|
|
|| scalar(@{$user->get_products_by_permission('editcomponents')})
|
2005-01-16 17:07:31 +03:00
|
|
|
|| ThrowUserError("auth_failure", {group => "editcomponents",
|
|
|
|
action => "edit",
|
|
|
|
object => "products"});
|
1999-10-13 03:00:35 +04:00
|
|
|
|
|
|
|
#
|
|
|
|
# often used variables
|
|
|
|
#
|
2005-10-18 01:43:42 +04:00
|
|
|
my $classification_name = trim($cgi->param('classification') || '');
|
|
|
|
my $product_name = trim($cgi->param('product') || '');
|
2005-04-09 03:51:02 +04:00
|
|
|
my $action = trim($cgi->param('action') || '');
|
2005-10-31 00:42:13 +03:00
|
|
|
my $showbugcounts = (defined $cgi->param('showbugcounts'));
|
2006-10-15 02:02:13 +04:00
|
|
|
my $token = $cgi->param('token');
|
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
|
|
|
#
|
|
|
|
|
2006-07-04 01:26:22 +04:00
|
|
|
if (Bugzilla->params->{'useclassification'}
|
2005-10-18 01:43:42 +04:00
|
|
|
&& !$classification_name
|
|
|
|
&& !$product_name)
|
2005-09-16 20:14:18 +04:00
|
|
|
{
|
2005-12-12 06:12:26 +03:00
|
|
|
$vars->{'classifications'} = $user->get_selectable_classifications;
|
2005-10-18 01:43:42 +04:00
|
|
|
|
2005-12-12 06:12:26 +03:00
|
|
|
$template->process("admin/products/list-classifications.html.tmpl", $vars)
|
2005-09-16 20:14:18 +04:00
|
|
|
|| ThrowTemplateError($template->error());
|
|
|
|
exit;
|
2004-08-21 01:49:20 +04:00
|
|
|
}
|
|
|
|
|
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-10-18 01:43:42 +04:00
|
|
|
if (!$action && !$product_name) {
|
2006-11-10 19:51:30 +03:00
|
|
|
my $classification;
|
2005-12-12 06:12:26 +03:00
|
|
|
my $products;
|
2005-02-16 21:05:06 +03:00
|
|
|
|
2006-07-04 01:26:22 +04:00
|
|
|
if (Bugzilla->params->{'useclassification'}) {
|
2006-11-10 19:51:30 +03:00
|
|
|
$classification =
|
2005-10-18 01:43:42 +04:00
|
|
|
Bugzilla::Classification::check_classification($classification_name);
|
2005-02-16 21:05:06 +03:00
|
|
|
|
2005-12-12 06:12:26 +03:00
|
|
|
$products = $user->get_selectable_products($classification->id);
|
2005-10-18 01:43:42 +04:00
|
|
|
$vars->{'classification'} = $classification;
|
|
|
|
} else {
|
2005-12-12 06:12:26 +03:00
|
|
|
$products = $user->get_selectable_products;
|
2004-08-21 01:49:20 +04:00
|
|
|
}
|
2005-02-16 21:05:06 +03:00
|
|
|
|
2006-11-10 19:51:30 +03:00
|
|
|
# If the user has editcomponents privs for some products only,
|
|
|
|
# we have to restrict the list of products to display.
|
|
|
|
unless ($user->in_group('editcomponents')) {
|
|
|
|
$products = $user->get_products_by_permission('editcomponents');
|
|
|
|
if (Bugzilla->params->{'useclassification'}) {
|
|
|
|
@$products = grep {$_->classification_id == $classification->id} @$products;
|
|
|
|
}
|
|
|
|
}
|
2005-12-12 06:12:26 +03:00
|
|
|
$vars->{'products'} = $products;
|
2005-10-31 00:42:13 +03:00
|
|
|
$vars->{'showbugcounts'} = $showbugcounts;
|
2005-02-16 21:05:06 +03:00
|
|
|
|
2005-10-31 00:42:13 +03:00
|
|
|
$template->process("admin/products/list.html.tmpl", $vars)
|
2005-02-16 21:05:06 +03:00
|
|
|
|| 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') {
|
2006-11-10 19:51:30 +03:00
|
|
|
# The user must have the global editcomponents privs to add
|
|
|
|
# new products.
|
|
|
|
$user->in_group('editcomponents')
|
|
|
|
|| ThrowUserError("auth_failure", {group => "editcomponents",
|
|
|
|
action => "add",
|
|
|
|
object => "products"});
|
|
|
|
|
2006-07-04 01:26:22 +04:00
|
|
|
if (Bugzilla->params->{'useclassification'}) {
|
2005-10-18 01:43:42 +04:00
|
|
|
my $classification =
|
|
|
|
Bugzilla::Classification::check_classification($classification_name);
|
|
|
|
$vars->{'classification'} = $classification;
|
2004-08-21 01:49:20 +04:00
|
|
|
}
|
2006-10-15 02:02:13 +04:00
|
|
|
$vars->{'token'} = issue_session_token('add_product');
|
|
|
|
|
2005-09-02 01:33:07 +04:00
|
|
|
$template->process("admin/products/create.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
|
|
|
|
1999-10-13 03:00:35 +04:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# action='new' -> add product entered in the 'action=add' screen
|
|
|
|
#
|
|
|
|
|
|
|
|
if ($action eq 'new') {
|
2006-11-10 19:51:30 +03:00
|
|
|
# The user must have the global editcomponents privs to add
|
|
|
|
# new products.
|
|
|
|
$user->in_group('editcomponents')
|
|
|
|
|| ThrowUserError("auth_failure", {group => "editcomponents",
|
|
|
|
action => "add",
|
|
|
|
object => "products"});
|
|
|
|
|
2006-10-15 02:02:13 +04:00
|
|
|
check_token_data($token, 'add_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;
|
2006-07-04 01:26:22 +04:00
|
|
|
if (Bugzilla->params->{'useclassification'}) {
|
2005-10-18 01:43:42 +04:00
|
|
|
my $classification =
|
|
|
|
Bugzilla::Classification::check_classification($classification_name);
|
|
|
|
$classification_id = $classification->id;
|
2005-09-12 17:50:42 +04:00
|
|
|
$vars->{'classification'} = $classification;
|
2005-05-03 22:32:58 +04:00
|
|
|
}
|
|
|
|
|
2005-10-18 01:43:42 +04:00
|
|
|
unless ($product_name) {
|
2005-09-12 17:50:42 +04:00
|
|
|
ThrowUserError("product_blank_name");
|
1999-10-13 03:00:35 +04:00
|
|
|
}
|
2004-07-20 09:06:18 +04:00
|
|
|
|
2005-10-18 01:43:42 +04:00
|
|
|
my $product = new Bugzilla::Product({name => $product_name});
|
2004-07-20 09:06:18 +04:00
|
|
|
|
2005-10-18 01:43:42 +04:00
|
|
|
if ($product) {
|
2004-09-09 02:53:39 +04:00
|
|
|
|
|
|
|
# Check for exact case sensitive match:
|
2005-10-18 01:43:42 +04:00
|
|
|
if ($product->name eq $product_name) {
|
2006-05-01 00:52:26 +04:00
|
|
|
ThrowUserError("product_name_already_in_use",
|
2005-10-18 01:43:42 +04:00
|
|
|
{'product' => $product->name});
|
2004-09-09 02:53:39 +04:00
|
|
|
}
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2004-09-09 02:53:39 +04:00
|
|
|
# Next check for a case-insensitive match:
|
2005-10-18 01:43:42 +04:00
|
|
|
if (lc($product->name) eq lc($product_name)) {
|
2006-05-01 00:52:26 +04:00
|
|
|
ThrowUserError("product_name_diff_in_case",
|
2005-10-18 01:43:42 +04:00
|
|
|
{'product' => $product_name,
|
|
|
|
'existing_product' => $product->name});
|
2004-09-09 02:53:39 +04:00
|
|
|
}
|
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 '') {
|
2005-09-12 17:50:42 +04:00
|
|
|
ThrowUserError("product_must_have_version",
|
2005-10-18 01:43:42 +04:00
|
|
|
{'product' => $product_name});
|
1999-10-13 03:00:35 +04:00
|
|
|
}
|
|
|
|
|
2005-04-09 03:51:02 +04:00
|
|
|
my $description = trim($cgi->param('description') || '');
|
2005-09-28 01:47:33 +04:00
|
|
|
|
|
|
|
if ($description eq '') {
|
|
|
|
ThrowUserError('product_must_have_description',
|
2005-10-18 01:43:42 +04:00
|
|
|
{'product' => $product_name});
|
2005-09-28 01:47:33 +04:00
|
|
|
}
|
|
|
|
|
2005-04-09 03:51:02 +04:00
|
|
|
my $milestoneurl = trim($cgi->param('milestoneurl') || '');
|
2005-10-28 14:25:06 +04:00
|
|
|
my $disallownew = $cgi->param('disallownew') ? 1 : 0;
|
|
|
|
my $votesperuser = $cgi->param('votesperuser') || 0;
|
|
|
|
my $maxvotesperbug = defined($cgi->param('maxvotesperbug')) ?
|
|
|
|
$cgi->param('maxvotesperbug') : 10000;
|
|
|
|
my $votestoconfirm = $cgi->param('votestoconfirm') || 0;
|
2005-04-09 03:51:02 +04:00
|
|
|
my $defaultmilestone = $cgi->param('defaultmilestone') || "---";
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2005-10-28 14:25:06 +04:00
|
|
|
# The following variables are used in placeholders only.
|
|
|
|
trick_taint($product_name);
|
|
|
|
trick_taint($version);
|
|
|
|
trick_taint($description);
|
|
|
|
trick_taint($milestoneurl);
|
|
|
|
trick_taint($defaultmilestone);
|
|
|
|
detaint_natural($disallownew);
|
|
|
|
detaint_natural($votesperuser);
|
|
|
|
detaint_natural($maxvotesperbug);
|
|
|
|
detaint_natural($votestoconfirm);
|
|
|
|
|
1999-10-13 03:00:35 +04:00
|
|
|
# Add the new product.
|
2005-10-28 14:25:06 +04:00
|
|
|
$dbh->do('INSERT INTO products
|
|
|
|
(name, description, milestoneurl, disallownew, votesperuser,
|
|
|
|
maxvotesperbug, votestoconfirm, defaultmilestone, classification_id)
|
|
|
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
|
|
|
undef, ($product_name, $description, $milestoneurl, $disallownew,
|
|
|
|
$votesperuser, $maxvotesperbug, $votestoconfirm, $defaultmilestone,
|
|
|
|
$classification_id));
|
2004-08-21 01:49:20 +04:00
|
|
|
|
2005-10-18 01:43:42 +04:00
|
|
|
$product = new Bugzilla::Product({name => $product_name});
|
|
|
|
|
2005-10-28 14:25:06 +04:00
|
|
|
$dbh->do('INSERT INTO versions (value, product_id) VALUES (?, ?)',
|
|
|
|
undef, ($version, $product->id));
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2005-10-28 14:25:06 +04:00
|
|
|
$dbh->do('INSERT INTO milestones (product_id, value) VALUES (?, ?)',
|
|
|
|
undef, ($product->id, $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
|
2006-07-04 01:26:22 +04:00
|
|
|
if (Bugzilla->params->{"makeproductgroups"}) {
|
2000-03-10 19:25:03 +03:00
|
|
|
# Next we insert into the groups table
|
2005-10-18 01:43:42 +04:00
|
|
|
my $productgroup = $product->name;
|
2006-03-15 01:47:24 +03:00
|
|
|
while (new Bugzilla::Group({name => $productgroup})) {
|
2004-05-12 03:17:05 +04:00
|
|
|
$productgroup .= '_';
|
|
|
|
}
|
2005-10-28 14:25:06 +04:00
|
|
|
my $group_description = "Access to bugs in the " .
|
|
|
|
$product->name . " product";
|
|
|
|
|
2006-08-05 02:24:48 +04:00
|
|
|
$dbh->do('INSERT INTO groups (name, description, isbuggroup)
|
|
|
|
VALUES (?, ?, ?)',
|
2005-10-28 14:25:06 +04:00
|
|
|
undef, ($productgroup, $group_description, 1));
|
|
|
|
|
2005-02-18 19:01:48 +03:00
|
|
|
my $gid = $dbh->bz_last_key('groups', 'id');
|
2005-10-28 14:25:06 +04:00
|
|
|
|
2006-06-19 17:23:11 +04:00
|
|
|
# If we created a new group, give the "admin" group privileges
|
2004-07-27 20:33:41 +04:00
|
|
|
# initially.
|
2006-03-15 01:47:24 +03:00
|
|
|
my $admin = Bugzilla::Group->new({name => 'admin'})->id();
|
2005-10-28 14:25:06 +04:00
|
|
|
|
|
|
|
my $sth = $dbh->prepare('INSERT INTO group_group_map
|
|
|
|
(member_id, grantor_id, grant_type)
|
|
|
|
VALUES (?, ?, ?)');
|
|
|
|
|
|
|
|
$sth->execute($admin, $gid, GROUP_MEMBERSHIP);
|
|
|
|
$sth->execute($admin, $gid, GROUP_BLESS);
|
|
|
|
$sth->execute($admin, $gid, GROUP_VISIBLE);
|
2002-11-24 22:56:34 +03:00
|
|
|
|
|
|
|
# Associate the new group and new product.
|
2005-10-28 14:25:06 +04:00
|
|
|
$dbh->do('INSERT INTO group_control_map
|
|
|
|
(group_id, product_id, entry, membercontrol,
|
|
|
|
othercontrol, canedit)
|
|
|
|
VALUES (?, ?, ?, ?, ?, ?)',
|
2006-07-04 01:26:22 +04:00
|
|
|
undef, ($gid, $product->id,
|
|
|
|
Bugzilla->params->{'useentrygroupdefault'},
|
2005-10-28 14:25:06 +04:00
|
|
|
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.
|
2006-06-20 00:15:18 +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-06 05:12:29 +04:00
|
|
|
|
|
|
|
my @series;
|
|
|
|
|
|
|
|
# We do every status, every resolution, and an "opened" one as well.
|
2006-06-20 00:15:18 +04:00
|
|
|
foreach my $bug_status (@{get_legal_field_values('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
|
|
|
|
2006-06-20 00:15:18 +04:00
|
|
|
foreach my $resolution (@{get_legal_field_values('resolution')}) {
|
2004-07-06 05:12:29 +04:00
|
|
|
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
|
|
|
|
2007-07-23 02:25:13 +04:00
|
|
|
# For localization reasons, we get the name of the "global" subcategory
|
2004-07-06 05:12:29 +04:00
|
|
|
# and the title of the "open" query from the submitted form.
|
2006-03-07 00:42:10 +03:00
|
|
|
my @openedstatuses = BUG_STATE_OPEN;
|
2004-08-30 01:29:36 +04:00
|
|
|
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) {
|
2005-10-18 01:43:42 +04:00
|
|
|
my $series = new Bugzilla::Series(undef, $product->name,
|
2005-04-09 03:51:02 +04:00
|
|
|
scalar $cgi->param('subcategory'),
|
2005-10-31 00:31:29 +03:00
|
|
|
$sdata->[0], $whoid, 1,
|
2005-10-18 01:43:42 +04:00
|
|
|
$sdata->[1] . "&product=" .
|
|
|
|
url_quote($product->name), 1);
|
2004-07-06 05:12:29 +04:00
|
|
|
$series->writeToDatabase();
|
|
|
|
}
|
2000-03-10 19:25:03 +03:00
|
|
|
}
|
2006-10-15 02:02:13 +04:00
|
|
|
delete_token($token);
|
|
|
|
|
2005-09-12 17:50:42 +04:00
|
|
|
$vars->{'product'} = $product;
|
2006-06-20 00:15:18 +04:00
|
|
|
|
2005-09-12 17:50:42 +04:00
|
|
|
$template->process("admin/products/created.html.tmpl", $vars)
|
|
|
|
|| 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') {
|
2006-11-10 19:51:30 +03:00
|
|
|
my $product = $user->check_can_admin_product($product_name);
|
2005-12-12 06:12:26 +03:00
|
|
|
|
2006-07-04 01:26:22 +04:00
|
|
|
if (Bugzilla->params->{'useclassification'}) {
|
2005-10-18 01:43:42 +04:00
|
|
|
my $classification =
|
|
|
|
Bugzilla::Classification::check_classification($classification_name);
|
|
|
|
if ($classification->id != $product->classification_id) {
|
|
|
|
ThrowUserError('classification_doesnt_exist_for_product',
|
|
|
|
{ product => $product->name,
|
|
|
|
classification => $classification->name });
|
|
|
|
}
|
2005-07-08 01:03:05 +04:00
|
|
|
$vars->{'classification'} = $classification;
|
1999-10-13 03:00:35 +04:00
|
|
|
}
|
|
|
|
|
2005-10-18 01:43:42 +04:00
|
|
|
$vars->{'product'} = $product;
|
2006-10-15 02:02:13 +04:00
|
|
|
$vars->{'token'} = issue_session_token('delete_product');
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2005-07-08 01:03:05 +04:00
|
|
|
$template->process("admin/products/confirm-delete.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
1999-10-13 03:00:35 +04:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# action='delete' -> really delete the product
|
|
|
|
#
|
|
|
|
|
|
|
|
if ($action eq 'delete') {
|
2006-11-10 19:51:30 +03:00
|
|
|
my $product = $user->check_can_admin_product($product_name);
|
2006-10-15 02:02:13 +04:00
|
|
|
check_token_data($token, 'delete_product');
|
2005-12-12 06:12:26 +03:00
|
|
|
|
2005-07-08 01:03:05 +04:00
|
|
|
$vars->{'product'} = $product;
|
|
|
|
|
2006-07-04 01:26:22 +04:00
|
|
|
if (Bugzilla->params->{'useclassification'}) {
|
2005-10-18 01:43:42 +04:00
|
|
|
my $classification =
|
|
|
|
Bugzilla::Classification::check_classification($classification_name);
|
|
|
|
if ($classification->id != $product->classification_id) {
|
|
|
|
ThrowUserError('classification_doesnt_exist_for_product',
|
|
|
|
{ product => $product->name,
|
|
|
|
classification => $classification->name });
|
|
|
|
}
|
|
|
|
$vars->{'classification'} = $classification;
|
|
|
|
}
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2005-10-18 01:43:42 +04:00
|
|
|
if ($product->bug_count) {
|
2006-07-04 01:26:22 +04:00
|
|
|
if (Bugzilla->params->{"allowbugdeletion"}) {
|
2005-10-18 01:43:42 +04:00
|
|
|
foreach my $bug_id (@{$product->bug_ids}) {
|
2006-08-12 03:45:08 +04:00
|
|
|
# Note that we allow the user to delete bugs he can't see,
|
|
|
|
# which is okay, because he's deleting the whole Product.
|
|
|
|
my $bug = new Bugzilla::Bug($bug_id);
|
2005-04-06 04:19:56 +04:00
|
|
|
$bug->remove_from_db();
|
|
|
|
}
|
1999-12-17 06:41:13 +03:00
|
|
|
}
|
2005-04-06 04:19:56 +04:00
|
|
|
else {
|
2005-10-18 01:43:42 +04:00
|
|
|
ThrowUserError("product_has_bugs",
|
|
|
|
{ nb => $product->bug_count });
|
2005-04-06 04:19:56 +04:00
|
|
|
}
|
|
|
|
}
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2007-10-10 03:21:49 +04:00
|
|
|
$dbh->bz_start_transaction();
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2007-07-12 06:40:02 +04:00
|
|
|
my $comp_ids = $dbh->selectcol_arrayref('SELECT id FROM components
|
|
|
|
WHERE product_id = ?',
|
|
|
|
undef, $product->id);
|
|
|
|
|
|
|
|
$dbh->do('DELETE FROM component_cc WHERE component_id IN
|
|
|
|
(' . join(',', @$comp_ids) . ')') if scalar(@$comp_ids);
|
|
|
|
|
2005-07-08 01:03:05 +04:00
|
|
|
$dbh->do("DELETE FROM components WHERE product_id = ?",
|
2005-10-18 01:43:42 +04:00
|
|
|
undef, $product->id);
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2005-07-08 01:03:05 +04:00
|
|
|
$dbh->do("DELETE FROM versions WHERE product_id = ?",
|
2005-10-18 01:43:42 +04:00
|
|
|
undef, $product->id);
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2005-07-08 01:03:05 +04:00
|
|
|
$dbh->do("DELETE FROM milestones WHERE product_id = ?",
|
2005-10-18 01:43:42 +04:00
|
|
|
undef, $product->id);
|
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 = ?",
|
2005-10-18 01:43:42 +04:00
|
|
|
undef, $product->id);
|
2002-11-24 22:56:34 +03:00
|
|
|
|
2005-04-06 04:19:56 +04:00
|
|
|
$dbh->do("DELETE FROM flaginclusions WHERE product_id = ?",
|
2005-10-18 01:43:42 +04:00
|
|
|
undef, $product->id);
|
2005-07-08 01:03:05 +04:00
|
|
|
|
2005-04-06 04:19:56 +04:00
|
|
|
$dbh->do("DELETE FROM flagexclusions WHERE product_id = ?",
|
2005-10-18 01:43:42 +04:00
|
|
|
undef, $product->id);
|
2005-07-08 01:03:05 +04:00
|
|
|
|
|
|
|
$dbh->do("DELETE FROM products WHERE id = ?",
|
2005-10-18 01:43:42 +04:00
|
|
|
undef, $product->id);
|
2000-03-10 19:25:03 +03:00
|
|
|
|
2007-10-10 03:21:49 +04:00
|
|
|
$dbh->bz_commit_transaction();
|
2005-02-18 00:57:27 +03:00
|
|
|
|
2006-10-15 02:02:13 +04:00
|
|
|
delete_token($token);
|
|
|
|
|
2005-07-08 01:03:05 +04:00
|
|
|
$template->process("admin/products/deleted.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
1999-10-13 03:00:35 +04:00
|
|
|
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-10-18 01:43:42 +04:00
|
|
|
if ($action eq 'edit' || (!$action && $product_name)) {
|
2006-11-10 19:51:30 +03:00
|
|
|
my $product = $user->check_can_admin_product($product_name);
|
2005-12-12 06:12:26 +03:00
|
|
|
|
2006-07-04 01:26:22 +04:00
|
|
|
if (Bugzilla->params->{'useclassification'}) {
|
2005-10-18 01:43:42 +04:00
|
|
|
my $classification;
|
|
|
|
if (!$classification_name) {
|
|
|
|
$classification =
|
|
|
|
new Bugzilla::Classification($product->classification_id);
|
2005-03-24 00:24:19 +03:00
|
|
|
} else {
|
2005-10-18 01:43:42 +04:00
|
|
|
$classification =
|
|
|
|
Bugzilla::Classification::check_classification($classification_name);
|
|
|
|
if ($classification->id != $product->classification_id) {
|
|
|
|
ThrowUserError('classification_doesnt_exist_for_product',
|
|
|
|
{ product => $product->name,
|
|
|
|
classification => $classification->name });
|
|
|
|
}
|
2005-03-24 00:24:19 +03:00
|
|
|
}
|
2005-10-18 01:43:42 +04:00
|
|
|
$vars->{'classification'} = $classification;
|
2000-03-21 19:47:06 +03:00
|
|
|
}
|
2005-10-18 01:43:42 +04:00
|
|
|
my $group_controls = $product->group_controls;
|
2005-09-02 01:33:07 +04:00
|
|
|
|
|
|
|
# Convert Group Controls(membercontrol and othercontrol) from
|
|
|
|
# integer to string to display Membercontrol/Othercontrol names
|
|
|
|
# at the template. <gabriel@async.com.br>
|
|
|
|
my $constants = {
|
|
|
|
(CONTROLMAPNA) => 'NA',
|
|
|
|
(CONTROLMAPSHOWN) => 'Shown',
|
|
|
|
(CONTROLMAPDEFAULT) => 'Default',
|
|
|
|
(CONTROLMAPMANDATORY) => 'Mandatory'};
|
|
|
|
|
2005-10-18 01:43:42 +04:00
|
|
|
foreach my $group (keys(%$group_controls)) {
|
|
|
|
foreach my $control ('membercontrol', 'othercontrol') {
|
|
|
|
$group_controls->{$group}->{$control} =
|
|
|
|
$constants->{$group_controls->{$group}->{$control}};
|
|
|
|
}
|
2005-09-02 01:33:07 +04:00
|
|
|
}
|
2005-10-18 01:43:42 +04:00
|
|
|
$vars->{'group_controls'} = $group_controls;
|
|
|
|
$vars->{'product'} = $product;
|
2006-10-15 02:02:13 +04:00
|
|
|
$vars->{'token'} = issue_session_token('edit_product');
|
|
|
|
|
2005-09-02 01:33:07 +04:00
|
|
|
$template->process("admin/products/edit.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
1999-10-13 03:00:35 +04:00
|
|
|
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2002-11-24 22:56:34 +03:00
|
|
|
#
|
|
|
|
# action='updategroupcontrols' -> update the product
|
|
|
|
#
|
|
|
|
|
|
|
|
if ($action eq 'updategroupcontrols') {
|
2006-11-10 19:51:30 +03:00
|
|
|
my $product = $user->check_can_admin_product($product_name);
|
2006-10-15 02:02:13 +04:00
|
|
|
check_token_data($token, 'edit_group_controls');
|
2005-12-12 06:12:26 +03:00
|
|
|
|
2002-11-24 22:56:34 +03:00
|
|
|
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')) {
|
2005-10-28 14:25:06 +04:00
|
|
|
my $na_groups;
|
2002-11-24 22:56:34 +03:00
|
|
|
if (@now_na) {
|
2005-10-28 14:25:06 +04:00
|
|
|
$na_groups = $dbh->selectall_arrayref(
|
|
|
|
'SELECT groups.name, COUNT(bugs.bug_id) AS count
|
|
|
|
FROM bugs
|
|
|
|
INNER 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_na) . ')
|
|
|
|
AND bugs.product_id = ? ' .
|
|
|
|
$dbh->sql_group_by('groups.name'),
|
|
|
|
{'Slice' => {}}, $product->id);
|
2002-11-24 22:56:34 +03:00
|
|
|
}
|
|
|
|
|
2005-10-28 14:25:06 +04:00
|
|
|
my $mandatory_groups;
|
2002-11-24 22:56:34 +03:00
|
|
|
if (@now_mandatory) {
|
2005-10-28 14:25:06 +04:00
|
|
|
$mandatory_groups = $dbh->selectall_arrayref(
|
|
|
|
'SELECT groups.name, COUNT(bugs.bug_id) AS count
|
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
|
2005-10-28 14:25:06 +04:00
|
|
|
WHERE groups.id IN (' . join(', ', @now_mandatory) . ')
|
|
|
|
AND bugs.product_id = ?
|
|
|
|
AND bug_group_map.bug_id IS NULL ' .
|
|
|
|
$dbh->sql_group_by('groups.name'),
|
|
|
|
{'Slice' => {}}, $product->id);
|
2002-11-24 22:56:34 +03:00
|
|
|
}
|
2005-10-28 14:25:06 +04:00
|
|
|
if (($na_groups && scalar(@$na_groups))
|
|
|
|
|| ($mandatory_groups && scalar(@$mandatory_groups)))
|
|
|
|
{
|
2002-11-24 22:56:34 +03:00
|
|
|
$vars->{'product'} = $product;
|
2005-10-28 14:25:06 +04:00
|
|
|
$vars->{'na_groups'} = $na_groups;
|
|
|
|
$vars->{'mandatory_groups'} = $mandatory_groups;
|
2002-11-24 22:56:34 +03:00
|
|
|
$template->process("admin/products/groupcontrol/confirm-edit.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
2005-10-28 14:25:06 +04:00
|
|
|
|
|
|
|
my $groups = $dbh->selectall_arrayref('SELECT id, name FROM groups
|
|
|
|
WHERE isbuggroup != 0
|
|
|
|
AND isactive != 0');
|
|
|
|
foreach my $group (@$groups) {
|
|
|
|
my ($groupid, $groupname) = @$group;
|
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',
|
2005-09-16 20:14:18 +04:00
|
|
|
{groupname => $groupname});
|
2002-11-24 22:56:34 +03:00
|
|
|
}
|
|
|
|
}
|
2007-10-10 03:21:49 +04:00
|
|
|
$dbh->bz_start_transaction();
|
2005-10-28 14:25:06 +04:00
|
|
|
|
|
|
|
my $sth_Insert = $dbh->prepare('INSERT INTO group_control_map
|
|
|
|
(group_id, product_id, entry, membercontrol,
|
2006-11-10 19:51:30 +03:00
|
|
|
othercontrol, canedit, editcomponents,
|
|
|
|
canconfirm, editbugs)
|
|
|
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)');
|
2005-10-28 14:25:06 +04:00
|
|
|
|
|
|
|
my $sth_Update = $dbh->prepare('UPDATE group_control_map
|
|
|
|
SET entry = ?, membercontrol = ?,
|
2006-11-10 19:51:30 +03:00
|
|
|
othercontrol = ?, canedit = ?,
|
|
|
|
editcomponents = ?, canconfirm = ?,
|
|
|
|
editbugs = ?
|
2005-10-28 14:25:06 +04:00
|
|
|
WHERE group_id = ? AND product_id = ?');
|
|
|
|
|
|
|
|
my $sth_Delete = $dbh->prepare('DELETE FROM group_control_map
|
|
|
|
WHERE group_id = ? AND product_id = ?');
|
|
|
|
|
|
|
|
$groups = $dbh->selectall_arrayref('SELECT id, name, entry, membercontrol,
|
2006-11-10 19:51:30 +03:00
|
|
|
othercontrol, canedit,
|
|
|
|
editcomponents, canconfirm, editbugs
|
2005-10-28 14:25:06 +04:00
|
|
|
FROM groups
|
|
|
|
LEFT JOIN group_control_map
|
|
|
|
ON group_control_map.group_id = id
|
|
|
|
AND product_id = ?
|
|
|
|
WHERE isbuggroup != 0
|
|
|
|
AND isactive != 0',
|
|
|
|
undef, $product->id);
|
|
|
|
|
|
|
|
foreach my $group (@$groups) {
|
2006-11-10 19:51:30 +03:00
|
|
|
my ($groupid, $groupname, $entry, $membercontrol, $othercontrol,
|
|
|
|
$canedit, $editcomponents, $canconfirm, $editbugs) = @$group;
|
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;
|
2006-11-10 19:51:30 +03:00
|
|
|
my $new_editcomponents = $cgi->param("editcomponents_$groupid") || 0;
|
|
|
|
my $new_canconfirm = $cgi->param("canconfirm_$groupid") || 0;
|
|
|
|
my $new_editbugs = $cgi->param("editbugs_$groupid") || 0;
|
|
|
|
|
2002-11-24 22:56:34 +03:00
|
|
|
my $oldentry = $entry;
|
2006-11-10 19:51:30 +03:00
|
|
|
# Set undefined values to 0.
|
|
|
|
$entry ||= 0;
|
|
|
|
$membercontrol ||= 0;
|
|
|
|
$othercontrol ||= 0;
|
|
|
|
$canedit ||= 0;
|
|
|
|
$editcomponents ||= 0;
|
|
|
|
$canconfirm ||= 0;
|
|
|
|
$editbugs ||= 0;
|
|
|
|
|
|
|
|
# We use them in placeholders only. So it's safe to detaint them.
|
2002-11-24 22:56:34 +03:00
|
|
|
detaint_natural($newentry);
|
|
|
|
detaint_natural($newothercontrol);
|
|
|
|
detaint_natural($newmembercontrol);
|
|
|
|
detaint_natural($newcanedit);
|
2006-11-10 19:51:30 +03:00
|
|
|
detaint_natural($new_editcomponents);
|
|
|
|
detaint_natural($new_canconfirm);
|
|
|
|
detaint_natural($new_editbugs);
|
|
|
|
|
|
|
|
if (!defined($oldentry)
|
|
|
|
&& ($newentry || $newmembercontrol || $newcanedit
|
|
|
|
|| $new_editcomponents || $new_canconfirm || $new_editbugs))
|
|
|
|
{
|
2005-10-28 14:25:06 +04:00
|
|
|
$sth_Insert->execute($groupid, $product->id, $newentry,
|
2006-11-10 19:51:30 +03:00
|
|
|
$newmembercontrol, $newothercontrol, $newcanedit,
|
|
|
|
$new_editcomponents, $new_canconfirm, $new_editbugs);
|
|
|
|
}
|
|
|
|
elsif (($newentry != $entry)
|
|
|
|
|| ($newmembercontrol != $membercontrol)
|
|
|
|
|| ($newothercontrol != $othercontrol)
|
|
|
|
|| ($newcanedit != $canedit)
|
|
|
|
|| ($new_editcomponents != $editcomponents)
|
|
|
|
|| ($new_canconfirm != $canconfirm)
|
|
|
|
|| ($new_editbugs != $editbugs))
|
|
|
|
{
|
2005-10-28 14:25:06 +04:00
|
|
|
$sth_Update->execute($newentry, $newmembercontrol, $newothercontrol,
|
2006-11-10 19:51:30 +03:00
|
|
|
$newcanedit, $new_editcomponents, $new_canconfirm,
|
|
|
|
$new_editbugs, $groupid, $product->id);
|
2002-11-24 22:56:34 +03:00
|
|
|
}
|
|
|
|
|
2006-11-10 19:51:30 +03:00
|
|
|
if (!$newentry && !$newmembercontrol && !$newothercontrol
|
|
|
|
&& !$newcanedit && !$new_editcomponents && !$new_canconfirm
|
|
|
|
&& !$new_editbugs)
|
|
|
|
{
|
2005-10-28 14:25:06 +04:00
|
|
|
$sth_Delete->execute($groupid, $product->id);
|
2002-11-24 22:56:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-10-28 14:25:06 +04:00
|
|
|
my $sth_Select = $dbh->prepare(
|
|
|
|
'SELECT bugs.bug_id,
|
|
|
|
CASE WHEN (lastdiffed >= delta_ts) THEN 1 ELSE 0 END
|
|
|
|
FROM bugs
|
|
|
|
INNER JOIN bug_group_map
|
|
|
|
ON bug_group_map.bug_id = bugs.bug_id
|
|
|
|
WHERE group_id = ?
|
|
|
|
AND bugs.product_id = ?
|
|
|
|
ORDER BY bugs.bug_id');
|
|
|
|
|
|
|
|
my $sth_Select2 = $dbh->prepare('SELECT name, NOW() FROM groups WHERE id = ?');
|
|
|
|
|
|
|
|
$sth_Update = $dbh->prepare('UPDATE bugs SET delta_ts = ? WHERE bug_id = ?');
|
|
|
|
|
|
|
|
my $sth_Update2 = $dbh->prepare('UPDATE bugs SET delta_ts = ?, lastdiffed = ?
|
|
|
|
WHERE bug_id = ?');
|
|
|
|
|
|
|
|
$sth_Delete = $dbh->prepare('DELETE FROM bug_group_map
|
|
|
|
WHERE bug_id = ? AND group_id = ?');
|
|
|
|
|
2005-09-16 20:14:18 +04:00
|
|
|
my @removed_na;
|
2002-11-24 22:56:34 +03:00
|
|
|
foreach my $groupid (@now_na) {
|
|
|
|
my $count = 0;
|
2005-10-28 14:25:06 +04:00
|
|
|
my $bugs = $dbh->selectall_arrayref($sth_Select, undef,
|
|
|
|
($groupid, $product->id));
|
|
|
|
|
2006-05-07 23:56:05 +04:00
|
|
|
my ($removed, $timestamp) =
|
|
|
|
$dbh->selectrow_array($sth_Select2, undef, $groupid);
|
|
|
|
|
2005-10-28 14:25:06 +04:00
|
|
|
foreach my $bug (@$bugs) {
|
|
|
|
my ($bugid, $mailiscurrent) = @$bug;
|
|
|
|
$sth_Delete->execute($bugid, $groupid);
|
|
|
|
|
2002-11-24 22:56:34 +03:00
|
|
|
LogActivityEntry($bugid, "bug_group", $removed, "",
|
2005-10-31 00:31:29 +03:00
|
|
|
$whoid, $timestamp);
|
2005-10-28 14:25:06 +04:00
|
|
|
|
2005-03-11 22:45:03 +03:00
|
|
|
if ($mailiscurrent) {
|
2005-10-28 14:25:06 +04:00
|
|
|
$sth_Update2->execute($timestamp, $timestamp, $bugid);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$sth_Update->execute($timestamp, $bugid);
|
2002-11-24 22:56:34 +03:00
|
|
|
}
|
|
|
|
$count++;
|
|
|
|
}
|
2006-05-07 23:56:05 +04:00
|
|
|
my %group = (name => $removed, bug_count => $count);
|
2005-09-16 20:14:18 +04:00
|
|
|
|
|
|
|
push(@removed_na, \%group);
|
2002-11-24 22:56:34 +03:00
|
|
|
}
|
|
|
|
|
2005-10-28 14:25:06 +04:00
|
|
|
$sth_Select = $dbh->prepare(
|
|
|
|
'SELECT bugs.bug_id,
|
|
|
|
CASE WHEN (lastdiffed >= delta_ts) THEN 1 ELSE 0 END
|
|
|
|
FROM bugs
|
|
|
|
LEFT JOIN bug_group_map
|
|
|
|
ON bug_group_map.bug_id = bugs.bug_id
|
|
|
|
AND group_id = ?
|
|
|
|
WHERE bugs.product_id = ?
|
|
|
|
AND bug_group_map.bug_id IS NULL
|
|
|
|
ORDER BY bugs.bug_id');
|
|
|
|
|
|
|
|
$sth_Insert = $dbh->prepare('INSERT INTO bug_group_map
|
|
|
|
(bug_id, group_id) VALUES (?, ?)');
|
|
|
|
|
2005-09-16 20:14:18 +04:00
|
|
|
my @added_mandatory;
|
2002-11-24 22:56:34 +03:00
|
|
|
foreach my $groupid (@now_mandatory) {
|
|
|
|
my $count = 0;
|
2005-10-28 14:25:06 +04:00
|
|
|
my $bugs = $dbh->selectall_arrayref($sth_Select, undef,
|
|
|
|
($groupid, $product->id));
|
|
|
|
|
2006-05-07 23:56:05 +04:00
|
|
|
my ($added, $timestamp) =
|
|
|
|
$dbh->selectrow_array($sth_Select2, undef, $groupid);
|
|
|
|
|
2005-10-28 14:25:06 +04:00
|
|
|
foreach my $bug (@$bugs) {
|
|
|
|
my ($bugid, $mailiscurrent) = @$bug;
|
|
|
|
$sth_Insert->execute($bugid, $groupid);
|
|
|
|
|
2002-11-24 22:56:34 +03:00
|
|
|
LogActivityEntry($bugid, "bug_group", "", $added,
|
2005-10-31 00:31:29 +03:00
|
|
|
$whoid, $timestamp);
|
2005-10-28 14:25:06 +04:00
|
|
|
|
2005-03-11 22:45:03 +03:00
|
|
|
if ($mailiscurrent) {
|
2005-10-28 14:25:06 +04:00
|
|
|
$sth_Update2->execute($timestamp, $timestamp, $bugid);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$sth_Update->execute($timestamp, $bugid);
|
2002-11-24 22:56:34 +03:00
|
|
|
}
|
|
|
|
$count++;
|
|
|
|
}
|
2006-05-07 23:56:05 +04:00
|
|
|
my %group = (name => $added, bug_count => $count);
|
2005-09-16 20:14:18 +04:00
|
|
|
|
|
|
|
push(@added_mandatory, \%group);
|
2002-11-24 22:56:34 +03:00
|
|
|
}
|
2007-10-10 03:21:49 +04:00
|
|
|
$dbh->bz_commit_transaction();
|
2005-02-18 00:57:27 +03:00
|
|
|
|
2006-10-15 02:02:13 +04:00
|
|
|
delete_token($token);
|
2002-11-24 22:56:34 +03:00
|
|
|
|
2006-10-15 02:02:13 +04:00
|
|
|
$vars->{'removed_na'} = \@removed_na;
|
2005-09-16 20:14:18 +04:00
|
|
|
$vars->{'added_mandatory'} = \@added_mandatory;
|
|
|
|
$vars->{'product'} = $product;
|
|
|
|
|
|
|
|
$template->process("admin/products/groupcontrol/updated.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
2002-11-24 22:56:34 +03:00
|
|
|
exit;
|
|
|
|
}
|
1999-10-13 03:00:35 +04:00
|
|
|
|
|
|
|
#
|
|
|
|
# action='update' -> update the product
|
|
|
|
#
|
|
|
|
if ($action eq 'update') {
|
2006-10-15 02:02:13 +04:00
|
|
|
check_token_data($token, 'edit_product');
|
2005-10-18 01:43:42 +04:00
|
|
|
my $product_old_name = trim($cgi->param('product_old_name') || '');
|
2005-04-09 03:51:02 +04:00
|
|
|
my $description = trim($cgi->param('description') || '');
|
|
|
|
my $disallownew = trim($cgi->param('disallownew') || '');
|
|
|
|
my $milestoneurl = trim($cgi->param('milestoneurl') || '');
|
|
|
|
my $votesperuser = trim($cgi->param('votesperuser') || 0);
|
|
|
|
my $maxvotesperbug = trim($cgi->param('maxvotesperbug') || 0);
|
|
|
|
my $votestoconfirm = trim($cgi->param('votestoconfirm') || 0);
|
|
|
|
my $defaultmilestone = trim($cgi->param('defaultmilestone') || '---');
|
2000-02-17 08:15:23 +03:00
|
|
|
|
|
|
|
my $checkvotes = 0;
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2006-11-10 19:51:30 +03:00
|
|
|
my $product_old = $user->check_can_admin_product($product_old_name);
|
2005-12-12 06:12:26 +03:00
|
|
|
|
2006-07-04 01:26:22 +04:00
|
|
|
if (Bugzilla->params->{'useclassification'}) {
|
2005-10-18 01:43:42 +04:00
|
|
|
my $classification;
|
|
|
|
if (!$classification_name) {
|
|
|
|
$classification =
|
|
|
|
new Bugzilla::Classification($product_old->classification_id);
|
|
|
|
} else {
|
|
|
|
$classification =
|
|
|
|
Bugzilla::Classification::check_classification($classification_name);
|
|
|
|
if ($classification->id != $product_old->classification_id) {
|
|
|
|
ThrowUserError('classification_doesnt_exist_for_product',
|
|
|
|
{ product => $product_old->name,
|
|
|
|
classification => $classification->name });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$vars->{'classification'} = $classification;
|
|
|
|
}
|
|
|
|
|
|
|
|
unless ($product_name) {
|
2006-05-01 00:52:26 +04:00
|
|
|
ThrowUserError('product_cant_delete_name',
|
2005-10-18 01:43:42 +04:00
|
|
|
{product => $product_old->name});
|
|
|
|
}
|
|
|
|
|
|
|
|
unless ($description) {
|
2006-05-01 00:52:26 +04:00
|
|
|
ThrowUserError('product_cant_delete_description',
|
2005-10-18 01:43:42 +04:00
|
|
|
{product => $product_old->name});
|
|
|
|
}
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2005-09-08 20:58:57 +04:00
|
|
|
my $stored_maxvotesperbug = $maxvotesperbug;
|
2005-06-07 01:37:57 +04:00
|
|
|
if (!detaint_natural($maxvotesperbug)) {
|
2006-05-01 00:52:26 +04:00
|
|
|
ThrowUserError('product_votes_per_bug_must_be_nonnegative',
|
2005-09-08 20:58:57 +04:00
|
|
|
{maxvotesperbug => $stored_maxvotesperbug});
|
2000-02-17 08:15:23 +03:00
|
|
|
}
|
|
|
|
|
2005-09-08 20:58:57 +04:00
|
|
|
my $stored_votesperuser = $votesperuser;
|
2004-07-09 00:08:55 +04:00
|
|
|
if (!detaint_natural($votesperuser)) {
|
2006-05-01 00:52:26 +04:00
|
|
|
ThrowUserError('product_votes_per_user_must_be_nonnegative',
|
2005-09-08 20:58:57 +04:00
|
|
|
{votesperuser => $stored_votesperuser});
|
2004-07-09 00:08:55 +04:00
|
|
|
}
|
|
|
|
|
2005-09-08 20:58:57 +04:00
|
|
|
my $stored_votestoconfirm = $votestoconfirm;
|
2004-07-09 00:08:55 +04:00
|
|
|
if (!detaint_natural($votestoconfirm)) {
|
2006-05-01 00:52:26 +04:00
|
|
|
ThrowUserError('product_votes_to_confirm_must_be_nonnegative',
|
2005-09-08 20:58:57 +04:00
|
|
|
{votestoconfirm => $stored_votestoconfirm});
|
2004-07-09 00:08:55 +04:00
|
|
|
}
|
|
|
|
|
2007-10-10 03:21:49 +04:00
|
|
|
$dbh->bz_start_transaction();
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2005-10-18 01:43:42 +04:00
|
|
|
my $testproduct =
|
|
|
|
new Bugzilla::Product({name => $product_name});
|
|
|
|
if (lc($product_name) ne lc($product_old->name) &&
|
|
|
|
$testproduct) {
|
2006-05-01 00:52:26 +04:00
|
|
|
ThrowUserError('product_name_already_in_use',
|
2005-10-18 01:43:42 +04:00
|
|
|
{product => $product_name});
|
|
|
|
}
|
|
|
|
|
2006-03-01 01:06:34 +03:00
|
|
|
# Only update milestone related stuff if 'usetargetmilestone' is on.
|
2006-07-04 01:26:22 +04:00
|
|
|
if (Bugzilla->params->{'usetargetmilestone'}) {
|
2006-12-19 13:35:43 +03:00
|
|
|
my $milestone = new Bugzilla::Milestone(
|
|
|
|
{ product => $product_old, name => $defaultmilestone });
|
2006-03-01 01:06:34 +03:00
|
|
|
|
|
|
|
unless ($milestone) {
|
2006-05-01 00:52:26 +04:00
|
|
|
ThrowUserError('product_must_define_defaultmilestone',
|
2006-03-01 01:06:34 +03:00
|
|
|
{product => $product_old->name,
|
|
|
|
defaultmilestone => $defaultmilestone,
|
|
|
|
classification => $classification_name});
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($milestoneurl ne $product_old->milestone_url) {
|
|
|
|
trick_taint($milestoneurl);
|
|
|
|
$dbh->do('UPDATE products SET milestoneurl = ? WHERE id = ?',
|
|
|
|
undef, ($milestoneurl, $product_old->id));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($milestone->name ne $product_old->default_milestone) {
|
|
|
|
$dbh->do('UPDATE products SET defaultmilestone = ? WHERE id = ?',
|
|
|
|
undef, ($milestone->name, $product_old->id));
|
|
|
|
}
|
2005-10-18 01:43:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
$disallownew = $disallownew ? 1 : 0;
|
|
|
|
if ($disallownew ne $product_old->disallow_new) {
|
2005-10-28 14:25:06 +04:00
|
|
|
$dbh->do('UPDATE products SET disallownew = ? WHERE id = ?',
|
|
|
|
undef, ($disallownew, $product_old->id));
|
1999-10-13 03:00:35 +04:00
|
|
|
}
|
|
|
|
|
2005-10-18 01:43:42 +04:00
|
|
|
if ($description ne $product_old->description) {
|
2005-10-28 14:25:06 +04:00
|
|
|
trick_taint($description);
|
|
|
|
$dbh->do('UPDATE products SET description = ? WHERE id = ?',
|
|
|
|
undef, ($description, $product_old->id));
|
1999-10-13 03:00:35 +04:00
|
|
|
}
|
|
|
|
|
2005-10-18 01:43:42 +04:00
|
|
|
if ($votesperuser ne $product_old->votes_per_user) {
|
2005-10-28 14:25:06 +04:00
|
|
|
$dbh->do('UPDATE products SET votesperuser = ? WHERE id = ?',
|
|
|
|
undef, ($votesperuser, $product_old->id));
|
2000-02-17 08:15:23 +03:00
|
|
|
$checkvotes = 1;
|
2000-01-05 00:29:51 +03:00
|
|
|
}
|
|
|
|
|
2005-10-18 01:43:42 +04:00
|
|
|
if ($maxvotesperbug ne $product_old->max_votes_per_bug) {
|
2005-10-28 14:25:06 +04:00
|
|
|
$dbh->do('UPDATE products SET maxvotesperbug = ? WHERE id = ?',
|
|
|
|
undef, ($maxvotesperbug, $product_old->id));
|
2000-02-17 08:15:23 +03:00
|
|
|
$checkvotes = 1;
|
|
|
|
}
|
|
|
|
|
2005-10-18 01:43:42 +04:00
|
|
|
if ($votestoconfirm ne $product_old->votes_to_confirm) {
|
2005-10-28 14:25:06 +04:00
|
|
|
$dbh->do('UPDATE products SET votestoconfirm = ? WHERE id = ?',
|
|
|
|
undef, ($votestoconfirm, $product_old->id));
|
2000-02-17 08:15:23 +03:00
|
|
|
$checkvotes = 1;
|
|
|
|
}
|
|
|
|
|
2005-10-18 01:43:42 +04:00
|
|
|
if ($product_name ne $product_old->name) {
|
2005-10-28 14:25:06 +04:00
|
|
|
trick_taint($product_name);
|
|
|
|
$dbh->do('UPDATE products SET name = ? WHERE id = ?',
|
|
|
|
undef, ($product_name, $product_old->id));
|
1999-10-13 03:00:35 +04:00
|
|
|
}
|
2005-10-28 14:25:06 +04:00
|
|
|
|
2007-10-10 03:21:49 +04:00
|
|
|
$dbh->bz_commit_transaction();
|
1999-10-13 03:00:35 +04:00
|
|
|
|
2005-10-18 01:43:42 +04:00
|
|
|
my $product = new Bugzilla::Product({name => $product_name});
|
|
|
|
|
2000-02-17 08:15:23 +03:00
|
|
|
if ($checkvotes) {
|
2005-09-08 20:58:57 +04:00
|
|
|
$vars->{'checkvotes'} = 1;
|
|
|
|
|
2004-12-11 16:33:27 +03:00
|
|
|
# 1. too many votes for a single user on a single bug.
|
2005-09-08 20:58:57 +04:00
|
|
|
my @toomanyvotes_list = ();
|
2000-02-17 08:15:23 +03:00
|
|
|
if ($maxvotesperbug < $votesperuser) {
|
2005-10-28 14:25:06 +04:00
|
|
|
my $votes = $dbh->selectall_arrayref(
|
|
|
|
'SELECT votes.who, votes.bug_id
|
|
|
|
FROM votes
|
|
|
|
INNER JOIN bugs
|
|
|
|
ON bugs.bug_id = votes.bug_id
|
|
|
|
WHERE bugs.product_id = ?
|
|
|
|
AND votes.vote_count > ?',
|
|
|
|
undef, ($product->id, $maxvotesperbug));
|
|
|
|
|
|
|
|
foreach my $vote (@$votes) {
|
|
|
|
my ($who, $id) = (@$vote);
|
2006-02-25 01:53:32 +03:00
|
|
|
# If some votes are removed, RemoveVotes() returns a list
|
|
|
|
# of messages to send to voters.
|
|
|
|
my $msgs =
|
|
|
|
RemoveVotes($id, $who, "The rules for voting on this product " .
|
|
|
|
"has changed;\nyou had too many votes " .
|
|
|
|
"for a single bug.");
|
|
|
|
foreach my $msg (@$msgs) {
|
2006-06-02 14:50:15 +04:00
|
|
|
MessageToMTA($msg);
|
2006-02-25 01:53:32 +03:00
|
|
|
}
|
2006-06-19 21:30:24 +04:00
|
|
|
my $name = user_id_to_login($who);
|
2005-09-08 20:58:57 +04:00
|
|
|
|
|
|
|
push(@toomanyvotes_list,
|
|
|
|
{id => $id, name => $name});
|
2000-02-17 08:15:23 +03:00
|
|
|
}
|
|
|
|
}
|
2005-09-08 20:58:57 +04:00
|
|
|
$vars->{'toomanyvotes'} = \@toomanyvotes_list;
|
|
|
|
|
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
|
2005-10-28 14:25:06 +04:00
|
|
|
# than maxvotesperbug). See Bugzilla::Bug::RemoveVotes().
|
|
|
|
|
|
|
|
my $votes = $dbh->selectall_arrayref(
|
|
|
|
'SELECT votes.who, votes.vote_count
|
|
|
|
FROM votes
|
|
|
|
INNER JOIN bugs
|
|
|
|
ON bugs.bug_id = votes.bug_id
|
|
|
|
WHERE bugs.product_id = ?',
|
|
|
|
undef, $product->id);
|
2005-09-08 20:58:57 +04:00
|
|
|
|
2000-02-17 08:15:23 +03:00
|
|
|
my %counts;
|
2005-10-28 14:25:06 +04:00
|
|
|
foreach my $vote (@$votes) {
|
|
|
|
my ($who, $count) = @$vote;
|
2000-02-17 08:15:23 +03:00
|
|
|
if (!defined $counts{$who}) {
|
|
|
|
$counts{$who} = $count;
|
|
|
|
} else {
|
|
|
|
$counts{$who} += $count;
|
|
|
|
}
|
|
|
|
}
|
2005-09-08 20:58:57 +04:00
|
|
|
my @toomanytotalvotes_list = ();
|
2000-02-17 08:15:23 +03:00
|
|
|
foreach my $who (keys(%counts)) {
|
|
|
|
if ($counts{$who} > $votesperuser) {
|
2005-10-28 14:25:06 +04:00
|
|
|
my $bug_ids = $dbh->selectcol_arrayref(
|
|
|
|
'SELECT votes.bug_id
|
|
|
|
FROM votes
|
|
|
|
INNER JOIN bugs
|
|
|
|
ON bugs.bug_id = votes.bug_id
|
|
|
|
WHERE bugs.product_id = ?
|
|
|
|
AND votes.who = ?',
|
|
|
|
undef, ($product->id, $who));
|
|
|
|
|
|
|
|
foreach my $bug_id (@$bug_ids) {
|
2006-02-25 01:53:32 +03:00
|
|
|
# RemoveVotes() returns a list of messages to send
|
|
|
|
# in case some voters had too many votes.
|
|
|
|
my $msgs =
|
|
|
|
RemoveVotes($bug_id, $who, "The rules for voting on this " .
|
|
|
|
"product has changed; you had " .
|
|
|
|
"too many\ntotal votes, so all " .
|
|
|
|
"votes have been removed.");
|
|
|
|
foreach my $msg (@$msgs) {
|
2006-06-02 14:50:15 +04:00
|
|
|
MessageToMTA($msg);
|
2006-02-25 01:53:32 +03:00
|
|
|
}
|
2006-06-19 21:30:24 +04:00
|
|
|
my $name = user_id_to_login($who);
|
2005-09-08 20:58:57 +04:00
|
|
|
|
|
|
|
push(@toomanytotalvotes_list,
|
2005-10-28 14:25:06 +04:00
|
|
|
{id => $bug_id, name => $name});
|
2000-02-17 08:15:23 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-09-08 20:58:57 +04:00
|
|
|
$vars->{'toomanytotalvotes'} = \@toomanytotalvotes_list;
|
|
|
|
|
2004-12-11 16:33:27 +03:00
|
|
|
# 3. enough votes to confirm
|
2005-10-28 14:25:06 +04:00
|
|
|
my $bug_list = $dbh->selectcol_arrayref(
|
|
|
|
"SELECT bug_id FROM bugs
|
|
|
|
WHERE product_id = ?
|
|
|
|
AND bug_status = 'UNCONFIRMED'
|
|
|
|
AND votes >= ?",
|
|
|
|
undef, ($product->id, $votestoconfirm));
|
2005-09-08 20:58:57 +04:00
|
|
|
|
2005-08-23 16:17:17 +04:00
|
|
|
my @updated_bugs = ();
|
|
|
|
foreach my $bug_id (@$bug_list) {
|
|
|
|
my $confirmed = CheckIfVotedConfirmed($bug_id, $whoid);
|
|
|
|
push (@updated_bugs, $bug_id) if $confirmed;
|
|
|
|
}
|
|
|
|
|
2005-09-08 20:58:57 +04:00
|
|
|
$vars->{'confirmedbugs'} = \@updated_bugs;
|
2006-06-19 02:57:34 +04:00
|
|
|
$vars->{'changer'} = $user->login;
|
2000-02-17 08:15:23 +03:00
|
|
|
}
|
2006-10-15 02:02:13 +04:00
|
|
|
delete_token($token);
|
2000-02-17 08:15:23 +03:00
|
|
|
|
2005-10-18 01:43:42 +04:00
|
|
|
$vars->{'old_product'} = $product_old;
|
|
|
|
$vars->{'product'} = $product;
|
|
|
|
|
2005-09-08 20:58:57 +04:00
|
|
|
$template->process("admin/products/updated.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
1999-10-13 03:00:35 +04:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2002-11-24 22:56:34 +03:00
|
|
|
#
|
|
|
|
# action='editgroupcontrols' -> update product group controls
|
|
|
|
#
|
|
|
|
|
|
|
|
if ($action eq 'editgroupcontrols') {
|
2006-11-10 19:51:30 +03:00
|
|
|
my $product = $user->check_can_admin_product($product_name);
|
2005-12-12 06:12:26 +03:00
|
|
|
|
2002-11-24 22:56:34 +03:00
|
|
|
# Display a group if it is either enabled or has bugs for this product.
|
2005-10-28 14:25:06 +04:00
|
|
|
my $groups = $dbh->selectall_arrayref(
|
|
|
|
'SELECT id, name, entry, membercontrol, othercontrol, canedit,
|
2006-11-10 19:51:30 +03:00
|
|
|
editcomponents, editbugs, canconfirm,
|
2005-10-28 14:25:06 +04:00
|
|
|
isactive, COUNT(bugs.bug_id) AS bugcount
|
|
|
|
FROM groups
|
|
|
|
LEFT JOIN group_control_map
|
|
|
|
ON group_control_map.group_id = groups.id
|
|
|
|
AND group_control_map.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 = ?
|
|
|
|
WHERE isbuggroup != 0
|
|
|
|
AND (isactive != 0 OR entry IS NOT NULL OR bugs.bug_id IS NOT NULL) ' .
|
|
|
|
$dbh->sql_group_by('name', 'id, entry, membercontrol,
|
2006-11-10 19:51:30 +03:00
|
|
|
othercontrol, canedit, isactive,
|
|
|
|
editcomponents, canconfirm, editbugs'),
|
2005-10-28 14:25:06 +04:00
|
|
|
{'Slice' => {}}, ($product->id, $product->id));
|
|
|
|
|
2002-11-24 22:56:34 +03:00
|
|
|
$vars->{'product'} = $product;
|
2005-10-28 14:25:06 +04:00
|
|
|
$vars->{'groups'} = $groups;
|
2006-10-15 02:02:13 +04:00
|
|
|
$vars->{'token'} = issue_session_token('edit_group_controls');
|
2005-10-18 01:43:42 +04:00
|
|
|
|
2002-11-24 22:56:34 +03:00
|
|
|
$vars->{'const'} = {
|
|
|
|
'CONTROLMAPNA' => CONTROLMAPNA,
|
|
|
|
'CONTROLMAPSHOWN' => CONTROLMAPSHOWN,
|
|
|
|
'CONTROLMAPDEFAULT' => CONTROLMAPDEFAULT,
|
|
|
|
'CONTROLMAPMANDATORY' => CONTROLMAPMANDATORY,
|
|
|
|
};
|
|
|
|
|
|
|
|
$template->process("admin/products/groupcontrol/edit.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|
|
|
|
exit;
|
|
|
|
}
|
1999-10-13 03:00:35 +04:00
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# No valid action found
|
|
|
|
#
|
|
|
|
|
2005-09-16 20:14:18 +04:00
|
|
|
ThrowUserError('no_valid_action', {field => "product"});
|