[freeside-commits] branch FREESIDE_4_BRANCH updated. d20626460a7b547c88d06b30c6a279069ef3b17d

Mitch Jackson mitch at freeside.biz
Wed Nov 28 12:49:46 PST 2018


The branch, FREESIDE_4_BRANCH has been updated
       via  d20626460a7b547c88d06b30c6a279069ef3b17d (commit)
       via  c578460d221f455483cd1ca57eedf092dbeef75e (commit)
       via  11fbfa8202889e84c2dacaa5d0b0dc6c0960eb38 (commit)
       via  4267c47797189621effba74f0d83f29fadf3e259 (commit)
      from  9de321e11b1463bda7d8dc9cfa2c438c66687a4b (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 d20626460a7b547c88d06b30c6a279069ef3b17d
Author: Mitch Jackson <mitch at freeside.biz>
Date:   Wed Nov 28 15:32:14 2018 -0500

    RT# 76309 Fix typo

diff --git a/FS/FS/part_event/Action/notice_to.pm b/FS/FS/part_event/Action/notice_to.pm
index 98f5cd3c9..565d169b0 100644
--- a/FS/FS/part_event/Action/notice_to.pm
+++ b/FS/FS/part_event/Action/notice_to.pm
@@ -23,7 +23,7 @@ sub option_fields {
   (
     'to'     => { 'label'      => 'Destination',
                   'type'       => 'text',
-                  'size'       => 200,
+                  'size'       => 30,
                   'validation' => 'ut_email',
                 },
     'msgnum' => { 'label'    => 'Template',

commit c578460d221f455483cd1ca57eedf092dbeef75e
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 11fbfa8202889e84c2dacaa5d0b0dc6c0960eb38
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 4267c47797189621effba74f0d83f29fadf3e259
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 60e7ff7a9..dfe6f1871 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;
 
@@ -3360,6 +3361,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