sub add_comment {
my ($self, $params) = @_;
-
- #The user must login in order add a comment
- Bugzilla->login(LOGIN_REQUIRED);
-
+
+ # The user must login in order add a comment
+ my $user = Bugzilla->login(LOGIN_REQUIRED);
+
# Check parameters
defined $params->{id}
|| ThrowCodeError('param_required', { param => 'id' });
|| ThrowCodeError('param_required', { param => 'comment' });
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});
# Backwards-compatibility for versions before 3.6
$dbh->bz_commit_transaction();
# 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) };
}
# so that it can be modified easily.
$vars->{'searchname'} = $cgi->param('namedcmd');
if (!$cgi->param('sharer_id') ||
- $cgi->param('sharer_id') == Bugzilla->user->id) {
+ $cgi->param('sharer_id') == $user->id) {
$vars->{'searchtype'} = "saved";
$vars->{'search_id'} = $query_id;
}
# 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)
-if (!Bugzilla->user->is_timetracker) {
+if (!$user->is_timetracker) {
@displaycolumns = grep($_ ne 'estimated_time', @displaycolumns);
@displaycolumns = grep($_ ne 'remaining_time', @displaycolumns);
@displaycolumns = grep($_ ne 'actual_time', @displaycolumns);
# 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
# examining).
- if (Bugzilla->user->in_group('admin')) {
+ if ($user->in_group('admin')) {
$vars->{'query_explain'} = $dbh->bz_explain($query);
}
}
$vars->{'caneditbugs'} = 1;
$vars->{'time_info'} = $time_info;
-if (!Bugzilla->user->in_group('editbugs')) {
+if (!$user->in_group('editbugs')) {
foreach my $product (keys %$bugproducts) {
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;
last;
}
}
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'};
map(s/$/$suffix/, @bugowners) if $suffix;
my $bugowners = join(",", @bugowners);
}
# We only want the template to use it if the user can actually
# 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->{'token'} = issue_session_token('buglist_mass_change');
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->{'op_sys'} = get_legal_field_values('op_sys');
$vars->{'priorities'} = get_legal_field_values('priority');
'Bugzilla::Keyword' => 'keywords',
};
-Bugzilla->login();
+my $user = Bugzilla->login();
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
delete $columns->{$column} if !$class->any_exist;
}
-if (!Bugzilla->user->is_timetracker) {
+if (!$user->is_timetracker) {
foreach my $column (TIMETRACKING_FIELDS) {
delete $columns->{$column};
}
$vars->{'message'} = "change_columns";
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);
$params->param('columnlist', join(",", @collist));
my $search;
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);
if ($search) {
# Generate a list of fields that can be queried.
my @fields = @{Bugzilla::Field->match({obsolete => 0})};
# 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;
}
$vars->{'field'} = \@fields;
# 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
# actually created.
-Bugzilla->login(LOGIN_OPTIONAL);
+my $user = Bugzilla->login(LOGIN_OPTIONAL);
my $dbh = Bugzilla->dbh;
my $cgi = Bugzilla->cgi;
print $cgi->header();
# 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");
}
use Bugzilla::User;
use Bugzilla::Keyword;
-Bugzilla->login();
+my $user = Bugzilla->login();
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
Bugzilla->switch_to_shadow_db;
$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)
|| ThrowTemplateError($template->error());
# Preliminary checks:
#
-Bugzilla->login(LOGIN_REQUIRED);
+my $user = Bugzilla->login(LOGIN_REQUIRED);
print $cgi->header();
-Bugzilla->user->in_group('editclassifications')
+$user->in_group('editclassifications')
|| ThrowUserError("auth_failure", {group => "editclassifications",
action => "edit",
object => "classifications"});
######################################################################
# require the user to have logged in
-Bugzilla->login(LOGIN_REQUIRED);
+my $user = Bugzilla->login(LOGIN_REQUIRED);
my $dbh = Bugzilla->dbh;
my $cgi = Bugzilla->cgi;
print $cgi->header();
-Bugzilla->user->in_group('admin') ||
- ThrowUserError('auth_failure', {group => "admin",
- action => "edit",
- object => "field_values"});
+$user->in_group('admin')
+ || ThrowUserError('auth_failure', {group => "admin",
+ action => "edit",
+ object => "field_values"});
#
# often-used variables
object => "reports"});
# 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
# removed, then what was altered.
$vars->{'comment'} = "";
$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
# pointless to clone.
$vars->{'comment'} = $bug_desc->body;
# 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.
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",
{ product => $bug->product });
}
}
} else {
@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
# need to be removed...
# status, so we should inform the user about that.
if (!is_open_state($new_status) && $changes->{'remaining_time'}) {
$vars->{'message'} = "remaining_time_zeroed"
- if Bugzilla->user->is_timetracker;
+ if $user->is_timetracker;
}
}
push @chfields, $val;
}
-if (Bugzilla->user->is_timetracker) {
+if ($user->is_timetracker) {
push @chfields, "work_time";
} else {
@chfields = grep($_ ne "estimated_time", @chfields);
my @fields = @{ Bugzilla->fields({ obsolete => 0 }) };
# 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) {
@fields = grep($_->name ne $tt_field, @fields);
}
# 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
# is to choose the currently logged in user for email notification.
- $vars->{'changer'} = Bugzilla->user;
+ $vars->{'changer'} = $user;
foreach my $bugid (@$list) {
Bugzilla::BugMail::Send($bugid, $vars);
# If we don't have an ID, _AND_ we're only doing a single bug, then prompt
if (!$cgi->param('id') && $single) {
- print Bugzilla->cgi->header();
+ print $cgi->header();
$template->process("bug/choose.html.tmpl", $vars) ||
ThrowTemplateError($template->error());
exit;
@fieldlist = $cgi->param("field");
}
-unless (Bugzilla->user->is_timetracker) {
+unless ($user->is_timetracker) {
@fieldlist = grep($_ !~ /(^deadline|_time)$/, @fieldlist);
}
use Bugzilla::Bug;
use Bugzilla::Status;
-Bugzilla->login();
+my $user = Bugzilla->login();
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my ($stat, $resolution, $summary) = $dbh->selectrow_array($sth, undef, $k);
# 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 = '';
}
# Template code starts here
#
-Bugzilla->login(LOGIN_REQUIRED);
+my $user = Bugzilla->login(LOGIN_REQUIRED);
my $cgi = Bugzilla->cgi;
-my $user = Bugzilla->user;
my $template = Bugzilla->template;
my $vars = {};
($vars->{'realname'}) = $dbh->selectrow_array(
"SELECT realname FROM profiles WHERE userid = ?", undef, $user->id);
- if(Bugzilla->params->{'allowemailchange'}
- && Bugzilla->user->authorizer->can_change_email) {
+ if (Bugzilla->params->{'allowemailchange'} && $user->authorizer->can_change_email) {
# First delete old tokens.
Bugzilla::Token::CleanTokenTable();
$cgi->delete('GoAheadAndLogIn');
# 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.
$cgi->param('Bugzilla_login', $cgi->param('old_login'));
$cgi->param('Bugzilla_password', $cgi->param('old_password'));