|
20 | 20 | use Bugzilla::Keyword;
|
21 | 21 | use Bugzilla::Config qw(:admin);
|
22 | 22 | use Bugzilla::User::Setting;
|
| 23 | +use Bugzilla::Status; |
23 | 24 |
|
24 | 25 | my $dbh = Bugzilla->dbh;
|
25 | 26 |
|
|
546 | 547 | }
|
547 | 548 | }
|
548 | 549 |
|
| 550 | +########################################################### |
| 551 | +# Create bug status |
| 552 | +########################################################### |
| 553 | + |
| 554 | +my @statuses = ( |
| 555 | + { |
| 556 | + value => undef, |
| 557 | + transitions => [['UNCONFIRMED', 0], ['NEW', 0], ['ASSIGNED', 0]], |
| 558 | + }, |
| 559 | + { |
| 560 | + value => 'UNCONFIRMED', |
| 561 | + sortkey => 100, |
| 562 | + isactive => 1, |
| 563 | + isopen => 1, |
| 564 | + transitions => [['NEW', 0], ['ASSIGNED', 0], ['RESOLVED', 0]], |
| 565 | + }, |
| 566 | + { |
| 567 | + value => 'NEW', |
| 568 | + sortkey => 200, |
| 569 | + isactive => 1, |
| 570 | + isopen => 1, |
| 571 | + transitions => [['UNCONFIRMED', 0], ['ASSIGNED', 0], ['RESOLVED', 0]], |
| 572 | + }, |
| 573 | + { |
| 574 | + value => 'ASSIGNED', |
| 575 | + sortkey => 300, |
| 576 | + isactive => 1, |
| 577 | + isopen => 1, |
| 578 | + transitions => [['UNCONFIRMED', 0], ['NEW', 0], ['RESOLVED', 0]], |
| 579 | + }, |
| 580 | + { |
| 581 | + value => 'REOPENED', |
| 582 | + sortkey => 400, |
| 583 | + isactive => 1, |
| 584 | + isopen => 1, |
| 585 | + transitions => [['UNCONFIRMED', 0], ['NEW', 0], ['ASSIGNED', 0], ['RESOLVED', 0]], |
| 586 | + }, |
| 587 | + { |
| 588 | + value => 'RESOLVED', |
| 589 | + sortkey => 500, |
| 590 | + isactive => 1, |
| 591 | + isopen => 0, |
| 592 | + transitions => [['UNCONFIRMED', 0], ['REOPENED', 0], ['VERIFIED', 0]], |
| 593 | + }, |
| 594 | + { |
| 595 | + value => 'VERIFIED', |
| 596 | + sortkey => 600, |
| 597 | + isactive => 1, |
| 598 | + isopen => 0, |
| 599 | + transitions => [['UNCONFIRMED', 0], ['REOPENED', 0], ['RESOLVED', 0]], |
| 600 | + }, |
| 601 | + { |
| 602 | + value => 'CLOSED', |
| 603 | + sortkey => 700, |
| 604 | + isactive => 1, |
| 605 | + isopen => 0, |
| 606 | + transitions => [['UNCONFIRMED', 0], ['REOPENED', 0], ['RESOLVED', 0]], |
| 607 | + }, |
| 608 | +); |
| 609 | + |
| 610 | +if (!$dbh->selectrow_array("SELECT 1 FROM bug_status WHERE value = 'ASSIGNED'")) { |
| 611 | + $dbh->do('DELETE FROM bug_status'); |
| 612 | + $dbh->do('DELETE FROM status_workflow'); |
| 613 | + |
| 614 | + print "creating status workflow...\n"; |
| 615 | + |
| 616 | + # One pass to add the status entries. |
| 617 | + foreach my $status (@statuses) { |
| 618 | + next if !$status->{value}; |
| 619 | + $dbh->do('INSERT INTO bug_status (value, sortkey, isactive, is_open) VALUES (?, ?, ?, ?)', |
| 620 | + undef, ( $status->{value}, $status->{sortkey}, $status->{isactive}, $status->{isopen} )); |
| 621 | + } |
| 622 | + |
| 623 | + # Another pass to add the transitions. |
| 624 | + foreach my $status (@statuses) { |
| 625 | + my $old_id; |
| 626 | + if ($status->{value}) { |
| 627 | + my $from_status = new Bugzilla::Status({ name => $status->{value} }); |
| 628 | + $old_id = $from_status->{id}; |
| 629 | + } else { |
| 630 | + $old_id = undef; |
| 631 | + } |
| 632 | + |
| 633 | + foreach my $transition (@{$status->{transitions}}) { |
| 634 | + my $to_status = new Bugzilla::Status({ name => $transition->[0] }); |
| 635 | + |
| 636 | + $dbh->do('INSERT INTO status_workflow (old_status, new_status, require_comment) VALUES (?, ?, ?)', |
| 637 | + undef, ( $old_id, $to_status->{id}, $transition->[1] )); |
| 638 | + } |
| 639 | + } |
| 640 | +} |
| 641 | + |
549 | 642 | ###########################################################
|
550 | 643 | # Create Keywords
|
551 | 644 | ###########################################################
|
|
0 commit comments