From 09bdfab67b64a2a6651bc03aadfbf924d7b70fde Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Mon, 25 Jul 2005 14:56:38 +0000 Subject: Bug 284264: Move canSeeUser from editusers.cgi to User.pm - Patch by Marc Schumann r=mkanat,joel a=justdave --- Bugzilla/User.pm | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'Bugzilla/User.pm') diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index 231f09667..9f88c8aac 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -344,6 +344,29 @@ sub in_group { return defined($res); } +sub can_see_user { + my ($self, $otherUser) = @_; + my $query; + + if (Param('usevisibilitygroups')) { + # If the user can see no groups, then no users are visible either. + my $visibleGroups = $self->visible_groups_as_string() || return 0; + $query = qq{SELECT COUNT(DISTINCT userid) + FROM profiles, user_group_map + WHERE userid = ? + AND user_id = userid + AND isbless = 0 + AND group_id IN ($visibleGroups) + }; + } else { + $query = qq{SELECT COUNT(userid) + FROM profiles + WHERE userid = ? + }; + } + return Bugzilla->dbh->selectrow_array($query, undef, $otherUser->id); +} + sub can_see_bug { my ($self, $bugid) = @_; my $dbh = Bugzilla->dbh; @@ -455,6 +478,11 @@ sub visible_groups_direct { return $self->{visible_groups_direct}; } +sub visible_groups_as_string { + my $self = shift; + return join(', ', @{$self->visible_groups_inherited()}); +} + sub derive_groups { my ($self, $already_locked) = @_; @@ -1403,6 +1431,11 @@ are the names of the groups, whilst the values are the respective group ids. (This is so that a set of all groupids for groups the user can bless can be obtained by Cbless_groups})>.) +=item C + +Returns 1 if the specified user account exists and is visible to the user, +0 otherwise. + =item C Determines if the user can see the specified bug. @@ -1446,6 +1479,11 @@ be have derived groups up-to-date to select the users meeting this criteria. Returns a list of groups that the user is aware of. +=item C + +Returns the result of C as a string (a comma-separated +list). + =begin undocumented This routine takes an optional argument. If true, then this routine will not -- cgit v1.2.3-24-g4f1b