summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2002-03-22 18:56:33 +0000
committerivan <ivan>2002-03-22 18:56:33 +0000
commit20bb426a02c0ea54d8feaea7c5da51735ab70293 (patch)
tree28282f7c74f9f13ba831df23b26465d9b7b1b6e2
parentb159f42fa3f48cc2ca3b43773e7661e17d2fb072 (diff)
RADIUS groups on the way!
-rw-r--r--FS/FS/cust_main_county.pm2
-rw-r--r--FS/FS/svc_acct.pm60
-rw-r--r--FS/MANIFEST4
-rw-r--r--FS/t/radius_usergroup.t5
-rw-r--r--Makefile4
-rw-r--r--README.1.4.0pre128
-rwxr-xr-xbin/create-history-tables11
-rwxr-xr-xbin/fs-setup13
-rw-r--r--httemplate/docs/schema.html6
-rw-r--r--httemplate/docs/upgrade8.html8
-rwxr-xr-xhttemplate/edit/part_svc.cgi4
-rwxr-xr-xhttemplate/edit/svc_acct.cgi4
-rwxr-xr-xhttemplate/view/svc_acct.cgi3
13 files changed, 124 insertions, 8 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,
diff --git a/FS/MANIFEST b/FS/MANIFEST
index 19915cd..54aaaa1 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 0000000..325742c
--- /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 8f577c5..21aeb45 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 d61656c..abbf6e5 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 fb4c866..9ed641e 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 7ee04a5..01e08f7 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 b828213..192f56b 100644
--- a/httemplate/docs/schema.html
+++ b/httemplate/docs/schema.html
@@ -383,5 +383,11 @@
<li>jobnum - <a href="#queue">job</a>
<li>arg - argument
</ul>
+ <li><a name="radius_usergroup" href="man/FS/radius_usergroup.html">radius_usergroup</a> - Link users to RADIUS groups.
+ <ul>
+ <li>usergroupnum - primary key
+ <li>svcnum - <a href="#svc_acct">account</a>
+ <li>groupname
+ </ul>
</ul>
</body>
diff --git a/httemplate/docs/upgrade8.html b/httemplate/docs/upgrade8.html
index e52b69a..440024d 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 3292a9b..b1bb7f3 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 d147a16..6846b5c 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 '<TR><TD ALIGN="right">RADIUS groups</TD><TD>'.
+ &FS::svc_acct::radius_usergroup_selector( [ $svc_acct->radius_groups ] ).
+ '</TD></TR>';
+
#submit
print qq!</TABLE><BR><INPUT TYPE="submit" VALUE="Submit">!;
diff --git a/httemplate/view/svc_acct.cgi b/httemplate/view/svc_acct.cgi
index d1c6157..b779e87 100755
--- a/httemplate/view/svc_acct.cgi
+++ b/httemplate/view/svc_acct.cgi
@@ -129,6 +129,9 @@ if ($svc_acct->slipip) {
print "<TR><TH COLSPAN=2>(No SLIP/PPP account)</TH></TR>";
}
+print '<TR><TD ALIGN="right">RADIUS groups</TD><TD BGCOLOR="#ffffff">'.
+ join('<BR>', $svc_acct->radius_groups). '</TD></TR>';
+
print "</TABLE></TD></TR></TABLE>".
'<BR>'. joblisting({'svcnum'=>$svcnum}, 1).
"</BODY></HTML>";