Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / httemplate / edit / process / msg_template.html
1 <% include( 'elements/process.html',  
2               'table'       => 'msg_template',
3               'viewall_dir' => 'browse',
4               #'popup_reload'=> 1,
5               'debug'       => 0,
6               'precheck_callback' => \&precheck_callback,
7               'args_callback' => \&args_callback,
8           )
9 %>
10 <%init>
11 die "access denied"
12   unless $FS::CurrentUser::CurrentUser->access_right(['Edit templates','Edit global templates']);
13
14 sub precheck_callback {
15   my $cgi = shift;
16   # validate some fields
17   $cgi->param('locale') =~ /^(\w*)$/;
18   my $locale = $1;
19   return mt('Language required') if $locale eq 'new'; # the user didn't choose
20   die "unknown locale $locale" if ( $locale and 
21                                     !FS::Locales->locale_info($locale) );
22 }
23
24 sub args_callback {
25   my ($cgi, $object) = @_;
26   my %content;
27   $cgi->param('locale') =~ /^(\w*)$/;
28   $content{'locale'} = $1;
29   # no validation of these; they can contain just about anything
30   $content{'subject'} = $cgi->param('subject') || '';
31   $content{'body'} = $cgi->param('body') || '';
32   $object->subject('');
33   $object->body('');
34   return %content;
35 }
36
37 </%init>