Show the same detailed table in group administration UI

master
Vitaliy Filippov 2014-08-12 19:07:24 +04:00
parent 461748c4a9
commit 37c688e5bb
8 changed files with 205 additions and 319 deletions

View File

@ -508,6 +508,36 @@ sub ValidateGroupName {
return $ret;
}
sub get_per_group_permissions
{
my $class = shift;
my $rows = Bugzilla->dbh->selectall_arrayref(
"SELECT g.*, p.name product_name FROM group_control_map g, products p".
" WHERE p.id=g.product_id", {Slice=>{}}
);
my $pergroup = {};
for my $row (@$rows)
{
for (qw(entry canedit editcomponents editbugs canconfirm))
{
if ($row->{$_})
{
push @{$pergroup->{$row->{group_id}}->{$_}}, $row->{product_name};
}
}
if ($row->{membercontrol} == CONTROLMAPMANDATORY &&
$row->{othercontrol} == CONTROLMAPMANDATORY)
{
push @{$pergroup->{$row->{group_id}}->{access}}, $row->{product_name};
}
elsif ($row->{membercontrol} || $row->{othercontrol})
{
push @{$pergroup->{$row->{group_id}}->{optional}}, $row->{product_name};
}
}
return $pergroup;
}
###############################
### Validators ###
###############################

View File

