Allow to go into editusersingroup.cgi from Administration->Groups

master
Vitaliy Filippov 2014-05-30 17:07:04 +04:00
parent 5cfdec71f6
commit 65b39b45d2
5 changed files with 72 additions and 31 deletions

View File

@ -120,7 +120,7 @@ sub _get_members {
return Bugzilla::User->new_from_list($user_ids);
}
# Returns all active users who are in this group or can bless it
# Returns all active visible users who are in this group or can bless it
sub users_in_group
{
my $self = shift;
@ -152,9 +152,14 @@ sub users_in_group
$check_bless{$_} ||= 1 for map { keys %{$group_grants->{$_}} } keys %check_bless;
}
# Optionally show only users in visible groups
my $vis = Bugzilla->params->{usevisibilitygroups} && Bugzilla->user->visible_groups_as_string;
my $rows = Bugzilla->dbh->selectall_arrayref(
"SELECT ugm.*, g.name group_name FROM user_group_map ugm, groups g".
" WHERE ugm.group_id=g.id AND ugm.group_id IN (".join(', ', keys %check_grant, keys %check_bless).")",
"SELECT ugm.*, g.name group_name FROM user_group_map ugm".
" INNER JOIN groups g ON g.id=ugm.group_id".
($vis ? " INNER JOIN user_group_map uvm ON uvm.user_id=ugm.user_id AND uvm.isbless=0 AND uvm.group_id IN ($vis)" : "").
" WHERE ugm.group_id IN (".join(', ', keys %check_grant, keys %check_bless).")",
{Slice=>{}}
);
my $res = {};

View File

@ -47,11 +47,6 @@ my $vars = {};
my $user = Bugzilla->login(LOGIN_REQUIRED);
$user->in_group('creategroups')
|| ThrowUserError("auth_failure", {group => "creategroups",
action => "edit",
object => "groups"});
my $action = trim($cgi->param('action') || '');
my $token = $cgi->param('token');
@ -146,17 +141,31 @@ sub get_current_and_available {
}
}
# If no action is specified, get a list of all groups available.
# If no action is specified, get a list of groups the current user can bless
# so he can enter 'editusersingroup' for them, or the list of all groups
# available if he has 'creategroups' permissions.
$vars->{allow_edit} = $user->in_group('creategroups');
unless ($action)
{
my $groups = $vars->{allow_edit}
? [ Bugzilla::Group->get_all ]
: $user->bless_groups;
$vars->{groups} = $groups;
unless ($action) {
my @groups = Bugzilla::Group->get_all;
$vars->{'groups'} = \@groups;
$template->process("admin/groups/list.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
|| ThrowTemplateError($template->error());
exit;
}
# All other actions are protected by the 'creategroups' permission.
$vars->{allow_edit}
|| ThrowUserError("auth_failure", {group => "creategroups",
action => "edit",
object => "groups"});
#
# action='changeform' -> present form for altering an existing group
#

View File

@ -108,11 +108,17 @@
statuses available on [% terms.bug %] creation and allowed [% terms.bug %] status
transitions when editing existing [% terms.bugs %].</dd>
[% class = user.in_group('creategroups') ? "" : "forbidden" %]
[% class = user.in_group('creategroups') || user.can_bless ? "" : "forbidden" %]
<dt id="groups" class="[% class %]"><a href="editgroups.cgi">Groups</a></dt>
<dd class="[% class %]">Define groups which will be used in the installation.
They can either be used to define new user privileges or to restrict the access
to some [% terms.bugs %].</dd>
<dd class="[% class %]">
[% IF user.can_bless && !user.in_group('creategroups') %]
Add/remove users in groups you are allowed to do so.
[% ELSE %]
Define groups which will be used in the installation.
They can either be used to define new user privileges or to restrict the access
to some [% terms.bugs %].
[% END %]
</dd>
[% class = user.in_group('editkeywords') ? "" : "forbidden" %]
<dt id="keywords" class="[% class %]"><a href="editkeywords.cgi">Keywords</a></dt>

View File

@ -41,38 +41,49 @@
[% editusers_contentlink = "editusersingroup.cgi?group=%%id%%" %]
[% del_contentlink = "editgroups.cgi?action=del&amp;group=%%id%%" %]
[% columns =
[{name => 'name'
[% columns = [
{
name => 'name'
heading => 'Name'
contentlink => edit_contentlink
contentlink => allow_edit ? edit_contentlink : editusers_contentlink
}
{name => 'description'
{
name => 'description'
heading => 'Description'
allow_html_content => 1
}
{name => 'userregexp'
];
%]
[% IF allow_edit;
columns.push(
{
name => 'userregexp'
heading => 'User RegExp'
}
{name => 'is_active_bug_group'
{
name => 'is_active_bug_group'
heading => "Use For $terms.Bugs"
align => 'center'
}
{name => 'type'
{
name => 'type'
heading => 'Type'
align => 'center'
}
{name => 'action'
{
name => 'action'
heading => 'Action'
align => 'center'
}
{name => 'members'
{
name => 'members'
heading => 'Members'
align => 'center'
contentlink => editusers_contentlink
content => 'edit'
}
]
%]
);
END %]
[% overrides.is_active_bug_group = {
'is_active_bug_group' => {
@ -128,7 +139,7 @@
content => "user"
}
}
%]
%]
[% PROCESS admin/table.html.tmpl
columns = columns
@ -136,6 +147,8 @@
overrides = overrides
%]
[% IF allow_edit %]
<p><a href="editgroups.cgi?action=add">Add Group</a></p>
<p>
@ -173,4 +186,6 @@ for [% terms.bug %] restrictions.
The <b>Type</b> field identifies system groups.
</p>
[% END %]
[% PROCESS global/footer.html.tmpl %]

View File

@ -24,6 +24,12 @@
<th>Description:</th>
<td>[% group.description | html %]</td>
</tr>
[% IF group.regexp %]
<tr>
<th>Regexp:</th>
<td>[% group.regexp | html %]</td>
</tr>
[% END %]
</table>
<p>Add users to this group:</p>
@ -87,7 +93,7 @@
[% ELSIF u.bless_regexp %][%# (in fact impossible) %]
matches regexp
[% ELSIF u.bless_indirect %]
via [% u.member_indirect | html %]
via [% u.bless_indirect | html %]
[% END %]
</td>
</tr>