diff options
-rw-r--r-- | Bugzilla/Series.pm | 24 | ||||
-rwxr-xr-x | checksetup.pl | 10 | ||||
-rwxr-xr-x | editcomponents.cgi | 8 | ||||
-rwxr-xr-x | editproducts.cgi | 9 | ||||
-rw-r--r-- | template/en/default/reports/create-chart.html.tmpl | 4 |
5 files changed, 24 insertions, 31 deletions
diff --git a/Bugzilla/Series.pm b/Bugzilla/Series.pm index bc11389c9..cb4d52c02 100644 --- a/Bugzilla/Series.pm +++ b/Bugzilla/Series.pm @@ -39,17 +39,22 @@ sub new { if ($#_ == 0) { if (ref($_[0])) { - # We've been given a CGI object + # We've been given a CGI object to create a new Series from. $self->readParametersFromCGI($_[0]); $self->createInDatabase(); } else { - # We've been given a series_id. + # We've been given a series_id, which should represent an existing + # Series. $self->initFromDatabase($_[0]); } } - elsif ($#_ >= 3) { - $self->initFromParameters(@_); + elsif ($#_ == 6) { + # We've been given a load of parameters to create a new Series from. + # We don't get given a series_id; we generate that for ourselves + # when we call createInDatabase(). So we pass -1 here. + $self->initFromParameters(-1, @_); + $self->createInDatabase(); } else { die("Bad parameters passed in - invalid number of args \($#_\)($_)"); @@ -77,7 +82,11 @@ sub initFromDatabase { "WHERE series.series_id = $series_id"); if (@series) { + # Note that we calculate $self->{'public'} ourselves instead of passing + # it as the last parameter in @series; this is because isSubscribed() + # requires the rest of the object to be set up correctly. $self->initFromParameters(@series); + $self->{'public'} = $self->isSubscribed(0); } else { &::ThrowCodeError("invalid_series_id", { 'series_id' => $series_id }); @@ -87,14 +96,9 @@ sub initFromDatabase { sub initFromParameters { my $self = shift; - # The first four parameters are compulsory, unless you immediately call - # createInDatabase(), in which case series_id can be left off. ($self->{'series_id'}, $self->{'category'}, $self->{'subcategory'}, $self->{'name'}, $self->{'creator'}, $self->{'frequency'}, - $self->{'query'}) = @_; - - $self->{'public'} = $self->isSubscribed(0); - $self->{'subscribed'} = $self->isSubscribed($::userid); + $self->{'query'}, $self->{'public'}) = @_; } sub createInDatabase { diff --git a/checksetup.pl b/checksetup.pl index 15d5231fb..da8715c4d 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -3713,10 +3713,9 @@ if (!$series_exists) { foreach my $field (@fields) { # Create a Series for each field in this product - my $series = new Bugzilla::Series(-1, $product, $all_name, + my $series = new Bugzilla::Series($product, $all_name, $field, $::userid, 1, - $queries{$field}); - $series->createInDatabase(); + $queries{$field}, 1); $seriesids{$field} = $series->{'series_id'}; } @@ -3724,10 +3723,9 @@ if (!$series_exists) { # the same set as new products (see editproducts.cgi.) my @openedstatuses = ("UNCONFIRMED", "NEW", "ASSIGNED", "REOPENED"); my $query = join("&", map { "bug_status=$_" } @openedstatuses); - my $series = new Bugzilla::Series(-1, $product, $all_name, + my $series = new Bugzilla::Series($product, $all_name, $open_name, $::userid, 1, - $query_prod . $query); - $series->createInDatabase(); + $query_prod . $query, 1); # Now, we attempt to read in historical data, if any # Convert the name in the same way that collectstats.pl does diff --git a/editcomponents.cgi b/editcomponents.cgi index 539da47a5..adf41ea1f 100755 --- a/editcomponents.cgi +++ b/editcomponents.cgi @@ -465,13 +465,9 @@ if ($action eq 'new') { push(@series, [$::FORM{'closed_name'}, $resolved . $prodcomp]); foreach my $sdata (@series) { - # We create the series with an nonsensical series_id, which is - # guaranteed not to exist. This is OK, because we immediately call - # createInDatabase(). - my $series = new Bugzilla::Series(-1, $product, $component, + my $series = new Bugzilla::Series($product, $component, $sdata->[0], $::userid, 1, - $sdata->[1]); - $series->createInDatabase(); + $sdata->[1], 1); } # Make versioncache flush diff --git a/editproducts.cgi b/editproducts.cgi index c36537c22..5cc10ddc2 100755 --- a/editproducts.cgi +++ b/editproducts.cgi @@ -426,14 +426,9 @@ if ($action eq 'new') { push(@series, [$::FORM{'open_name'}, $query]); foreach my $sdata (@series) { - # We create the series with an nonsensical series_id, which is - # guaranteed not to exist. This is OK, because we immediately call - # createInDatabase(). - my $series = new Bugzilla::Series(-1, $product, - $::FORM{'subcategory'}, + my $series = new Bugzilla::Series($product, $::FORM{'subcategory'}, $sdata->[0], $::userid, 1, - $sdata->[1] . "&product=$product"); - $series->createInDatabase(); + $sdata->[1] . "&product=$product", 1); } # Make versioncache flush diff --git a/template/en/default/reports/create-chart.html.tmpl b/template/en/default/reports/create-chart.html.tmpl index fe0b4a76c..441bd9b06 100644 --- a/template/en/default/reports/create-chart.html.tmpl +++ b/template/en/default/reports/create-chart.html.tmpl @@ -123,7 +123,7 @@ function subcatSelected() { <td> [% IF series.creator != 0 %] - [% IF series.subscribed %] + [% IF series.isSubscribed(user.id) %] <input type="submit" value="Unsubscribe" style="width: 12ex;" name="action-unsubscribe[% series.series_id %]"> [% ELSE %] @@ -134,7 +134,7 @@ function subcatSelected() { </td> <td align="center"> - [% IF user.userid == series.creator OR UserInGroup("admin") %] + [% IF user.id == series.creator OR UserInGroup("admin") %] <a href="chart.cgi?action=edit&series_id= [% series.series_id %]">Edit</a> [% END %] |