[freeside-commits] branch FREESIDE_3_BRANCH updated. bcc11e8b99854452cdccd9406918c015bee784cb

Mitch Jackson mitch at freeside.biz
Wed Nov 28 12:59:55 PST 2018


The branch, FREESIDE_3_BRANCH has been updated
       via  bcc11e8b99854452cdccd9406918c015bee784cb (commit)
       via  6bfe5420178d7f92961275388b366aa9a15e0794 (commit)
       via  efd203c04eac2ccc6590d7908b8629afb8e1d7df (commit)
       via  a1cb420e2647d8b78d7169694145c2dd3b660448 (commit)
      from  3f36d52bbd1d5be4c9f81cc0b1ce96e22a217052 (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 bcc11e8b99854452cdccd9406918c015bee784cb
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 6bfe5420178d7f92961275388b366aa9a15e0794
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 efd203c04eac2ccc6590d7908b8629afb8e1d7df
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 a1cb420e2647d8b78d7169694145c2dd3b660448
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 fe8fad969..2bffdc377 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -28,6 +28,7 @@ use FS::Msgcat qw(gettext);
 use NetAddr::IP; # for validation
 use Data::Dumper;
 #use FS::Conf; #dependency loop bs, in install_callback below instead
+use Email::Valid;
 
 use FS::part_virtual_field;
 
@@ -3153,6 +3154,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