- unless $FS::CurrentUser::CurrentUser->access_right('Edit templates')
- || $FS::CurrentUser::CurrentUser->access_right('Edit global templates')
- || $FS::CurrentUser::CurrentUser->access_right('Configuration');
+ unless $FS::CurrentUser::CurrentUser->access_right(['Edit templates','Edit global templates']);
+
+my $msgclass = 'email';
+if ( $cgi->param('msgclass') =~ /^(\w+)$/ ) {
+ $msgclass = $1;
+}
+
+my $fields = [ fields('msg_template') ];
+my $class = "FS::msg_template::$msgclass";
+eval "use $class;";
+if ( $class->extension_table ) {
+ push @$fields, fields($class->extension_table);
+}