From 0e70cd46fe9377b9a267a8e1efbc6f8e7064e95e Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Sun, 20 Aug 2006 06:02:55 +0000 Subject: Bug 344875: Implement a UI to manage custom fields and remove customfield.pl - Patch by Frédéric Buclin r=mkanat a=myk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bugzilla/Field.pm | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) (limited to 'Bugzilla') diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm index c6c889957..cd510471d 100644 --- a/Bugzilla/Field.pm +++ b/Bugzilla/Field.pm @@ -93,6 +93,8 @@ use constant DB_COLUMNS => ( 'description', 'type', 'custom', + 'mailhead', + 'sortkey', 'obsolete', 'enter_bug', ); @@ -216,6 +218,31 @@ sub custom { return $_[0]->{custom} } =over +=item C + +a boolean specifying whether or not the field is displayed in bugmail +for newly-created bugs; + +=back + +=cut + +sub in_new_bugmail { return $_[0]->{mailhead} } + +=over + +=item C + +an integer specifying the sortkey of the field. + +=back + +=cut + +sub sortkey { return $_[0]->{sortkey} } + +=over + =item C a boolean specifying whether or not the field is obsolete; @@ -256,8 +283,14 @@ Params: This function takes named parameters in a hashref: C - string - The field label to display in the UI. C - boolean - Whether this field appears at the top of the bugmail for a newly-filed bug. + + The following parameters are only available on field creation: C - boolean - True if this is a Custom Field. The field will be added to the C table if it does not exist. + C - integer - The sortkey of the field. + C - boolean - Whether this field is + editable on the bug creation form. + C - boolean - Whether this field is obsolete. Returns: a C object. @@ -267,12 +300,16 @@ Returns: a C object. sub create_or_update { my ($params) = @_; - + my $custom = $params->{custom} ? 1 : 0; my $name = $params->{name}; my $in_new_bugmail = $params->{in_new_bugmail} ? 1 : 0; + my $sortkey = $params->{sortkey} || 0; + my $enter_bug = $params->{editable_on_enter_bug} ? 1 : 0; + my $is_obsolete = $params->{is_obsolete} ? 1 : 0; # Some day we'll allow invocants to specify the field type. + # We don't care about $params->{type} yet. my $type = $custom ? FIELD_TYPE_FREETEXT : FIELD_TYPE_UNKNOWN; my $field = new Bugzilla::Field({name => $name}); @@ -285,16 +322,15 @@ sub create_or_update { undef, $params->{desc}, $in_new_bugmail, $field->id); } else { - # Some day we'll allow invocants to specify the sort key. - my ($sortkey) = $dbh->selectrow_array( + $sortkey ||= $dbh->selectrow_array( "SELECT MAX(sortkey) + 100 FROM fielddefs") || 100; # Add the field to the list of fields at this Bugzilla installation. $dbh->do("INSERT INTO fielddefs (name, description, sortkey, type, - custom, mailhead) - VALUES (?, ?, ?, ?, ?, ?)", undef, + custom, mailhead, obsolete, enter_bug) + VALUES (?, ?, ?, ?, ?, ?, ?, ?)", undef, $name, $params->{desc}, $sortkey, $type, $custom, - $in_new_bugmail); + $in_new_bugmail, $is_obsolete, $enter_bug); } if (!$dbh->bz_column_info('bugs', $name) && $custom) { -- cgit v1.2.3-24-g4f1b