[freeside-commits] branch FREESIDE_4_BRANCH updated. cbbd50ee14704f15c2f7c390ba0ee03b8b0175c4

Jonathan Prykop jonathan at 420.am
Wed Dec 23 20:28:36 PST 2015


The branch, FREESIDE_4_BRANCH has been updated
       via  cbbd50ee14704f15c2f7c390ba0ee03b8b0175c4 (commit)
       via  39565644151816e1c2f93d065c8129ea2153bf94 (commit)
      from  c8f4149f2dc5a1f593a6ba422181c3d433cc6ef7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit cbbd50ee14704f15c2f7c390ba0ee03b8b0175c4
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Wed Dec 23 22:21:01 2015 -0600

    RT#38217 Send email when logging conditions are met [fixed bad char in template]

diff --git a/FS/FS/msg_template/InitialData.pm b/FS/FS/msg_template/InitialData.pm
index 29dd417..d502b3f 100644
--- a/FS/FS/msg_template/InitialData.pm
+++ b/FS/FS/msg_template/InitialData.pm
@@ -45,8 +45,8 @@ END
       _upgrade_journal => 'system_log_email_template',
       _insert_args => [ subject => '{ $company_name } system log',
                         body    => <<'END',
-Level: {$loglevel}<BR>
-Context: {$logcontext}<BR>
+Level: {$loglevel}<BR>
+Context: {$logcontext}<BR>
 <BR>
 {$logmessage}<BR>
 

commit 39565644151816e1c2f93d065c8129ea2153bf94
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Wed Dec 23 21:46:53 2015 -0600

    RT#38217 Send email when logging conditions are met [default template & dump-email_to upgrade]

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} );
   
   }
 
diff --git a/FS/FS/msg_template/InitialData.pm b/FS/FS/msg_template/InitialData.pm
index baf145d..29dd417 100644
--- a/FS/FS/msg_template/InitialData.pm
+++ b/FS/FS/msg_template/InitialData.pm
@@ -39,6 +39,20 @@ Amount:    {$refund}<BR>
 END
                       ],
     },
+    { msgname   => 'System log',
+      msgclass  => 'email',
+      mime_type => 'text/html',
+      _upgrade_journal => 'system_log_email_template',
+      _insert_args => [ subject => '{ $company_name } system log',
+                        body    => <<'END',
+Level: {$loglevel}<BR>
+Context: {$logcontext}<BR>
+<BR>
+{$logmessage}<BR>
+
+END
+                      ],
+    },
   ];
 }
 
diff --git a/httemplate/edit/log_email.html b/httemplate/edit/log_email.html
index bbce7c7..709a240 100644
--- a/httemplate/edit/log_email.html
+++ b/httemplate/edit/log_email.html
@@ -18,6 +18,7 @@
                             { 'field' => 'msgnum',
                               'type' => 'select-msg_template',
                               'empty_label' => 'Select template',
+                              'value' => $msgnum,
                               'required' => 1,
                             },
                           ],
@@ -42,4 +43,14 @@ my %opts = @_;
 die "access denied"
   unless $FS::CurrentUser::CurrentUser->access_right([ 'View system logs', 'Configuration' ]);
 
+my $msgnum = $cgi->param('msgnum');
+unless ($msgnum) {
+  my ($msg_template) = qsearch('msg_template',{ msgname => 'System log' });
+  # doesn't seem worth having a config just for the default selected template
+  # if they've deleted the system-generated one, just default to empty "Select template"
+  if ($msg_template) {
+    $msgnum = $msg_template->msgnum;
+  }
+}
+
 </%init>

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/msg_template.pm             |   23 +++++++++++++++++++++++
 FS/FS/msg_template/InitialData.pm |   14 ++++++++++++++
 httemplate/edit/log_email.html    |   11 +++++++++++
 3 files changed, 48 insertions(+)




More information about the freeside-commits mailing list