default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / httemplate / edit / radius_group.html
1 <& elements/edit.html,
2   'name'   => 'RADIUS Group',
3   'table'  => 'radius_group',
4   'labels' => { 
5     'groupnum'  => 'Group',
6     'groupname' => 'RADIUS Group',
7     'description' => 'Description',
8     'attrnum'   => 'Attribute',
9     'priority'  => 'Priority',
10     'speed_down'  => 'Download speed',
11     'speed_up'    => 'Upload speed',
12   },
13   'viewall_dir' => 'browse',
14   'menubar' => \@menubar,
15   'edit_callback' => $edit_callback,
16   'error_callback' => $edit_callback,
17   'fields' => [
18     { 'field'     => 'groupname',
19       'type'      => 'text',
20       'size'      => 20,
21       'colspan'   => 6, # just to not interfere with radius_attr columns
22     },
23     { 'field'     => 'description',
24       'type'      => 'text',
25       'size'      => 40,
26       'colspan'   => 6,
27     },
28     { 'field'     => 'priority',
29       'type'      => 'text',
30       'size'      => 2,
31       'colspan'   => 6, # just to not interfere with radius_attr columns
32     },
33     { 'field'     => 'speed_down',
34       'type'      => 'text',
35       'size'      => 8,
36       'colspan'   => 6,
37     },
38     { 'field'     => 'speed_up',
39       'type'      => 'text',
40       'size'      => 8,
41       'colspan'   => 6,
42     },
43     {
44       'field'     => 'attrnum',
45       'type'      => 'radius_attr',
46       'o2m_table' => 'radius_attr',
47       'm2_label'  => 'Attribute',
48       'm2_error_callback' => $m2_error_callback,
49     },
50   ],
51   #debug => 1
52 &>
53 <%init>
54
55 die "access denied"
56   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
57
58 my @menubar = ('View all RADIUS Groups' => $p.'browse/radius_group.html');
59
60 my $edit_callback = sub {
61   my ($cgi, $object) = @_;
62   if ( $object->groupnum ) {
63     my $link = $p.'misc/delete-radius_group.html?'.$object->groupnum;
64     push @menubar, 'Delete this Group', $link;
65   }
66 };
67
68 my $m2_error_callback = sub { # reconstruct the list
69   my ($cgi, $object) = @_;
70
71   my @fields = qw(attrname attrtype op value);
72   map {
73     my $k = $_;
74     next if !length($cgi->param($k.'_attrname'));
75     new FS::radius_attr {
76       'groupnum' => $object->groupnum,
77       'attrnum'  => scalar( $cgi->param($k) ),
78       map {  $_  => scalar( $cgi->param($k.'_'.$_) ) } @fields,
79     };
80   } grep /^attrnum\d+$/, ($cgi->param);
81 };
82 </%init>