diff options
author | mark <mark> | 2011-10-31 19:20:16 +0000 |
---|---|---|
committer | mark <mark> | 2011-10-31 19:20:16 +0000 |
commit | 2ad6569982365759d7baaf5a97bc836770a54291 (patch) | |
tree | 81c72ce1e7687e27ea1f727643f659fdb6335793 /httemplate | |
parent | 588ac92d054671aa13cb61f76b5da472661cb1ac (diff) |
export NAS table to sqlradius, #14697
Diffstat (limited to 'httemplate')
-rw-r--r-- | httemplate/edit/nas.html | 25 | ||||
-rw-r--r-- | httemplate/edit/part_export.cgi | 20 | ||||
-rw-r--r-- | httemplate/edit/process/nas.html | 7 | ||||
-rw-r--r-- | httemplate/edit/process/part_export.cgi | 10 | ||||
-rw-r--r-- | httemplate/elements/checkboxes-table.html | 4 |
5 files changed, 62 insertions, 4 deletions
diff --git a/httemplate/edit/nas.html b/httemplate/edit/nas.html index 64d722e52..9d9b8e9fd 100644 --- a/httemplate/edit/nas.html +++ b/httemplate/edit/nas.html @@ -8,7 +8,7 @@ 'secret' => 'Shared secret', 'type' => 'Type', 'ports' => 'Ports', - 'server' => 'Server', + 'server' => 'Virtual server', 'community' => 'Community', 'description' => 'Description', }, @@ -25,8 +25,7 @@ { field=>'community', size=>40, maxlength=>50 }, { field=>'description', size=>100, maxlength=>200 }, ], - 'html_bottom' => '<font color="#ff0000">*</font> '. - emt('required fields'). '<BR>', + 'html_bottom' => \&html_bottom, 'new_hashref_callback' => sub { +{ 'type' => 'other', 'secret' => 'secret', 'description' => 'RADIUS Client', @@ -38,4 +37,24 @@ die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); +sub html_bottom { + my $nas = shift; + '<font color="#ff0000">*</font> '. + emt('required fields'). '<BR><BR>'. + '<FONT SIZE="+1"><B>'.emt('Export to these RADIUS servers:'). + '</B></FONT><BR>'. + + include('/elements/checkboxes-table.html', + 'source_obj' => $nas, + 'link_table' => 'export_nas', + 'target_table' => 'part_export', + 'hashref' => { 'exporttype' => 'sqlradius' }, + 'name_callback' => sub { $_[0]->label }, + 'default' => 'yes', + 'target_link' => $p.'edit/part_export.cgi?', + 'disable-able' => 1, + ) +} + + </%init> diff --git a/httemplate/edit/part_export.cgi b/httemplate/edit/part_export.cgi index 32ed1fc94..9a0e0bd29 100644 --- a/httemplate/edit/part_export.cgi +++ b/httemplate/edit/part_export.cgi @@ -139,6 +139,26 @@ my $widget = new HTML::Widgets::SelectLayers( $html .= '</TD></TR>'; } } + + if ( $exports->{$layer}{nas} and qsearch('nas',{}) ) { + # show NAS checkboxes + $html .= '<TR><TD ALIGN="right">Export RADIUS clients</TD><TD>'; + + $html .= include('/elements/checkboxes-table.html', + 'source_obj' => $part_export, + 'link_table' => 'export_nas', + 'target_table' => 'nas', + #hashref => {}, + 'name_callback' => sub { + $_[0]->shortname . ' (' . $_[0]->nasname . ')', + }, + 'default' => 'yes', + 'target_link' => $p.'edit/nas.html?', + ); + + $html .= '</TD></TR>'; + } + $html .= '</TABLE>'; $html .= '<INPUT TYPE="hidden" NAME="options" VALUE="'. diff --git a/httemplate/edit/process/nas.html b/httemplate/edit/process/nas.html index 04b46a5c0..6b8e4b825 100644 --- a/httemplate/edit/process/nas.html +++ b/httemplate/edit/process/nas.html @@ -1,4 +1,9 @@ -<& elements/process.html, table=>'nas', viewall_dir=>'browse', &> +<& elements/process.html, + table => 'nas', + viewall_dir => 'browse', + process_m2m => { link_table => 'export_nas', + target_table => 'part_export' }, +&> <%init> die "access denied" diff --git a/httemplate/edit/process/part_export.cgi b/httemplate/edit/process/part_export.cgi index 209419f0b..21150ef67 100644 --- a/httemplate/edit/process/part_export.cgi +++ b/httemplate/edit/process/part_export.cgi @@ -39,4 +39,14 @@ if ( $exportnum ) { # $exportnum = $new->exportnum; } +my $info = FS::part_export::export_info()->{$new->exporttype}; +if ( $info->{nas} ) { + my @nasnums = map { /^nasnum(\d+)$/ ? $1 : () } keys %{ $cgi->Vars }; + $error ||= $new->process_m2m( + link_table => 'export_nas', + target_table => 'nas', + params => \@nasnums + ); +} + </%init> diff --git a/httemplate/elements/checkboxes-table.html b/httemplate/elements/checkboxes-table.html index a31bdb919..671cd1f9b 100644 --- a/httemplate/elements/checkboxes-table.html +++ b/httemplate/elements/checkboxes-table.html @@ -81,6 +81,10 @@ % ? 'CHECKED' % : ''; % +% } elsif ( !$sourcenum ) { # newly created object, has no links yet +% +% $checked = $opt{'default'} ? 'CHECKED' : '' +% % } else { % % $checked = qsearchs( $opt{'link_table'}, { |