]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 282628: Move OpenStates and IsOpenedState out of globals.pl
authormkanat%kerio.com <>
Tue, 7 Mar 2006 05:42:09 +0000 (05:42 +0000)
committermkanat%kerio.com <>
Tue, 7 Mar 2006 05:42:09 +0000 (05:42 +0000)
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=wicked, a=myk

17 files changed:
Bugzilla/Bug.pm
Bugzilla/BugMail.pm
Bugzilla/Constants.pm
Bugzilla/Search.pm
Bugzilla/Search/Quicksearch.pm
Bugzilla/Template.pm
buglist.cgi
checksetup.pl
config.cgi
editproducts.cgi
globals.pl
importxml.pl
process_bug.cgi
sanitycheck.cgi
showdependencygraph.cgi
showdependencytree.cgi
votes.cgi

index f297ec6813dd523ed534ad22ca095461800875d2..43f5a128537d05fe9f1a1e864d77ef8d436e8610 100755 (executable)
@@ -54,6 +54,7 @@ use base qw(Exporter);
     bug_alias_to_id ValidateBugAlias ValidateBugID
     RemoveVotes CheckIfVotedConfirmed
     LogActivityEntry
+    is_open_state
 );
 
 #####################################################################
@@ -203,7 +204,7 @@ sub initBug  {
   }
 
   $self->{'isunconfirmed'} = ($self->{bug_status} eq 'UNCONFIRMED');
-  $self->{'isopened'} = &::IsOpenedState($self->{bug_status});
+  $self->{'isopened'} = is_open_state($self->{bug_status});
   
   return $self;
 }
@@ -758,6 +759,12 @@ sub EmitDependList {
     return $list_ref;
 }
 
