[freeside-commits] freeside/FS/FS Schema.pm, 1.317.2.9, 1.317.2.10 dsl_device.pm, NONE, 1.1.2.1 svc_dsl.pm, 1.10.2.1, 1.10.2.2 ClientAPI_XMLRPC.pm, 1.5.2.3, 1.5.2.4 Record.pm, 1.226.2.2, 1.226.2.3

Ivan,,, ivan at wavetail.420.am
Thu Oct 6 00:00:09 PDT 2011


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv12192/FS/FS

Modified Files:
      Tag: FREESIDE_2_3_BRANCH
	Schema.pm svc_dsl.pm ClientAPI_XMLRPC.pm Record.pm 
Added Files:
      Tag: FREESIDE_2_3_BRANCH
	dsl_device.pm 
Log Message:
add dsl_device to track mac addresses, RT#13656

--- NEW FILE: dsl_device.pm ---
package FS::dsl_device;

use strict;
use base qw( FS::Record );
use FS::Record qw( qsearch qsearchs );
use FS::svc_dsl;

=head1 NAME

FS::dsl_device - Object methods for dsl_device records

=head1 SYNOPSIS

  use FS::dsl_device;

  $record = new FS::dsl_device \%hash;
  $record = new FS::dsl_device { 'column' => 'value' };

  $error = $record->insert;

  $error = $new_record->replace($old_record);

  $error = $record->delete;

  $error = $record->check;

=head1 DESCRIPTION

An FS::dsl_device object represents a specific customer MAC address.  The 
following fields are currently supported:

=over 4

=item devicenum

primary key

=item svcnum

svcnum

=item mac_addr

mac_addr


=back

=head1 METHODS

=over 4

=item new HASHREF

Creates a new device.  To add the device to the database, see L<"insert">.

Note that this stores the hash reference, not a distinct copy of the hash it
points to.  You can ask the object for a copy with the I<hash> method.

=cut

# the new method can be inherited from FS::Record, if a table method is defined

sub table { 'dsl_device'; }

=item insert

Adds this record to the database.  If there is an error, returns the error,
otherwise returns false.

=cut

# the insert method can be inherited from FS::Record

=item delete

Delete this record from the database.

=cut

# the delete method can be inherited from FS::Record

=item replace OLD_RECORD

Replaces the OLD_RECORD with this one in the database.  If there is an error,
returns the error, otherwise returns false.

=cut

# the replace method can be inherited from FS::Record

=item check

Checks all fields to make sure this is a valid device.  If there is
an error, returns the error, otherwise returns false.  Called by the insert
and replace methods.

=cut

# the check method should currently be supplied - FS::Record contains some
# data checking routines

sub check {
  my $self = shift;

  my $error = 
    $self->ut_numbern('devicenum')
    || $self->ut_foreign_key('svcnum', 'svc_dsl', 'svcnum' )
    || $self->ut_mac_addrn('mac_addr')
  ;
  return $error if $error;

  $self->SUPER::check;
}

=item svc_dsl

Returns the phone number (see L<FS::svc_dsl>) associated with this customer
device.

=cut

sub svc_phone {
  my $self = shift;
  qsearchs( 'svc_dsl', { 'svcnum' => $self->svcnum } );
}

=back

=head1 BUGS

=head1 SEE ALSO

L<FS::Record>, schema.html from the base documentation.

=cut

1;


Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.317.2.9
retrieving revision 1.317.2.10
diff -u -w -d -r1.317.2.9 -r1.317.2.10
--- Schema.pm	27 Sep 2011 23:01:33 -0000	1.317.2.9
+++ Schema.pm	6 Oct 2011 07:00:06 -0000	1.317.2.10
@@ -2024,6 +2024,19 @@
       'index' => [ ['phonenum'], ['vendor_order_id'] ],
     },
     
