re-write RADIUS groups, RT13274
authorlevinse <levinse>
Wed, 29 Jun 2011 03:51:11 +0000 (03:51 +0000)
committerlevinse <levinse>
Wed, 29 Jun 2011 03:51:11 +0000 (03:51 +0000)
FS/FS/Upgrade.pm
FS/FS/part_svc.pm
httemplate/edit/svc_acct.cgi

index 787ee24..ca6036e 100644 (file)
@@ -193,6 +193,7 @@ sub upgrade_data {
 
     # migrate to radius_group and groupnum instead of groupname
     'radius_usergroup' => [],
+    'part_svc'         => [],
 
   ;
 
index c4881c7..d3fe3b6 100644 (file)
@@ -867,6 +867,26 @@ sub process_bulk_cust_svc {
 
 }
 
+sub _upgrade_data {  #class method
+  my ($class, %opts) = @_;
+
+  my @part_svc_column = qsearch('part_svc_column', { 'columnname' => 'usergroup' });
+  foreach my $col ( @part_svc_column ) {
+    next if $col->columnvalue =~ /^[\d,]+$/ || !$col->columnvalue;
+    my @groupnames = split(',',$col->columnvalue);
+    my @groupnums;
+    foreach my $groupname ( @groupnames ) {
+        my $g = qsearchs('radius_group', { 'groupname' => $groupname } )
+                    || die "invalid group ".$groupname;
+        push @groupnums, $g->groupnum;
+    }
+    $col->columnvalue(join(',',@groupnums));
+    my $error = $col->replace;
+    die $error if $error;
+  }
+
+}
+
 =head1 BUGS
 
 Delete is unimplemented.
index 995bf3b..1271237 100755 (executable)
@@ -308,7 +308,7 @@ function randomPass() {
 <TR>
   <TD ALIGN="right"><% mt('RADIUS groups') |h %></TD>
 % if ( $part_svc_usergroup->columnflag eq 'F' ) { 
-    <TD BGCOLOR="#eeeeee"><% join('<BR>', @groups) %></TD>
+    <TD BGCOLOR="#eeeeee"><% join('<BR>', @groupnames) %></TD>
 % } else { 
 %   my $radius_group_selected = '';
 %   if ( $svc_acct->svcnum ) {
@@ -449,8 +449,13 @@ unless ( $svcnum || $cgi->param('error') ) { #adding
 
 my $part_svc_usergroup = $part_svc->part_svc_column('usergroup');
 #fixed radius groups always override & display
+my @groupnames; # only used for display of Fixed RADIUS groups
 if ( $part_svc_usergroup->columnflag eq 'F' ) {
-  @groups = split(',', $part_svc_usergroup->columnvalue);
+  @groups = split(',',$part_svc_usergroup->columnvalue);
+  @groupnames = map { $_->description . " (" . $_->groupname . ")" } 
+                    qsearch({ 'table'         => 'radius_group',
+                           'extra_sql'     => "where groupnum in (".$part_svc_usergroup->columnvalue.")",
+                        });
 }
 
 my $action = $svcnum ? 'Edit' : 'Add';