Skip to content

Commit

Permalink
Bug 1173442: Implement admin UI changes to allow selecting default pr…
Browse files Browse the repository at this point in the history
…oduct security group instead of editing code
  • Loading branch information
dklawren committed Jul 9, 2015
1 parent c230ed4 commit 5cc7059
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions extensions/BMO/Extension.pm
Expand Up @@ -1112,6 +1112,38 @@ sub install_update_db {
buglist => 0,
});
}

# Add default security group id column
if (!$dbh->bz_column_info('products', 'security_group_id')) {
$dbh->bz_add_column(
'products',
'security_group_id' => {
TYPE => 'INT3',
REFERENCES => {
TABLE => 'groups',
COLUMN => 'id',
DELETE => 'SET NULL',
},
}
);
# Migrate values in Data.pm
# 1. Set all to core-security by default
my $core_sec_group = Bugzilla::Group->new({ name => 'core-security' });
$dbh->do("UPDATE products SET security_group_id = ?",
undef, $core_sec_group->id);
# 2. Update the ones that have explicit security groups
foreach my $prod_name (keys %product_sec_groups) {
my $group_name = $product_sec_groups{$prod_name};
next if $group_name eq 'core-security'; # already done
my $group = Bugzilla::Group->new({ name => $group_name, cache => 1 });
if (!$group) {
print "Security group $group_name not found. Using core-security instead.\n";
next;
}
$dbh->do("UPDATE products SET security_group_id = ? WHERE name = ?",
undef, $group->id, $prod_name);
}
}
}

# return the Bugzilla::Field::Choice object for the specified field and value.
Expand Down

0 comments on commit 5cc7059

Please sign in to comment.