read only access to message templates, RT#1`7477
[freeside.git] / httemplate / browse / msg_template.html
1 <% include( 'elements/browse.html',
2               'title'         => 'Message templates',
3               'name_singular' => 'template',
4               'menubar'       => \@menubar,
5               'query'         => { 'table' => 'msg_template', },
6               'count_query'   => 'SELECT COUNT(*) FROM msg_template',
7               'disableable'   => 1,
8               'disabled_statuspos' => 2,
9               'agent_virt'         => 1,
10               'agent_null_right'   => ['View global templates','Edit global templates'],
11               'agent_pos'          => 1,
12               'header'     => [ 'Name', '', map '', @locales ],
13               'fields'     => [ 'msgname', @locales ],
14               'links'      => [ $link, @locale_links ],
15               'cell_style' => [ '', '', map $locale_style, @locales ],
16           )
17 %>
18 <%init>
19
20 my $curuser = $FS::CurrentUser::CurrentUser;
21
22 die "access denied"
23   unless $curuser->access_right([ 'View templates', 'View global templates',
24                                   'Edit templates', 'Edit global templates', ]);
25
26 my @menubar = ();
27 if ( $curuser->access_right(['Edit templates', 'Edit global templates']) ) {
28   push @menubar, 'Add a new template' => $p.'edit/msg_template.html';
29 }
30
31 my $link = [ "${p}edit/msg_template.html?msgnum=", 'msgnum' ];
32
33 my $locale_style = 'font-size:0.8em; padding:3px; background-color:';
34
35 my (@locales, @locale_links);
36 foreach my $l ( FS::Locales->locales ) {
37   push @locales, sub {
38     exists ( $_[0]->content_locales->{$l} )
39     ? +{ FS::Locales->locale_info($l) }->{'name'} 
40     : '';
41   };
42   push @locale_links, sub {
43     my $content = $_[0]->content_locales->{$l} or return '';
44     [ "${p}edit/msg_template.html?locale=$l;msgnum=", 'msgnum' ];
45   };
46 }
47     
48
49 </%init>