diff options
author | lpsolit%gmail.com <> | 2009-01-02 13:59:22 +0000 |
---|---|---|
committer | lpsolit%gmail.com <> | 2009-01-02 13:59:22 +0000 |
commit | f6c2d743d87f86cdc206ab4bc772639b4569eebe (patch) | |
tree | e4740db3fee1b4b67e30bcc0271696af1b4ab280 /Bugzilla/Classification.pm | |
parent | Bug 339381: Make Bugzilla::Classification use Bugzilla::Object - Patch by FrÃ... (diff) | |
download | bugzilla-f6c2d743d87f86cdc206ab4bc772639b4569eebe.tar.gz bugzilla-f6c2d743d87f86cdc206ab4bc772639b4569eebe.tar.bz2 bugzilla-f6c2d743d87f86cdc206ab4bc772639b4569eebe.zip |
Bug 313126: Clean up editclassification.cgi and make it use Bugzilla::Classification methods - Patch by Frédéric Buclin <LpSolit@gmail.com> r=wicked a=LpSolit
Diffstat (limited to 'Bugzilla/Classification.pm')
-rw-r--r-- | Bugzilla/Classification.pm | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Bugzilla/Classification.pm b/Bugzilla/Classification.pm index 2eb253aa7..7c362bc45 100644 --- a/Bugzilla/Classification.pm +++ b/Bugzilla/Classification.pm @@ -30,6 +30,7 @@ use base qw(Bugzilla::Object); ############################### use constant DB_TABLE => 'classifications'; +use constant LIST_ORDER => 'sortkey, name'; use constant DB_COLUMNS => qw( id @@ -55,6 +56,26 @@ use constant VALIDATORS => { }; ############################### +#### Constructors ##### +############################### +sub remove_from_db { + my $self = shift; + my $dbh = Bugzilla->dbh; + + ThrowUserError("classification_not_deletable") if ($self->id == 1); + + $dbh->bz_start_transaction(); + # Reclassify products to the default classification, if needed. + $dbh->do("UPDATE products SET classification_id = 1 + WHERE classification_id = ?", undef, $self->id); + + $dbh->do("DELETE FROM classifications WHERE id = ?", undef, $self->id); + + $dbh->bz_commit_transaction(); + +} + +############################### #### Validators #### ############################### @@ -93,6 +114,10 @@ sub _check_sortkey { #### Methods #### ############################### +sub set_name { $_[0]->set('name', $_[1]); } +sub set_description { $_[0]->set('description', $_[1]); } +sub set_sortkey { $_[0]->set('sortkey', $_[1]); } + sub product_count { my $self = shift; my $dbh = Bugzilla->dbh; |