From 80c434b3c9afec9ba606e5061ef042d3b96720d3 Mon Sep 17 00:00:00 2001 From: Simon Green Date: Sat, 14 Jun 2014 15:22:22 +1000 Subject: Bug 1012508 - Add a admin_menu hook to change who has access to admin.cgi r=gerv, a=sgreen --- Bugzilla/User.pm | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'Bugzilla/User.pm') diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index 7aeb9f8ee..2631a5eae 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -1446,6 +1446,30 @@ sub get_accessible_products { return [ sort { $a->name cmp $b->name } values %products ]; } +sub can_administer { + my $self = shift; + + if (not defined $self->{can_administer}) { + my $can_administer = 0; + + $can_administer = 1 if $self->in_group('admin') + || $self->in_group('tweakparams') + || $self->in_group('editusers') + || $self->can_bless + || (Bugzilla->params->{'useclassification'} && $self->in_group('editclassifications')) + || $self->in_group('editcomponents') + || scalar(@{$self->get_products_by_permission('editcomponents')}) + || $self->in_group('creategroups') + || $self->in_group('editkeywords') + || $self->in_group('bz_canusewhines'); + + Bugzilla::Hook::process('user_can_administer', { can_administer => \$can_administer }); + $self->{can_administer} = $can_administer; + } + + return $self->{can_administer}; +} + sub check_can_admin_product { my ($self, $product_name) = @_; @@ -2876,6 +2900,10 @@ not be aware of the existence of the product. Returns: an array of product objects. +=item C + +Returns 1 if the user can see the admin menu. Otherwise, returns 0 + =item C Description: Checks whether the user is allowed to administrate the product. -- cgit v1.2.3-24-g4f1b