[freeside-commits] freeside/FS/FS svc_acct.pm, 1.316, 1.317 radius_group.pm, 1.1, 1.2 part_export.pm, 1.107, 1.108 Upgrade.pm, 1.50, 1.51 Conf.pm, 1.464, 1.465

Erik Levinson levinse at wavetail.420.am
Thu Jun 30 23:54:05 PDT 2011


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv21974/FS/FS

Modified Files:
	svc_acct.pm radius_group.pm part_export.pm Upgrade.pm Conf.pm 
Log Message:
RADIUS group enhancements, overlimit_groups changes, etc. RT13432

Index: part_export.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_export.pm,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -w -d -r1.107 -r1.108
--- part_export.pm	13 Jun 2011 21:07:49 -0000	1.107
+++ part_export.pm	1 Jul 2011 06:54:02 -0000	1.108
@@ -431,6 +431,34 @@
   my $r = { map { %{$exports{$_}} } keys %exports };
 }
 
+
+sub _upgrade_data {  #class method
+  my ($class, %opts) = @_;
+
+  my @part_export_option = qsearch('part_export_option', { 'optionname' => 'overlimit_groups' });
+  foreach my $opt ( @part_export_option ) {
+    next if $opt->optionvalue =~ /^[\d\s]+$/ || !$opt->optionvalue;
+    my @groupnames = split(' ',$opt->optionvalue);
+    my @groupnums;
+    my $error = '';
+    foreach my $groupname ( @groupnames ) {
+        my $g = qsearchs('radius_group', { 'groupname' => $groupname } );
+        unless ( $g ) {
+            $g = new FS::radius_group {
+                            'groupname' => $groupname,
+                            'description' => $groupname,
+                            };
+            $error = $g->insert;
+            die $error if $error;
+        }
+        push @groupnums, $g->groupnum;
+    }
+    $opt->optionvalue(join(' ', at groupnums));
+    $error = $opt->replace;
+    die $error if $error;
+  }
+}
+
 #=item exporttype2svcdb EXPORTTYPE
 #
 #Returns the applicable I<svcdb> for an I<exporttype>.

Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.464
retrieving revision 1.465
diff -u -w -d -r1.464 -r1.465
--- Conf.pm	27 Jun 2011 07:10:59 -0000	1.464
+++ Conf.pm	1 Jul 2011 06:54:02 -0000	1.465
@@ -2856,8 +2856,21 @@
     'key'         => 'overlimit_groups',
     'section'     => '',
     'description' => 'RADIUS group (or comma-separated groups) to assign to svc_acct which has exceeded its bandwidth or time limit.',
-    'type'        => 'text',
+    'type'        => 'select-sub',
     'per_agent'   => 1,
+    'multiple'    => 1,
+    'options_sub' => sub { require FS::Record;
+                           require FS::radius_group;
+			   map { $_->groupnum => $_->long_description }
+                               FS::Record::qsearch('radius_group', {} );
+			 },
+    'option_sub'  => sub { require FS::Record;
+                           require FS::radius_group;
+			   my $radius_group = FS::Record::qsearchs(
+			     'radius_group', { 'groupnum' => shift }
+			   );
+               $radius_group ? $radius_group->long_description : '';
+			 },
   },
 
   {

Index: svc_acct.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_acct.pm,v
retrieving revision 1.316
retrieving revision 1.317
diff -u -w -d -r1.316 -r1.317
--- svc_acct.pm	24 Jun 2011 02:48:44 -0000	1.316
+++ svc_acct.pm	1 Jul 2011 06:54:02 -0000	1.317
@@ -2227,20 +2227,19 @@
 
   my $cust_pkg = $self->cust_svc->cust_pkg;
 
-  my $conf_overlimit =
+  my @conf_overlimit =
     $cust_pkg
       ? $conf->config('overlimit_groups', $cust_pkg->cust_main->agentnum )
       : $conf->config('overlimit_groups');
 
   foreach my $part_export ( $self->cust_svc->part_svc->part_export ) {
 
-    my $groups = $conf_overlimit || $part_export->option('overlimit_groups');
-    next unless $groups;
-
-    my $gref = &{ $self->_fieldhandlers->{'usergroup'} }( $self, $groups );
+    my @groups = scalar(@conf_overlimit) ? @conf_overlimit
+                                         : split(' ',$part_export->option('overlimit_groups'));
+    next unless scalar(@groups);
 
     my $other = new FS::svc_acct $self->hashref;
-    $other->usergroup( $gref );
+    $other->usergroup(\@groups);
 
     my($new,$old);
     if ($action eq 'suspend') {

Index: Upgrade.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Upgrade.pm,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -w -d -r1.50 -r1.51
--- Upgrade.pm	29 Jun 2011 03:51:11 -0000	1.50
+++ Upgrade.pm	1 Jul 2011 06:54:02 -0000	1.51
@@ -6,7 +6,7 @@
 use Tie::IxHash;
 use FS::UID qw( dbh driver_name );
 use FS::Conf;
-use FS::Record qw(qsearchs str2time_sql);
+use FS::Record qw(qsearchs qsearch str2time_sql);
 
 use FS::svc_domain;
 $FS::svc_domain::whois_hack = 1;
@@ -47,6 +47,35 @@
     if $conf->exists('payment_receipt_email')
     || $conf->config('payment_receipt_msgnum');
 
+  upgrade_overlimit_groups($conf);
+  map { upgrade_overlimit_groups($conf,$_->agentnum) } qsearch('agent', {});
+  
+}
+
+sub upgrade_overlimit_groups {
+    my $conf = shift;
+    my $agentnum = shift;
+    my @groups = $conf->config('overlimit_groups',$agentnum); 
+    if(scalar(@groups)) {
+        my $groups = join(',', at groups);
+        my @groupnums;
+        my $error = '';
+        if ( $groups !~ /^[\d,]+$/ ) {
+            foreach my $groupname ( @groups ) {
+                my $g = qsearchs('radius_group', { 'groupname' => $groupname } );
+                unless ( $g ) {
+                    $g = new FS::radius_group {
+                                    'groupname' => $groupname,
+                                    'description' => $groupname,
+                                    };
+                    $error = $g->insert;
+                    die $error if $error;
+                }
+                push @groupnums, $g->groupnum;
+            }
+            $conf->set('overlimit_groups',join("\n", at groupnums),$agentnum);
+        }
+    }
 }
 
 =item upgrade
@@ -194,6 +223,7 @@
     # migrate to radius_group and groupnum instead of groupname
     'radius_usergroup' => [],
     'part_svc'         => [],
+    'part_export'      => [],
 
   ;
 

Index: radius_group.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/radius_group.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- radius_group.pm	21 Jun 2011 01:04:55 -0000	1.1
+++ radius_group.pm	1 Jul 2011 06:54:02 -0000	1.2
@@ -112,6 +112,19 @@
   $self->SUPER::check;
 }
 
+=item long_description
+
+Returns a description for this group consisting of its description field, 
+if any, and the RADIUS group name.
+
+=cut
+
+sub long_description {
+    my $self = shift;
+    $self->description ? $self->description . " (". $self->groupname . ")"
+                       : $self->groupname;
+}
+
 =back
 
 =head1 BUGS



More information about the freeside-commits mailing list