X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Fmsg_template.html;h=d8b125ae0ade7332d2224623dc63ece89e3b0d75;hb=a354fed1dedc65cf62e63d940e1cfb9c4364e6d3;hp=5cf88bfad5f842b90d50b20352722dced958da33;hpb=9569b2f1e6147f97bfacb41bc94c6605eb59206f;p=freeside.git diff --git a/httemplate/edit/process/msg_template.html b/httemplate/edit/process/msg_template.html index 5cf88bfad..d8b125ae0 100644 --- a/httemplate/edit/process/msg_template.html +++ b/httemplate/edit/process/msg_template.html @@ -1,12 +1,49 @@ <% include( 'elements/process.html', 'table' => 'msg_template', - 'viewall_dir' => 'browse', + 'fields' => $fields, + 'viewall_url' => "browse/msg_template/$msgclass.html", + 'debug' => 0, + 'precheck_callback' => \&precheck_callback, + 'args_callback' => \&args_callback, ) %> <%init> - die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('Edit templates') - || $FS::CurrentUser::CurrentUser->access_right('Edit global templates'); + 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); +} + +sub precheck_callback { + my $cgi = shift; + # validate locale field (for email-type records) + $cgi->param('locale') =~ /^(\w*)$/; + my $locale = $1; + return mt('Language required') if $locale eq 'new'; # the user didn't choose + die "unknown locale $locale" if ( $locale and + !FS::Locales->locale_info($locale) ); +} + +sub args_callback { + my ($cgi, $object) = @_; + my %content; + $cgi->param('locale') =~ /^(\w*)$/; + $content{'locale'} = $1; + # no validation of these; they can contain just about anything + $content{'subject'} = $cgi->param('subject') || ''; + $content{'body'} = $cgi->param('body') || ''; + $object->subject(''); + $object->body(''); + return %content; +}