diff options
author | Simon Green <sgreen@redhat.com> | 2014-06-14 07:22:22 +0200 |
---|---|---|
committer | Simon Green <sgreen@redhat.com> | 2014-06-14 07:22:22 +0200 |
commit | 80c434b3c9afec9ba606e5061ef042d3b96720d3 (patch) | |
tree | 535d7785636b038ade627b082bd078c2764b7e2a /Bugzilla/User.pm | |
parent | 6c6efdde5b5e041deb75f65b5a18baae7665d660 (diff) | |
download | bugzilla-80c434b3c9afec9ba606e5061ef042d3b96720d3.tar.gz bugzilla-80c434b3c9afec9ba606e5061ef042d3b96720d3.tar.xz |
Bug 1012508 - Add a admin_menu hook to change who has access to admin.cgi
r=gerv, a=sgreen
Diffstat (limited to 'Bugzilla/User.pm')
-rw-r--r-- | Bugzilla/User.pm | 28 |
1 files changed, 28 insertions, 0 deletions
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<can_administer> + +Returns 1 if the user can see the admin menu. Otherwise, returns 0 + =item C<check_can_admin_product($product_name)> Description: Checks whether the user is allowed to administrate the product. |