From: mkanat%bugzilla.org <> Date: Wed, 19 Jul 2006 04:10:31 +0000 (+0000) Subject: Bug 344521: Make custom fields optionally functional on enter_bug.cgi X-Git-Tag: bugzilla-2.23.3~251 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f27aaa287562fb880934565d6a091ab1674bfab4;p=thirdparty%2Fbugzilla.git Bug 344521: Make custom fields optionally functional on enter_bug.cgi Patch By Max Kanat-Alexander r=LpSolit, a=myk --- diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm index c885987bc6..94e457dd09 100644 --- a/Bugzilla/DB/Schema.pm +++ b/Bugzilla/DB/Schema.pm @@ -464,6 +464,8 @@ use constant ABSTRACT_SCHEMA => { sortkey => {TYPE => 'INT2', NOTNULL => 1}, obsolete => {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'FALSE'}, + enter_bug => {TYPE => 'BOOLEAN', NOTNULL => 1, + DEFAULT => 'FALSE'}, ], INDEXES => [ fielddefs_name_idx => {FIELDS => ['name'], diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm index 2118d41aca..e964141d48 100644 --- a/Bugzilla/Field.pm +++ b/Bugzilla/Field.pm @@ -82,7 +82,8 @@ use constant DB_COLUMNS => ( 'description', 'type', 'custom', - 'obsolete' + 'obsolete', + 'enter_bug', ); our $columns = join(", ", DB_COLUMNS); @@ -182,6 +183,19 @@ a boolean specifying whether or not the field is obsolete; sub obsolete { return $_[0]->{obsolete} } +=over + +=item C + +A boolean specifying whether or not this field should appear on +enter_bug.cgi + +=back + +=cut + +sub enter_bug { return $_[0]->{enter_bug} } + =pod @@ -267,6 +281,9 @@ sub match { if (defined $criteria->{obsolete}) { push(@terms, "obsolete=" . ($criteria->{obsolete} ? "1" : "0")); } + if (defined $criteria->{enter_bug}) { + push(@terms, "enter_bug=" . ($criteria->{enter_bug} ? '1' : '0')); + } my $where = (scalar(@terms) > 0) ? "WHERE " . join(" AND ", @terms) : ""; my $records = Bugzilla->dbh->selectall_arrayref( diff --git a/checksetup.pl b/checksetup.pl index 71e43d281a..d6a76a0a01 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -4246,6 +4246,9 @@ if (!$dbh->bz_column_info('classifications', 'sortkey')) { } } +$dbh->bz_add_column('fielddefs', 'enter_bug', + {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'FALSE'}); + # If you had to change the --TABLE-- definition in any way, then add your # differential change code *** A B O V E *** this comment. # diff --git a/enter_bug.cgi b/enter_bug.cgi index 66f4109c73..70c989ecae 100755 --- a/enter_bug.cgi +++ b/enter_bug.cgi @@ -336,6 +336,13 @@ $vars->{'cloned_bug_id'} = $cloned_bug_id; $vars->{'token'} = Bugzilla::Token::IssueSessionToken('createbug:'); + +my @enter_bug_fields = Bugzilla->get_fields({ custom => 1, obsolete => 0, + enter_bug => 1 }); +foreach my $field (@enter_bug_fields) { + $vars->{$field->name} = formvalue($field->name); +} + if ($cloned_bug_id) { $default{'component_'} = $cloned_bug->{'component'}; @@ -357,6 +364,10 @@ if ($cloned_bug_id) { $vars->{'cc'} = formvalue('cc'); } + foreach my $field (@enter_bug_fields) { + $vars->{$field->name} = $cloned_bug->{$field->name}; + } + # We need to ensure that we respect the 'insider' status of # the first comment, if it has one. Either way, make a note # that this bug was cloned from another bug. diff --git a/post_bug.cgi b/post_bug.cgi index b3f668e3ff..083f577ac3 100755 --- a/post_bug.cgi +++ b/post_bug.cgi @@ -172,10 +172,15 @@ if (!UserInGroup("editbugs") || $cgi->param('assigned_to') eq "") { -value => login_to_id(trim($cgi->param('assigned_to')), THROW_ERROR)); } + +my @enter_bug_field_names = map {$_->name} Bugzilla->get_fields({ custom => 1, + obsolete => 0, enter_bug => 1}); + my @bug_fields = ("version", "rep_platform", "bug_severity", "priority", "op_sys", "assigned_to", "bug_status", "everconfirmed", "bug_file_loc", "short_desc", - "target_milestone", "status_whiteboard"); + "target_milestone", "status_whiteboard", + @enter_bug_field_names); if (Bugzilla->params->{"usebugaliases"}) { my $alias = trim($cgi->param('alias') || ""); diff --git a/template/en/default/bug/create/create.html.tmpl b/template/en/default/bug/create/create.html.tmpl index 1749813e37..8b2bcb9972 100644 --- a/template/en/default/bug/create/create.html.tmpl +++ b/template/en/default/bug/create/create.html.tmpl @@ -313,6 +313,15 @@ function handleWantsAttachment(wants_attachment) { + [% USE Bugzilla %] + [% FOREACH field = Bugzilla.get_fields({ obsolete => 0, custom => 1, + enter_bug => 1 }) %] + [% SET value = ${field.name} IF ${field.name}.defined %] + + [% PROCESS bug/field.html.tmpl editable=1 value_span=3 %] + + [% END %] + Summary: diff --git a/template/en/default/bug/field.html.tmpl b/template/en/default/bug/field.html.tmpl index 9c45b3e57e..ece2f64bfe 100644 --- a/template/en/default/bug/field.html.tmpl +++ b/template/en/default/bug/field.html.tmpl @@ -25,6 +25,8 @@ # value: The value of the field for this bug. # editable: Whether the field should be displayed as an editable # or as just the plain text of its value. + # value_span: A colspan for the table cell containing + # the field value. #%] @@ -41,6 +43,7 @@ [% CASE constants.FIELD_TYPE_FREETEXT %] [% END %] [% ELSE %]