From: ivan Date: Fri, 22 Mar 2002 18:56:33 +0000 (+0000) Subject: RADIUS groups on the way! X-Git-Tag: freeside_1_4_0_pre12~135 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=20bb426a02c0ea54d8feaea7c5da51735ab70293 RADIUS groups on the way! --- 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). + +=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 = < + 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; + } + + !. + qq!!; + + $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, 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"; diff --git a/Makefile b/Makefile index 8f577c579..21aeb4566 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,8 @@ DATASOURCE = DBI:Pg:host=localhost;dbname=freeside DB_USER = freeside DB_PASSWORD= -TEMPLATE = asp -#TEMPLATE = mason +#TEMPLATE = asp +TEMPLATE = mason ASP_GLOBAL = /usr/local/etc/freeside/asp-global diff --git a/README.1.4.0pre12 b/README.1.4.0pre12 index d61656c38..abbf6e55c 100644 --- a/README.1.4.0pre12 +++ b/README.1.4.0pre12 @@ -15,6 +15,14 @@ ALTER TABLE cust_bill_event ADD status varchar(80); ALTER TABLE cust_bill_event ADD statustext text NULL; UPDATE cust_bill_event SET status = 'done'; +CREATE TABLE radius_usergroup ( + usergroupnum int primary key, + svcnum int not null, + groupname varchar(80) not null +); +CREATE INDEX radius_usergroup1 ON radius_usergroup ( svcnum ); +CREATE INDEX radius_usergroup2 ON radius_usergroup ( groupname ); + Run bin/dbdef-create Run bin/create-history-tables diff --git a/bin/create-history-tables b/bin/create-history-tables index fb4c866c6..9ed641efd 100755 --- a/bin/create-history-tables +++ b/bin/create-history-tables @@ -16,8 +16,13 @@ my $dbh = adminsuidsetup $user; my $schema = dbdef(); #false laziness w/fs-setup -foreach my $table ( grep { ! /^h_/ } $schema->tables ) { - my $tableobj = $schema->table($table); +my @tables = scalar(@ARGV) + ? @ARGV + : grep { ! /^h_/ } $schema->tables; +foreach my $table ( @tables ) { + warn "creating history table for $table\n"; + my $tableobj = $schema->table($table) + or die "unknown talble $table (did you run dbdef-create?)\n"; my $h_tableobj = DBIx::DBSchema::Table->new( { name => "h_$table", primary_key => 'historynum', @@ -73,6 +78,6 @@ $dbh->commit or die $dbh->errstr; $dbh->disconnect or die $dbh->errstr; sub usage { - die "Usage:\n create-history-tables user\n"; + die "Usage:\n create-history-tables user [ table table ... ] \n"; } diff --git a/bin/fs-setup b/bin/fs-setup index 7ee04a5d8..01e08f77d 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.83 2002-03-04 12:48:49 ivan Exp $ +# $Id: fs-setup,v 1.84 2002-03-22 18:56:32 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -951,6 +951,17 @@ sub tables_hash_hack { 'index' => [ [ 'exportnum' ], [ 'optionname' ] ], }, + 'radius_usergroup' => { + 'columns' => [ + 'usergroupnum', 'int', '', '', + 'svcnum', 'int', '', '', + 'groupname', 'varchar', '', $char_d, + ], + 'primary_key' => 'usergroupnum', + 'unique' => [], + 'index' => [ [ 'svcnum' ], [ 'groupname' ] ], + }, + ); %tables; diff --git a/httemplate/docs/schema.html b/httemplate/docs/schema.html index b828213ff..192f56ba9 100644 --- a/httemplate/docs/schema.html +++ b/httemplate/docs/schema.html @@ -383,5 +383,11 @@
  • jobnum - job
  • arg - argument +
  • radius_usergroup - Link users to RADIUS groups. +
      +
    • usergroupnum - primary key +
    • svcnum - account +
    • groupname +
    diff --git a/httemplate/docs/upgrade8.html b/httemplate/docs/upgrade8.html index e52b69ad3..440024de2 100644 --- a/httemplate/docs/upgrade8.html +++ b/httemplate/docs/upgrade8.html @@ -171,6 +171,14 @@ CREATE TABLE part_export_option ( CREATE INDEX part_export_option1 ON part_export_option ( exportnum ); CREATE INDEX part_export_option2 ON part_export_option ( optionname ); +CREATE TABLE radius_usergroup ( + usergroupnum int primary key, + svcnum int not null, + groupname varchar(80) not null +); +CREATE INDEX radius_usergroup1 ON radius_usergroup ( svcnum ); +CREATE INDEX radius_usergroup2 ON radius_usergroup ( groupname ); + ALTER TABLE svc_acct ADD domsvc integer NOT NULL; ALTER TABLE svc_domain ADD catchall integer NULL; ALTER TABLE cust_main ADD referral_custnum integer NULL; diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi index 3292a9b9b..b1bb7f3d3 100755 --- a/httemplate/edit/part_svc.cgi +++ b/httemplate/edit/part_svc.cgi @@ -86,6 +86,10 @@ my %defs = ( select_key => 'svcnum', select_label => 'domain', }, + 'radius_groups' => { + desc =>'ICRADIUS/FreeRADIUS groups', + type =>'radius_usergroup_selector', + }, }, 'svc_domain' => { 'domain' => 'Domain', diff --git a/httemplate/edit/svc_acct.cgi b/httemplate/edit/svc_acct.cgi index d147a1683..6846b5c93 100755 --- a/httemplate/edit/svc_acct.cgi +++ b/httemplate/edit/svc_acct.cgi @@ -239,6 +239,10 @@ foreach my $r ( grep { /^r(adius|[cr])_/ } fields('svc_acct') ) { } } +print 'RADIUS groups'. + &FS::svc_acct::radius_usergroup_selector( [ $svc_acct->radius_groups ] ). + ''; + #submit print qq!
    !; diff --git a/httemplate/view/svc_acct.cgi b/httemplate/view/svc_acct.cgi index d1c61576d..b779e8774 100755 --- a/httemplate/view/svc_acct.cgi +++ b/httemplate/view/svc_acct.cgi @@ -129,6 +129,9 @@ if ($svc_acct->slipip) { print "(No SLIP/PPP account)"; } +print 'RADIUS groups'. + join('
    ', $svc_acct->radius_groups). ''; + print "". '
    '. joblisting({'svcnum'=>$svcnum}, 1). "";