hopefully ignore errors about deleted accounts and properly finish freeside-sqlradius...
authorivan <ivan>
Tue, 4 Aug 2009 23:43:48 +0000 (23:43 +0000)
committerivan <ivan>
Tue, 4 Aug 2009 23:43:48 +0000 (23:43 +0000)
FS/FS/svc_acct.pm
FS/bin/freeside-sqlradius-reset

index 6f61eae..294e327 100644 (file)
@@ -1496,11 +1496,15 @@ sub radius_check {
   $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;
index 5c77747..a77bad6 100755 (executable)
@@ -53,14 +53,25 @@ foreach my $export ( @exports ) {
 
   my @svc_x =
     map  { $_->svc_x }
-    map  { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) }
-    grep { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) }
+    #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
+    #$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'} }