From 7351a5b76bd4c025d0b7a06ea8466cb3b204ee9f Mon Sep 17 00:00:00 2001 From: "travis%sedsystems.ca" Date: Tue, 15 Mar 2005 22:10:14 +0000 Subject: [PATCH] Bug 283581 : Move UserInGroup out of globals.pl Patch by Colin Ogilvie r=mkanat a=justdave git-svn-id: svn://10.0.0.236/trunk@170734 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/Bugzilla/Attachment.pm | 3 ++- mozilla/webtools/bugzilla/Bugzilla/DB.pm | 3 ++- mozilla/webtools/bugzilla/Bugzilla/Search.pm | 10 +++++----- mozilla/webtools/bugzilla/Bugzilla/Series.pm | 2 +- mozilla/webtools/bugzilla/Bugzilla/Template.pm | 3 ++- mozilla/webtools/bugzilla/Bugzilla/User.pm | 13 +++++++++++-- mozilla/webtools/bugzilla/CGI.pl | 1 + mozilla/webtools/bugzilla/buglist.cgi | 1 + mozilla/webtools/bugzilla/chart.cgi | 1 + mozilla/webtools/bugzilla/colchange.cgi | 1 + mozilla/webtools/bugzilla/describekeywords.cgi | 1 + mozilla/webtools/bugzilla/doeditparams.cgi | 1 + mozilla/webtools/bugzilla/editflagtypes.cgi | 1 + mozilla/webtools/bugzilla/editgroups.cgi | 1 + mozilla/webtools/bugzilla/editkeywords.cgi | 1 + mozilla/webtools/bugzilla/editmilestones.cgi | 1 + mozilla/webtools/bugzilla/editparams.cgi | 1 + mozilla/webtools/bugzilla/editproducts.cgi | 2 +- mozilla/webtools/bugzilla/editsettings.cgi | 1 + mozilla/webtools/bugzilla/editversions.cgi | 1 + mozilla/webtools/bugzilla/enter_bug.cgi | 1 + mozilla/webtools/bugzilla/globals.pl | 8 -------- mozilla/webtools/bugzilla/query.cgi | 1 + mozilla/webtools/bugzilla/sanitycheck.cgi | 1 + mozilla/webtools/bugzilla/show_bug.cgi | 1 + mozilla/webtools/bugzilla/showdependencytree.cgi | 1 + mozilla/webtools/bugzilla/summarize_time.cgi | 2 +- 27 files changed, 43 insertions(+), 21 deletions(-) diff --git a/mozilla/webtools/bugzilla/Bugzilla/Attachment.pm b/mozilla/webtools/bugzilla/Bugzilla/Attachment.pm index 8be92dcf253..1a1246d862d 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Attachment.pm +++ b/mozilla/webtools/bugzilla/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/mozilla/webtools/bugzilla/Bugzilla/DB.pm b/mozilla/webtools/bugzilla/Bugzilla/DB.pm index 6e0903a76f5..098d10ba19f 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/DB.pm +++ b/mozilla/webtools/bugzilla/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/mozilla/webtools/bugzilla/Bugzilla/Search.pm b/mozilla/webtools/bugzilla/Bugzilla/Search.pm index e38aed7bfab..af8df0ab2e0 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Search.pm +++ b/mozilla/webtools/bugzilla/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/mozilla/webtools/bugzilla/Bugzilla/Series.pm b/mozilla/webtools/bugzilla/Bugzilla/Series.pm index 53e6fbabfd8..3d4f301b97f 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Series.pm +++ b/mozilla/webtools/bugzilla/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/mozilla/webtools/bugzilla/Bugzilla/Template.pm b/mozilla/webtools/bugzilla/Bugzilla/Template.pm index aea32a2b3cf..3e37ed5e75c 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Template.pm +++ b/mozilla/webtools/bugzilla/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/mozilla/webtools/bugzilla/Bugzilla/User.pm b/mozilla/webtools/bugzilla/Bugzilla/User.pm index 63b2f6848d9..fabffa62168 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/User.pm +++ b/mozilla/webtools/bugzilla/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 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 + +Takes a name of a group, and returns 1 if a user is in the group, 0 otherwise. + +=back + =head1 SEE ALSO L diff --git a/mozilla/webtools/bugzilla/CGI.pl b/mozilla/webtools/bugzilla/CGI.pl index 31ed48e3d40..d1c738ff93c 100644 --- a/mozilla/webtools/bugzilla/CGI.pl +++ b/mozilla/webtools/bugzilla/CGI.pl @@ -46,6 +46,7 @@ use Bugzilla::Constants; use Bugzilla::Error; use Bugzilla::BugMail; use Bugzilla::Bug; +use Bugzilla::User; # Shut up misguided -w warnings about "used only once". For some reason, # "use vars" chokes on me when I try it here. diff --git a/mozilla/webtools/bugzilla/buglist.cgi b/mozilla/webtools/bugzilla/buglist.cgi index 9727177313a..c401c43c27c 100755 --- a/mozilla/webtools/bugzilla/buglist.cgi +++ b/mozilla/webtools/bugzilla/buglist.cgi @@ -39,6 +39,7 @@ use vars qw($template $vars); use Bugzilla; use Bugzilla::Search; use Bugzilla::Constants; +use Bugzilla::User; # Include the Bugzilla CGI and general utility library. require "CGI.pl"; diff --git a/mozilla/webtools/bugzilla/chart.cgi b/mozilla/webtools/bugzilla/chart.cgi index 8b0d3971e94..321c867fef1 100755 --- a/mozilla/webtools/bugzilla/chart.cgi +++ b/mozilla/webtools/bugzilla/chart.cgi @@ -48,6 +48,7 @@ require "CGI.pl"; use Bugzilla::Constants; use Bugzilla::Chart; use Bugzilla::Series; +use Bugzilla::User; use vars qw($cgi $template $vars); diff --git a/mozilla/webtools/bugzilla/colchange.cgi b/mozilla/webtools/bugzilla/colchange.cgi index d84ee5404fb..11caca423f8 100755 --- a/mozilla/webtools/bugzilla/colchange.cgi +++ b/mozilla/webtools/bugzilla/colchange.cgi @@ -34,6 +34,7 @@ use vars qw( use Bugzilla; use Bugzilla::Constants; +use Bugzilla::User; require "CGI.pl"; Bugzilla->login(); diff --git a/mozilla/webtools/bugzilla/describekeywords.cgi b/mozilla/webtools/bugzilla/describekeywords.cgi index 8597e67910d..dd25c40d69f 100755 --- a/mozilla/webtools/bugzilla/describekeywords.cgi +++ b/mozilla/webtools/bugzilla/describekeywords.cgi @@ -25,6 +25,7 @@ use strict; use lib "."; use Bugzilla; +use Bugzilla::User; require "CGI.pl"; diff --git a/mozilla/webtools/bugzilla/doeditparams.cgi b/mozilla/webtools/bugzilla/doeditparams.cgi index 099b98404ca..028f28a60ff 100755 --- a/mozilla/webtools/bugzilla/doeditparams.cgi +++ b/mozilla/webtools/bugzilla/doeditparams.cgi @@ -28,6 +28,7 @@ use lib qw(.); use Bugzilla; use Bugzilla::Constants; use Bugzilla::Config qw(:DEFAULT :admin $datadir); +use Bugzilla::User; require "CGI.pl"; diff --git a/mozilla/webtools/bugzilla/editflagtypes.cgi b/mozilla/webtools/bugzilla/editflagtypes.cgi index 9c14219d20d..7936823dc78 100755 --- a/mozilla/webtools/bugzilla/editflagtypes.cgi +++ b/mozilla/webtools/bugzilla/editflagtypes.cgi @@ -36,6 +36,7 @@ use Bugzilla; use Bugzilla::Constants; use Bugzilla::Flag; use Bugzilla::FlagType; +use Bugzilla::User; use vars qw( $template $vars ); diff --git a/mozilla/webtools/bugzilla/editgroups.cgi b/mozilla/webtools/bugzilla/editgroups.cgi index abef251f426..c352908bb7c 100755 --- a/mozilla/webtools/bugzilla/editgroups.cgi +++ b/mozilla/webtools/bugzilla/editgroups.cgi @@ -31,6 +31,7 @@ use lib "."; use Bugzilla; use Bugzilla::Constants; +use Bugzilla::User; require "CGI.pl"; my $cgi = Bugzilla->cgi; diff --git a/mozilla/webtools/bugzilla/editkeywords.cgi b/mozilla/webtools/bugzilla/editkeywords.cgi index 4f4cf4bd52c..f5fcf6a574c 100755 --- a/mozilla/webtools/bugzilla/editkeywords.cgi +++ b/mozilla/webtools/bugzilla/editkeywords.cgi @@ -27,6 +27,7 @@ require "CGI.pl"; use Bugzilla::Constants; use Bugzilla::Config qw(:DEFAULT $datadir); +use Bugzilla::User; my $cgi = Bugzilla->cgi; diff --git a/mozilla/webtools/bugzilla/editmilestones.cgi b/mozilla/webtools/bugzilla/editmilestones.cgi index 85bcae8d30c..e62dcc4cb6c 100755 --- a/mozilla/webtools/bugzilla/editmilestones.cgi +++ b/mozilla/webtools/bugzilla/editmilestones.cgi @@ -23,6 +23,7 @@ require "globals.pl"; use Bugzilla::Constants; use Bugzilla::Config qw(:DEFAULT $datadir); +use Bugzilla::User; use vars qw($template $vars); diff --git a/mozilla/webtools/bugzilla/editparams.cgi b/mozilla/webtools/bugzilla/editparams.cgi index 5d7ff9178e3..620ae6baee1 100755 --- a/mozilla/webtools/bugzilla/editparams.cgi +++ b/mozilla/webtools/bugzilla/editparams.cgi @@ -27,6 +27,7 @@ use lib "."; use Bugzilla::Constants; use Bugzilla::Config qw(:DEFAULT :admin); +use Bugzilla::User; require "CGI.pl"; diff --git a/mozilla/webtools/bugzilla/editproducts.cgi b/mozilla/webtools/bugzilla/editproducts.cgi index de0c874e2d7..aff79871ca9 100755 --- a/mozilla/webtools/bugzilla/editproducts.cgi +++ b/mozilla/webtools/bugzilla/editproducts.cgi @@ -35,7 +35,7 @@ use Bugzilla::Constants; require "CGI.pl"; require "globals.pl"; use Bugzilla::Series; - +use Bugzilla::User; use Bugzilla::Config qw(:DEFAULT $datadir); # Shut up misguided -w warnings about "used only once". "use vars" just diff --git a/mozilla/webtools/bugzilla/editsettings.cgi b/mozilla/webtools/bugzilla/editsettings.cgi index 7ce05b2a22c..b5e810ba9f3 100755 --- a/mozilla/webtools/bugzilla/editsettings.cgi +++ b/mozilla/webtools/bugzilla/editsettings.cgi @@ -21,6 +21,7 @@ use lib qw(.); use Bugzilla; use Bugzilla::Constants; +use Bugzilla::User; use Bugzilla::User::Setting; require "CGI.pl"; diff --git a/mozilla/webtools/bugzilla/editversions.cgi b/mozilla/webtools/bugzilla/editversions.cgi index 7faea7c8d59..86c82beea39 100755 --- a/mozilla/webtools/bugzilla/editversions.cgi +++ b/mozilla/webtools/bugzilla/editversions.cgi @@ -35,6 +35,7 @@ require "globals.pl"; use Bugzilla::Constants; use Bugzilla::Config qw(:DEFAULT $datadir); +use Bugzilla::User; use vars qw($template $vars); diff --git a/mozilla/webtools/bugzilla/enter_bug.cgi b/mozilla/webtools/bugzilla/enter_bug.cgi index e2cd7f295d3..a242c1883f5 100755 --- a/mozilla/webtools/bugzilla/enter_bug.cgi +++ b/mozilla/webtools/bugzilla/enter_bug.cgi @@ -40,6 +40,7 @@ use lib qw(.); use Bugzilla; use Bugzilla::Constants; use Bugzilla::Bug; +use Bugzilla::User; require "CGI.pl"; use vars qw( diff --git a/mozilla/webtools/bugzilla/globals.pl b/mozilla/webtools/bugzilla/globals.pl index ec7d396933b..ec8c52d4d43 100644 --- a/mozilla/webtools/bugzilla/globals.pl +++ b/mozilla/webtools/bugzilla/globals.pl @@ -966,14 +966,6 @@ sub get_legal_field_values { return @$result_ref; } -sub UserInGroup { - if ($_[1]) { - die "UserInGroup no longer takes a second parameter."; - } - - return defined Bugzilla->user->groups->{$_[0]}; -} - sub BugInGroupId { my ($bugid, $groupid) = (@_); PushGlobalSQLState(); diff --git a/mozilla/webtools/bugzilla/query.cgi b/mozilla/webtools/bugzilla/query.cgi index ef02bbbca93..62511713959 100755 --- a/mozilla/webtools/bugzilla/query.cgi +++ b/mozilla/webtools/bugzilla/query.cgi @@ -32,6 +32,7 @@ require "CGI.pl"; use Bugzilla::Constants; use Bugzilla::Search; +use Bugzilla::User; use vars qw( @CheckOptionValues diff --git a/mozilla/webtools/bugzilla/sanitycheck.cgi b/mozilla/webtools/bugzilla/sanitycheck.cgi index c3c41531252..6f85e6cfd9d 100755 --- a/mozilla/webtools/bugzilla/sanitycheck.cgi +++ b/mozilla/webtools/bugzilla/sanitycheck.cgi @@ -28,6 +28,7 @@ use lib qw(.); require "CGI.pl"; use Bugzilla::Constants; +use Bugzilla::User; ########################################################################### # General subs diff --git a/mozilla/webtools/bugzilla/show_bug.cgi b/mozilla/webtools/bugzilla/show_bug.cgi index 03cf6f60d57..e855b442f2c 100755 --- a/mozilla/webtools/bugzilla/show_bug.cgi +++ b/mozilla/webtools/bugzilla/show_bug.cgi @@ -26,6 +26,7 @@ use lib qw(.); use Bugzilla; use Bugzilla::Constants; +use Bugzilla::User; require "CGI.pl"; diff --git a/mozilla/webtools/bugzilla/showdependencytree.cgi b/mozilla/webtools/bugzilla/showdependencytree.cgi index f1a495a6d43..b373563c154 100755 --- a/mozilla/webtools/bugzilla/showdependencytree.cgi +++ b/mozilla/webtools/bugzilla/showdependencytree.cgi @@ -27,6 +27,7 @@ use strict; use lib qw(.); require "CGI.pl"; +use Bugzilla::User; # Use global template variables. use vars qw($template $vars); diff --git a/mozilla/webtools/bugzilla/summarize_time.cgi b/mozilla/webtools/bugzilla/summarize_time.cgi index 94b7e83f885..8992918cc02 100755 --- a/mozilla/webtools/bugzilla/summarize_time.cgi +++ b/mozilla/webtools/bugzilla/summarize_time.cgi @@ -26,7 +26,7 @@ use Date::Format; # strftime use Bugzilla::Bug; # EmitDependList use Bugzilla::Util; # trim use Bugzilla::Constants; # LOGIN_* - +use Bugzilla::User; # UserInGroup require "CGI.pl"; GetVersionTable();