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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
<% include( 'elements/browse.html',
'title' => 'Employee Groups',
'menubar' => [ 'Internal users' => $p.'browse/access_user.html', ],
'html_init' => $html_init,
'name' => 'employee groups',
'query' => { 'table' => 'access_group',
'hashref' => {},
'extra_sql' => 'ORDER BY groupname', #??
},
'count_query' => $count_query,
'header' => [ '#',
'Group name',
'Agents',
'Rights',
],
'fields' => [ 'groupnum',
'groupname',
$agents_sub,
$rights_sub,
],
'links' => [ $link,
$link,
'',
'',
],
)
%>
<%once>
my $html_init =
"Employee groups control access to the back-office interface.<BR><BR>".
qq!<A HREF="${p}edit/access_group.html"><I>Add an employee group</I></A><BR><BR>!;
#false laziness w/access_user.html & agent_type.cgi
my $agents_sub = sub {
my $access_group = shift;
[ map {
my $access_groupagent = $_;
my $agent = $access_groupagent->agent;
[
{
'data' => $agent->agent,
'align' => 'left',
'link' => $p. 'edit/agent.cgi?'. $agent->agentnum,
},
];
}
grep { $_->agent } #?
$access_group->access_groupagent,
];
};
tie my %rights, 'Tie::IxHash', FS::AccessRight->rights_info;
my $rights_sub = sub {
my $access_group = shift;
#[ map { my $access_right = $_;
# [
# {
# 'data' => $access_right->rightname,
# 'align' => 'left',
# },
# ];
# }
# $access_group->access_rights,
#];
#some false laziness w/edit/access_group.html
my $columns = 3;
my $count = 0;
#include('/elements/table-grid.html', bgcolor=>'#cccccc' ).
'<TABLE>'.
'<TR>'. join( '', map {
'<TD CLASS="inv" VALIGN="top"><TABLE WIDTH=100%>'.
'<TR><TH BGCOLOR="#dcdcdc">'. $_. '</TH></TR>'.
'<TR><TD>'.
join('<BR>', grep { warn "$access_group->access_right($_): ".
$access_group->access_right($_). "\n";
$access_group->access_right($_); }
map { ref($_) ? $_->{'rightname'} : $_; }
@{ $rights{$_} }
).
'</TD></TR></TABLE></TD>'.
( ++$count % $columns ? '' : '</TR><TR>')
} keys %rights ). '</TR></TABLE>';
};
my $count_query = 'SELECT COUNT(*) FROM access_group';
my $link = [ $p.'edit/access_group.html?', 'groupnum' ];
</%once>
<%init>
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
</%init>
|