X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fbroadband_nas.pm;h=d52ccae88c7bb8ae8b842be9069513945a648667;hb=ffa18709ee8a4d05e18d2d406cf73afe79e52524;hp=5a8ffac3bc2915e09046b36ee203c22f5a0b5d7c;hpb=aa38c070977cf63365a4d26a3e4a7e5049ad70d0;p=freeside.git diff --git a/FS/FS/part_export/broadband_nas.pm b/FS/FS/part_export/broadband_nas.pm index 5a8ffac3b..d52ccae88 100644 --- a/FS/FS/part_export/broadband_nas.pm +++ b/FS/FS/part_export/broadband_nas.pm @@ -50,6 +50,11 @@ FS::UID->install_callback( address and description of the broadband service. This can be used with 'sqlradius' or 'broadband_sqlradius' exports to maintain entries in the client table on a RADIUS server.

+

The checkboxes at the bottom of this page correspond to RADIUS server +databases that Freeside knows about (i.e. 'sqlradius' or 'broadband_sqlradius' +exports that you have configured). Check the box for each server that you +want the NAS entries to be exported to. Do not create multiple broadband_nas +exports for the same service definition; this will fail.

Most broadband configurations should not use this, even if they use RADIUS for access control.

END @@ -64,27 +69,41 @@ will be applied to the attached NAS record. =cut -sub export_insert { +sub _export_insert { my $self = shift; my $svc_broadband = shift; - my %hash = map { $_ => $svc_broadband->get($_) } FS::nas->fields; - my $nas = $self->default_nas( - %hash, + my %hash = ( 'nasname' => $svc_broadband->ip_addr, 'description' => $svc_broadband->description, 'svcnum' => $svc_broadband->svcnum, ); - - my $error = - $nas->insert() - || $nas->process_m2m('link_table' => 'export_nas', - 'target_table' => 'part_export', - 'params' => { $self->options }); + foreach (FS::nas->fields) { + if ( length($svc_broadband->get($_)) ) { + $hash{$_} = $svc_broadband->get($_); + } + } + # if there's somehow a completely identical NAS in the table already, + # use that one. + my $nas = qsearchs('nas', \%hash); + my $error; + if ($nas) { + # propagate the export message + foreach my $part_export ($nas->part_export) { + $error = $part_export->export_nas_insert($nas); + die $error if $error; + } + } else { + $nas = $self->default_nas( %hash ); + $error = $nas->insert || + $nas->process_m2m('link_table' => 'export_nas', + 'target_table' => 'part_export', + 'params' => { $self->options }); + } die $error if $error; return; } -sub export_delete { +sub _export_delete { my $self = shift; my $svc_broadband = shift; my $svcnum = $svc_broadband->svcnum; @@ -99,7 +118,7 @@ sub export_delete { return; } -sub export_replace { +sub _export_replace { my $self = shift; my ($new_svc, $old_svc) = (shift, shift);