# If so, then groups may have to be changed when bugs move from
# one bug to another.
sub AnyDefaultGroups {
+ my $product_id = shift;
my $dbh = Bugzilla->dbh;
+ my $grouplist = Bugzilla->user->groups_as_string;
+
+ my $and_product = $product_id ? ' AND product_id = ? ' : '';
+ my @args = (CONTROLMAPDEFAULT);
+ unshift(@args, $product_id) if $product_id;
+
my $any_default =
- $dbh->selectrow_array('SELECT 1
+ $dbh->selectrow_array("SELECT 1
FROM group_control_map
INNER JOIN groups
ON groups.id = group_control_map.group_id
WHERE isactive != 0
- AND (membercontrol = ? OR othercontrol = ?) ' .
+ $and_product
+ AND membercontrol = ?
+ AND group_id IN ($grouplist) " .
$dbh->sql_limit(1),
- undef, (CONTROLMAPDEFAULT, CONTROLMAPDEFAULT));
+ undef, @args);
return $any_default;
}
# shown. Also show the verification form if the product-specific fields
# somehow still need to be verified, or if we need to verify whether or not
# to add the bugs to their new product's group.
+ my $has_default_groups = AnyDefaultGroups($prod_obj->id);
+
if (!$vok || !$cok || !$mok || !defined $cgi->param('confirm_product_change')
- || (AnyDefaultGroups() && !defined $cgi->param('addtonewgroup'))) {
+ || ($has_default_groups && !defined $cgi->param('addtonewgroup'))) {
if (Bugzilla->usage_mode == USAGE_MODE_EMAIL) {
if (!$vok) {
else {
$vars->{'verify_fields'} = 0;
}
-
- $vars->{'verify_bug_group'} = (AnyDefaultGroups()
+
+ $vars->{'verify_bug_group'} = ($has_default_groups
&& !defined $cgi->param('addtonewgroup'));
-
+
+ # Get the ID of groups which are no longer valid in the new product.
+ # If the bug was restricted to some group which still exists in the new
+ # product, leave it alone, independently of your privileges.
+ my $gids =
+ $dbh->selectcol_arrayref("SELECT bgm.group_id
+ FROM bug_group_map AS bgm
+ WHERE bgm.bug_id IN (" . join(', ', @idlist) . ")
+ AND bgm.group_id NOT IN
+ (SELECT gcm.group_id
+ FROM group_control_map AS gcm
+ WHERE gcm.product_id = ?
+ AND gcm.membercontrol IN (?, ?, ?))",
+ undef, ($prod_obj->id, CONTROLMAPSHOWN,
+ CONTROLMAPDEFAULT, CONTROLMAPMANDATORY));
+
+ $vars->{'old_groups'} = Bugzilla::Group->new_from_list($gids);
+
$template->process("bug/process/verify-new-product.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
undef, $oldhash{'product_id'}, $product->id, $id);
my @groupstoremove = ();
my @groupstoadd = ();
- my @defaultstoremove = ();
my @defaultstoadd = ();
my @allgroups = ();
my $buginanydefault = 0;
- my $buginanychangingdefault = 0;
foreach my $group (@$groups) {
my ($groupid, $isactive, $oldcontrol, $newcontrol,
$useringroup, $bugingroup) = @$group;
&& ($oldcontrol == CONTROLMAPDEFAULT)) {
# Bug was in a default group.
$buginanydefault = 1;
- if (($newcontrol != CONTROLMAPDEFAULT)
- && ($newcontrol != CONTROLMAPMANDATORY)) {
- # Bug was in a default group that no longer is.
- $buginanychangingdefault = 1;
- push (@defaultstoremove, $groupid);
- }
}
if (($isactive) && (!$bugingroup)
&& ($newcontrol == CONTROLMAPDEFAULT)
push(@groupstoadd, $groupid);
}
}
- # If addtonewgroups = "yes", old default groups will be removed
- # and new default groups will be added.
- # If addtonewgroups = "yesifinold", old default groups will be removed
- # and new default groups will be added only if the bug was in ANY
- # of the old default groups.
- # If addtonewgroups = "no", old default groups will be removed and not
- # replaced.
- push(@groupstoremove, @defaultstoremove);
+ # If addtonewgroups = "yes", new default groups will be added.
+ # If addtonewgroups = "yesifinold", new default groups will be
+ # added only if the bug was in ANY of the old default groups.
+ # If addtonewgroups = "no", old default groups are left alone
+ # and no new default group will be added.
if (AnyDefaultGroups()
&& (($cgi->param('addtonewgroup') eq 'yes')
|| (($cgi->param('addtonewgroup') eq 'yesifinold')
# Rights Reserved.
#
# Contributor(s): Myk Melez <myk@mozilla.org>
+ # Frédéric Buclin <LpSolit@gmail.com>
#%]
[%# INTERFACE:
# if they want to add the bug to its new product's group
# use_target_milestone: boolean; whether or not to use
# the target milestone field
+ # old_groups: a list of group objects which are not available
+ # for the new product.
#%]
[%# The global Bugzilla->cgi object is used to obtain form variable values. %]
[% END %]
-[% IF verify_bug_group %]
+[% IF verify_bug_group || old_groups.size %]
<h3>Verify [% terms.Bug %] Group</h3>
- <p>
- Do you want to add the [% terms.bug %] to its new product's default groups (if any)?
- </p>
+ [% IF old_groups.size %]
+ <p>The following groups are not legal for the <b>[% cgi.param("product") FILTER html %]</b>
+ product or you are not allowed to restrict [% terms.bugs %] to these groups:</p>
+ <ul>
+ [% FOREACH group = old_groups %]
+ <li>[% group.name FILTER html %]: [% group.description FILTER html %]</li>
+ [% END %]
+ </ul>
+ <p><b>[%+ terms.Bugs %] will no longer be restricted to these groups and may become
+ public if no other group applies.</b></p>
+ [% END %]
- <p>
- <input type="radio" name="addtonewgroup" value="no"><b>no</b><br>
- <input type="radio" name="addtonewgroup" value="yes"><b>yes</b><br>
- <input type="radio" name="addtonewgroup" value="yesifinold" checked="checked">
- <b>yes, but only if the [% terms.bug %] was in any of its old product's default groups</b><br>
- </p>
+ [% IF verify_bug_group %]
+ <p>
+ This new product has default groups associated to it. Do you want to add the
+ [%+ terms.bug %] to them?<br>
+ <input type="radio" id="add_no" name="addtonewgroup" value="no"><label for="add_no">no</label><br>
+ <input type="radio" id="add_yes" name="addtonewgroup" value="yes"><label for="add_yes">yes</label><br>
+ <input type="radio" id="add_yesifinold" name="addtonewgroup" value="yesifinold" checked="checked">
+ <label for="add_yesifinold">yes, but only if the [% terms.bug %] was in any of
+ its old product's default groups</label>
+ </p>
+ [% END %]
[% END %]
-<input type="submit" id="change_product" value="Commit">
+<p>
+ <input type="submit" id="change_product" value="Commit">
+</p>
</form>
<hr>