Commit e15dcf48 authored by Frédéric Buclin's avatar Frédéric Buclin

Bug 678970: Use $user and $cgi instead of Bugzilla->user and Bugzilla->cgi

r=timello a=LpSolit
parent 7a859893
...@@ -670,10 +670,10 @@ sub add_attachment { ...@@ -670,10 +670,10 @@ sub add_attachment {
sub add_comment { sub add_comment {
my ($self, $params) = @_; my ($self, $params) = @_;
#The user must login in order add a comment # The user must login in order add a comment
Bugzilla->login(LOGIN_REQUIRED); my $user = Bugzilla->login(LOGIN_REQUIRED);
# Check parameters # Check parameters
defined $params->{id} defined $params->{id}
|| ThrowCodeError('param_required', { param => 'id' }); || ThrowCodeError('param_required', { param => 'id' });
...@@ -682,8 +682,8 @@ sub add_comment { ...@@ -682,8 +682,8 @@ sub add_comment {
|| ThrowCodeError('param_required', { param => 'comment' }); || ThrowCodeError('param_required', { param => 'comment' });
my $bug = Bugzilla::Bug->check($params->{id}); my $bug = Bugzilla::Bug->check($params->{id});
Bugzilla->user->can_edit_product($bug->product_id) $user->can_edit_product($bug->product_id)
|| ThrowUserError("product_edit_denied", {product => $bug->product}); || ThrowUserError("product_edit_denied", {product => $bug->product});
# Backwards-compatibility for versions before 3.6 # Backwards-compatibility for versions before 3.6
...@@ -707,8 +707,8 @@ sub add_comment { ...@@ -707,8 +707,8 @@ sub add_comment {
$dbh->bz_commit_transaction(); $dbh->bz_commit_transaction();
# Send mail. # Send mail.
Bugzilla::BugMail::Send($bug->bug_id, { changer => Bugzilla->user }); Bugzilla::BugMail::Send($bug->bug_id, { changer => $user });
return { id => $self->type('int', $new_comment_id) }; return { id => $self->type('int', $new_comment_id) };
} }
......
...@@ -389,7 +389,7 @@ if ($cmdtype eq "dorem") { ...@@ -389,7 +389,7 @@ if ($cmdtype eq "dorem") {
# so that it can be modified easily. # so that it can be modified easily.
$vars->{'searchname'} = $cgi->param('namedcmd'); $vars->{'searchname'} = $cgi->param('namedcmd');
if (!$cgi->param('sharer_id') || if (!$cgi->param('sharer_id') ||
$cgi->param('sharer_id') == Bugzilla->user->id) { $cgi->param('sharer_id') == $user->id) {
$vars->{'searchtype'} = "saved"; $vars->{'searchtype'} = "saved";
$vars->{'search_id'} = $query_id; $vars->{'search_id'} = $query_id;
} }
...@@ -590,7 +590,7 @@ else { ...@@ -590,7 +590,7 @@ else {
# Remove the timetracking columns if they are not a part of the group # Remove the timetracking columns if they are not a part of the group
# (happens if a user had access to time tracking and it was revoked/disabled) # (happens if a user had access to time tracking and it was revoked/disabled)
if (!Bugzilla->user->is_timetracker) { if (!$user->is_timetracker) {
@displaycolumns = grep($_ ne 'estimated_time', @displaycolumns); @displaycolumns = grep($_ ne 'estimated_time', @displaycolumns);
@displaycolumns = grep($_ ne 'remaining_time', @displaycolumns); @displaycolumns = grep($_ ne 'remaining_time', @displaycolumns);
@displaycolumns = grep($_ ne 'actual_time', @displaycolumns); @displaycolumns = grep($_ ne 'actual_time', @displaycolumns);
...@@ -793,7 +793,7 @@ if ($cgi->param('debug')) { ...@@ -793,7 +793,7 @@ if ($cgi->param('debug')) {
# out how many hidden bugs are in a particular product (by doing # out how many hidden bugs are in a particular product (by doing
# searches and looking at the number of rows the explain says it's # searches and looking at the number of rows the explain says it's
# examining). # examining).
if (Bugzilla->user->in_group('admin')) { if ($user->in_group('admin')) {
$vars->{'query_explain'} = $dbh->bz_explain($query); $vars->{'query_explain'} = $dbh->bz_explain($query);
} }
} }
...@@ -984,10 +984,10 @@ $vars->{'order'} = $order; ...@@ -984,10 +984,10 @@ $vars->{'order'} = $order;
$vars->{'caneditbugs'} = 1; $vars->{'caneditbugs'} = 1;
$vars->{'time_info'} = $time_info; $vars->{'time_info'} = $time_info;
if (!Bugzilla->user->in_group('editbugs')) { if (!$user->in_group('editbugs')) {
foreach my $product (keys %$bugproducts) { foreach my $product (keys %$bugproducts) {
my $prod = new Bugzilla::Product({name => $product}); my $prod = new Bugzilla::Product({name => $product});
if (!Bugzilla->user->in_group('editbugs', $prod->id)) { if (!$user->in_group('editbugs', $prod->id)) {
$vars->{'caneditbugs'} = 0; $vars->{'caneditbugs'} = 0;
last; last;
} }
...@@ -995,7 +995,7 @@ if (!Bugzilla->user->in_group('editbugs')) { ...@@ -995,7 +995,7 @@ if (!Bugzilla->user->in_group('editbugs')) {
} }
my @bugowners = keys %$bugowners; my @bugowners = keys %$bugowners;
if (scalar(@bugowners) > 1 && Bugzilla->user->in_group('editbugs')) { if (scalar(@bugowners) > 1 && $user->in_group('editbugs')) {
my $suffix = Bugzilla->params->{'emailsuffix'}; my $suffix = Bugzilla->params->{'emailsuffix'};
map(s/$/$suffix/, @bugowners) if $suffix; map(s/$/$suffix/, @bugowners) if $suffix;
my $bugowners = join(",", @bugowners); my $bugowners = join(",", @bugowners);
...@@ -1024,7 +1024,7 @@ elsif (my @product_input = $cgi->param('product')) { ...@@ -1024,7 +1024,7 @@ elsif (my @product_input = $cgi->param('product')) {
} }
# We only want the template to use it if the user can actually # We only want the template to use it if the user can actually
# enter bugs against it. # enter bugs against it.
if ($one_product && Bugzilla->user->can_enter_product($one_product)) { if ($one_product && $user->can_enter_product($one_product)) {
$vars->{'one_product'} = $one_product; $vars->{'one_product'} = $one_product;
} }
...@@ -1043,7 +1043,7 @@ if ($dotweak && scalar @bugs) { ...@@ -1043,7 +1043,7 @@ if ($dotweak && scalar @bugs) {
$vars->{'token'} = issue_session_token('buglist_mass_change'); $vars->{'token'} = issue_session_token('buglist_mass_change');
Bugzilla->switch_to_shadow_db(); Bugzilla->switch_to_shadow_db();
$vars->{'products'} = Bugzilla->user->get_enterable_products; $vars->{'products'} = $user->get_enterable_products;
$vars->{'platforms'} = get_legal_field_values('rep_platform'); $vars->{'platforms'} = get_legal_field_values('rep_platform');
$vars->{'op_sys'} = get_legal_field_values('op_sys'); $vars->{'op_sys'} = get_legal_field_values('op_sys');
$vars->{'priorities'} = get_legal_field_values('priority'); $vars->{'priorities'} = get_legal_field_values('priority');
......
...@@ -53,7 +53,7 @@ use constant COLUMN_CLASSES => { ...@@ -53,7 +53,7 @@ use constant COLUMN_CLASSES => {
'Bugzilla::Keyword' => 'keywords', 'Bugzilla::Keyword' => 'keywords',
}; };
Bugzilla->login(); my $user = Bugzilla->login();
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template; my $template = Bugzilla->template;
...@@ -77,7 +77,7 @@ foreach my $class (keys %{ COLUMN_CLASSES() }) { ...@@ -77,7 +77,7 @@ foreach my $class (keys %{ COLUMN_CLASSES() }) {
delete $columns->{$column} if !$class->any_exist; delete $columns->{$column} if !$class->any_exist;
} }
if (!Bugzilla->user->is_timetracker) { if (!$user->is_timetracker) {
foreach my $column (TIMETRACKING_FIELDS) { foreach my $column (TIMETRACKING_FIELDS) {
delete $columns->{$column}; delete $columns->{$column};
} }
...@@ -138,7 +138,7 @@ if (defined $cgi->param('rememberedquery')) { ...@@ -138,7 +138,7 @@ if (defined $cgi->param('rememberedquery')) {
$vars->{'message'} = "change_columns"; $vars->{'message'} = "change_columns";
if ($cgi->param('save_columns_for_search') if ($cgi->param('save_columns_for_search')
&& defined $search && $search->user->id == Bugzilla->user->id) && defined $search && $search->user->id == $user->id)
{ {
my $params = new Bugzilla::CGI($search->url); my $params = new Bugzilla::CGI($search->url);
$params->param('columnlist', join(",", @collist)); $params->param('columnlist', join(",", @collist));
...@@ -188,7 +188,7 @@ $vars->{'buffer'} = $cgi->query_string(); ...@@ -188,7 +188,7 @@ $vars->{'buffer'} = $cgi->query_string();
my $search; my $search;
if (defined $cgi->param('query_based_on')) { if (defined $cgi->param('query_based_on')) {
my $searches = Bugzilla->user->queries; my $searches = $user->queries;
my ($search) = grep($_->name eq $cgi->param('query_based_on'), @$searches); my ($search) = grep($_->name eq $cgi->param('query_based_on'), @$searches);
if ($search) { if ($search) {
......
...@@ -107,7 +107,7 @@ $vars->{'closed_status'} = \@closed_status; ...@@ -107,7 +107,7 @@ $vars->{'closed_status'} = \@closed_status;
# Generate a list of fields that can be queried. # Generate a list of fields that can be queried.
my @fields = @{Bugzilla::Field->match({obsolete => 0})}; my @fields = @{Bugzilla::Field->match({obsolete => 0})};
# Exclude fields the user cannot query. # Exclude fields the user cannot query.
if (!Bugzilla->user->is_timetracker) { if (!$user->is_timetracker) {
@fields = grep { $_->name !~ /^(estimated_time|remaining_time|work_time|percentage_complete|deadline)$/ } @fields; @fields = grep { $_->name !~ /^(estimated_time|remaining_time|work_time|percentage_complete|deadline)$/ } @fields;
} }
$vars->{'field'} = \@fields; $vars->{'field'} = \@fields;
......
...@@ -38,7 +38,7 @@ use Bugzilla::Util; ...@@ -38,7 +38,7 @@ use Bugzilla::Util;
# Just in case someone already has an account, let them get the correct footer # Just in case someone already has an account, let them get the correct footer
# on an error message. The user is logged out just after the account is # on an error message. The user is logged out just after the account is
# actually created. # actually created.
Bugzilla->login(LOGIN_OPTIONAL); my $user = Bugzilla->login(LOGIN_OPTIONAL);
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
...@@ -50,7 +50,7 @@ $vars->{'doc_section'} = 'myaccount.html'; ...@@ -50,7 +50,7 @@ $vars->{'doc_section'} = 'myaccount.html';
print $cgi->header(); print $cgi->header();
# If we're using LDAP for login, then we can't create a new account here. # If we're using LDAP for login, then we can't create a new account here.
unless (Bugzilla->user->authorizer->user_can_create_account) { unless ($user->authorizer->user_can_create_account) {
ThrowUserError("auth_cant_create_account"); ThrowUserError("auth_cant_create_account");
} }
......
...@@ -29,7 +29,7 @@ use Bugzilla::Error; ...@@ -29,7 +29,7 @@ use Bugzilla::Error;
use Bugzilla::User; use Bugzilla::User;
use Bugzilla::Keyword; use Bugzilla::Keyword;
Bugzilla->login(); my $user = Bugzilla->login();
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template; my $template = Bugzilla->template;
...@@ -39,8 +39,8 @@ my $vars = {}; ...@@ -39,8 +39,8 @@ my $vars = {};
Bugzilla->switch_to_shadow_db; Bugzilla->switch_to_shadow_db;
$vars->{'keywords'} = Bugzilla::Keyword->get_all_with_bug_count(); $vars->{'keywords'} = Bugzilla::Keyword->get_all_with_bug_count();
$vars->{'caneditkeywords'} = Bugzilla->user->in_group("editkeywords"); $vars->{'caneditkeywords'} = $user->in_group("editkeywords");
print Bugzilla->cgi->header(); print $cgi->header();
$template->process("reports/keywords.html.tmpl", $vars) $template->process("reports/keywords.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
...@@ -58,11 +58,11 @@ sub LoadTemplate { ...@@ -58,11 +58,11 @@ sub LoadTemplate {
# Preliminary checks: # Preliminary checks:
# #
Bugzilla->login(LOGIN_REQUIRED); my $user = Bugzilla->login(LOGIN_REQUIRED);
print $cgi->header(); print $cgi->header();
Bugzilla->user->in_group('editclassifications') $user->in_group('editclassifications')
|| ThrowUserError("auth_failure", {group => "editclassifications", || ThrowUserError("auth_failure", {group => "editclassifications",
action => "edit", action => "edit",
object => "classifications"}); object => "classifications"});
......
...@@ -47,7 +47,7 @@ sub display_field_values { ...@@ -47,7 +47,7 @@ sub display_field_values {
###################################################################### ######################################################################
# require the user to have logged in # require the user to have logged in
Bugzilla->login(LOGIN_REQUIRED); my $user = Bugzilla->login(LOGIN_REQUIRED);
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
...@@ -60,10 +60,10 @@ $vars->{'doc_section'} = 'edit-values.html'; ...@@ -60,10 +60,10 @@ $vars->{'doc_section'} = 'edit-values.html';
print $cgi->header(); print $cgi->header();
Bugzilla->user->in_group('admin') || $user->in_group('admin')
ThrowUserError('auth_failure', {group => "admin", || ThrowUserError('auth_failure', {group => "admin",
action => "edit", action => "edit",
object => "field_values"}); object => "field_values"});
# #
# often-used variables # often-used variables
......
...@@ -82,7 +82,7 @@ $user->in_group('bz_canusewhines') ...@@ -82,7 +82,7 @@ $user->in_group('bz_canusewhines')
object => "reports"}); object => "reports"});
# May this user send mail to other users? # May this user send mail to other users?
my $can_mail_others = Bugzilla->user->in_group('bz_canusewhineatothers'); my $can_mail_others = $user->in_group('bz_canusewhineatothers');
# If the form was submitted, we need to look for what needs to be added or # If the form was submitted, we need to look for what needs to be added or
# removed, then what was altered. # removed, then what was altered.
......
...@@ -267,7 +267,7 @@ if ($cloned_bug_id) { ...@@ -267,7 +267,7 @@ if ($cloned_bug_id) {
$vars->{'comment'} = ""; $vars->{'comment'} = "";
$vars->{'comment_is_private'} = 0; $vars->{'comment_is_private'} = 0;
if (!$isprivate || Bugzilla->user->is_insider) { if (!$isprivate || $user->is_insider) {
# We use "body" to avoid any format_comment text, which would be # We use "body" to avoid any format_comment text, which would be
# pointless to clone. # pointless to clone.
$vars->{'comment'} = $bug_desc->body; $vars->{'comment'} = $bug_desc->body;
......
...@@ -216,7 +216,7 @@ else { ...@@ -216,7 +216,7 @@ else {
# For each bug, we have to check if the user can edit the bug the product # For each bug, we have to check if the user can edit the bug the product
# is currently in, before we allow them to change anything. # is currently in, before we allow them to change anything.
foreach my $bug (@bug_objects) { foreach my $bug (@bug_objects) {
if (!Bugzilla->user->can_edit_product($bug->product_obj->id) ) { if (!$user->can_edit_product($bug->product_obj->id)) {
ThrowUserError("product_edit_denied", ThrowUserError("product_edit_denied",
{ product => $bug->product }); { product => $bug->product });
} }
...@@ -301,7 +301,7 @@ if (defined $cgi->param('newcc') ...@@ -301,7 +301,7 @@ if (defined $cgi->param('newcc')
} }
} else { } else {
@cc_add = $cgi->param('newcc'); @cc_add = $cgi->param('newcc');
push(@cc_add, Bugzilla->user) if $cgi->param('addselfcc'); push(@cc_add, $user) if $cgi->param('addselfcc');
# We came from show_bug which uses a select box to determine what cc's # We came from show_bug which uses a select box to determine what cc's
# need to be removed... # need to be removed...
...@@ -378,7 +378,7 @@ foreach my $bug (@bug_objects) { ...@@ -378,7 +378,7 @@ foreach my $bug (@bug_objects) {
# status, so we should inform the user about that. # status, so we should inform the user about that.
if (!is_open_state($new_status) && $changes->{'remaining_time'}) { if (!is_open_state($new_status) && $changes->{'remaining_time'}) {
$vars->{'message'} = "remaining_time_zeroed" $vars->{'message'} = "remaining_time_zeroed"
if Bugzilla->user->is_timetracker; if $user->is_timetracker;
} }
} }
......
...@@ -202,7 +202,7 @@ foreach my $val (editable_bug_fields()) { ...@@ -202,7 +202,7 @@ foreach my $val (editable_bug_fields()) {
push @chfields, $val; push @chfields, $val;
} }
if (Bugzilla->user->is_timetracker) { if ($user->is_timetracker) {
push @chfields, "work_time"; push @chfields, "work_time";
} else { } else {
@chfields = grep($_ ne "estimated_time", @chfields); @chfields = grep($_ ne "estimated_time", @chfields);
...@@ -221,7 +221,7 @@ $vars->{'resolution'} = Bugzilla::Field->new({name => 'resolution'})->legal_valu ...@@ -221,7 +221,7 @@ $vars->{'resolution'} = Bugzilla::Field->new({name => 'resolution'})->legal_valu
my @fields = @{ Bugzilla->fields({ obsolete => 0 }) }; my @fields = @{ Bugzilla->fields({ obsolete => 0 }) };
# If we're not in the time-tracking group, exclude time-tracking fields. # If we're not in the time-tracking group, exclude time-tracking fields.
if (!Bugzilla->user->is_timetracker) { if (!$user->is_timetracker) {
foreach my $tt_field (TIMETRACKING_FIELDS) { foreach my $tt_field (TIMETRACKING_FIELDS) {
@fields = grep($_->name ne $tt_field, @fields); @fields = grep($_->name ne $tt_field, @fields);
} }
......
...@@ -258,7 +258,7 @@ if ($cgi->param('rescanallBugMail')) { ...@@ -258,7 +258,7 @@ if ($cgi->param('rescanallBugMail')) {
# and so choosing this user as being the last one having done a change # and so choosing this user as being the last one having done a change
# for the bug may be problematic. So the best we can do at this point # for the bug may be problematic. So the best we can do at this point
# is to choose the currently logged in user for email notification. # is to choose the currently logged in user for email notification.
$vars->{'changer'} = Bugzilla->user; $vars->{'changer'} = $user;
foreach my $bugid (@$list) { foreach my $bugid (@$list) {
Bugzilla::BugMail::Send($bugid, $vars); Bugzilla::BugMail::Send($bugid, $vars);
......
...@@ -43,7 +43,7 @@ my $single = !$cgi->param('format') ...@@ -43,7 +43,7 @@ my $single = !$cgi->param('format')
# If we don't have an ID, _AND_ we're only doing a single bug, then prompt # If we don't have an ID, _AND_ we're only doing a single bug, then prompt
if (!$cgi->param('id') && $single) { if (!$cgi->param('id') && $single) {
print Bugzilla->cgi->header(); print $cgi->header();
$template->process("bug/choose.html.tmpl", $vars) || $template->process("bug/choose.html.tmpl", $vars) ||
ThrowTemplateError($template->error()); ThrowTemplateError($template->error());
exit; exit;
...@@ -111,7 +111,7 @@ if ($cgi->param("field")) { ...@@ -111,7 +111,7 @@ if ($cgi->param("field")) {
@fieldlist = $cgi->param("field"); @fieldlist = $cgi->param("field");
} }
unless (Bugzilla->user->is_timetracker) { unless ($user->is_timetracker) {
@fieldlist = grep($_ !~ /(^deadline|_time)$/, @fieldlist); @fieldlist = grep($_ !~ /(^deadline|_time)$/, @fieldlist);
} }
......
...@@ -35,7 +35,7 @@ use Bugzilla::Error; ...@@ -35,7 +35,7 @@ use Bugzilla::Error;
use Bugzilla::Bug; use Bugzilla::Bug;
use Bugzilla::Status; use Bugzilla::Status;
Bugzilla->login(); my $user = Bugzilla->login();
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template; my $template = Bugzilla->template;
...@@ -189,7 +189,7 @@ foreach my $k (keys(%seen)) { ...@@ -189,7 +189,7 @@ foreach my $k (keys(%seen)) {
my ($stat, $resolution, $summary) = $dbh->selectrow_array($sth, undef, $k); my ($stat, $resolution, $summary) = $dbh->selectrow_array($sth, undef, $k);
# Resolution and summary are shown only if user can see the bug # Resolution and summary are shown only if user can see the bug
if (!Bugzilla->user->can_see_bug($k)) { if (!$user->can_see_bug($k)) {
$resolution = $summary = ''; $resolution = $summary = '';
} }
......
...@@ -250,10 +250,9 @@ sub get_earliest_activity_date { ...@@ -250,10 +250,9 @@ sub get_earliest_activity_date {
# Template code starts here # Template code starts here
# #
Bugzilla->login(LOGIN_REQUIRED); my $user = Bugzilla->login(LOGIN_REQUIRED);
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
my $user = Bugzilla->user;
my $template = Bugzilla->template; my $template = Bugzilla->template;
my $vars = {}; my $vars = {};
......
...@@ -51,8 +51,7 @@ sub DoAccount { ...@@ -51,8 +51,7 @@ sub DoAccount {
($vars->{'realname'}) = $dbh->selectrow_array( ($vars->{'realname'}) = $dbh->selectrow_array(
"SELECT realname FROM profiles WHERE userid = ?", undef, $user->id); "SELECT realname FROM profiles WHERE userid = ?", undef, $user->id);
if(Bugzilla->params->{'allowemailchange'} if (Bugzilla->params->{'allowemailchange'} && $user->authorizer->can_change_email) {
&& Bugzilla->user->authorizer->can_change_email) {
# First delete old tokens. # First delete old tokens.
Bugzilla::Token::CleanTokenTable(); Bugzilla::Token::CleanTokenTable();
...@@ -493,9 +492,9 @@ $cgi->delete('Bugzilla_login', 'Bugzilla_password') if ($cgi->cookie('sudo')); ...@@ -493,9 +492,9 @@ $cgi->delete('Bugzilla_login', 'Bugzilla_password') if ($cgi->cookie('sudo'));
$cgi->delete('GoAheadAndLogIn'); $cgi->delete('GoAheadAndLogIn');
# First try to get credentials from cookies. # First try to get credentials from cookies.
Bugzilla->login(LOGIN_OPTIONAL); my $user = Bugzilla->login(LOGIN_OPTIONAL);
if (!Bugzilla->user->id) { if (!$user->id) {
# Use credentials given in the form if login cookies are not available. # Use credentials given in the form if login cookies are not available.
$cgi->param('Bugzilla_login', $cgi->param('old_login')); $cgi->param('Bugzilla_login', $cgi->param('old_login'));
$cgi->param('Bugzilla_password', $cgi->param('old_password')); $cgi->param('Bugzilla_password', $cgi->param('old_password'));
......
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