From 946e9116c2a2a4ccbc44f657827087bf44ba295a Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Thu, 7 Sep 2017 11:04:07 -0400 Subject: Bug 1397747 - Move _get_all_group_names to Bugzilla::Config::Common::_get_all_group_names, and remove copy-pasted code --- Bugzilla/Config/Common.pm | 8 ++++++++ Bugzilla/Config/GroupSecurity.pm | 18 +++++++----------- extensions/AntiSpam/lib/Config.pm | 8 +------- extensions/BMO/Extension.pm | 4 ++-- extensions/EditComments/Extension.pm | 2 +- extensions/RestrictComments/lib/Config.pm | 10 ++-------- 6 files changed, 21 insertions(+), 29 deletions(-) diff --git a/Bugzilla/Config/Common.pm b/Bugzilla/Config/Common.pm index cbb030a9c..8b1a9da91 100644 --- a/Bugzilla/Config/Common.pm +++ b/Bugzilla/Config/Common.pm @@ -30,6 +30,7 @@ use base qw(Exporter); check_bug_status check_smtp_auth check_theschwartz_available check_maxattachmentsize check_email check_comment_taggers_group + get_all_group_names ); # Checking functions for the various values @@ -345,6 +346,13 @@ sub check_comment_taggers_group { return check_group($group_name); } +sub get_all_group_names { + return [ + '', + map { $_->name } Bugzilla::Group->get_all, + ]; +} + # OK, here are the parameter definitions themselves. # # Each definition is a hash with keys: diff --git a/Bugzilla/Config/GroupSecurity.pm b/Bugzilla/Config/GroupSecurity.pm index c9d6421d3..68c852fe6 100644 --- a/Bugzilla/Config/GroupSecurity.pm +++ b/Bugzilla/Config/GroupSecurity.pm @@ -29,7 +29,7 @@ sub get_param_list { { name => 'chartgroup', type => 's', - choices => \&_get_all_group_names, + choices => \&get_all_group_names, default => 'editbugs', checker => \&check_group }, @@ -37,7 +37,7 @@ sub get_param_list { { name => 'insidergroup', type => 's', - choices => \&_get_all_group_names, + choices => \&get_all_group_names, default => '', checker => \&check_group }, @@ -45,7 +45,7 @@ sub get_param_list { { name => 'timetrackinggroup', type => 's', - choices => \&_get_all_group_names, + choices => \&get_all_group_names, default => 'editbugs', checker => \&check_group }, @@ -53,7 +53,7 @@ sub get_param_list { { name => 'querysharegroup', type => 's', - choices => \&_get_all_group_names, + choices => \&get_all_group_names, default => 'editbugs', checker => \&check_group }, @@ -61,7 +61,7 @@ sub get_param_list { { name => 'comment_taggers_group', type => 's', - choices => \&_get_all_group_names, + choices => \&get_all_group_names, default => 'editbugs', checker => \&check_comment_taggers_group }, @@ -69,7 +69,7 @@ sub get_param_list { { name => 'debug_group', type => 's', - choices => \&_get_all_group_names, + choices => \&get_all_group_names, default => 'admin', checker => \&check_group }, @@ -89,10 +89,6 @@ sub get_param_list { return @param_list; } -sub _get_all_group_names { - my @group_names = map { $_->name } Bugzilla::Group->get_all; - unshift( @group_names, '' ); - return \@group_names; -} + 1; diff --git a/extensions/AntiSpam/lib/Config.pm b/extensions/AntiSpam/lib/Config.pm index b6d1234d9..e35a7f001 100644 --- a/extensions/AntiSpam/lib/Config.pm +++ b/extensions/AntiSpam/lib/Config.pm @@ -23,7 +23,7 @@ sub get_param_list { { name => 'antispam_spammer_exclude_group', type => 's', - choices => \&_get_all_group_names, + choices => \&get_all_group_names, default => 'canconfirm', checker => \&check_group }, @@ -79,10 +79,4 @@ sub get_param_list { return @param_list; } -sub _get_all_group_names { - my @group_names = map {$_->name} Bugzilla::Group->get_all; - unshift(@group_names, ''); - return \@group_names; -} - 1; diff --git a/extensions/BMO/Extension.pm b/extensions/BMO/Extension.pm index cb1996cbc..db672f82a 100644 --- a/extensions/BMO/Extension.pm +++ b/extensions/BMO/Extension.pm @@ -31,7 +31,7 @@ use base qw(Bugzilla::Extension); use Bugzilla::Bug; use Bugzilla::BugMail; -use Bugzilla::Config::Common qw(check_group); +use Bugzilla::Config::Common qw(check_group get_all_group_names); use Bugzilla::Constants; use Bugzilla::Error; use Bugzilla::Field; @@ -2579,7 +2579,7 @@ sub config_modify_panels { push @{ $args->{panels}->{groupsecurity}->{params} }, { name => 'delete_comments_group', type => 's', - choices => \&Bugzilla::Config::GroupSecurity::_get_all_group_names, + choices => \&get_all_group_names, default => 'admin', checker => \&check_group }; diff --git a/extensions/EditComments/Extension.pm b/extensions/EditComments/Extension.pm index 1dc22a85e..ab19ab6e7 100644 --- a/extensions/EditComments/Extension.pm +++ b/extensions/EditComments/Extension.pm @@ -249,7 +249,7 @@ sub config_modify_panels { push @{ $args->{panels}->{groupsecurity}->{params} }, { name => 'edit_comments_group', type => 's', - choices => \&Bugzilla::Config::GroupSecurity::_get_all_group_names, + choices => \&get_all_group_names, default => 'admin', checker => \&check_group }; diff --git a/extensions/RestrictComments/lib/Config.pm b/extensions/RestrictComments/lib/Config.pm index 55cf11187..e5dbc518c 100644 --- a/extensions/RestrictComments/lib/Config.pm +++ b/extensions/RestrictComments/lib/Config.pm @@ -23,14 +23,14 @@ sub get_param_list { { name => 'restrict_comments_group', type => 's', - choices => \&_get_all_group_names, + choices => \&get_all_group_names, default => '', checker => \&check_group }, { name => 'restrict_comments_enable_group', type => 's', - choices => \&_get_all_group_names, + choices => \&get_all_group_names, default => '', checker => \&check_group }, @@ -39,10 +39,4 @@ sub get_param_list { return @param_list; } -sub _get_all_group_names { - my @group_names = map {$_->name} Bugzilla::Group->get_all; - unshift(@group_names, ''); - return \@group_names; -} - 1; -- cgit v1.2.3-24-g4f1b