[freeside-commits] branch master updated. 55a734433fe1625cecca50f85c6da3cecf7c8618

Mark Wells mark at 420.am
Sat Mar 3 14:42:48 PST 2012


The branch, master has been updated
       via  55a734433fe1625cecca50f85c6da3cecf7c8618 (commit)
      from  712864e9372891cc3773d01e546103c23c10ff03 (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 55a734433fe1625cecca50f85c6da3cecf7c8618
Author: Mark Wells <mark at freeside.biz>
Date:   Sat Mar 3 14:42:40 2012 -0800

    option to validate MAC address in svc_hardware, #16266

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 4b2bc30..ac80a55 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -4402,6 +4402,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