X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fradiator.pm;h=f09d36abbb0405fca6f94c05a54965061ab11e54;hb=60c34bd328a404008313d4ab78d25152ebdb9226;hp=8f4a92911b5ad63ca79cbf08b29525a1fad38e65;hpb=7555ad2262d45d5bf92d0ac958d6e92296eb00e0;p=freeside.git
diff --git a/FS/FS/part_export/radiator.pm b/FS/FS/part_export/radiator.pm
index 8f4a92911..f09d36abb 100644
--- a/FS/FS/part_export/radiator.pm
+++ b/FS/FS/part_export/radiator.pm
@@ -1,6 +1,6 @@
package FS::part_export::radiator;
-use vars qw(@ISA %info);
+use vars qw(@ISA %info $radusers);
use Tie::IxHash;
use FS::part_export::sqlradius;
@@ -11,6 +11,8 @@ tie my %options, 'Tie::IxHash', %FS::part_export::sqlradius::options;
'desc' => 'Real-time export to RADIATOR',
'options' => \%options,
'nodomain' => '',
+ 'no_machine' => 1,
+ 'default_svc_class' => 'Internet',
'notes' => <<'END',
Real-time export of the radusers table to any SQL database in
Radiator-native format.
@@ -21,6 +23,8 @@ END
@ISA = qw(FS::part_export::sqlradius); #for regular sqlradius accounting
+$radusers = 'RADUSERS'; #MySQL is case sensitive about table names! huh
+
#sub export_username {
# my($self, $svc_acct) = (shift, shift);
# $svc_acct->email;
@@ -66,17 +70,34 @@ sub _radiator_hash {
my( $self, $svc_acct ) = @_;
my %hash = (
'username' => $self->export_username($svc_acct),
- 'pass_word' => $svc_acct->_password,
+ 'pass_word' => $svc_acct->crypt_password,
'fullname' => $svc_acct->finger,
map { my $method = "radius_$_"; $_ => $svc_acct->$method(); }
qw( framed_filter_id framed_mtu framed_netmask framed_protocol
framed_routing login_host login_service login_tcp_port )
);
- $hash{timeleft} = $svc_acct->seconds
+ $hash{'timeleft'} = $svc_acct->seconds
if $svc_acct->seconds =~ /^\d+$/;
- $hash{staticaddress} = $svc_acct->slipip
+ $hash{'staticaddress'} = $svc_acct->slipip
if $svc_acct->slipip =~ /^[\d\.]+$/; # and $self->slipip ne '0.0.0.0';
+ $hash{'servicename'} = ( $svc_acct->radius_groups )[0];
+
+ my $cust_pkg = $svc_acct->cust_svc->cust_pkg;
+ $hash{'validto'} = $cust_pkg->bill
+ if $cust_pkg && $cust_pkg->part_pkg->is_prepaid && $cust_pkg->bill;
+
+ #some other random stuff, should probably be attributes or virtual fields
+ #$hash{'state'} = 0; #only inserts
+ #$hash{'badlogins'} = 0; #only inserts
+ $hash{'maxlogins'} = 1;
+ $hash{'addeddate'} = $cust_pkg->setup
+ if $cust_pkg && $cust_pkg->setup;
+ $hash{'validfrom'} = $cust_pkg->last_bill || $cust_pkg->setup
+ if $cust_pkg && ( $cust_pkg->last_bill || $cust_pkg->setup );
+ $hash{'state'} = $cust_pkg->susp ? 1 : 0
+ if $cust_pkg;
+
%hash;
}
@@ -97,9 +118,11 @@ sub radiator_queue {
sub radiator_insert { #subroutine, not method
my $dbh = radiator_connect(shift, shift, shift);
my %hash = @_;
+ $hash{'state'} = 0; #see "random stuff" above
+ $hash{'badlogins'} = 0; #see "random stuff" above
my $sth = $dbh->prepare(
- 'INSERT INTO radusers ( '. join(', ', keys %hash ). ' ) '.
+ "INSERT INTO $radusers ( ". join(', ', keys %hash ). ' ) '.
'VALUES ( '. join(', ', map '?', keys %hash ). ' ) '
) or die $dbh->errstr;
$sth->execute( values %hash )
@@ -114,7 +137,7 @@ sub radiator_replace { #subroutine, not method
my ( $old_username, %hash ) = @_;
my $sth = $dbh->prepare(
- 'UPDATE radusers SET '. join(', ', map " $_ = ?", keys %hash ).
+ "UPDATE $radusers SET ". join(', ', map " $_ = ?", keys %hash ).
' WHERE username = ?'
) or die $dbh->errstr;
$sth->execute( values(%hash), $old_username )
@@ -128,7 +151,7 @@ sub radiator_delete { #subroutine, not method
my ( $username ) = @_;
my $sth = $dbh->prepare(
- 'DELETE FROM radusers WHERE username = ?'
+ "DELETE FROM $radusers WHERE username = ?"
) or die $dbh->errstr;
$sth->execute( $username )
or die $sth->errstr;