Commit c457b4c4 authored by bugreport%peshkin.net's avatar bugreport%peshkin.net

Bug 184081 Change search interfaces to use Viewable products instead of enterable products

r=bbaetz a=justdave
parent e9093fd7
...@@ -261,8 +261,11 @@ sub check_netmask { ...@@ -261,8 +261,11 @@ sub check_netmask {
{ {
name => 'useentrygroupdefault', name => 'useentrygroupdefault',
desc => 'If this is on, Bugzilla will use product bug groups to restrict ' . desc => 'If this is on, Bugzilla will use product bug groups by default ' .
'who can enter bugs. Requires makeproductgroups to be on as well.', 'to restrict who can enter bugs. If this is on, users can see ' .
'any product to which they have entry access in search menus. ' .
'If this is off, users can see any product to which they have not ' .
'been excluded by a mandatory restriction.',
type => 'b', type => 'b',
default => 0 default => 0
}, },
......
...@@ -774,12 +774,17 @@ sub CanEnterProduct { ...@@ -774,12 +774,17 @@ sub CanEnterProduct {
# #
# This function returns an alphabetical list of product names to which # This function returns an alphabetical list of product names to which
# the user can enter bugs. # the user can enter bugs.
sub GetEnterableProducts { sub GetSelectableProducts {
my $query = "SELECT name " . my $query = "SELECT name " .
"FROM products " . "FROM products " .
"LEFT JOIN group_control_map " . "LEFT JOIN group_control_map " .
"ON group_control_map.product_id = products.id " . "ON group_control_map.product_id = products.id ";
"AND group_control_map.entry != 0 "; if (Param('useentrygroupdefault')) {
$query .= "AND group_control_map.entry != 0 ";
} else {
$query .= "AND group_control_map.membercontrol = " .
CONTROLMAPMANDATORY . " ";
}
if ((defined @{$::vars->{user}{groupids}}) if ((defined @{$::vars->{user}{groupids}})
&& (@{$::vars->{user}{groupids}} > 0)) { && (@{$::vars->{user}{groupids}} > 0)) {
$query .= "AND group_id NOT IN(" . $query .= "AND group_id NOT IN(" .
...@@ -796,19 +801,24 @@ sub GetEnterableProducts { ...@@ -796,19 +801,24 @@ sub GetEnterableProducts {
return (@products); return (@products);
} }
# GetEnterableProductHash # GetSelectableProductHash
# returns a hash containing # returns a hash containing
# legal_products => an enterable product list # legal_products => an enterable product list
# legal_components => the list of components of enterable products # legal_components => the list of components of enterable products
# components => a hash of component lists for each enterable product # components => a hash of component lists for each enterable product
sub GetEnterableProductHash { sub GetSelectableProductHash {
my $query = "SELECT products.name, components.name " . my $query = "SELECT products.name, components.name " .
"FROM products " . "FROM products " .
"LEFT JOIN components " . "LEFT JOIN components " .
"ON components.product_id = products.id " . "ON components.product_id = products.id " .
"LEFT JOIN group_control_map " . "LEFT JOIN group_control_map " .
"ON group_control_map.product_id = products.id " . "ON group_control_map.product_id = products.id ";
"AND group_control_map.entry != 0 "; if (Param('useentrygroupdefault')) {
$query .= "AND group_control_map.entry != 0 ";
} else {
$query .= "AND group_control_map.membercontrol = " .
CONTROLMAPMANDATORY . " ";
}
if ((defined @{$::vars->{user}{groupids}}) if ((defined @{$::vars->{user}{groupids}})
&& (@{$::vars->{user}{groupids}} > 0)) { && (@{$::vars->{user}{groupids}} > 0)) {
$query .= "AND group_id NOT IN(" . $query .= "AND group_id NOT IN(" .
......
...@@ -198,7 +198,7 @@ my @products = (); ...@@ -198,7 +198,7 @@ my @products = ();
my %component_set; my %component_set;
my %version_set; my %version_set;
my %milestone_set; my %milestone_set;
foreach my $p (GetEnterableProducts()) { foreach my $p (GetSelectableProducts()) {
# We build up boolean hashes in the "-set" hashes for each of these things # We build up boolean hashes in the "-set" hashes for each of these things
# before making a list because there may be duplicates names across products. # before making a list because there may be duplicates names across products.
push @products, $p; push @products, $p;
......
...@@ -61,9 +61,7 @@ GetVersionTable(); ...@@ -61,9 +61,7 @@ GetVersionTable();
# We only want those products that the user has permissions for. # We only want those products that the user has permissions for.
my @myproducts; my @myproducts;
push( @myproducts, "-All-"); push( @myproducts, "-All-");
foreach my $this_product (@legal_product) { push( @myproducts, GetSelectableProducts());
push(@myproducts, $this_product) if CanEnterProduct($this_product);
}
if (! defined $FORM{'product'}) { if (! defined $FORM{'product'}) {
......
...@@ -254,10 +254,10 @@ sub queue { ...@@ -254,10 +254,10 @@ sub queue {
# menu when the products menu changes; used by the template to populate # menu when the products menu changes; used by the template to populate
# the menus and keep the components menu consistent with the products menu # the menus and keep the components menu consistent with the products menu
GetVersionTable(); GetVersionTable();
my $enterable = GetEnterableProductHash(); my $selectable = GetSelectableProductHash();
$vars->{'products'} = $enterable->{legal_products}; $vars->{'products'} = $selectable->{legal_products};
$vars->{'components'} = $enterable->{legal_components}; $vars->{'components'} = $selectable->{legal_components};
$vars->{'components_by_product'} = $enterable->{components}; $vars->{'components_by_product'} = $selectable->{components};
$vars->{'excluded_columns'} = \@excluded_columns; $vars->{'excluded_columns'} = \@excluded_columns;
$vars->{'group_field'} = $::FORM{'group'}; $vars->{'group_field'} = $::FORM{'group'};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment