- unless $FS::CurrentUser::CurrentUser->access_right('Edit templates')
- || $FS::CurrentUser::CurrentUser->access_right('Edit global templates')
- || $FS::CurrentUser::CurrentUser->access_right('Configuration');
+ 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 template' => $p.'edit/msg_template.html';
+}
+
+my $link = [ "${p}edit/msg_template.html?msgnum=", 'msgnum' ];
+
+my $locale_style = 'font-size:0.8em; padding:3px';
+
+my (@locales, @locale_links);
+foreach my $l ( FS::Locales->locales ) {
+ push @locales, sub {
+ exists ( $_[0]->content_locales->{$l} )
+ ? +{ FS::Locales->locale_info($l) }->{'label'}
+ : '';
+ };
+ push @locale_links, sub {
+ my $content = $_[0]->content_locales->{$l} or return '';
+ [ "${p}edit/msg_template.html?locale=$l;msgnum=", 'msgnum' ];
+ };
+}
+
+my $disable_link = sub {
+ my $template = shift;
+ include('/elements/popup_link_onclick.html',
+ action => $p.'misc/disable-msg_template.cgi?msgnum=' .
+ $template->msgnum .
+ ($template->disabled ? ';enable=1' : ''),
+ actionlabel => 'Disable lemplate',
+ );
+};