summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2009-08-04 23:49:33 +0000
committerivan <ivan>2009-08-04 23:49:33 +0000
commit136e8a1ac9cd533671844381a1754acbbd6a170b (patch)
tree62f496b8254639927c3d06da206d1f73327a5bcc
parent17956ae071c2a6fca1d677a81be7995248fcaef4 (diff)
hopefully ignore errors about deleted accounts and properly finish freeside-sqlradius-reset, RT#5868
-rw-r--r--FS/FS/svc_acct.pm14
-rwxr-xr-xFS/bin/freeside-sqlradius-reset48
2 files changed, 38 insertions, 24 deletions
diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm
index 37eaf4a15..8376d7bd0 100644
--- a/FS/FS/svc_acct.pm
+++ b/FS/FS/svc_acct.pm
@@ -1448,11 +1448,15 @@ sub radius_check {
my $pw_attrib = length($password) <= 12 ? $radius_password : 'Crypt-Password'; $check{$pw_attrib} = $password;
my $cust_svc = $self->cust_svc;
- die "FATAL: no cust_svc record for svc_acct.svcnum ". $self->svcnum. "\n"
- unless $cust_svc;
- my $cust_pkg = $cust_svc->cust_pkg;
- if ( $cust_pkg && $cust_pkg->part_pkg->is_prepaid && $cust_pkg->bill ) {
- $check{'Expiration'} = time2str('%B %e %Y %T', $cust_pkg->bill ); #http://lists.cistron.nl/pipermail/freeradius-users/2005-January/040184.html
+ if ( $cust_svc ) {
+ my $cust_pkg = $cust_svc->cust_pkg;
+ if ( $cust_pkg && $cust_pkg->part_pkg->is_prepaid && $cust_pkg->bill ) {
+ $check{'Expiration'} = time2str('%B %e %Y %T', $cust_pkg->bill ); #http://lists.cistron.nl/pipermail/freeradius-users/2005-January/040184.html
+ }
+ } else {
+ warn "WARNING: no cust_svc record for svc_acct.svcnum ". $self->svcnum.
+ "; can't set Expiration\n"
+ unless $cust_svc;
}
%check;
diff --git a/FS/bin/freeside-sqlradius-reset b/FS/bin/freeside-sqlradius-reset
index b97c9fd3c..424114907 100755
--- a/FS/bin/freeside-sqlradius-reset
+++ b/FS/bin/freeside-sqlradius-reset
@@ -6,7 +6,7 @@ use Getopt::Std;
use FS::UID qw(adminsuidsetup);
use FS::Record qw(qsearch qsearchs);
use FS::part_export;
-use FS::svc_acct;
+#use FS::svc_acct;
use FS::cust_svc;
getopts("n");
@@ -51,25 +51,36 @@ foreach my $export ( @exports ) {
#my @svcparts = map { $_->svcpart } $export->export_svc;
my $overlimit_groups = $export->option('overlimit_groups');
- my @svc_acct =
- map { qsearchs('svc_acct', { 'svcnum' => $_->svcnum } ) }
- map { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) }
- grep { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) }
- $export->export_svc;
-
- foreach my $svc_acct ( @svc_acct ) {
-
- $svc_acct->check; #set any fixed usergroup so it'll export even if all
- #svc_acct records don't have the group yet
-
- if ($overlimit_groups && $svc_acct->overlimit) {
- $svc_acct->usergroup( &{ $svc_acct->_fieldhandlers->{'usergroup'} }
- ($svc_acct, $overlimit_groups)
- );
+ my @svc_x =
+ map { $_->svc_x }
+ #map { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) }
+ #grep { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) }
+ # $export->export_svc;
+ map { @{ $_->[1] } }
+ grep { scalar( @{ $_->[1] } ) }
+ map { [ $_, [ qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) ] ] }
+ $export->export_svc;
+
+
+ foreach my $svc_x ( @svc_x ) {
+
+ #$svc_x->check; #set any fixed usergroup so it'll export even if all
+ # #svc_acct records don't have the group yet
+ #more efficient?
+ my $x = $svc_x->setfixed( $svc_x->_fieldhandlers);
+ unless ( ref($x) ) {
+ warn "WARNING: can't set fixed usergroups for svcnum ". $svc_x->svcnum.
+ "\n";
+ }
+
+ if ($overlimit_groups && $svc_x->overlimit) {
+ $svc_x->usergroup( &{ $svc_x->_fieldhandlers->{'usergroup'} }
+ ($svc_x, $overlimit_groups)
+ );
}
#false laziness with FS::svc_acct::insert (like it matters)
- my $error = $export->export_insert($svc_acct);
+ my $error = $export->export_insert($svc_x);
die $error if $error;
}
@@ -104,5 +115,4 @@ L<freeside-reexport>, L<FS::part_export>, L<FS::part_export::sqlradius>
=cut
-
-
+1;