From f6c2d743d87f86cdc206ab4bc772639b4569eebe Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Fri, 2 Jan 2009 13:59:22 +0000 Subject: Bug 313126: Clean up editclassification.cgi and make it use Bugzilla::Classification methods - Patch by Frédéric Buclin r=wicked a=LpSolit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bugzilla/Classification.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'Bugzilla/Classification.pm') 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 @@ -54,6 +55,26 @@ use constant VALIDATORS => { sortkey => \&_check_sortkey, }; +############################### +#### 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; -- cgit v1.2.3-24-g4f1b