Bug 40933
group editing style fixes, merge group members editing page (Bug 23445) into Bugzilla 3.2 git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@83 6955db30-a419-402b-8a0d-67ecbb4d7f56custis
parent
0f9ed238aa
commit
95e447ea6b
|
@ -0,0 +1,118 @@
|
|||
#!/usr/bin/perl -wT
|
||||
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
||||
|
||||
use strict;
|
||||
use lib qw(. lib);
|
||||
|
||||
use Bugzilla;
|
||||
use Bugzilla::Constants;
|
||||
use Bugzilla::User;
|
||||
use Bugzilla::Util;
|
||||
|
||||
my $vars;
|
||||
my $cgi = Bugzilla->cgi;
|
||||
my $dbh = Bugzilla->dbh;
|
||||
my $user = Bugzilla->login(LOGIN_REQUIRED);
|
||||
my $template = Bugzilla->template;
|
||||
my $userid = $user->id;
|
||||
|
||||
unless ($user->in_group('creategroups'))
|
||||
{
|
||||
ThrowUserError("auth_failure", {
|
||||
group => "creategroups",
|
||||
action => "edit",
|
||||
object => "groups",
|
||||
});
|
||||
}
|
||||
|
||||
# CheckGroupID checks that a positive integer is given and is
|
||||
# actually a valid group ID. If all tests are successful, the
|
||||
# trimmed group ID is returned.
|
||||
sub CheckGroupID
|
||||
{
|
||||
my ($group_id) = @_;
|
||||
$group_id = trim($group_id || 0);
|
||||
ThrowUserError("group_not_specified") unless $group_id;
|
||||
unless (detaint_natural($group_id) &&
|
||||
Bugzilla->dbh->selectrow_array("SELECT id FROM groups WHERE id = ?", undef, $group_id)
|
||||
) {
|
||||
ThrowUserError("invalid_group_ID");
|
||||
}
|
||||
return $group_id;
|
||||
}
|
||||
|
||||
sub get_users_from_group
|
||||
{
|
||||
my ($group_id) = @_;
|
||||
my %users;
|
||||
|
||||
my $dbh = Bugzilla->dbh;
|
||||
my $sql =
|
||||
"SELECT p.userid, p.login_name, p.realname, m.isbless, m.grant_type" .
|
||||
" FROM user_group_map m, profiles p" .
|
||||
" WHERE m.user_id = p.userid AND m.group_id = ?" .
|
||||
" AND trim(p.disabledtext) = '' ORDER BY p.login_name";
|
||||
|
||||
my $rows = $dbh->selectall_arrayref($sql, {Slice=>{}}, $group_id);
|
||||
foreach my $g (@$rows)
|
||||
{
|
||||
my $gg = ($users{$g->{login_name}} ||= $g);
|
||||
if ($g->{grant_type} == GRANT_DIRECT)
|
||||
{
|
||||
$gg->{direct_char} = '.' unless exists $gg->{direct_char};
|
||||
$gg->{direct_char} = 'S' if $g->{isbless};
|
||||
}
|
||||
if ($g->{grant_type} == GRANT_REGEXP)
|
||||
{
|
||||
$gg->{regexp_char} = '.' unless exists $gg->{regexp_char};
|
||||
$gg->{regexp_char} = 'S' if $g->{isbless};
|
||||
}
|
||||
}
|
||||
|
||||
return [ sort { $a->{login_name} cmp $b->{login_name} } values %users ];
|
||||
}
|
||||
|
||||
my $group_id = CheckGroupID($cgi->param('group'));
|
||||
my @users = split /(\s+,?\s*)/, $cgi->param('addusers');
|
||||
|
||||
if (@users)
|
||||
{
|
||||
foreach my $user (@users)
|
||||
{
|
||||
my $userid = login_to_id($user);
|
||||
if ($userid)
|
||||
{
|
||||
$dbh->do(
|
||||
"INSERT IGNORE INTO user_group_map SET user_id=?, group_id=?, grant_type=?, isbless=?",
|
||||
undef, $userid, $group_id, GRANT_DIRECT, 0
|
||||
);
|
||||
}
|
||||
}
|
||||
my $url = "editusersingroup.cgi?group=$group_id";
|
||||
print $cgi->redirect(-location => $url);
|
||||
exit;
|
||||
}
|
||||
|
||||
my ($name, $description, $regexp, $isactive, $isbuggroup) =
|
||||
$dbh->selectrow_array(
|
||||
"SELECT name, description, userregexp, isactive, isbuggroup" .
|
||||
" FROM groups WHERE id=?", undef, $group_id
|
||||
);
|
||||
|
||||
$vars->{group_id} = $group_id;
|
||||
$vars->{name} = $name;
|
||||
$vars->{description} = $description;
|
||||
$vars->{regexp} = $regexp;
|
||||
$vars->{isactive} = $isactive;
|
||||
$vars->{isbuggroup} = $isbuggroup;
|
||||
$vars->{users} = get_users_from_group($group_id);
|
||||
$vars->{user} = $user;
|
||||
|
||||
print $cgi->header();
|
||||
$template->process("admin/groups/usersingroup.html.tmpl", $vars)
|
||||
|| ThrowTemplateError($template->error());
|
||||
$template->process("global/footer.html.tmpl", $vars)
|
||||
|| ThrowTemplateError($template->error());
|
||||
|
||||
1;
|
||||
__END__
|
|
@ -291,3 +291,71 @@ input:not([type="submit"]):not([type="button"]):not([type="checkbox"]):not([type
|
|||
border-style: solid;
|
||||
border-color: #747e93;
|
||||
}
|
||||
|
||||
.grant_table {
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-color: #747e93;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.grant_table th {
|
||||
background-color: #d8d8e6;
|
||||
}
|
||||
|
||||
.grant_table tr {
|
||||
border-width: 0 0 1px 0;
|
||||
border-style: solid;
|
||||
border-color: #747e93;
|
||||
}
|
||||
|
||||
.grant_table td {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.grant_table td.one, .grant_table th.one {
|
||||
border-width: 0 1px 0 0;
|
||||
border-style: solid;
|
||||
border-color: #747e93;
|
||||
}
|
||||
|
||||
.grant_table table {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.grant_table table td {
|
||||
width: 50%;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.grant_table table td select {
|
||||
width: 100%;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.grant_table table th {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.grant_table table tr {
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
.editgr_grinfo {
|
||||
border-collapse: collapse;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.editgr_grinfo td {
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-color: #747e93;
|
||||
}
|
||||
|
||||
.editgr_grinfo th {
|
||||
background-color: #d8d8e6;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-color: #747e93;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
[%# 1.0@bugzilla.org %]
|
||||
|
||||
[%# INTERFACE:
|
||||
# group_id: number. The group ID.
|
||||
# name: Name of the group.
|
||||
# description: Name of the group.
|
||||
# users: array with group objects having the properties:
|
||||
# - grpid: number. The ID of the group.
|
||||
# - grpname: string. The name of the group. [member]
|
||||
# - grpdesc: string. The description of the group.
|
||||
# - grpmember: boolean int. Is 1 if members of the group are to inherit
|
||||
# membership in the group being edited.
|
||||
# - blessmember: boolean int. Is 1 if members of the group are to be able
|
||||
# to bless users into the group being edited.
|
||||
# - membercansee: boolean int. Is 1 if the members of the group are to
|
||||
# be aware of the group being edited and its members.
|
||||
#%]
|
||||
|
||||
[% PROCESS global/variables.none.tmpl %]
|
||||
[% PROCESS global/header.html.tmpl
|
||||
title = "Change Users in Group: $name"
|
||||
style = "
|
||||
.users { border-collapse: collapse; }
|
||||
.users tr { border: 1px solid #747e93; }
|
||||
.users th { background: #d8d8e6; border: 1px solid #747e93; }
|
||||
"
|
||||
%]
|
||||
|
||||
<form method="post" action="editusersingroup.cgi">
|
||||
<input name="group" type="hidden" value=[% group_id %]>
|
||||
<table class="editgr_grinfo" cellpadding="4">
|
||||
<tr>
|
||||
<th>Group:</th>
|
||||
<td>
|
||||
[% name FILTER html %]
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Description:</th>
|
||||
<td>
|
||||
[% description FILTER html %]
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h4>Users in the group «[% name FILTER html %]»</h4>
|
||||
<table class="users" cellspacing="0" cellpadding="2" width="80%">
|
||||
<tr>
|
||||
<th>Login</th><th>Name</th><th>Direct</th><th>Regexp</th>
|
||||
</tr>
|
||||
[% row = 0 %]
|
||||
[% FOREACH user = users %]
|
||||
[% row = row + 1 %]
|
||||
<tr [% 'class="odd_row"' IF row % 2 %]>
|
||||
<td><a target="edituser" href="editusers.cgi?action=edit&userid=[% user.userid %]">
|
||||
[% user.login_name FILTER html %]</a>
|
||||
</td>
|
||||
<td>[% user.realname FILTER html %]</td>
|
||||
<td align="center">[% user.direct_char FILTER html %]</td>
|
||||
<td align="center">[% user.regexp_char FILTER html %]</td>
|
||||
</tr>
|
||||
[% END %]
|
||||
</table>
|
||||
<p>
|
||||
Add multiple user to the group (comma/space/newline separated list of userlogins):
|
||||
</p>
|
||||
<textarea rows="3" cols="100" wrap="virtual" name="addusers"></textarea>
|
||||
<p>
|
||||
<input value="Add new users" type="submit">
|
||||
</form>
|
|
@ -35,23 +35,13 @@
|
|||
[% PROCESS global/header.html.tmpl
|
||||
title = title
|
||||
doc_section = "groups.html#edit-groups"
|
||||
style = "
|
||||
.grant_table { border-collapse: collapse; }
|
||||
.grant_table td, .grant_table th {
|
||||
padding-left: .5em;
|
||||
}
|
||||
.grant_table td.one, .grant_table th.one {
|
||||
border-right: 1px solid black;
|
||||
padding-right: .5em;
|
||||
}
|
||||
"
|
||||
%]
|
||||
|
||||
<form method="post" action="editgroups.cgi">
|
||||
<input type="hidden" name="action" value="postchanges">
|
||||
<input type="hidden" name="group_id" value="[% group.id FILTER html %]">
|
||||
|
||||
<table border="1" cellpadding="4">
|
||||
<table class="editgr_grinfo" cellpadding="4">
|
||||
<tr>
|
||||
<th>Group:</th>
|
||||
<td>
|
||||
|
@ -122,18 +112,22 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td class="one">
|
||||
[% PROCESS select_pair name = "members" size = 10
|
||||
items_available = members_available
|
||||
items_current = members_current %]
|
||||
[% PROCESS select_pair
|
||||
name = "members"
|
||||
size = 10
|
||||
items_available = members_available
|
||||
items_current = members_current
|
||||
%]
|
||||
</td>
|
||||
<td>
|
||||
[% PROCESS select_pair
|
||||
name = "member_of"
|
||||
size = 10
|
||||
items_available = member_of_available
|
||||
items_current = member_of_current
|
||||
%]
|
||||
</td>
|
||||
|
||||
<td>[% PROCESS select_pair name = "member_of" size = 10
|
||||
items_available = member_of_available
|
||||
items_current = member_of_current %]</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table class="grant_table">
|
||||
<tr>
|
||||
<th class="one">
|
||||
Groups That Can Grant Membership in This Group<br>
|
||||
|
@ -184,10 +178,12 @@
|
|||
</table>
|
||||
[% END %]
|
||||
|
||||
<p>
|
||||
<input type="submit" value="Update Group">
|
||||
<input type="hidden" name="token" value="[% token FILTER html %]">
|
||||
</p>
|
||||
</form>
|
||||
|
||||
|
||||
<h4>Mass Remove</h4>
|
||||
|
||||
<p>You can use this form to do mass-removal of users from groups.
|
||||
|
|
Loading…
Reference in New Issue