summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2007-09-17 11:48:04 +0200
committermkanat%bugzilla.org <>2007-09-17 11:48:04 +0200
commit61ac61f0a55f8e07ee4eb6be325b7d53ca64e7fe (patch)
tree0431b21137267c9d25a2a8549718eae256b4104c /Bugzilla
parente2ced36948e4edd9ad6354cb183a92ef6aebee45 (diff)
downloadbugzilla-61ac61f0a55f8e07ee4eb6be325b7d53ca64e7fe.tar.gz
bugzilla-61ac61f0a55f8e07ee4eb6be325b7d53ca64e7fe.tar.xz
Bug 357315: Add the ability to create <textarea> fields
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=LpSolit
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Constants.pm2
-rw-r--r--Bugzilla/Field.pm3
-rw-r--r--Bugzilla/Template.pm6
-rw-r--r--Bugzilla/Util.pm5
4 files changed, 12 insertions, 4 deletions
diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm
index 4406d7415..27a1b0d77 100644
--- a/Bugzilla/Constants.pm
+++ b/Bugzilla/Constants.pm
@@ -120,6 +120,7 @@ use File::Basename;
FIELD_TYPE_FREETEXT
FIELD_TYPE_SINGLE_SELECT
FIELD_TYPE_MULTI_SELECT
+ FIELD_TYPE_TEXTAREA
USAGE_MODE_BROWSER
USAGE_MODE_CMDLINE
@@ -342,6 +343,7 @@ use constant FIELD_TYPE_UNKNOWN => 0;
use constant FIELD_TYPE_FREETEXT => 1;
use constant FIELD_TYPE_SINGLE_SELECT => 2;
use constant FIELD_TYPE_MULTI_SELECT => 3;
+use constant FIELD_TYPE_TEXTAREA => 4;
# 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 6555bba96..34a1818de 100644
--- a/Bugzilla/Field.pm
+++ b/Bugzilla/Field.pm
@@ -126,6 +126,7 @@ use constant SQL_DEFINITIONS => {
FIELD_TYPE_FREETEXT, { TYPE => 'varchar(255)' },
FIELD_TYPE_SINGLE_SELECT, { TYPE => 'varchar(64)', NOTNULL => 1,
DEFAULT => "'---'" },
+ FIELD_TYPE_TEXTAREA, { TYPE => 'MEDIUMTEXT' },
};
# Field definitions for the fields that ship with Bugzilla.
@@ -254,7 +255,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_MULTI_SELECT)
+ (detaint_natural($type) && $type <= FIELD_TYPE_TEXTAREA)
|| ThrowCodeError('invalid_customfield_type', { type => $saved_type });
return $type;
}
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index 386be82ea..c22502806 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -665,7 +665,11 @@ sub create {
},
# Wrap a displayed comment to the appropriate length
- wrap_comment => \&Bugzilla::Util::wrap_comment,
+ wrap_comment => [
+ sub {
+ my ($context, $cols) = @_;
+ return sub { wrap_comment($_[0], $cols) }
+ }, 1],
# We force filtering of every variable in key security-critical
# places; we have a none filter for people to use when they
diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm
index 87caa0527..e15edc6b5 100644
--- a/Bugzilla/Util.pm
+++ b/Bugzilla/Util.pm
@@ -312,11 +312,11 @@ sub diff_strings {
}
sub wrap_comment {
- my ($comment) = @_;
+ my ($comment, $cols) = @_;
my $wrappedcomment = "";
# Use 'local', as recommended by Text::Wrap's perldoc.
- local $Text::Wrap::columns = COMMENT_COLS;
+ local $Text::Wrap::columns = $cols || COMMENT_COLS;
# Make words that are longer than COMMENT_COLS not wrap.
local $Text::Wrap::huge = 'overflow';
# Don't mess with tabs.
@@ -332,6 +332,7 @@ sub wrap_comment {
}
}
+ chomp($wrappedcomment); # Text::Wrap adds an extra newline at the end.
return $wrappedcomment;
}