diff options
author | ivan <ivan> | 2002-03-22 18:56:33 +0000 |
---|---|---|
committer | ivan <ivan> | 2002-03-22 18:56:33 +0000 |
commit | 20bb426a02c0ea54d8feaea7c5da51735ab70293 (patch) | |
tree | 28282f7c74f9f13ba831df23b26465d9b7b1b6e2 /FS/FS | |
parent | b159f42fa3f48cc2ca3b43773e7661e17d2fb072 (diff) |
RADIUS groups on the way!
Diffstat (limited to 'FS/FS')
-rw-r--r-- | FS/FS/cust_main_county.pm | 2 | ||||
-rw-r--r-- | FS/FS/svc_acct.pm | 60 |
2 files changed, 61 insertions, 1 deletions
diff --git a/FS/FS/cust_main_county.pm b/FS/FS/cust_main_county.pm index 95ed53d..56d29da 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 2305aeb..9da5a66 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, |