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); 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 sub users_in_group
{ {
my $self = shift; my $self = shift;
@ -152,9 +152,14 @@ sub users_in_group
$check_bless{$_} ||= 1 for map { keys %{$group_grants->{$_}} } keys %check_bless; $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( my $rows = Bugzilla->dbh->selectall_arrayref(
"SELECT ugm.*, g.name group_name FROM user_group_map ugm, groups g". "SELECT ugm.*, g.name group_name FROM user_group_map ugm".
" WHERE ugm.group_id=g.id AND ugm.group_id IN (".join(', ', keys %check_grant, keys %check_bless).")", " 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=>{}} {Slice=>{}}
); );
my $res = {}; my $res = {};

View File

@ -47,11 +47,6 @@ my $vars = {};
my $user = Bugzilla->login(LOGIN_REQUIRED); 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 $action = trim($cgi->param('action') || '');
my $token = $cgi->param('token'); 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.
unless ($action) { $vars->{allow_edit} = $user->in_group('creategroups');
my @groups = Bugzilla::Group->get_all;
$vars->{'groups'} = \@groups; unless ($action)
{
my $groups = $vars->{allow_edit}
? [ Bugzilla::Group->get_all ]
: $user->bless_groups;
$vars->{groups} = $groups;
$template->process("admin/groups/list.html.tmpl", $vars) $template->process("admin/groups/list.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
exit; 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 # 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 statuses available on [% terms.bug %] creation and allowed [% terms.bug %] status
transitions when editing existing [% terms.bugs %].</dd> 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> <dt id="groups" class="[% class %]"><a href="editgroups.cgi">Groups</a></dt>
<dd class="[% class %]">Define groups which will be used in the installation. <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 They can either be used to define new user privileges or to restrict the access
to some [% terms.bugs %].</dd> to some [% terms.bugs %].
[% END %]
</dd>
[% class = user.in_group('editkeywords') ? "" : "forbidden" %] [% class = user.in_group('editkeywords') ? "" : "forbidden" %]
<dt id="keywords" class="[% class %]"><a href="editkeywords.cgi">Keywords</a></dt> <dt id="keywords" class="[% class %]"><a href="editkeywords.cgi">Keywords</a></dt>

View File

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

View File

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