diff options
author | Jonathan Prykop <jonathan@freeside.biz> | 2015-10-20 20:56:13 -0500 |
---|---|---|
committer | Jonathan Prykop <jonathan@freeside.biz> | 2015-10-20 20:56:13 -0500 |
commit | 974fceaaca8e1404750a60a4daafb568b1be5159 (patch) | |
tree | bfd6943babb0551302951cc9fd3a163491b95ba1 /httemplate/edit | |
parent | b25c22890cc4523988b1dc84938d1e52bc681e25 (diff) |
RT#38217: Send email when logging conditions are met
Diffstat (limited to 'httemplate/edit')
-rw-r--r-- | httemplate/edit/log_email.html | 45 | ||||
-rw-r--r-- | httemplate/edit/msg_template/email.html | 6 | ||||
-rw-r--r-- | httemplate/edit/process/log_email.html | 18 |
3 files changed, 69 insertions, 0 deletions
diff --git a/httemplate/edit/log_email.html b/httemplate/edit/log_email.html new file mode 100644 index 000000000..bbce7c708 --- /dev/null +++ b/httemplate/edit/log_email.html @@ -0,0 +1,45 @@ +<% include( 'elements/edit.html', + 'name_singular' => 'log email condition', + 'table' => 'log_email', + 'fields' => [ + { 'field' => 'context', + 'type' => 'select', + 'options' => [ '', @contexts ], + 'labels' => { '' => '(all)', map { $_ => $_ } @contexts }, + 'curr_value' => scalar($cgi->param('context')), + }, + { 'field' => 'min_level', + 'type' => 'select', + 'options' => [ 0..7 ], + 'labels' => { map {$_ => $FS::Log::LEVELS[$_]} 0..7 }, + 'curr_value' => scalar($cgi->param('min_level')), + }, + 'to_addr', + { 'field' => 'msgnum', + 'type' => 'select-msg_template', + 'empty_label' => 'Select template', + 'required' => 1, + }, + ], + 'labels' => { + 'context' => 'Context', + 'min_level' => 'Min. Level', + 'to_addr' => 'To', + 'msgnum' => 'Message', + }, + 'viewall_dir' => 'browse', + 'popup' => $opts{'popup'}, + 'form_init' => $opts{'popup'} ? q(<INPUT TYPE="hidden" NAME="popup" VALUE="1">) : '', + ) +%> +<%once> +my @contexts = sort FS::log_context->contexts; +</%once> +<%init> + +my %opts = @_; + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right([ 'View system logs', 'Configuration' ]); + +</%init> diff --git a/httemplate/edit/msg_template/email.html b/httemplate/edit/msg_template/email.html index dc70ef6ec..b0c1aa31a 100644 --- a/httemplate/edit/msg_template/email.html +++ b/httemplate/edit/msg_template/email.html @@ -302,6 +302,11 @@ my %substitutions = ( '$payinfo' => 'Card/account# (masked)', '$error' => 'Decline reason', ], + 'system_log' => [ + '$logmessage' => 'Log entry message', + '$loglevel' => 'Log entry level', + '$logcontext' => 'Log entry context', + ], ); tie my %sections, 'Tie::IxHash', ( @@ -315,6 +320,7 @@ tie my %sections, 'Tie::IxHash', ( 'svc_domain'=> 'Domain service fields', 'svc_phone' => 'Phone service fields', 'svc_broadband' => 'Broadband service fields', +'system_log' => 'System log fields', ); my $widget = new HTML::Widgets::SelectLayers( diff --git a/httemplate/edit/process/log_email.html b/httemplate/edit/process/log_email.html new file mode 100644 index 000000000..769e180a8 --- /dev/null +++ b/httemplate/edit/process/log_email.html @@ -0,0 +1,18 @@ +<% include('elements/process.html', + 'table' => 'log_email', + %processopts + ) %> +<%init> + +my %opts = @_; + +my $curuser = $FS::CurrentUser::CurrentUser; + +die "access denied" + unless $curuser->access_right([ 'View system logs', 'Configuration' ]); + +my %processopts = $opts{'popup'} + ? ( 'popup_reload' => 'Logging email added' ) + : ( 'redirect' => $fsurl.'browse/log_email.html?' ); # id will be needlessly appended, should be harmless + +</%init> |