diff options
author | Mark Wells <mark@freeside.biz> | 2013-03-23 13:45:47 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2013-03-23 13:45:47 -0700 |
commit | 6bf3df8177a22d2275b1a68045ab5ff2e831af42 (patch) | |
tree | c7e183b0ef1a3159ae519b36a8350e91c95ab9ee /FS/FS | |
parent | c3d0d1fba9dfc9988f148cbf7bd07de33d5025d8 (diff) |
option to show both open and closed RADIUS sessions, #21483
Diffstat (limited to 'FS/FS')
-rw-r--r-- | FS/FS/part_export/sqlradius.pm | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/FS/FS/part_export/sqlradius.pm b/FS/FS/part_export/sqlradius.pm index 18ee30488..db66c39c0 100644 --- a/FS/FS/part_export/sqlradius.pm +++ b/FS/FS/part_export/sqlradius.pm @@ -597,7 +597,8 @@ New-style: pass a hashref with the following keys: =item stoptime_end - Upper bound for AcctStopTime, as a UNIX timestamp -=item open_sessions - Only show records with no AcctStopTime (typically used without stoptime_* options and with starttime_* options instead) +=item session_status - 'closed' to only show records with AcctStopTime, +'open' to only show records I<without> AcctStopTime, empty to show both. =item starttime_start - Lower bound for AcctStartTime, as a UNIX timestamp @@ -727,20 +728,23 @@ sub usage_sessions { push @where, " CalledStationID LIKE 'sip:$prefix\%'"; } - if ( $opt->{open_sessions} ) { - push @where, 'AcctStopTime IS NULL'; - } else { - + my $acctstoptime = ''; + if ( $opt->{session_status} ne 'open' ) { if ( $start ) { - push @where, "$str2time AcctStopTime ) >= ?"; + $acctstoptime .= "$str2time AcctStopTime ) >= ?"; push @param, $start; + $acctstoptime .= ' AND ' if $end; } if ( $end ) { - push @where, "$str2time AcctStopTime ) <= ?"; + $acctstoptime .= "$str2time AcctStopTime ) <= ?"; push @param, $end; } - } + if ( $opt->{session_status} ne 'closed' ) { + $acctstoptime = "( $acctstoptime ) OR " if $acctstoptime; + $acctstoptime .= 'AcctStopTime IS NULL'; + } + push @where, $acctstoptime; if ( $opt->{starttime_start} ) { push @where, "$str2time AcctStartTime ) >= ?"; |