[freeside-commits] branch master updated. c740112fba28d2ad31e99f85eafcb722f3080ef9
Mitch Jackson
mitch at freeside.biz
Wed Nov 28 12:29:01 PST 2018
The branch, master has been updated
via c740112fba28d2ad31e99f85eafcb722f3080ef9 (commit)
via 05da91c115be0adae38533c4d16156250f6d2080 (commit)
via 940889971fcc8c9d4eb612e273acbb6ae0c562a2 (commit)
from 01bf59988d1e8617a422dcd564a87582ed75a7ed (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit c740112fba28d2ad31e99f85eafcb722f3080ef9
Author: Mitch Jackson <mitch at freeside.biz>
Date: Wed Nov 28 15:24:45 2018 -0500
RT# 76309 Validate E-Mail address on billing event action notice_to
diff --git a/FS/FS/part_event/Action/notice_to.pm b/FS/FS/part_event/Action/notice_to.pm
index dee293b70..98f5cd3c9 100644
--- a/FS/FS/part_event/Action/notice_to.pm
+++ b/FS/FS/part_event/Action/notice_to.pm
@@ -21,9 +21,10 @@ sub eventtable_hashref {
sub option_fields {
(
- 'to' => { 'label' => 'Destination',
- 'type' => 'text',
- 'size' => 30,
+ 'to' => { 'label' => 'Destination',
+ 'type' => 'text',
+ 'size' => 200,
+ 'validation' => 'ut_email',
},
'msgnum' => { 'label' => 'Template',
'type' => 'select-table',
commit 05da91c115be0adae38533c4d16156250f6d2080
Author: Mitch Jackson <mitch at freeside.biz>
Date: Wed Nov 28 15:20:48 2018 -0500
RT# 76309 Add validation for part_event_option.optionvalue
diff --git a/FS/FS/part_event/Action.pm b/FS/FS/part_event/Action.pm
index c0c70b1c3..1916e40a1 100644
--- a/FS/FS/part_event/Action.pm
+++ b/FS/FS/part_event/Action.pm
@@ -85,6 +85,8 @@ hashref with the following values:
=item size - Size for text fields
+=item validation - (optional) Validate optionvalue using the given object method, such as ut_textn, ut_email
+
=item options - For checkbox-multiple and select, a list reference of available option values.
=item option_labels - For select, a hash reference of availble option values and labels.
diff --git a/FS/FS/part_event_option.pm b/FS/FS/part_event_option.pm
index 6df9e84c1..1421f6f0f 100644
--- a/FS/FS/part_event_option.pm
+++ b/FS/FS/part_event_option.pm
@@ -183,11 +183,19 @@ sub check {
$self->ut_numbern('optionnum')
|| $self->ut_foreign_key('eventpart', 'part_event', 'eventpart' )
|| $self->ut_text('optionname')
- #|| $self->ut_textn('optionvalue')
|| $self->ut_anything('optionvalue') #http.pm content has \n
;
return $error if $error;
+ if ( my %option_fields = $self->option_fields ) {
+ if ( my $option_field = $option_fields{ $self->optionname } ) {
+ if ( my $validation_method = $option_field->{validation} ) {
+ $error = $self->$validation_method('optionvalue');
+ }
+ }
+ }
+ return $error if $error;
+
$self->SUPER::check;
}
@@ -203,6 +211,34 @@ sub insert_reason {
}
+=item part_event
+
+Return the associated part_event row
+
+=cut
+
+sub part_event {
+ qsearchs( part_event => { eventpart => shift->eventpart })
+}
+
+=item option_fields
+
+Return the option_fields from the associated part_event::action::$action
+
+=cut
+
+sub option_fields {
+ my $part_event = shift->part_event
+ or return;
+ my $action = $part_event->action
+ or return;
+
+ # For utility scripts, doesn't seem to be necessary
+ # eval "require FS::part_event::Action::$action;";
+
+ return "FS::part_event::Action::$action"->option_fields;
+}
+
=back
=head1 SEE ALSO
commit 940889971fcc8c9d4eb612e273acbb6ae0c562a2
Author: Mitch Jackson <mitch at freeside.biz>
Date: Wed Nov 28 15:16:32 2018 -0500
RT# 76309 E-Mail validation methods
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
index 9eb1c9aeb..b24b69e82 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -25,6 +25,7 @@ use FS::Schema qw(dbdef);
use FS::SearchCache;
use FS::Msgcat qw(gettext);
#use FS::Conf; #dependency loop bs, in install_callback below instead
+use Email::Valid;
use FS::part_virtual_field;
@@ -3364,6 +3365,36 @@ sub ut_agentnum_acl {
}
+
+=item ut_email COLUMN
+
+Check column contains a valid E-Mail address
+
+=cut
+
+sub ut_email {
+ my ( $self, $field ) = @_;
+ Email::Valid->address( $self->getfield( $field ) )
+ ? ''
+ : "Illegal (email) field $field: ". $self->getfield( $field );
+}
+
+=item ut_emailn COLUMN
+
+Check column contains a valid E-Mail address
+
+May be null
+
+=cut
+
+sub ut_emailn {
+ my ( $self, $field ) = @_;
+
+ $self->getfield( $field ) =~ /^$/
+ ? $self->getfield( $field, '' )
+ : $self->ut_email( $field );
+}
+
=item trim_whitespace FIELD[, FIELD ... ]
Strip leading and trailing spaces from the value in the named FIELD(s).
-----------------------------------------------------------------------
Summary of changes:
FS/FS/Record.pm | 31 +++++++++++++++++++++++++++++
FS/FS/part_event/Action.pm | 2 ++
FS/FS/part_event/Action/notice_to.pm | 7 ++++---
FS/FS/part_event_option.pm | 38 +++++++++++++++++++++++++++++++++++-
4 files changed, 74 insertions(+), 4 deletions(-)
More information about the freeside-commits
mailing list