summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorwurblzap%gmail.com <>2006-10-06 03:05:41 +0200
committerwurblzap%gmail.com <>2006-10-06 03:05:41 +0200
commitce0b20a534cc5e4906bceb529e9e925207087604 (patch)
tree70d99664090f9971b8fb0ba4e3f3eb529088fc45 /Bugzilla
parentd5d46fd5894b7339532c4f7576c8aa55ce44d285 (diff)
downloadbugzilla-ce0b20a534cc5e4906bceb529e9e925207087604.tar.gz
bugzilla-ce0b20a534cc5e4906bceb529e9e925207087604.tar.xz
Bug 352410: Shared Queries don't work if usevisibilitygroups is off.
Patch by Marc Schumann <wurblzap@gmail.com>, r=LpSolit, a=myk
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/User.pm40
1 files changed, 31 insertions, 9 deletions
diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm
index 09fd2f9ce..19a72b9e7 100644
--- a/Bugzilla/User.pm
+++ b/Bugzilla/User.pm
@@ -678,11 +678,19 @@ sub visible_groups_direct {
return [] unless $self->id;
my $dbh = Bugzilla->dbh;
- my $glist = join(',',(-1,values(%{$self->groups})));
- my $sth = $dbh->prepare("SELECT DISTINCT grantor_id
- FROM group_group_map
- WHERE member_id IN($glist)
- AND grant_type=" . GROUP_VISIBLE);
+ my $sth;
+
+ if (Bugzilla->params->{'usevisibilitygroups'}) {
+ my $glist = join(',',(-1,values(%{$self->groups})));
+ $sth = $dbh->prepare("SELECT DISTINCT grantor_id
+ FROM group_group_map
+ WHERE member_id IN($glist)
+ AND grant_type=" . GROUP_VISIBLE);
+ }
+ else {
+ # All groups are visible if usevisibilitygroups is off.
+ $sth = $dbh->prepare('SELECT id FROM groups');
+ }
$sth->execute();
while (my ($row) = $sth->fetchrow_array) {
@@ -703,12 +711,26 @@ sub visible_groups_as_string {
# from bless_groups instead of mirroring visible_groups_inherited, perhaps.
sub queryshare_groups {
my $self = shift;
+ my @queryshare_groups;
+
+ return $self->{queryshare_groups} if defined $self->{queryshare_groups};
+
if ($self->in_group(Bugzilla->params->{'querysharegroup'})) {
- return $self->visible_groups_inherited();
- }
- else {
- return [];
+ # We want to be allowed to share with groups we're in only.
+ # If usevisibilitygroups is on, then we need to restrict this to groups
+ # we may see.
+ if (Bugzilla->params->{'usevisibilitygroups'}) {
+ foreach(@{$self->visible_groups_inherited()}) {
+ next unless $self->in_group_id($_);
+ push(@queryshare_groups, $_);
+ }
+ }
+ else {
+ @queryshare_groups = values(%{$self->groups});
+ }
}
+
+ return $self->{queryshare_groups} = \@queryshare_groups;
}
sub queryshare_groups_as_string {