+# Tells you whether or not the argument is a valid "open" state.
+sub is_open_state {
+    my ($state) = @_;
+    return (grep($_ eq $state, BUG_STATE_OPEN) ? 1 : 0);
+}
+
 sub ValidateTime {
     my ($time, $field) = @_;
 
@@ -979,7 +986,7 @@ sub CountOpenDependencies {
             "FROM bugs, dependencies " .
            "WHERE blocked IN (" . (join "," , @bug_list) . ") " .
              "AND bug_id = dependson " .
-             "AND bug_status IN ('" . (join "','", &::OpenStates())  . "') " .
+             "AND bug_status IN ('" . (join "','", BUG_STATE_OPEN)  . "') " .
           $dbh->sql_group_by('blocked'));
     $sth->execute();
 
index e20fb5f61173db49ecf0f1aa7440e1714a28e12a..2b76a211abf46fd6a7b66483bf8fb536183bd229 100644 (file)
@@ -37,6 +37,7 @@ use Bugzilla::User;
 use Bugzilla::Constants;
 use Bugzilla::Config qw(:DEFAULT $datadir);
 use Bugzilla::Util;
+use Bugzilla::Bug;
 
 use Date::Parse;
 use Date::Format;
@@ -309,7 +310,7 @@ sub ProcessOneBug {
             $interestingchange = 0;
         }
         $thisdiff .= FormatTriple($fielddescription{$what}, $old, $new);
-        if ($what eq 'bug_status' && &::IsOpenedState($old) ne &::IsOpenedState($new)) {
+        if ($what eq 'bug_status' && is_open_state($old) ne is_open_state($new)) {
             $interestingchange = 1;
         }
         
index afb621f78a33472e8c118709331812c9abcab59b..0b612cbbacb01c61abc36e60d2a7c9dff6e18fe9 100644 (file)
@@ -94,6 +94,8 @@ use base qw(Exporter);
 
     FIELD_TYPE_UNKNOWN
     FIELD_TYPE_FREETEXT
+
+    BUG_STATE_OPEN
 );
 
 @Bugzilla::Constants::EXPORT_OK = qw(contenttypes);
@@ -256,4 +258,8 @@ use constant SENDMAIL_EXE => '/usr/lib/sendmail.exe';
 use constant FIELD_TYPE_UNKNOWN   => 0;
 use constant FIELD_TYPE_FREETEXT  => 1;
 
+# States that are considered to be "open" for bugs.
+use constant BUG_STATE_OPEN => ('NEW', 'REOPENED', 'ASSIGNED', 
+                                'UNCONFIRMED');
+
 1;
index 9b6c5bca7fb6eb6520cae936ae7fd4816ee128b2..0914d69b029f640323ab03055b2b568d884a98e2 100644 (file)
@@ -41,6 +41,7 @@ use Bugzilla::Constants;
 use Bugzilla::Group;
 use Bugzilla::User;
 use Bugzilla::Field;
+use Bugzilla::Bug;
 
 use Date::Format;
 use Date::Parse;
@@ -186,11 +187,11 @@ sub init {
             $params->delete('bug_status');
         }
         elsif ($bug_statuses[0] eq '__open__') {
-            $params->param('bug_status', map(&::IsOpenedState($_) ? $_ : undef, 
+            $params->param('bug_status', map(is_open_state($_) ? $_ : undef, 
                                              @::legal_bug_status));
         }
         elsif ($bug_statuses[0] eq "__closed__") {
-            $params->param('bug_status', map(&::IsOpenedState($_) ? undef : $_, 
+            $params->param('bug_status', map(is_open_state($_) ? undef : $_, 
                                              @::legal_bug_status));
         }
     }
index 365e5646923651ce046aa8eef05ca51e42eba0d0..4d9958c6319891b740568cc3aad0e231fe3e5f71 100644 (file)
@@ -26,6 +26,8 @@ use strict;
 use Bugzilla;
 use Bugzilla::Config;
 use Bugzilla::Error;
+use Bugzilla::Constants;
+use Bugzilla::Bug;
 
 use base qw(Exporter);
 @Bugzilla::Search::Quicksearch::EXPORT = qw(quicksearch);
@@ -153,12 +155,12 @@ sub quicksearch {
 
         my @words = splitString($searchstring);
         my $searchComments = $#words < Param('quicksearch_comment_cutoff');
-        my @openStates = &::OpenStates();
+        my @openStates = BUG_STATE_OPEN;
         my @closedStates;
         my (%states, %resolutions);
 
         foreach (@::legal_bug_status) {
-            push(@closedStates, $_) unless &::IsOpenedState($_);
+            push(@closedStates, $_) unless is_open_state($_);
         }
         foreach (@openStates) { $states{$_} = 1 }
         if ($words[0] eq 'ALL') {
index 2a83a4bea962c637d86165481d44023f3d9a1493..edfc037c62ea684ab82fe27056c21f7b6bcaeea3 100644 (file)
@@ -40,6 +40,7 @@ use Bugzilla::Util;
 use Bugzilla::User;
 use Bugzilla::Error;
 use MIME::Base64;
+use Bugzilla::Bug;
 
 # for time2str - replace by TT Date plugin??
 use Date::Format ();
@@ -415,7 +416,7 @@ sub get_bug_link {
             $pre = "<i>";
             $post = "</i>";
         }
-        elsif (! &::IsOpenedState($bug_state)) {
+        elsif (!is_open_state($bug_state)) {
             $pre = '<span class="bz_closed">';
             $title .= " $bug_res";
             $post = '</span>';
index 7b66f14e8061e7cc01ad57295a826627e90ae18e..4954ac607f45b05248e119c12635c648b8c42985 100755 (executable)
@@ -1007,7 +1007,7 @@ $vars->{'buglist_joined'} = join(',', @bugidlist);
 $vars->{'columns'} = $columns;
 $vars->{'displaycolumns'} = \@displaycolumns;
 
-my @openstates = OpenStates();
+my @openstates = BUG_STATE_OPEN;
 $vars->{'openstates'} = \@openstates;
 $vars->{'closedstates'} = ['CLOSED', 'VERIFIED', 'RESOLVED'];
 
index 5d3a2e540f51704a7e7ce4456a19caa3650a2539..ab847674bf459265691bf985db135a8002267655 100755 (executable)
@@ -1449,6 +1449,9 @@ import Bugzilla::Util qw(bz_crypt trim html_quote is_7bit_clean);
 require Bugzilla::User;
 import Bugzilla::User qw(insert_new_user);
 
+require Bugzilla::Bug;
+import Bugzilla::Bug qw(is_open_state);
+
 # globals.pl clears the PATH, but File::Find uses Cwd::cwd() instead of
 # Cwd::getcwd(), which we need to do because `pwd` isn't in the path - see
 # http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2001-09/msg00115.html
@@ -3545,7 +3548,7 @@ if (!$series_exists) {
                     $data{$fields[$i]}{$numbers[0]} = $numbers[$i + 1];
                     
                     # Keep a total of the number of open bugs for this day
-                    if (IsOpenedState($fields[$i])) {
+                    if (is_open_state($fields[$i])) {
                         $data{$open_name}{$numbers[0]} += $numbers[$i + 1];
                     }
                 }
@@ -4120,7 +4123,7 @@ if (@$broken_nonopen_series) {
         join("&", map { "bug_status=" . url_quote($_) }
                       ('UNCONFIRMED', 'NEW', 'ASSIGNED', 'REOPENED'));
     my $open_bugs_query_base_new = 
-        join("&", map { "bug_status=" . url_quote($_) } OpenStates());
+        join("&", map { "bug_status=" . url_quote($_) } BUG_STATE_OPEN);
     my $sth_openbugs_series =
         $dbh->prepare("SELECT series_id FROM series
                         WHERE query IN (?, ?)");
index c8c8ec88706954a434120a86417a269f8f4971dc..371383e1c0659abeafa9b771b5dfbd9fb52207ff 100755 (executable)
@@ -33,6 +33,7 @@ use lib qw(.);
 require "globals.pl";
 use Bugzilla;
 use Bugzilla::Constants;
+use Bugzilla::Bug;
 
 # Suppress "used only once" warnings.
 use vars 
@@ -80,7 +81,7 @@ $vars->{'products'} = $user->get_selectable_products;
 my @open_status;
 my @closed_status;
 foreach my $status (@::legal_bug_status) {
-    IsOpenedState($status) ? push(@open_status, $status) 
+    is_open_state($status) ? push(@open_status, $status) 
                            : push(@closed_status, $status);
 }
 $vars->{'open_status'} = \@open_status;
index 25bad900d311ea507ca9a07536a3a4777ebe8fbb..68e6bd42add73fe9b48f043f84c3710fa21df236 100755 (executable)
@@ -294,7 +294,7 @@ if ($action eq 'new') {
 
         # For localisation reasons, we get the name of the "global" subcategory
         # and the title of the "open" query from the submitted form.
-        my @openedstatuses = OpenStates();
+        my @openedstatuses = BUG_STATE_OPEN;
         my $query = 
                join("&", map { "bug_status=" . url_quote($_) } @openedstatuses);
         push(@series, [$open_name, $query]);
index 4bf1b3b34a8ac2fd62d9844276bc5e970e472910..be3df7d75a0d0421300364c4274ddd63d2d62db5 100644 (file)
@@ -472,25 +472,6 @@ sub GroupIdToName {
     return $name;
 }
 
-# Determines if the given bug_status string represents an "Opened" bug.  This
-# routine ought to be parameterizable somehow, as people tend to introduce
-# new states into Bugzilla.
-
-sub IsOpenedState {
-    my ($state) = (@_);
-    if (grep($_ eq $state, OpenStates())) {
-        return 1;
-    }
-    return 0;
-}
-
-# This sub will return an array containing any status that
-# is considered an open bug.
-
-sub OpenStates {
-    return ('NEW', 'REOPENED', 'ASSIGNED', 'UNCONFIRMED');
-}
-
 ############# Live code below here (that is, not subroutine defs) #############
 
 use Bugzilla;
index 3ad1ad4b662685a5e7a553196e7e41966d03588b..7b96cb59ee25d3c4ee583e44196848c1af0e4a19 100755 (executable)
@@ -896,7 +896,7 @@ sub process_bug {
     my $valid_status = check_field('bug_status',  
                                   scalar $bug_fields{'bug_status'}, 
                                   \@::legal_bug_status, ERR_LEVEL );
-    my $is_open = IsOpenedState($bug_fields{'bug_status'}); 
+    my $is_open = is_open_state($bug_fields{'bug_status'}); 
     my $status = $bug_fields{'bug_status'} || undef;
     my $resolution = $bug_fields{'resolution'} || undef;
     
index 0e5ec94271e5351d80c49cbfc4f048b37ef23b8a..c2605afc2465b7d4c4b67f818482b135bb61bbbc 100755 (executable)
@@ -500,7 +500,7 @@ sub CheckCanChangeField {
     if ($field eq "canconfirm"
         || ($field eq "bug_status"
             && $oldvalue eq 'UNCONFIRMED'
-            && IsOpenedState($newvalue)))
+            && is_open_state($newvalue)))
     {
         $PrivilegesRequired = 3;
         return $UserInCanConfirmGroupSet;
@@ -785,7 +785,7 @@ sub ChangeStatus {
             # confirmed or not
             $::query .= "bug_status = CASE WHEN everconfirmed = 1 THEN " .
                          SqlQuote($str) . " ELSE 'UNCONFIRMED' END";
-        } elsif (IsOpenedState($str)) {
+        } elsif (is_open_state($str)) {
             # Note that we cannot combine this with the above branch - here we
             # need to check if bugs.bug_status is open, (since we don't want to
             # reopen closed bugs when reassigning), while above the whole point
@@ -811,7 +811,7 @@ sub ChangeStatus {
             # This also relies on the fact that confirming and accepting have
             # already called DoConfirm before this is called
 
-            my @open_state = map(SqlQuote($_), OpenStates());
+            my @open_state = map(SqlQuote($_), BUG_STATE_OPEN);
             my $open_state = join(", ", @open_state);
 
             # If we are changing everconfirmed to 1, we have to take this change
@@ -2040,7 +2040,7 @@ foreach my $id (@idlist) {
             }
 
             if ($col eq 'bug_status' 
-                && IsOpenedState($old) ne IsOpenedState($new))
+                && is_open_state($old) ne is_open_state($new))
             {
                 $check_dep_bugs = 1;
             }
index 9a80efd24c552fbdc65832a3524b1b10d6fb595c..7d2029bacbcdbcc7899ac12c2edd89c084b1ad99 100755 (executable)
@@ -737,7 +737,7 @@ BugCheck("bugs LEFT JOIN duplicates ON bugs.bug_id = duplicates.dupe WHERE " .
 
 Status("Checking statuses/resolutions");
 
-my @open_states = map(SqlQuote($_), OpenStates());
+my @open_states = map(SqlQuote($_), BUG_STATE_OPEN);
 my $open_states = join(', ', @open_states);
 
 BugCheck("bugs WHERE bug_status IN ($open_states) AND resolution != ''",
index e97af975bdee3914da5e7aa5d178058dca163c9e..ed87b6d90dce6b7ddc610d5379db69996712759c 100755 (executable)
@@ -188,7 +188,7 @@ foreach my $k (keys(%seen)) {
         push(@params, "shape=box");
     }
 
-    if (IsOpenedState($stat)) {
+    if (is_open_state($stat)) {
         push(@params, "color=green");
     }
 
index efc26a2b216a8218025145ca76e4c338aa60e175..1a1e51d3aa5ac216e4496ad495814a2d00a87b99 100755 (executable)
@@ -166,7 +166,7 @@ sub GetBug {
                   WHERE bugs.bug_id = ?", undef, $id);
      }
     
-    $bug->{'open'} = $bug->{'exists'} && IsOpenedState($bug->{'status'});
+    $bug->{'open'} = $bug->{'exists'} && is_open_state($bug->{'status'});
     $bug->{'dependencies'} = [];
     
     return $bug;
index f30eebe3cab417ce486914833912fd9dc2c8a53a..b7a53eca8e018a0dbcc5633bc66c5a22e71da5f4 100755 (executable)
--- a/votes.cgi
+++ b/votes.cgi
@@ -186,7 +186,7 @@ sub show_user {
             push (@bugs, { id => $id, 
                            summary => $summary,
                            count => $count,
-                           opened => IsOpenedState($status) });
+                           opened => is_open_state($status) });
         }
         
         # In case we didn't populate this earlier (i.e. an error, or