@ -218,10 +218,10 @@ $Bugzilla::messages->{en} = {
admin_index => 'Allows to <a href="admin.cgi">enter Administration area</a>, granted automatically if you can access any of the administration functions.',
tweakparams => 'Allows to <a href="editparams.cgi">change Parameters</a>.',
editusers => 'Allows to <a href="editusers.cgi">edit or disable users</a> and include/exclude them from <b>all</b> groups.',
creategroups => 'Allows to <a href="editgroups.cgi">create and destroy groups</a>.',
editclassifications => 'Allows to <a href="editclassifications.cgi">create, destroy, and edit classifications</a>.',
editcomponents => 'Allows to <a href="editproducts.cgi">create, destroy, and edit all products, components, versions and milestones</a>.',
editkeywords => 'Allows to <a href="editvalues.cgi?field=keywords">create, destroy, and edit keywords</a>.',
creategroups => 'Allows to <a href="editgroups.cgi">create, destroy and edit groups</a>.',
editclassifications => 'Allows to <a href="editclassifications.cgi">create, destroy and edit classifications</a>.',
editcomponents => 'Allows to <a href="editproducts.cgi">create, destroy and edit all products, components, versions and milestones</a>.',
editkeywords => 'Allows to <a href="editvalues.cgi?field=keywords">create, destroy and edit keywords</a>.',
editbugs => 'Allows to edit all fields of all bugs.',
canconfirm => 'Allows to confirm bugs or mark them as duplicates.',
bz_canusewhineatothers => 'Allows to <a href="editwhines.cgi">configure whine reports for other users</a>.',

View File

@ -149,13 +149,7 @@ $vars->{allow_edit} = $user->in_group('creategroups');
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)
|| ThrowTemplateError($template->error());
ListGroups($vars, $template);
exit;
}
@ -284,10 +278,7 @@ if ($action eq 'delete') {
Bugzilla::Hook::process('editgroups-post_delete', { group => $group });
$vars->{'message'} = 'group_deleted';
$vars->{'groups'} = [Bugzilla::Group->get_all];
$template->process("admin/groups/list.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
ListGroups($vars, $template);
exit;
}
@ -359,10 +350,8 @@ if ($action eq 'remove_regexp') {
$vars->{'message'} = 'group_membership_removed';
$vars->{'group'} = $group->name;
$vars->{'groups'} = [Bugzilla::Group->get_all];
$template->process("admin/groups/list.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
ListGroups($vars, $template);
exit;
}
@ -484,3 +473,17 @@ sub _do_remove {
push(@{$changes->{$field}}, $remove->name);
}
}
sub ListGroups
{
my ($vars, $template) = @_;
my $groups = $vars->{allow_edit}
? [ Bugzilla::Group->get_all ]
: $user->bless_groups;
$vars->{all_groups} = $groups;
$vars->{pergroup} = Bugzilla::Group->get_per_group_permissions;
$template->process("admin/groups/list.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
}

View File

@ -0,0 +1,103 @@
[%# Shows list of groups the user is a member of or can grant
# License: Dual-license MPL 1.1+ or GPL 3.0+
# Author(s): Vitaliy Filippov %]
[%# INTERFACE:
# all_groups: array of group objects
# show_member: boolean, whether to show groups the user is member
# pergroup: hashref in the form { group_id => { product_id => { <prod_perms> => [ product_names ] } } }
#%]
[% SET user = Bugzilla.user %]
[% SET prod_perms = {
'access' => terms.Bug _ ' access'
'optional' => 'Optional ' _ terms.bug _ ' access'
'canedit' => terms.Bug _ ' edit access'
'editcomponents' => 'Product administration'
'editbugs' => 'Bug field change access'
'canconfirm' => terms.Bug _ ' confirm access'
} %]
[% SET prod_perms_keys = [ 'access', 'optional', 'editcomponents', 'canedit', 'canconfirm', 'editbugs' ] %]
[% BLOCK special_groups %]
[% IF group.name == Param('chartgroup') %]
<br />Used as 'chartgroup'. Allows to use <a href="chart.cgi">New Charts</a>.
[% END %]
[% IF group.name == Param('insidergroup') %]
<br />Used as 'insidergroup'. Allows to see private comments and attachments.
[% END %]
[% IF group.name == Param('querysharegroup') %]
<br />Used as 'querysharegroup'. Allows to <a href="userprefs.cgi?tab=saved-searches">share Saved Searches</a> with other users.
[% END %]
[% IF group.name == Param('timetrackinggroup') %]
<br />Used as 'timetrackinggroup'. Allows to register add see working time for [% terms.bugs %].
[% END %]
[% END %]
<style type="text/css">
.first_group_head th { padding: 0 0 1em 0; }
.group_head th { padding: 1em 0; }
</style>
<p>
<b>System groups</b> just grant you some system-wide permission.<br />
<b>[% terms.Bug %] groups</b> are configured by [% terms.Bugzilla %] administrators to grant you some per-product permissions.
Note that several groups may restrict access to a single product; in this case you must be a member of <b>all</b> of them to see [% terms.bugs %] in that product.
</p>
[% PROCESS before_group_table %]
<table>
[% FOREACH group = all_groups %]
[% IF show_member AND user.in_group_id(group.id) OR user.can_bless(group.id) %]
[% IF NOT last_group OR last_group.is_bug_group != group.is_bug_group %]
<tr class="[% last_group ? "group_head" : "first_group_head" %]">
<th align="left">
[% group.is_bug_group ? terms.Bug _ " group" : "System group" %]
</th>
[% PROCESS group_head %]
[% IF group.is_bug_group %]
<th align="left">Description</th>
<th style="width: 50%" align="left">Product permissions</th>
[% ELSE %]
<th align="left" colspan="2">Description</th>
[% END %]
[% SET last_group = group %]
[% SET i = 0 %]
</tr>
[% END %]
[% SET i = i+1 %]
<tr[% (i % 2) ? ' style="background: #ddd"' : '' %]>
<th valign="top" align="left">
[% IF user.can_bless(group.id) %]
<a href="editusersingroup.cgi?group=[% group.id %]"[% IF !user.in_group_id(group.id) %] style="color: gray"[% END %]>[% group.name | html %]</a>
[% END %]
</th>
[% PROCESS group_row %]
[% IF group.is_bug_group %]
<td valign="top">
[% group.description | html_light %]
[% PROCESS special_groups %]
</td>
<td valign="top">
[% SET p = pergroup.${group.id} %]
[% FOREACH k = prod_perms_keys %]
[% IF p.$k.size %]
[% prod_perms.$k %]: [% p.$k.join(', ') %]<br />
[% END %]
[% END %]
</td>
[% ELSE %]
<td valign="top" colspan="2">
[% SET d = lc_messages.system_groups.${group.name} %]
[% IF d %]
[% d | none %]
[% ELSE %]
[% group.description | html_light %]
[% END %]
[% PROCESS special_groups %]
</td>
[% END %]
</tr>
[% END %]
[% END %]
</table>

View File

@ -2,108 +2,18 @@
# License: Dual-license MPL 1.1+ or GPL 3.0+
# Author(s): Vitaliy Filippov %]
[% SET user = Bugzilla.user %]
[% SET prod_perms = {
'access' => terms.Bug _ ' access'
'optional' => 'Optional ' _ terms.bug _ ' access'
'canedit' => terms.Bug _ ' edit access'
'editcomponents' => 'Product administration'
'editbugs' => 'Bug field change access'
'canconfirm' => terms.Bug _ ' confirm access'
} %]
[% SET prod_perms_keys = [ 'access', 'optional', 'editcomponents', 'canedit', 'canconfirm', 'editbugs' ] %]
[% BLOCK special_groups %]
[% IF group.name == Param('chartgroup') %]
<br />Used as 'chartgroup'. Allows to use <a href="chart.cgi">New Charts</a>.
[% END %]
[% IF group.name == Param('insidergroup') %]
<br />Used as 'insidergroup'. Allows to see private comments and attachments.
[% END %]
[% IF group.name == Param('querysharegroup') %]
<br />Used as 'querysharegroup'. Allows to share Saved Searches with other users.
[% END %]
[% IF group.name == Param('timetrackinggroup') %]
<br />Used as 'timetrackinggroup'. Allows to register add see working time for [% terms.bugs %].
[% END %]
[% END %]
[% IF user.groups.size OR user.can_bless %]
<p>
<b>System groups</b> just grant you some system-wide permission.<br />
<b>[% terms.Bug %] groups</b> are configured by [% terms.Bugzilla %] administrators to grant you some per-product permissions.
Note that several groups may restrict access to a single product; in this case you must be a member of <b>all</b> of them to see [% terms.bugs %] in that product.
</p>
[% BLOCK before_group_table %]
<p>
You are[% ' either' IF user.can_bless %] a member of the following groups
[%- ' and/or can include/exclude other users from them (clickable groups are editable)' IF user.can_bless %]:
</p>
[% END %]
[% BLOCK group_row %][% END %]
[% BLOCK group_head %][% END %]
<table>
[% FOREACH group = all_groups %]
[% IF user.in_group_id(group.id) OR user.can_bless(group.id) %]
[% IF NOT last_group OR last_group.is_bug_group != group.is_bug_group %]
<tr>
<th colspan="2" align="left" style="padding: [% last_group ? "1em" : "0" %] 0 1em 0">
[% group.is_bug_group ? terms.Bug _ " groups" : "System groups" %]
</th>
<th style="width: 50%" align="left">[% group.is_bug_group ? "Product permissions" : "" %]</th>
[% SET last_group = group %]
[% SET i = 0 %]
</tr>
[% END %]
[% SET i = i+1 %]
<tr[% (i % 2) ? ' style="background: #ddd"' : '' %]>
<th valign="top" align="left">
[% IF user.can_bless(group.id) %]
<a href="editusersingroup.cgi?group=[% group.id %]"[% IF !user.in_group_id(group.id) %] style="color: gray"[% END %]>[% group.name | html %]</a>
[% END %]
</th>
<td valign="top">
[% IF group.is_bug_group %]
[% group.description | html_light %]
[% PROCESS special_groups %]
[% ELSE %]
[% SET d = lc_messages.system_groups.${group.name} %]
[% IF d %]
[% d | none %]
[% ELSE %]
[% group.description | html_light %]
[% END %]
[% PROCESS special_groups %]
[% END %]
</td>
[% IF group.is_bug_group %]
<td valign="top">
[% SET p = pergroup.${group.id} %]
[% FOREACH k = prod_perms_keys %]
[% IF p.$k.size %]
[% prod_perms.$k %]: [% p.$k.join(', ') %]<br />
[% END %]
[% END %]
</td>
[% END %]
</tr>
[% END %]
[% END %]
</table>
[% IF user.groups.size OR user.can_bless %]
[% FOREACH privs = ["editcomponents", "canconfirm", "editbugs"] %]
[% SET products = ${"local_$privs"} %]
[% IF products && products.size %]
<br>
<p>
You also have local '[% privs | html %]' privileges
for the following products:
</p>
<p>
[% FOREACH product = products %]
[% product.name | html %]<br>
[% END %]
</p>
[% END %]
[% END %]
[% PROCESS "account/prefs/group-list.html.tmpl" show_member=1 %]
[% ELSE %]

View File

@ -209,10 +209,34 @@
</fieldset>
</form>
</td></tr></table>
<p>
<b>Description</b> is what will be shown in the [% terms.bug %] reports
to members of the group where they can choose whether the [% terms.bug %]
will be restricted to others in the same group.
</p>
<p>
<b>User RegExp</b> is optional, and if filled in, will automatically
grant membership to this group to anyone with an email address
that matches this perl regular expression. Do not forget
the trailing '$'. Example '@mycompany\.com$'
</p>
<p>
The <b>Use For [% terms.Bugs %]</b> flag determines whether or not
the group is eligible to be used for [% terms.bugs %]. If you remove
this flag, it will no longer be possible for users to add [% terms.bugs %]
to this group, although [% terms.bugs %] already in the group will remain
in the group. Doing so is a much less drastic way to stop a group
from growing than deleting the group as well as a way to maintain
lists of users without cluttering the lists of groups used
for [% terms.bug %] restrictions.
</p>
<p>Back to the <a href="editgroups.cgi">group list</a>.</p>
[% PROCESS global/footer.html.tmpl %]
[% PROCESS global/footer.html.tmpl %]
[% BLOCK select_pair %]
<table class="select_pair">

View File

@ -1,34 +1,9 @@
[%# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Dave Miller <justdave@syndicomm.com>
# Joel Peshkin <bugreport@peshkin.net>
# Jacob Steenhagen <jake@bugzilla.org>
# Vlad Dascalu <jocuri@softhome.net>
#%]
[%# Shows list of groups the user is a member of or can grant
# License: Dual-license MPL 1.1+ or GPL 3.0+
# Author(s): Vitaliy Filippov %]
[%# INTERFACE:
# groups: array with group objects having the properties:
# - id: number. The ID of the group.
# - name: string. The name of the group.
# - description: string. The description of the group.
# - userregexp: string. The user regexp for the given group.
# - isactive: boolean int. Specifies if the group is active or not.
# - isbuggroup: boolean int. Specifies if it can be used for bugs.
[%# INTERFACE: same as account/prefs/group-list.html.tmpl
# + allow_edit: boolean, whether the current user is allowed to edit groups
#%]
[% PROCESS global/header.html.tmpl
@ -37,155 +12,21 @@
doc_section = "groups.html"
%]
[% edit_contentlink = "editgroups.cgi?action=changeform&amp;group=%%id%%" %]
[% editusers_contentlink = "editusersingroup.cgi?group=%%id%%" %]
[% del_contentlink = "editgroups.cgi?action=del&amp;group=%%id%%" %]
[% columns = [
{
name => 'name'
heading => 'Name'
contentlink => allow_edit ? edit_contentlink : editusers_contentlink
}
{
name => 'description'
heading => 'Description'
allow_html_content => 1
}
];
%]
[% IF allow_edit;
columns.push(
{
name => 'userregexp'
heading => 'User RegExp'
}
{
name => 'is_active_bug_group'
heading => "Use For $terms.Bugs"
align => 'center'
}
{
name => 'type'
heading => 'Type'
align => 'center'
}
{
name => 'action'
heading => 'Action'
align => 'center'
}
{
name => 'members'
heading => 'Members'
align => 'center'
contentlink => editusers_contentlink
content => 'edit'
}
);
END %]
[% overrides.is_active_bug_group = {
'is_active_bug_group' => {
"0" => {
override_content => 1
content => "&nbsp;"
}
"1" => {
override_content => 1
content => "X"
}
}
}
overrides.userregexp = {
'userregexp' => {
"" => {
override_content => 1
content => "&nbsp;"
}
}
}
%]
[% FOREACH group IN ["chartgroup", "insidergroup", "timetrackinggroup", "querysharegroup"] %]
[% special_group = Param(group) %]
[% IF special_group %]
[% overrides.action.name.$special_group = {
override_content => 1
content => "(used as the '$group')"
}
%]
[% BLOCK before_group_table %][% END %]
[% BLOCK group_row %]
[% IF allow_edit %]
<td align="center" valign="top">
<a href="editgroups.cgi?action=changeform&group=[% group.id %]"><img src="images/edit.png" alt="edit" title="edit" /></a>
<a href="editgroups.cgi?action=del&group=[% group.id %]"><img src="images/delete.png" alt="delete" title="delete" /></a>
</td>
[% END %]
[% END %]
[% BLOCK group_head %]
[% IF allow_edit %]
<th>Actions</th>
[% END %]
[% END %]
[% overrides.action.isbuggroup = {
"1" => {
override_content => 1
content => "Delete"
override_contentlink => 1
contentlink => del_contentlink
}
}
overrides.type.isbuggroup = {
"0" => {
override_content => 1
content => "system"
}
"1" => {
override_content => 1
content => "user"
}
}
%]
[% PROCESS admin/table.html.tmpl
columns = columns
data = groups
overrides = overrides
%]
[% IF allow_edit %]
<p><a href="editgroups.cgi?action=add">Add Group</a></p>
<p>
<b>Name</b> is what is used with the B<!-- blah -->ugzilla->user->in_group()
function in any customized cgi files you write that use a given group.
It can also be used by people submitting [% terms.bugs %] by email to
limit [% terms.abug %] to a certain set of groups.
</p>
<p>
<b>Description</b> is what will be shown in the [% terms.bug %] reports
to members of the group where they can choose whether the [% terms.bug %]
will be restricted to others in the same group.
</p>
<p>
<b>User RegExp</b> is optional, and if filled in, will automatically
grant membership to this group to anyone with an email address
that matches this perl regular expression. Do not forget
the trailing '$'. Example '@mycompany\.com$'
</p>
<p>
The <b>Use For [% terms.Bugs %]</b> flag determines whether or not
the group is eligible to be used for [% terms.bugs %]. If you remove
this flag, it will no longer be possible for users to add [% terms.bugs %]
to this group, although [% terms.bugs %] already in the group will remain
in the group. Doing so is a much less drastic way to stop a group
from growing than deleting the group as well as a way to maintain
lists of users without cluttering the lists of groups used
for [% terms.bug %] restrictions.
</p>
<p>
The <b>Type</b> field identifies system groups.
</p>
[% END %]
[% PROCESS "account/prefs/group-list.html.tmpl" show_member = 0 %]
[% PROCESS global/footer.html.tmpl %]

View File

@ -363,33 +363,8 @@ sub SaveEmail {
sub DoPermissions
{
my $dbh = Bugzilla->dbh;
$vars->{all_groups} = [ Bugzilla::Group->get_all ];
my $rows = $dbh->selectall_arrayref(
"SELECT g.*, p.name product_name FROM group_control_map g, products p".
" WHERE p.id=g.product_id", {Slice=>{}}
);
my $pergroup = {};
for my $row (@$rows)
{
for (qw(entry canedit editcomponents editbugs canconfirm))
{
if ($row->{$_})
{
push @{$pergroup->{$row->{group_id}}->{$_}}, $row->{product_name};
}
}
if ($row->{membercontrol} == CONTROLMAPMANDATORY &&
$row->{othercontrol} == CONTROLMAPMANDATORY)
{
push @{$pergroup->{$row->{group_id}}->{access}}, $row->{product_name};
}
elsif ($row->{membercontrol} || $row->{othercontrol})
{
push @{$pergroup->{$row->{group_id}}->{optional}}, $row->{product_name};
}
}
$vars->{pergroup} = $pergroup;
$vars->{pergroup} = Bugzilla::Group->get_per_group_permissions;
}
# No SavePermissions() because this panel has no changeable fields.