diff options
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/cust_main_county.pm | 2 | ||||
-rw-r--r-- | FS/FS/svc_acct.pm | 60 | ||||
-rw-r--r-- | FS/MANIFEST | 4 | ||||
-rw-r--r-- | FS/t/radius_usergroup.t | 5 |
4 files changed, 69 insertions, 2 deletions
diff --git a/FS/FS/cust_main_county.pm b/FS/FS/cust_main_county.pm index 95ed53dab..56d29da94 100644 --- a/FS/FS/cust_main_county.pm +++ b/FS/FS/cust_main_county.pm @@ -227,7 +227,7 @@ END =head1 BUGS -regionseletor? putting web ui components in here? they should probably live +regionselector? putting web ui components in here? they should probably live somewhere else... =head1 SEE ALSO diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index 2305aeb80..9da5a6671 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -27,6 +27,7 @@ use FS::cust_main_invoice; use FS::svc_domain; use FS::raddb; use FS::queue; +use FS::radius_usergroup; @ISA = qw( FS::svc_Common ); @@ -1282,8 +1283,64 @@ sub seconds_since { $self->cust_svc->seconds_since(@_); } +=item radius_groups + +Returns all RADIUS groups for this account (see L<FS::radius_usergroup>). + +=cut + +sub radius_groups { + my $self = shift; + map { $_->groupname } + qsearch('radius_usergroup', { 'svcnum' => $self->svcnum } ); +} + =back +=head1 SUBROUTINES + +=item radius_usergroup_selector GROUPS_ARRAYREF + +=cut + +sub radius_usergroup_selector { + my $sel_groups = shift; + my %sel_groups = map { $_=>1 } @$sel_groups; + + my $selectname = shift || 'radius_usergroup'; + + my $dbh = dbh; + my $sth = $dbh->prepare( + 'SELECT DISTINCT(groupname) FROM radius_usergroup ORDER BY groupname' + ) or die $dbh->errstr; + $sth->execute() or die $sth->errstr; + my @all_groups = map { $_->[0] } @{$sth->fetchall_arrayref}; + + my $html = <<END; + <SCRIPT> + function ${selectname}_doadd(object) { + var myvalue = object.${selectname}_add.value; + var optionName = new Option(myvalue,myvalue,false,true); + var length = object.$selectname.length; + object.$selectname.options[length] = optionName; + } + </SCRIPT> + <SELECT MULTIPLE NAME="$selectname"> +END + + foreach my $group ( @all_groups ) { + $html .= '<OPTION'; + $html .= ' SELECTED' if $sel_groups{$group}; + $html .= ">$group</OPTION>\n"; + } + $html .= '</SELECT>'; + + $html .= qq!<BR><INPUT TYPE="text" NAME="${selectname}_add">!. + qq!<INPUT TYPE="button" VALUE="Add new group" onClick="${selectname}_doadd(this.form)">!; + + $html; +} + =head1 BUGS The $recref stuff in sub check should be cleaned up. @@ -1292,6 +1349,9 @@ The suspend, unsuspend and cancel methods update the database, but not the current object. This is probably a bug as it's unexpected and counterintuitive. +radius_usergroup_selector? putting web ui components in here? they should +probably live somewhere else... + =head1 SEE ALSO L<FS::svc_Common>, edit/part_svc.cgi from an installed web interface, diff --git a/FS/MANIFEST b/FS/MANIFEST index 19915cdc9..54aaaa19f 100644 --- a/FS/MANIFEST +++ b/FS/MANIFEST @@ -65,6 +65,7 @@ FS/prepay_credit.pm FS/svc_www.pm FS/svc_forward.pm FS/raddb.pm +FS/radius_usergroup.pm FS/queue.pm FS/queue_arg.pm t/agent.t @@ -72,6 +73,7 @@ t/agent_type.t t/CGI.t t/Conf.t t/ConfItem.t +t/Record.t t/cust_bill.t t/cust_bill_event.t t/cust_bill_pay.t @@ -100,7 +102,7 @@ t/part_svc_column.t t/pkg_svc.t t/port.t t/prepay_credit.t -t/Record.t +t/radius_usergroup.t t/session.t t/svc_acct.t t/svc_acct_pop.t diff --git a/FS/t/radius_usergroup.t b/FS/t/radius_usergroup.t new file mode 100644 index 000000000..325742cf5 --- /dev/null +++ b/FS/t/radius_usergroup.t @@ -0,0 +1,5 @@ +BEGIN { $| = 1; print "1..1\n" } +END {print "not ok 1\n" unless $loaded;} +use FS::radius_usergroup; +$loaded=1; +print "ok 1\n"; |