[freeside-commits] branch FREESIDE_2_3_BRANCH updated. 4e81a1e1637f95035af0e529370b4fbaf2f09d7d

Mark Wells mark at 420.am
Sat Mar 3 14:43:35 PST 2012


The branch, FREESIDE_2_3_BRANCH has been updated
       via  4e81a1e1637f95035af0e529370b4fbaf2f09d7d (commit)
      from  9361f0ce12ed45884005d5da86aaf64551c7502d (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 4e81a1e1637f95035af0e529370b4fbaf2f09d7d
Author: Mark Wells <mark at freeside.biz>
Date:   Sat Mar 3 14:43:30 2012 -0800

    option to validate MAC address in svc_hardware, #16266

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 29e3111..4593890 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -4407,6 +4407,13 @@ and customer address. Include units.',
   },
 
   {
+    'key'         => 'svc_hardware-check_mac_addr',
+    'section'     => '', #?
+    'description' => 'Require the "hardware address" field in hardware services to be a valid MAC address.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'tax-report_groups',
     'section'     => '',
     'description' => 'List of grouping possibilities for tax names on reports, one per line, "label op value" (op can be = or !=).',
diff --git a/FS/FS/svc_hardware.pm b/FS/FS/svc_hardware.pm
index 4970b3e..b4eb8cc 100644
--- a/FS/FS/svc_hardware.pm
+++ b/FS/FS/svc_hardware.pm
@@ -154,19 +154,25 @@ and replace methods.
 
 sub check {
   my $self = shift;
+  my $conf = FS::Conf->new;
 
   my $x = $self->setfixed;
   return $x unless ref $x;
 
   my $hw_addr = $self->getfield('hw_addr');
   $hw_addr = join('', split(/\W/, $hw_addr));
+  if ( $conf->exists('svc_hardware-check_mac_addr') ) {
+    $hw_addr = uc($hw_addr);
+    $hw_addr =~ /^[0-9A-F]{12}$/ 
+      or return "Illegal (MAC address) ".$self->getfield('hw_addr');
+  }
   $self->setfield('hw_addr', $hw_addr);
 
   my $error = 
     $self->ut_numbern('svcnum')
     || $self->ut_foreign_key('typenum', 'hardware_type', 'typenum')
     || $self->ut_ip46n('ip_addr')
-    || $self->ut_hexn('hw_addr')
+    || $self->ut_alphan('hw_addr')
     || $self->ut_alphan('serial')
     || $self->ut_alphan('smartcard')
     || $self->ut_foreign_keyn('statusnum', 'hardware_status', 'statusnum')

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Conf.pm         |    7 +++++++
 FS/FS/svc_hardware.pm |    8 +++++++-
 2 files changed, 14 insertions(+), 1 deletions(-)




More information about the freeside-commits mailing list