From bfcc230e3bf4b8876816f20911a46505dea0f61a Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Fri, 22 Aug 2008 04:58:43 +0000 Subject: Bug 287334: Ability to add custom "Bug ID" fields Patch By Elliotte Martin r=mkanat, a=mkanat --- Bugzilla/Bug.pm | 9 +++++++++ Bugzilla/Constants.pm | 2 ++ Bugzilla/Field.pm | 3 ++- template/en/default/bug/field.html.tmpl | 24 ++++++++++++++++++++++++ template/en/default/global/field-descs.none.tmpl | 2 ++ 5 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index b367954e6..d82b6f6e6 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -150,6 +150,9 @@ sub VALIDATORS { elsif ($field->type == FIELD_TYPE_FREETEXT) { $validator = \&_check_freetext_field; } + elsif ($field->type == FIELD_TYPE_BUG_ID) { + $validator = \&_check_bugid_field; + } else { $validator = \&_check_default_field; } @@ -1643,6 +1646,12 @@ sub _check_select_field { return $value; } +sub _check_bugid_field { + my ($invocant, $value, $field) = @_; + return undef if !$value; + return $invocant->check($value, $field)->id; +} + ##################################################################### # Class Accessors ##################################################################### diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm index b0dd0b6f6..e06fee00c 100644 --- a/Bugzilla/Constants.pm +++ b/Bugzilla/Constants.pm @@ -121,6 +121,7 @@ use File::Basename; FIELD_TYPE_MULTI_SELECT FIELD_TYPE_TEXTAREA FIELD_TYPE_DATETIME + FIELD_TYPE_BUG_ID USAGE_MODE_BROWSER USAGE_MODE_CMDLINE @@ -348,6 +349,7 @@ use constant FIELD_TYPE_SINGLE_SELECT => 2; use constant FIELD_TYPE_MULTI_SELECT => 3; use constant FIELD_TYPE_TEXTAREA => 4; use constant FIELD_TYPE_DATETIME => 5; +use constant FIELD_TYPE_BUG_ID => 6; # The maximum number of days a token will remain valid. use constant MAX_TOKEN_AGE => 3; diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm index 0d7479034..4b801f13d 100644 --- a/Bugzilla/Field.pm +++ b/Bugzilla/Field.pm @@ -125,6 +125,7 @@ use constant SQL_DEFINITIONS => { DEFAULT => "'---'" }, FIELD_TYPE_TEXTAREA, { TYPE => 'MEDIUMTEXT' }, FIELD_TYPE_DATETIME, { TYPE => 'DATETIME' }, + FIELD_TYPE_BUG_ID, { TYPE => 'INT3' }, }; # Field definitions for the fields that ship with Bugzilla. @@ -253,7 +254,7 @@ sub _check_type { my $saved_type = $type; # The constant here should be updated every time a new, # higher field type is added. - (detaint_natural($type) && $type <= FIELD_TYPE_DATETIME) + (detaint_natural($type) && $type <= FIELD_TYPE_BUG_ID) || ThrowCodeError('invalid_customfield_type', { type => $saved_type }); return $type; } diff --git a/template/en/default/bug/field.html.tmpl b/template/en/default/bug/field.html.tmpl index 1ba0b1784..7720ea0f8 100644 --- a/template/en/default/bug/field.html.tmpl +++ b/template/en/default/bug/field.html.tmpl @@ -17,6 +17,7 @@ # # Contributor(s): Myk Melez # Max Kanat-Alexander + # Elliotte Martin #%] [%# INTERFACE: @@ -61,6 +62,25 @@ + [% CASE constants.FIELD_TYPE_BUG_ID %] + + + + + [% IF bug.${field.name} %] + [% bug.${field.name} FILTER bug_link(bug.${field.name}) FILTER none %] + [% END %] + + (edit) + + [% CASE [ constants.FIELD_TYPE_SINGLE_SELECT constants.FIELD_TYPE_MULTI_SELECT ] %]