=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
use FS::svc_domain;
use FS::raddb;
use FS::queue;
+use FS::radius_usergroup;
@ISA = qw( FS::svc_Common );
$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.
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,
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
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
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
--- /dev/null
+BEGIN { $| = 1; print "1..1\n" }
+END {print "not ok 1\n" unless $loaded;}
+use FS::radius_usergroup;
+$loaded=1;
+print "ok 1\n";
DB_USER = freeside
DB_PASSWORD=
-TEMPLATE = asp
-#TEMPLATE = mason
+#TEMPLATE = asp
+TEMPLATE = mason
ASP_GLOBAL = /usr/local/etc/freeside/asp-global
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
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',
$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";
}
#!/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; }
'index' => [ [ 'exportnum' ], [ 'optionname' ] ],
},
+ 'radius_usergroup' => {
+ 'columns' => [
+ 'usergroupnum', 'int', '', '',
+ 'svcnum', 'int', '', '',
+ 'groupname', 'varchar', '', $char_d,
+ ],
+ 'primary_key' => 'usergroupnum',
+ 'unique' => [],
+ 'index' => [ [ 'svcnum' ], [ 'groupname' ] ],
+ },
+
);
%tables;
<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>
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;
select_key => 'svcnum',
select_label => 'domain',
},
+ 'radius_groups' => {
+ desc =>'ICRADIUS/FreeRADIUS groups',
+ type =>'radius_usergroup_selector',
+ },
},
'svc_domain' => {
'domain' => 'Domain',
}
}
+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">!;
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>";