Commit e490b45d authored by travis%sedsystems.ca's avatar travis%sedsystems.ca

Bug 283581 : Move UserInGroup out of globals.pl

Patch by Colin Ogilvie <colin.ogilvie@gmail.com> r=mkanat a=justdave
parent 235eaf84
...@@ -34,6 +34,7 @@ package Bugzilla::Attachment; ...@@ -34,6 +34,7 @@ package Bugzilla::Attachment;
# Use the Flag module to handle flags. # Use the Flag module to handle flags.
use Bugzilla::Flag; use Bugzilla::Flag;
use Bugzilla::Config qw(:locations); use Bugzilla::Config qw(:locations);
use Bugzilla::User;
############################################################################ ############################################################################
# Functions # Functions
...@@ -69,7 +70,7 @@ sub query ...@@ -69,7 +70,7 @@ sub query
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $in_editbugs = &::UserInGroup("editbugs"); my $in_editbugs = UserInGroup("editbugs");
&::SendSQL("SELECT product_id &::SendSQL("SELECT product_id
FROM bugs FROM bugs
WHERE bug_id = $bugid"); WHERE bug_id = $bugid");
......
...@@ -49,6 +49,7 @@ use Bugzilla::Config qw(:DEFAULT :db); ...@@ -49,6 +49,7 @@ use Bugzilla::Config qw(:DEFAULT :db);
use Bugzilla::Util; use Bugzilla::Util;
use Bugzilla::Error; use Bugzilla::Error;
use Bugzilla::DB::Schema; use Bugzilla::DB::Schema;
use Bugzilla::User;
# All this code is backwards compat fu. As such, its a bit ugly. Note the # All this code is backwards compat fu. As such, its a bit ugly. Note the
# circular dependencies on Bugzilla.pm # circular dependencies on Bugzilla.pm
...@@ -261,7 +262,7 @@ sub bz_get_field_defs { ...@@ -261,7 +262,7 @@ sub bz_get_field_defs {
my ($self) = @_; my ($self) = @_;
my $extra = ""; my $extra = "";
if (!&::UserInGroup(Param('timetrackinggroup'))) { if (!UserInGroup(Param('timetrackinggroup'))) {
$extra = "AND name NOT IN ('estimated_time', 'remaining_time', " . $extra = "AND name NOT IN ('estimated_time', 'remaining_time', " .
"'work_time', 'percentage_complete', 'deadline')"; "'work_time', 'percentage_complete', 'deadline')";
} }
......
...@@ -562,7 +562,7 @@ sub init { ...@@ -562,7 +562,7 @@ sub init {
my $table = "longdescs_$chartid"; my $table = "longdescs_$chartid";
my $extra = ""; my $extra = "";
if (Param("insidergroup") if (Param("insidergroup")
&& !&::UserInGroup(Param("insidergroup"))) && !UserInGroup(Param("insidergroup")))
{ {
$extra = "AND $table.isprivate < 1"; $extra = "AND $table.isprivate < 1";
} }
...@@ -625,7 +625,7 @@ sub init { ...@@ -625,7 +625,7 @@ sub init {
} }
my $table = "longdescs_$chartseq"; my $table = "longdescs_$chartseq";
my $extra = ""; my $extra = "";
if (Param("insidergroup") && !&::UserInGroup(Param("insidergroup"))) { if (Param("insidergroup") && !UserInGroup(Param("insidergroup"))) {
$extra = "AND $table.isprivate < 1"; $extra = "AND $table.isprivate < 1";
} }
push(@supptables, "LEFT JOIN longdescs AS $table " . push(@supptables, "LEFT JOIN longdescs AS $table " .
...@@ -643,7 +643,7 @@ sub init { ...@@ -643,7 +643,7 @@ sub init {
} }
my $table = "longdescs_$chartseq"; my $table = "longdescs_$chartseq";
my $extra = ""; my $extra = "";
if (Param("insidergroup") && !&::UserInGroup(Param("insidergroup"))) { if (Param("insidergroup") && !UserInGroup(Param("insidergroup"))) {
$extra = "AND $table.isprivate < 1"; $extra = "AND $table.isprivate < 1";
} }
if ($list) { if ($list) {
...@@ -664,7 +664,7 @@ sub init { ...@@ -664,7 +664,7 @@ sub init {
"^long_?desc," => sub { "^long_?desc," => sub {
my $table = "longdescs_$chartid"; my $table = "longdescs_$chartid";
my $extra = ""; my $extra = "";
if (Param("insidergroup") && !&::UserInGroup(Param("insidergroup"))) { if (Param("insidergroup") && !UserInGroup(Param("insidergroup"))) {
$extra = "AND $table.isprivate < 1"; $extra = "AND $table.isprivate < 1";
} }
push(@supptables, "INNER JOIN longdescs AS $table " . push(@supptables, "INNER JOIN longdescs AS $table " .
...@@ -740,7 +740,7 @@ sub init { ...@@ -740,7 +740,7 @@ sub init {
"^attachments\..*," => sub { "^attachments\..*," => sub {
my $table = "attachments_$chartid"; my $table = "attachments_$chartid";
my $extra = ""; my $extra = "";
if (Param("insidergroup") && !&::UserInGroup(Param("insidergroup"))) { if (Param("insidergroup") && !UserInGroup(Param("insidergroup"))) {
$extra = "AND $table.isprivate = 0"; $extra = "AND $table.isprivate = 0";
} }
push(@supptables, "INNER JOIN attachments AS $table " . push(@supptables, "INNER JOIN attachments AS $table " .
......
...@@ -163,7 +163,7 @@ sub initFromCGI { ...@@ -163,7 +163,7 @@ sub initFromCGI {
# Change 'admin' here and in series.html.tmpl, or remove the check # Change 'admin' here and in series.html.tmpl, or remove the check
# completely, if you want to change who can make series public. # 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 { sub writeToDatabase {
......
...@@ -32,6 +32,7 @@ use strict; ...@@ -32,6 +32,7 @@ use strict;
use Bugzilla::Config qw(:DEFAULT $templatedir $datadir); use Bugzilla::Config qw(:DEFAULT $templatedir $datadir);
use Bugzilla::Util; use Bugzilla::Util;
use Bugzilla::User;
# for time2str - replace by TT Date plugin?? # for time2str - replace by TT Date plugin??
use Date::Format (); use Date::Format ();
...@@ -406,7 +407,7 @@ sub create { ...@@ -406,7 +407,7 @@ sub create {
'user' => sub { return Bugzilla->user; }, 'user' => sub { return Bugzilla->user; },
# UserInGroup. Deprecated - use the user.* functions instead # UserInGroup. Deprecated - use the user.* functions instead
'UserInGroup' => \&::UserInGroup, 'UserInGroup' => \&Bugzilla::User::UserInGroup,
# SendBugMail - sends mail about a bug, using Bugzilla::BugMail.pm # SendBugMail - sends mail about a bug, using Bugzilla::BugMail.pm
'SendBugMail' => sub { 'SendBugMail' => sub {
......
...@@ -45,6 +45,7 @@ use Bugzilla::Auth; ...@@ -45,6 +45,7 @@ use Bugzilla::Auth;
use base qw(Exporter); use base qw(Exporter);
@Bugzilla::User::EXPORT = qw(insert_new_user is_available_username @Bugzilla::User::EXPORT = qw(insert_new_user is_available_username
login_to_id login_to_id
UserInGroup
); );
################################################################################ ################################################################################
...@@ -1058,6 +1059,10 @@ sub login_to_id ($) { ...@@ -1058,6 +1059,10 @@ sub login_to_id ($) {
} }
} }
sub UserInGroup ($) {
return defined Bugzilla->user->groups->{$_[0]} ? 1 : 0;
}
1; 1;
__END__ __END__
...@@ -1335,8 +1340,6 @@ Params: $username (scalar, string) - The full login name of the username ...@@ -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 can change his username to $username. (That is, this function
will return a boolean true value). will return a boolean true value).
=back
=item C<login_to_id($login)> =item C<login_to_id($login)>
Takes a login name of a Bugzilla user and changes that into a numeric 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. ...@@ -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 However, consider using a Bugzilla::User object instead of this function
if you need more information about the user than just their ID. 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 =head1 SEE ALSO
L<Bugzilla|Bugzilla> L<Bugzilla|Bugzilla>
...@@ -46,6 +46,7 @@ use Bugzilla::Constants; ...@@ -46,6 +46,7 @@ use Bugzilla::Constants;
use Bugzilla::Error; use Bugzilla::Error;
use Bugzilla::BugMail; use Bugzilla::BugMail;
use Bugzilla::Bug; use Bugzilla::Bug;
use Bugzilla::User;
# Shut up misguided -w warnings about "used only once". For some reason, # Shut up misguided -w warnings about "used only once". For some reason,
# "use vars" chokes on me when I try it here. # "use vars" chokes on me when I try it here.
......
...@@ -39,6 +39,7 @@ use vars qw($template $vars); ...@@ -39,6 +39,7 @@ use vars qw($template $vars);
use Bugzilla; use Bugzilla;
use Bugzilla::Search; use Bugzilla::Search;
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::User;
# Include the Bugzilla CGI and general utility library. # Include the Bugzilla CGI and general utility library.
require "CGI.pl"; require "CGI.pl";
......
...@@ -48,6 +48,7 @@ require "CGI.pl"; ...@@ -48,6 +48,7 @@ require "CGI.pl";
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Chart; use Bugzilla::Chart;
use Bugzilla::Series; use Bugzilla::Series;
use Bugzilla::User;
use vars qw($cgi $template $vars); use vars qw($cgi $template $vars);
......
...@@ -34,6 +34,7 @@ use vars qw( ...@@ -34,6 +34,7 @@ use vars qw(
use Bugzilla; use Bugzilla;
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::User;
require "CGI.pl"; require "CGI.pl";
Bugzilla->login(); Bugzilla->login();
......
...@@ -25,6 +25,7 @@ use strict; ...@@ -25,6 +25,7 @@ use strict;
use lib "."; use lib ".";
use Bugzilla; use Bugzilla;
use Bugzilla::User;
require "CGI.pl"; require "CGI.pl";
......
...@@ -28,6 +28,7 @@ use lib qw(.); ...@@ -28,6 +28,7 @@ use lib qw(.);
use Bugzilla; use Bugzilla;
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Config qw(:DEFAULT :admin $datadir); use Bugzilla::Config qw(:DEFAULT :admin $datadir);
use Bugzilla::User;
require "CGI.pl"; require "CGI.pl";
......
...@@ -36,6 +36,7 @@ use Bugzilla; ...@@ -36,6 +36,7 @@ use Bugzilla;
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Flag; use Bugzilla::Flag;
use Bugzilla::FlagType; use Bugzilla::FlagType;
use Bugzilla::User;
use vars qw( $template $vars ); use vars qw( $template $vars );
......
...@@ -31,6 +31,7 @@ use lib "."; ...@@ -31,6 +31,7 @@ use lib ".";
use Bugzilla; use Bugzilla;
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::User;
require "CGI.pl"; require "CGI.pl";
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
......
...@@ -27,6 +27,7 @@ require "CGI.pl"; ...@@ -27,6 +27,7 @@ require "CGI.pl";
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Config qw(:DEFAULT $datadir); use Bugzilla::Config qw(:DEFAULT $datadir);
use Bugzilla::User;
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
......
...@@ -23,6 +23,7 @@ require "globals.pl"; ...@@ -23,6 +23,7 @@ require "globals.pl";
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Config qw(:DEFAULT $datadir); use Bugzilla::Config qw(:DEFAULT $datadir);
use Bugzilla::User;
use vars qw($template $vars); use vars qw($template $vars);
......
...@@ -27,6 +27,7 @@ use lib "."; ...@@ -27,6 +27,7 @@ use lib ".";
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Config qw(:DEFAULT :admin); use Bugzilla::Config qw(:DEFAULT :admin);
use Bugzilla::User;
require "CGI.pl"; require "CGI.pl";
......
...@@ -35,7 +35,7 @@ use Bugzilla::Constants; ...@@ -35,7 +35,7 @@ use Bugzilla::Constants;
require "CGI.pl"; require "CGI.pl";
require "globals.pl"; require "globals.pl";
use Bugzilla::Series; use Bugzilla::Series;
use Bugzilla::User;
use Bugzilla::Config qw(:DEFAULT $datadir); use Bugzilla::Config qw(:DEFAULT $datadir);
# Shut up misguided -w warnings about "used only once". "use vars" just # Shut up misguided -w warnings about "used only once". "use vars" just
......
...@@ -21,6 +21,7 @@ use lib qw(.); ...@@ -21,6 +21,7 @@ use lib qw(.);
use Bugzilla; use Bugzilla;
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::User;
use Bugzilla::User::Setting; use Bugzilla::User::Setting;
require "CGI.pl"; require "CGI.pl";
......
...@@ -35,6 +35,7 @@ require "globals.pl"; ...@@ -35,6 +35,7 @@ require "globals.pl";
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Config qw(:DEFAULT $datadir); use Bugzilla::Config qw(:DEFAULT $datadir);
use Bugzilla::User;
use vars qw($template $vars); use vars qw($template $vars);
......
...@@ -40,6 +40,7 @@ use lib qw(.); ...@@ -40,6 +40,7 @@ use lib qw(.);
use Bugzilla; use Bugzilla;
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Bug; use Bugzilla::Bug;
use Bugzilla::User;
require "CGI.pl"; require "CGI.pl";
use vars qw( use vars qw(
......
...@@ -966,14 +966,6 @@ sub get_legal_field_values { ...@@ -966,14 +966,6 @@ sub get_legal_field_values {
return @$result_ref; return @$result_ref;
} }
sub UserInGroup {
if ($_[1]) {
die "UserInGroup no longer takes a second parameter.";
}
return defined Bugzilla->user->groups->{$_[0]};
}
sub BugInGroupId { sub BugInGroupId {
my ($bugid, $groupid) = (@_); my ($bugid, $groupid) = (@_);
PushGlobalSQLState(); PushGlobalSQLState();
......
...@@ -32,6 +32,7 @@ require "CGI.pl"; ...@@ -32,6 +32,7 @@ require "CGI.pl";
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Search; use Bugzilla::Search;
use Bugzilla::User;
use vars qw( use vars qw(
@CheckOptionValues @CheckOptionValues
......
...@@ -28,6 +28,7 @@ use lib qw(.); ...@@ -28,6 +28,7 @@ use lib qw(.);
require "CGI.pl"; require "CGI.pl";
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::User;
########################################################################### ###########################################################################
# General subs # General subs
......
...@@ -26,6 +26,7 @@ use lib qw(.); ...@@ -26,6 +26,7 @@ use lib qw(.);
use Bugzilla; use Bugzilla;
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::User;
require "CGI.pl"; require "CGI.pl";
......
...@@ -27,6 +27,7 @@ use strict; ...@@ -27,6 +27,7 @@ use strict;
use lib qw(.); use lib qw(.);
require "CGI.pl"; require "CGI.pl";
use Bugzilla::User;
# Use global template variables. # Use global template variables.
use vars qw($template $vars); use vars qw($template $vars);
......
...@@ -26,7 +26,7 @@ use Date::Format; # strftime ...@@ -26,7 +26,7 @@ use Date::Format; # strftime
use Bugzilla::Bug; # EmitDependList use Bugzilla::Bug; # EmitDependList
use Bugzilla::Util; # trim use Bugzilla::Util; # trim
use Bugzilla::Constants; # LOGIN_* use Bugzilla::Constants; # LOGIN_*
use Bugzilla::User; # UserInGroup
require "CGI.pl"; require "CGI.pl";
GetVersionTable(); GetVersionTable();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment