]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 678970: Use $user and $cgi instead of Bugzilla->user and Bugzilla->cgi
authorFrédéric Buclin <LpSolit@gmail.com>
Tue, 16 Aug 2011 22:45:22 +0000 (00:45 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Tue, 16 Aug 2011 22:45:22 +0000 (00:45 +0200)
r=timello a=LpSolit

17 files changed:
Bugzilla/WebService/Bug.pm
buglist.cgi
colchange.cgi
config.cgi
createaccount.cgi
describekeywords.cgi
editclassifications.cgi
editvalues.cgi
editwhines.cgi
enter_bug.cgi
process_bug.cgi
query.cgi
sanitycheck.cgi
show_bug.cgi
showdependencygraph.cgi
summarize_time.cgi
userprefs.cgi

index 9064f6a14e956805233de06df886683061866f2a..7844b4e97636ebee0eb1f0b21e3b492b28e1e8b7 100644 (file)
@@ -670,10 +670,10 @@ sub add_attachment {
 
 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' }); 
@@ -682,8 +682,8 @@ sub add_comment {
         || 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    
@@ -707,8 +707,8 @@ sub add_comment {
     $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) };
 }
 
index 7549063a4691b387ac567cde9a922d29099e3e78..0797aa389356133d17f9b405653276a28f6271c5 100755 (executable)
@@ -389,7 +389,7 @@ if ($cmdtype eq "dorem") {
         # 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;
         }
@@ -590,7 +590,7 @@ else {
 
 # 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);
@@ -793,7 +793,7 @@ if ($cgi->param('debug')) {
     # 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);
     }
 }
@@ -984,10 +984,10 @@ $vars->{'order'} = $order;
 $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;
         }
@@ -995,7 +995,7 @@ if (!Bugzilla->user->in_group('editbugs')) {
 }
 
 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);
@@ -1024,7 +1024,7 @@ elsif (my @product_input = $cgi->param('product')) {
 }
 # 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;
 }
 
@@ -1043,7 +1043,7 @@ if ($dotweak && scalar @bugs) {
     $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');
index 844f7615cedabea0b60bcc343b2df90dce695964..c3741f6238516376764d0944d74de801d7c51bcc 100755 (executable)
@@ -53,7 +53,7 @@ use constant COLUMN_CLASSES => {
     'Bugzilla::Keyword' => 'keywords',
 };
 
-Bugzilla->login();
+my $user = Bugzilla->login();
 
 my $cgi = Bugzilla->cgi;
 my $template = Bugzilla->template;
@@ -77,7 +77,7 @@ foreach my $class (keys %{ COLUMN_CLASSES() }) {
     delete $columns->{$column} if !$class->any_exist;
 }
 
-if (!Bugzilla->user->is_timetracker) {
+if (!$user->is_timetracker) {
     foreach my $column (TIMETRACKING_FIELDS) {
         delete $columns->{$column};
     }
@@ -138,7 +138,7 @@ if (defined $cgi->param('rememberedquery')) {
     $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));
@@ -188,7 +188,7 @@ $vars->{'buffer'} = $cgi->query_string();
 
 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) {
index 2c82fdc59a6023491c88fa01967e70e398df0442..f83ffcdf325ab1d4e91487dfd7933fd3a531333f 100755 (executable)
@@ -107,7 +107,7 @@ $vars->{'closed_status'} = \@closed_status;
 # 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;
index db0727adda7e50ede1d1d370b89b0c872ff2e6c8..d0437a02113ffc2d957849e311d5a2caa5671ef3 100755 (executable)
@@ -38,7 +38,7 @@ use Bugzilla::Util;
 # 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;
@@ -50,7 +50,7 @@ $vars->{'doc_section'} = 'myaccount.html';
 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");
 }
 
index 9796b77d502b9d7460133fe4bcd66902aac172ae..ffe14032f68838623277fff413be6293a30ac78f 100755 (executable)
@@ -29,7 +29,7 @@ use Bugzilla::Error;
 use Bugzilla::User;
 use Bugzilla::Keyword;
 
-Bugzilla->login();
+my $user = Bugzilla->login();
 
 my $cgi = Bugzilla->cgi;
 my $template = Bugzilla->template;
@@ -39,8 +39,8 @@ my $vars = {};
 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());
index db9dd7f0a877e0a9f71b928a25049deaa1fbd551..6eb3cb9102b887014ed19cb1b147fca2f168f668 100755 (executable)
@@ -58,11 +58,11 @@ sub LoadTemplate {
 # 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"});
index 53ea78512054a59f85dfaef4cee95210f2d82943..1a8d89531100ee8a0f862cb0cc0da36ed7ab6fdc 100755 (executable)
@@ -47,7 +47,7 @@ sub display_field_values {
 ######################################################################
 
 # 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;
@@ -60,10 +60,10 @@ $vars->{'doc_section'} = 'edit-values.html';
 
 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
index 04e2b548fcedc5cfb6631b81cfdf795a13fddcea..5d388cd0ff71b039a9e581107d5627d0df4f1cca 100755 (executable)
@@ -82,7 +82,7 @@ $user->in_group('bz_canusewhines')
                                      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.
index fc02aa86e25988333c2fa1af9b3ee1582b262c86..497209df402d3c098709d4b12d03dd4b650019ab 100755 (executable)
@@ -267,7 +267,7 @@ if ($cloned_bug_id) {
     $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;
index 382ee8b595f8eb4b86d9b50cf9807ed802a84e57..9ba03e27741fca44b2c9ec3e4ea39b67b68abd3e 100755 (executable)
@@ -216,7 +216,7 @@ else {
 # 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 });
     }
@@ -301,7 +301,7 @@ if (defined $cgi->param('newcc')
         }
     } 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...
@@ -378,7 +378,7 @@ foreach my $bug (@bug_objects) {
         # 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;
         }
     }
 
index 0182f66eb1bc3e9f5f9f5864f62f3ba14ac489ec..686d9db367021cb3232507872c62d3b18e281020 100755 (executable)
--- a/query.cgi
+++ b/query.cgi
@@ -202,7 +202,7 @@ foreach my $val (editable_bug_fields()) {
     push @chfields, $val;
 }
 
-if (Bugzilla->user->is_timetracker) {
+if ($user->is_timetracker) {
     push @chfields, "work_time";
 } else {
     @chfields = grep($_ ne "estimated_time", @chfields);
@@ -221,7 +221,7 @@ $vars->{'resolution'} = Bugzilla::Field->new({name => 'resolution'})->legal_valu
 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);
     }
index 7d530ea4bef2a05d05acc3e564ce4a5622bca4f6..da308aaebb356ee3f8e61a3a5552a93c59ef662b 100755 (executable)
@@ -258,7 +258,7 @@ if ($cgi->param('rescanallBugMail')) {
     # 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);
index 7ea55e7320d17d0c228327a3fe7dd4eb90a4f7ff..f38764b21697129896101ad3b7dd6e6b78f0c780 100755 (executable)
@@ -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 (!$cgi->param('id') && $single) {
-    print Bugzilla->cgi->header();
+    print $cgi->header();
     $template->process("bug/choose.html.tmpl", $vars) ||
       ThrowTemplateError($template->error());
     exit;
@@ -111,7 +111,7 @@ if ($cgi->param("field")) {
     @fieldlist = $cgi->param("field");
 }
 
-unless (Bugzilla->user->is_timetracker) {
+unless ($user->is_timetracker) {
     @fieldlist = grep($_ !~ /(^deadline|_time)$/, @fieldlist);
 }
 
index 0726760b90cf996d6cec559443ab3b35fbf2012f..676a3462fd3436fae6b79ca9ec20cb3831e36581 100755 (executable)
@@ -35,7 +35,7 @@ use Bugzilla::Error;
 use Bugzilla::Bug;
 use Bugzilla::Status;
 
-Bugzilla->login();
+my $user = Bugzilla->login();
 
 my $cgi = Bugzilla->cgi;
 my $template = Bugzilla->template;
@@ -189,7 +189,7 @@ foreach my $k (keys(%seen)) {
     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 = '';
     }
 
index dd8ba741b45c568ad7f2502f1685d06125fc532d..c7c7bebecb1678f89da15fce6d37dd1e64898f68 100755 (executable)
@@ -250,10 +250,9 @@ sub get_earliest_activity_date {
 # 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 = {};
 
index f411326a241b7ba1f16d9c4ae0ed069ddb939cfb..485ceb54f39c43c57abc577d476d50849c0bd0f5 100755 (executable)
@@ -51,8 +51,7 @@ sub DoAccount {
     ($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();
 
@@ -493,9 +492,9 @@ $cgi->delete('Bugzilla_login', 'Bugzilla_password') if ($cgi->cookie('sudo'));
 $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'));