Bug 134157 - Tweaks to check access

git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@1808 6955db30-a419-402b-8a0d-67ecbb4d7f56
master
vfilippov 2013-09-20 11:29:26 +00:00
parent dac8be2a35
commit 05b2de5ca0
6 changed files with 47 additions and 103 deletions

View File

@ -3437,8 +3437,7 @@ sub getAccessUserList {
my $user_ids_group = {};
foreach my $group (@{$self->groups}) {
my @childgroups = @{Bugzilla::Group->flatten_group_membership($group->{'bit'})};
my $group_users = $dbh->selectall_arrayref("SELECT distinct(user_id) FROM user_group_map WHERE isbless = 0 AND group_id IN(".join(",", @childgroups).")");
my @this_users;
my $group_users = $dbh->selectall_arrayref("SELECT DISTINCT user_id FROM user_group_map WHERE isbless = 0 AND group_id IN (".join(",", @childgroups).")");
foreach my $users (@$group_users) {
$user_ids_group->{$users->[0]}++;
}
@ -3448,17 +3447,12 @@ sub getAccessUserList {
push (@user_ids, grep { $user_ids_group->{$_} == $count_groups } keys %$user_ids_group);
return $dbh->selectall_arrayref("
SELECT
p.userid, p.login_name, p.realname
FROM
profiles p
WHERE
p.disabledtext = '' AND p.disable_mail = 0 AND p.userid in (".join(",", @user_ids).")
ORDER BY p.realname
", undef);
SELECT p.userid, p.login_name, p.realname
FROM profiles p
WHERE p.disabledtext = '' AND p.disable_mail = 0 AND p.userid in (".join(",", @user_ids).")
ORDER BY p.realname");
}
#####################################################################
# Subroutines
#####################################################################

View File

@ -1,33 +1,8 @@
#!/usr/bin/perl -wT
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# 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): Terry Weissman <terry@mozilla.org>
# Myk Melez <myk@mozilla.org>
# Daniel Raichle <draichle@gmx.net>
# Dave Miller <justdave@syndicomm.com>
# Alexander J. Vincent <ajvincent@juno.com>
# Max Kanat-Alexander <mkanat@bugzilla.org>
# Greg Hendricks <ghendricks@novell.com>
# Frédéric Buclin <LpSolit@gmail.com>
# Marc Schumann <wurblzap@gmail.com>
# Byron Jones <bugzilla@glob.com.au>
# Page listing users who can access a bug
# License: Dual-license GPL 3.0+ or MPL 1.1+
# Author(s): Andrey Krasilnikov, Vitaliy Filippov
################################################################################
# Script Initialization
@ -44,26 +19,21 @@ use Bugzilla::Error;
use Bugzilla::User;
use Bugzilla::Util;
use Bugzilla::Bug;
use Bugzilla::Field;
# For most scripts we don't make $cgi and $template global variables. But
# when preparing Bugzilla for mod_perl, this script used these
# variables in so many subroutines that it was easier to just
# make them globals.
local our $cgi = Bugzilla->cgi;
local our $template = Bugzilla->template;
local our $vars = {};
################################################################################
# Main Body Execution
################################################################################
my $user = Bugzilla->login();
viewlist();
exit;
sub viewlist {
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
my $user = Bugzilla->login();
# Retrieve and validate parameters
my $bug = Bugzilla::Bug->check(scalar $cgi->param('id'));
my $bugid = $bug->id;
@ -74,7 +44,6 @@ sub viewlist {
$vars->{'bug'} = $bug;
# Generate and return the UI (HTML page) from the appropriate template.
$template->process("pages/checkaccess.html.tmpl", $vars)
$template->process("bug/checkaccess.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}

View File

@ -78,14 +78,14 @@ if ($id) {
ThrowCodeError("bad_page_cgi_id", { "page_id" => $id });
}
my %vars = (
quicksearch_field_names => \&quicksearch_field_names,
my %vars = (
quicksearch_field_names => \&quicksearch_field_names,
);
Bugzilla::Hook::process('page_before_template',
Bugzilla::Hook::process('page_before_template',
{ page_id => $id, vars => \%vars });
my $format = $template->get_format("pages/$1", undef, $2);
$cgi->param('id', $id);
$cgi->send_header($format->{'ctype'});

View File

@ -0,0 +1,27 @@
[% INCLUDE global/header.html.tmpl title = "$terms.Bug $bug.id - Check access" %]
<h2>[% count_user_list %] Users can see <a href="show_bug.cgi?id=[% bug.id %]">[% terms.Bug _ " " _ bug.id %]</a></h2>
<hr/>
<table>
<thead>
<tr>
<th align="left">User login (email)</th>
<th align="left">User name</th>
</tr>
</thead>
<tbody>
[% FOREACH user = user_list %]
<tr>
<td>[% user.1 %]</td><td>[% user.2 %]</td>
</tr>
[% END %]
</tbody>
</table>
<hr/>
<p><a href="show_bug.cgi?id=[% bug.id %]">Back to [% terms.bug %] form</a></p>
[% INCLUDE global/footer.html.tmpl %]

View File

@ -152,7 +152,7 @@ document.changeform = document.[% cfname %];
[% PROCESS section_restrict_visibility %]
[%# *** Check access to bug *** %]
<div class="bz_group_visibility_section">
<a href="check_access.cgi?id=[% bug.bug_id %]" target="_blank">List users who can see this bug</a>
<a href="check_access.cgi?id=[% bug.bug_id %]">List users who can see this bug</a>
</div>
</td>
</tr></table>

View File

@ -1,46 +0,0 @@
[%# 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): Stefan Seifert <nine@detonation.org>
# Gervase Markham <gerv@gerv.net>
#%]
[% INCLUDE global/header.html.tmpl title = "Bug $bug.id - Check access" %]
[% USE Bugzilla %]
[% cgi = Bugzilla.cgi %]
<h2>[% count_user_list %] Users can see Bug [% bug.id %]</h2>
<hr/>
<table>
<thead>
<tr>
<th>User name</th>
<th>User login (email)</th>
</tr>
</thead>
<tbody>
[% FOREACH user = user_list %]
<tr>
<td>[% user.1 %]</td><td>[% user.2 %]</td>
</tr>
[% END %]
</tbody>
</table>
[% INCLUDE global/footer.html.tmpl %]