+    'dsl_device' => {
+      'columns' => [
+        'devicenum', 'serial',     '', '', '', '',
+        #part_device?  or our own part_dsl_device?
+        #'devicepart',   'int',     '', '', '', '',
+        'svcnum',       'int',     '', '', '', '', 
+        'mac_addr', 'varchar',     '', 12, '', '', 
+      ],
+      'primary_key' => 'devicenum',
+      'unique' => [ [ 'mac_addr' ], ],
+      'index'  => [ [ 'svcnum' ], ], # [ 'devicepart' ] ],
+    },
+    
     'dsl_note' => {
       'columns' => [
         'notenum',           'serial',    '',        '', '', '',

Index: svc_dsl.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_dsl.pm,v
retrieving revision 1.10.2.1
retrieving revision 1.10.2.2
diff -u -w -d -r1.10.2.1 -r1.10.2.2
--- svc_dsl.pm	22 Sep 2011 21:42:16 -0000	1.10.2.1
+++ svc_dsl.pm	6 Oct 2011 07:00:07 -0000	1.10.2.2
@@ -4,6 +4,7 @@
 use vars qw( @ISA $conf $DEBUG $me );
 use FS::Record qw( qsearch qsearchs );
 use FS::svc_Common;
+use FS::dsl_device;
 use FS::dsl_note;
 use FS::qual;
 
@@ -273,6 +274,18 @@
   $self->SUPER::check;
 }
 
+=item dsl_device
+
+Returns the MAC addresses associated with this DSL service, as FS::dsl_device
+objects.
+
+=cut
+
+sub dsl_device {
+  my $self = shift;
+  qsearch('dsl_device', { 'svcnum' => $self->svcnum });
+}
+
 sub predelete_hook_first {
     my $self = shift;
     my @exports = $self->part_svc->part_export_dsl_pull;

Index: ClientAPI_XMLRPC.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/ClientAPI_XMLRPC.pm,v
retrieving revision 1.5.2.3
retrieving revision 1.5.2.4
diff -u -w -d -r1.5.2.3 -r1.5.2.4
--- ClientAPI_XMLRPC.pm	28 Sep 2011 01:02:26 -0000	1.5.2.3
+++ ClientAPI_XMLRPC.pm	6 Oct 2011 07:00:07 -0000	1.5.2.4
@@ -87,6 +87,9 @@
   'list_pkgs'                 => 'MyAccount/list_pkgs',     #add to ss (added?)
   'list_svcs'                 => 'MyAccount/list_svcs',     #add to ss (added?)
   'list_svc_usage'            => 'MyAccount/list_svc_usage',   
+  'list_dsl_devices'          => 'MyAccount/list_dsl_devices',   
+  'add_dsl_device'            => 'MyAccount/add_dsl_device',   
+  'delete_dsl_device'         => 'MyAccount/delete_dsl_device',   
   'port_graph'                => 'MyAccount/port_graph',   
   'list_cdr_usage'            => 'MyAccount/list_cdr_usage',   
   'list_support_usage'        => 'MyAccount/list_support_usage',   

Index: Record.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Record.pm,v
retrieving revision 1.226.2.2
retrieving revision 1.226.2.3
diff -u -w -d -r1.226.2.2 -r1.226.2.3
--- Record.pm	29 Sep 2011 05:53:55 -0000	1.226.2.2
+++ Record.pm	6 Oct 2011 07:00:07 -0000	1.226.2.3
@@ -2385,6 +2385,42 @@
   $self->setfield($field, uc($1));
   '';
 }
+
+=item ut_mac_addr COLUMN
+
+Check/untaint mac addresses.  May be null.
+
+=cut
+
+sub ut_mac_addr {
+  my($self, $field) = @_;
+
+  my $mac = $self->get($field);
+  $mac =~ s/\s+//g;
+  $mac =~ s/://g;
+  $self->set($field, $mac);
+
+  my $e = $self->ut_hex($field);
+  return $e if $e;
+
+  return "Illegal (mac address) $field: ". $self->getfield($field)
+    unless length($self->getfield($field)) == 12;
+
+  '';
+
+}
+
+=item ut_mac_addrn COLUMN
+
+Check/untaint mac addresses.  May be null.
+
+=cut
+
+sub ut_mac_addrn {
+  my($self, $field) = @_;
+  ($self->getfield($field) eq '') ? '' : $self->ut_mac_addr($field);
+}
+
 =item ut_ip COLUMN
 
 Check/untaint ip addresses.  IPv4 only for now, though ::1 is auto-translated



More information about the freeside-commits mailing list