diff options
| author | mark <mark> | 2011-11-23 18:42:59 +0000 | 
|---|---|---|
| committer | mark <mark> | 2011-11-23 18:42:59 +0000 | 
| commit | bfee00e26a87ccc687f085fdeaffef8e4b2a9b50 (patch) | |
| tree | 103f4d15e50b88d334ea0c16fe12fb3798d28a54 /httemplate/edit | |
| parent | 91a65629b7c2659035408bafa1f90f96b6596498 (diff) | |
RADIUS group attributes, #15017
Diffstat (limited to 'httemplate/edit')
| -rw-r--r-- | httemplate/edit/process/radius_group.html | 23 | ||||
| -rw-r--r-- | httemplate/edit/radius_group.html | 58 | 
2 files changed, 70 insertions, 11 deletions
diff --git a/httemplate/edit/process/radius_group.html b/httemplate/edit/process/radius_group.html index 706813f2a..884694618 100644 --- a/httemplate/edit/process/radius_group.html +++ b/httemplate/edit/process/radius_group.html @@ -1,10 +1,27 @@  <& elements/process.html, -               'table'       => 'radius_group', -               'viewall_dir' => 'browse', +  'table'       => 'radius_group', +  'viewall_dir' => 'browse', +  'process_o2m' => { +    'table'   => 'radius_attr', +    'fields'  => [ qw( attrtype attrname op value )], +  }, +  'precheck_callback' => $precheck_callback,  &>  <%init> -  die "access denied"    unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); +my $precheck_callback = sub { +  my $cgi = shift; +  my $param = $cgi->Vars; +  # remove rows with a blank attrname and attrnum +  foreach my $k (grep /^attrnum\d+$/, keys %$param) { +    if ( !length($param->{$k}) and !length($param->{$k.'_attrname'}) ) { +      delete $param->{$k.'_'.$_} foreach qw(attrtype attrname op value); +      delete $param->{$k}; +    } +  } +  ''; +}; +  </%init> diff --git a/httemplate/edit/radius_group.html b/httemplate/edit/radius_group.html index 80e17ed83..c9bf52596 100644 --- a/httemplate/edit/radius_group.html +++ b/httemplate/edit/radius_group.html @@ -1,16 +1,58 @@  <& elements/edit.html, -                 'name'   => 'RADIUS Group', -                 'table'  => 'radius_group', -                 'labels' => {  -                               'groupnum'  => 'Group', -                               'groupname' => 'RADIUS Group', -                               'description' => 'Description', -                             }, -                 'viewall_dir' => 'browse', +  'name'   => 'RADIUS Group', +  'table'  => 'radius_group', +  'labels' => {  +    'groupnum'  => 'Group', +    'groupname' => 'RADIUS Group', +    'description' => 'Description', +    'attrnum'   => 'Attribute', +    'priority'  => 'Priority', +  }, +  'viewall_dir' => 'browse', +  'fields' => [ +    { 'field'     => 'groupname', +      'type'      => 'text', +      'size'      => 20, +      'colspan'   => 6, # just to not interfere with radius_attr columns +    }, +    { 'field'     => 'description', +      'type'      => 'text', +      'size'      => 40, +      'colspan'   => 6, +    }, +    { 'field'     => 'priority', +      'type'      => 'text', +      'size'      => 2, +      'colspan'   => 6, # just to not interfere with radius_attr columns +    }, +    { +      'field'     => 'attrnum', +      'type'      => 'radius_attr', +      'o2m_table' => 'radius_attr', +      'm2_label'  => 'Attribute', +      'm2_error_callback' => $m2_error_callback, +    }, +  ], +  #debug => 1  &>  <%init>  die "access denied"    unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); +my $m2_error_callback = sub { # reconstruct the list +  my ($cgi, $object) = @_; + +  warn Dumper({$cgi->Vars}); +  my @fields = qw(attrname attrtype op value); +  map { +    my $k = $_; +    next if !length($cgi->param($k.'_attrname')); +    new FS::radius_attr { +      'groupnum' => $object->groupnum, +      'attrnum'  => scalar( $cgi->param($k) ), +      map {  $_  => scalar( $cgi->param($k.'_'.$_) ) } @fields, +    }; +  } grep /^attrnum\d+$/, ($cgi->param); +};  </%init>  | 
