diff options
author | David Lawrence <dkl@mozilla.com> | 2015-07-09 03:44:19 +0200 |
---|---|---|
committer | David Lawrence <dkl@mozilla.com> | 2015-07-09 03:44:19 +0200 |
commit | 5cc7059954467225ef8055df8a1623bea926f216 (patch) | |
tree | 84a1c3cdce1e19a830f3251bb70a2f6caa8a3005 /extensions/BMO | |
parent | c230ed48168bf5dfaa76f2f5cdecf3f45e899b83 (diff) | |
download | bugzilla-5cc7059954467225ef8055df8a1623bea926f216.tar.gz bugzilla-5cc7059954467225ef8055df8a1623bea926f216.tar.xz |
Bug 1173442: Implement admin UI changes to allow selecting default product security group instead of editing code
Diffstat (limited to 'extensions/BMO')
-rw-r--r-- | extensions/BMO/Extension.pm | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/extensions/BMO/Extension.pm b/extensions/BMO/Extension.pm index 951799bfa..f90f08318 100644 --- a/extensions/BMO/Extension.pm +++ b/extensions/BMO/Extension.pm @@ -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. |