summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2009-07-24 09:38:15 +0000
committerivan <ivan>2009-07-24 09:38:15 +0000
commitf0edb7c4423b58ad3659e0069f1f69b2e9b11021 (patch)
treecccaf5b18535db994879e70c77075a12ad2fb0b6
parent68f56930178c09ee08d2ab4045298d0cb1757ce8 (diff)
add handling of ChilliSpot (and CoovaChilli) Max attributes, specifically ChilliSpot-Max-{Input,Output,Total}-{Octets,Gigawords}, RT#5815
-rw-r--r--FS/FS/Conf.pm8
-rw-r--r--FS/FS/svc_acct.pm45
2 files changed, 53 insertions, 0 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 8ae926e6b..832322faf 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1664,6 +1664,14 @@ worry that config_items is freeside-specific and icky.
'select_enum' => [ 'Framed-IP-Address', 'Framed-Address' ],
},
+ #http://dev.coova.org/svn/coova-chilli/doc/dictionary.chillispot
+ {
+ 'key' => 'radius-chillispot-max',
+ 'section' => '',
+ 'description' => 'Enable ChilliSpot (and CoovaChilli) Max attributes, specifically ChilliSpot-Max-{Input,Output,Total}-{Octets,Gigawords}.',
+ 'type' => 'checkbox',
+ },
+
{
'key' => 'svc_acct-alldomains',
'section' => '',
diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm
index 4669588d5..6f61eae0e 100644
--- a/FS/FS/svc_acct.pm
+++ b/FS/FS/svc_acct.pm
@@ -15,6 +15,7 @@ use vars qw( @ISA $DEBUG $me $conf $skip_fuzzyfiles
$dirhash
@saltset @pw_set );
use Scalar::Util qw( blessed );
+use Math::BigInt;
use Carp;
use Fcntl qw(:flock);
use Date::Format;
@@ -1440,6 +1441,28 @@ sub radius_reply {
$reply{'Session-Timeout'} = $self->seconds;
}
+ if ( $conf->exists('radius-chillispot-max') ) {
+ #http://dev.coova.org/svn/coova-chilli/doc/dictionary.chillispot
+
+ #hmm. just because sqlradius.pm says so?
+ my %whatis = (
+ 'input' => 'up',
+ 'output' => 'down',
+ 'total' => 'total',
+ );
+
+ foreach my $what (qw( input output total )) {
+ my $is = $whatis{$what}.'bytes';
+ if ( $self->$is() =~ /\d/ ) {
+ my $big = new Math::BigInt $self->$is();
+ my $att = "Chillispot-Max-\u$what";
+ $reply{"$att-Octets"} = $big->copy->band(0xffffffff)->bstr;
+ $reply{"$att-Gigawords"} = $big->copy->brsft(32)->bstr;
+ }
+ }
+
+ }
+
%reply;
}
@@ -1772,6 +1795,16 @@ sub _op_usage {
die "Can't update $column for svcnum". $self->svcnum
if $rv == 0;
+ #$self->snapshot; #not necessary, we retain the old values
+ #create an object with the updated usage values
+ my $new = qsearchs('svc_acct', { 'svcnum' => $self->svcnum });
+ #call exports
+ my $error = $new->replace($self);
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "Error replacing: $error";
+ }
+
#overlimit_action eq 'cancel' handling
my $cust_pkg = $self->cust_svc->cust_pkg;
if ( $cust_pkg
@@ -1925,6 +1958,16 @@ sub set_usage {
if $rv == 0;
}
+ #$self->snapshot; #not necessary, we retain the old values
+ #create an object with the updated usage values
+ my $new = qsearchs('svc_acct', { 'svcnum' => $self->svcnum });
+ #call exports
+ my $error = $new->replace($self);
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "Error replacing: $error";
+ }
+
if ( $reset ) {
my $error;
@@ -2706,6 +2749,8 @@ probably live somewhere else...
insertion of RADIUS group stuff in insert could be done with child_objects now
(would probably clean up export of them too)
+_op_usage and set_usage bypass the history... maybe they shouldn't
+
=head1 SEE ALSO
L<FS::svc_Common>, edit/part_svc.cgi from an installed web interface,