summaryrefslogtreecommitdiff
path: root/FS/FS/msg_template.pm
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2015-12-23 21:46:53 -0600
committerJonathan Prykop <jonathan@freeside.biz>2015-12-23 22:00:24 -0600
commit39565644151816e1c2f93d065c8129ea2153bf94 (patch)
tree726c96e3053271c3d0cc5fa2c9860f3e1bdd73fc /FS/FS/msg_template.pm
parentc8f4149f2dc5a1f593a6ba422181c3d433cc6ef7 (diff)
RT#38217 Send email when logging conditions are met [default template & dump-email_to upgrade]
Diffstat (limited to 'FS/FS/msg_template.pm')
-rw-r--r--FS/FS/msg_template.pm23
1 files changed, 23 insertions, 0 deletions
diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm
index 7d9750c..978d713 100644
--- a/FS/FS/msg_template.pm
+++ b/FS/FS/msg_template.pm
@@ -803,6 +803,25 @@ sub _upgrade_data {
###
$self->_populate_initial_data;
+ ### Fix dump-email_to (needs to happen after _populate_initial_data)
+ if ($conf->config('dump-email_to')) {
+ # anyone who still uses dump-email_to should have just had this created
+ my ($msg_template) = qsearch('msg_template',{ msgname => 'System log' });
+ if ($msg_template) {
+ eval "use FS::log_email;";
+ die $@ if $@;
+ my $log_email = new FS::log_email {
+ 'context' => 'Cron::backup',
+ 'min_level' => 1,
+ 'msgnum' => $msg_template->msgnum,
+ 'to_addr' => $conf->config('dump-email_to'),
+ };
+ my $error = $log_email->insert;
+ die $error if $error;
+ $conf->delete('dump-email_to');
+ }
+ }
+
}
sub _populate_initial_data { #class method
@@ -811,18 +830,22 @@ sub _populate_initial_data { #class method
eval "use FS::msg_template::InitialData;";
die $@ if $@;
+ eval "use FS::upgrade_journal;";
+ die $@ if $@;
my $initial_data = FS::msg_template::InitialData->_initial_data;
foreach my $hash ( @$initial_data ) {
next if $hash->{_conf} && $conf->config( $hash->{_conf} );
+ next if $hash->{_upgrade_journal} && FS::upgrade_journal->is_done( $hash->{_upgrade_journal} );
my $msg_template = new FS::msg_template($hash);
my $error = $msg_template->insert( @{ $hash->{_insert_args} || [] } );
die $error if $error;
$conf->set( $hash->{_conf}, $msg_template->msgnum ) if $hash->{_conf};
+ FS::upgrade_journal->set_done( $hash->{_upgrade_journal} );
}