1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
<& elements/edit.html,
'name' => 'RADIUS Group',
'table' => 'radius_group',
'labels' => {
'groupnum' => 'Group',
'groupname' => 'RADIUS Group',
'description' => 'Description',
'attrnum' => 'Attribute',
'priority' => 'Priority',
'speed_down' => 'Download speed',
'speed_up' => 'Upload speed',
},
'viewall_dir' => 'browse',
'menubar' => \@menubar,
'edit_callback' => $edit_callback,
'error_callback' => $edit_callback,
'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' => 'speed_down',
'type' => 'text',
'size' => 8,
'colspan' => 6,
},
{ 'field' => 'speed_up',
'type' => 'text',
'size' => 8,
'colspan' => 6,
},
{
'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 @menubar = ('View all RADIUS Groups' => $p.'browse/radius_group.html');
my $edit_callback = sub {
my ($cgi, $object) = @_;
if ( $object->groupnum ) {
my $link = $p.'misc/delete-radius_group.html?'.$object->groupnum;
push @menubar, 'Delete this Group', $link;
}
};
my $m2_error_callback = sub { # reconstruct the list
my ($cgi, $object) = @_;
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>
|