diff options
author | travis%sedsystems.ca <> | 2005-03-16 07:10:13 +0100 |
---|---|---|
committer | travis%sedsystems.ca <> | 2005-03-16 07:10:13 +0100 |
commit | e490b45d57aee2aacd171a4a9b586111a8c88f53 (patch) | |
tree | b54185c9f669cd2b309f727ecb21e178968866ff /Bugzilla | |
parent | 235eaf8436a7cb2f693c3fb8bc5d042c652c1c5f (diff) | |
download | bugzilla-e490b45d57aee2aacd171a4a9b586111a8c88f53.tar.gz bugzilla-e490b45d57aee2aacd171a4a9b586111a8c88f53.tar.xz |
Bug 283581 : Move UserInGroup out of globals.pl
Patch by Colin Ogilvie <colin.ogilvie@gmail.com> r=mkanat a=justdave
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/Attachment.pm | 3 | ||||
-rw-r--r-- | Bugzilla/DB.pm | 3 | ||||
-rw-r--r-- | Bugzilla/Search.pm | 10 | ||||
-rw-r--r-- | Bugzilla/Series.pm | 2 | ||||
-rw-r--r-- | Bugzilla/Template.pm | 3 | ||||
-rw-r--r-- | Bugzilla/User.pm | 13 |
6 files changed, 23 insertions, 11 deletions
diff --git a/Bugzilla/Attachment.pm b/Bugzilla/Attachment.pm index 8be92dcf2..1a1246d86 100644 --- a/Bugzilla/Attachment.pm +++ b/Bugzilla/Attachment.pm @@ -34,6 +34,7 @@ package Bugzilla::Attachment; # Use the Flag module to handle flags. use Bugzilla::Flag; use Bugzilla::Config qw(:locations); +use Bugzilla::User; ############################################################################ # Functions @@ -69,7 +70,7 @@ sub query my $dbh = Bugzilla->dbh; - my $in_editbugs = &::UserInGroup("editbugs"); + my $in_editbugs = UserInGroup("editbugs"); &::SendSQL("SELECT product_id FROM bugs WHERE bug_id = $bugid"); diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm index 6e0903a76..098d10ba1 100644 --- a/Bugzilla/DB.pm +++ b/Bugzilla/DB.pm @@ -49,6 +49,7 @@ use Bugzilla::Config qw(:DEFAULT :db); use Bugzilla::Util; use Bugzilla::Error; use Bugzilla::DB::Schema; +use Bugzilla::User; # All this code is backwards compat fu. As such, its a bit ugly. Note the # circular dependencies on Bugzilla.pm @@ -261,7 +262,7 @@ sub bz_get_field_defs { my ($self) = @_; my $extra = ""; - if (!&::UserInGroup(Param('timetrackinggroup'))) { + if (!UserInGroup(Param('timetrackinggroup'))) { $extra = "AND name NOT IN ('estimated_time', 'remaining_time', " . "'work_time', 'percentage_complete', 'deadline')"; } diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index e38aed7bf..af8df0ab2 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -562,7 +562,7 @@ sub init { my $table = "longdescs_$chartid"; my $extra = ""; if (Param("insidergroup") - && !&::UserInGroup(Param("insidergroup"))) + && !UserInGroup(Param("insidergroup"))) { $extra = "AND $table.isprivate < 1"; } @@ -625,7 +625,7 @@ sub init { } my $table = "longdescs_$chartseq"; my $extra = ""; - if (Param("insidergroup") && !&::UserInGroup(Param("insidergroup"))) { + if (Param("insidergroup") && !UserInGroup(Param("insidergroup"))) { $extra = "AND $table.isprivate < 1"; } push(@supptables, "LEFT JOIN longdescs AS $table " . @@ -643,7 +643,7 @@ sub init { } my $table = "longdescs_$chartseq"; my $extra = ""; - if (Param("insidergroup") && !&::UserInGroup(Param("insidergroup"))) { + if (Param("insidergroup") && !UserInGroup(Param("insidergroup"))) { $extra = "AND $table.isprivate < 1"; } if ($list) { @@ -664,7 +664,7 @@ sub init { "^long_?desc," => sub { my $table = "longdescs_$chartid"; my $extra = ""; - if (Param("insidergroup") && !&::UserInGroup(Param("insidergroup"))) { + if (Param("insidergroup") && !UserInGroup(Param("insidergroup"))) { $extra = "AND $table.isprivate < 1"; } push(@supptables, "INNER JOIN longdescs AS $table " . @@ -740,7 +740,7 @@ sub init { "^attachments\..*," => sub { my $table = "attachments_$chartid"; my $extra = ""; - if (Param("insidergroup") && !&::UserInGroup(Param("insidergroup"))) { + if (Param("insidergroup") && !UserInGroup(Param("insidergroup"))) { $extra = "AND $table.isprivate = 0"; } push(@supptables, "INNER JOIN attachments AS $table " . diff --git a/Bugzilla/Series.pm b/Bugzilla/Series.pm index 53e6fbabf..3d4f301b9 100644 --- a/Bugzilla/Series.pm +++ b/Bugzilla/Series.pm @@ -163,7 +163,7 @@ sub initFromCGI { # Change 'admin' here and in series.html.tmpl, or remove the check # completely, if you want to change who can make series public. - $self->{'public'} = 0 unless &::UserInGroup('admin'); + $self->{'public'} = 0 unless UserInGroup('admin'); } sub writeToDatabase { diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index aea32a2b3..3e37ed5e7 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -32,6 +32,7 @@ use strict; use Bugzilla::Config qw(:DEFAULT $templatedir $datadir); use Bugzilla::Util; +use Bugzilla::User; # for time2str - replace by TT Date plugin?? use Date::Format (); @@ -406,7 +407,7 @@ sub create { 'user' => sub { return Bugzilla->user; }, # UserInGroup. Deprecated - use the user.* functions instead - 'UserInGroup' => \&::UserInGroup, + 'UserInGroup' => \&Bugzilla::User::UserInGroup, # SendBugMail - sends mail about a bug, using Bugzilla::BugMail.pm 'SendBugMail' => sub { diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index 63b2f6848..fabffa621 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -45,6 +45,7 @@ use Bugzilla::Auth; use base qw(Exporter); @Bugzilla::User::EXPORT = qw(insert_new_user is_available_username login_to_id + UserInGroup ); ################################################################################ @@ -1058,6 +1059,10 @@ sub login_to_id ($) { } } +sub UserInGroup ($) { + return defined Bugzilla->user->groups->{$_[0]} ? 1 : 0; +} + 1; __END__ @@ -1335,8 +1340,6 @@ Params: $username (scalar, string) - The full login name of the username can change his username to $username. (That is, this function will return a boolean true value). -=back - =item C<login_to_id($login)> Takes a login name of a Bugzilla user and changes that into a numeric @@ -1351,6 +1354,12 @@ of a user, but you don't want the full weight of Bugzilla::User. However, consider using a Bugzilla::User object instead of this function if you need more information about the user than just their ID. +=item C<UserInGroup($groupname)> + +Takes a name of a group, and returns 1 if a user is in the group, 0 otherwise. + +=back + =head1 SEE ALSO L<Bugzilla|Bugzilla> |