<& /browse/elements/browse.html, 'title' => 'External message interfaces', 'name_singular' => 'interface', # what else do we call them? 'menubar' => \@menubar, 'query' => $query, 'count_query' => $count_query, 'disableable' => 1, 'disabled_statuspos' => 4, 'agent_virt' => 1, 'agent_null_right' => ['View global templates','Edit global templates'], 'agent_pos' => 1, 'header' => [ 'Name', # 'Agent', 'Prepare', 'Send', '' ], 'fields' => [ 'msgname', 'prepare_url', 'send_url', $disable_link_label ], 'links' => [ $link, ], 'link_onclicks' => [ '', '', '', $disable_link ], 'cell_style' => [ '', '', $url_style, $url_style ], &> <%init> my $curuser = $FS::CurrentUser::CurrentUser; die "access denied" unless $curuser->access_right([ 'View templates', 'View global templates', 'Edit templates', 'Edit global templates', ]); my @menubar = (); if ( $curuser->access_right(['Edit templates', 'Edit global templates']) ) { push @menubar, 'Add a new interface' => $fsurl.'edit/msg_template/http.html'; } push @menubar, 'Email templates' => $fsurl.'browse/msg_template/email.html'; push @menubar, 'Template images' => $fsurl.'browse/template_image.html'; my $query = { 'table' => 'msg_template', 'select' => '*', 'hashref' => { 'msgclass' => 'http' }, }; my $count_query = "SELECT COUNT(*) FROM msg_template WHERE msgclass = 'http'"; my $link = [ $fsurl.'edit/msg_template/http.html?msgnum=', 'msgnum' ]; my $url_style = 'font-size:0.8em; padding:3px'; # also for (disable) label my $disable_link = sub { my $template = shift; include('/elements/popup_link_onclick.html', action => $fsurl.'misc/disable-msg_template.cgi?msgnum=' . $template->msgnum . ($template->disabled ? ';enable=1' : ''), actionlabel => 'Disable template', ); }; my $disable_link_label = sub { my $template = shift; $template->disabled ? '(enable)' : '(disable)' ; };