Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ivan Ivlev
bugzilla
Commits
80c434b3
Commit
80c434b3
authored
Jun 14, 2014
by
Simon Green
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 1012508 - Add a admin_menu hook to change who has access to admin.cgi
r=gerv, a=sgreen
parent
6c6efdde
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
15 deletions
+42
-15
User.pm
Bugzilla/User.pm
+28
-0
admin.cgi
admin.cgi
+1
-10
Extension.pm
extensions/Example/Extension.pm
+12
-0
common-links.html.tmpl
template/en/default/global/common-links.html.tmpl
+1
-5
No files found.
Bugzilla/User.pm
View file @
80c434b3
...
...
@@ -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.
...
...
admin.cgi
View file @
80c434b3
...
...
@@ -20,16 +20,7 @@ my $user = Bugzilla->login(LOGIN_REQUIRED);
print
$cgi
->
header
();
$user
->
in_group
(
'admin'
)
||
$user
->
in_group
(
'tweakparams'
)
||
$user
->
in_group
(
'editusers'
)
||
$user
->
can_bless
||
(
Bugzilla
->
params
->
{
'useclassification'
}
&&
$user
->
in_group
(
'editclassifications'
))
||
$user
->
in_group
(
'editcomponents'
)
||
scalar
(
@
{
$user
->
get_products_by_permission
(
'editcomponents'
)})
||
$user
->
in_group
(
'creategroups'
)
||
$user
->
in_group
(
'editkeywords'
)
||
$user
->
in_group
(
'bz_canusewhines'
)
$user
->
can_administer
||
ThrowUserError
(
'auth_failure'
,
{
action
=>
'access'
,
object
=>
'administrative_pages'
});
$template
->
process
(
'admin/admin.html.tmpl'
)
...
...
extensions/Example/Extension.pm
View file @
80c434b3
...
...
@@ -31,6 +31,18 @@ use constant REL_EXAMPLE => -127;
our
$VERSION
=
'1.0'
;
sub
user_can_administer
{
my
(
$self
,
$args
)
=
@_
;
my
$can_administer
=
$args
->
{
can_administer
};
# If you add an option to the admin pages (e.g. by using the Hooks in
# template/en/default/admin/admin.html.tmpl), you may want to allow
# users in another group view admin.cgi
#if (Bugzilla->user->in_group('other_group')) {
# $$can_administer = 1;
#}
}
sub
admin_editusers_action
{
my
(
$self
,
$args
)
=
@_
;
my
(
$vars
,
$action
,
$user
)
=
@$args
{
qw(vars action user)
};
...
...
template/en/default/global/common-links.html.tmpl
View file @
80c434b3
...
...
@@ -53,11 +53,7 @@
[% IF user.login %]
<li><span class="separator">| </span><a href="userprefs.cgi">Preferences</a></li>
[% IF user.in_group('tweakparams') || user.in_group('editusers') || user.can_bless
|| (Param('useclassification') && user.in_group('editclassifications'))
|| user.in_group('editcomponents') || user.in_group('admin') || user.in_group('creategroups')
|| user.in_group('editkeywords') || user.in_group('bz_canusewhines')
|| user.get_products_by_permission("editcomponents").size %]
[% IF user.can_administer %]
<li><span class="separator">| </span><a href="admin.cgi">Administration</a></li>
[% END %]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment