[freeside-commits] branch master updated. efb10ac30bddb88bcc9c3ae2e4e9c9c92eefde34

Jonathan Prykop jonathan at 420.am
Wed Jul 27 20:40:48 PDT 2016


The branch, master has been updated
       via  efb10ac30bddb88bcc9c3ae2e4e9c9c92eefde34 (commit)
      from  76b22e66bf8e615def0a24cd8cda23c3949eae70 (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 efb10ac30bddb88bcc9c3ae2e4e9c9c92eefde34
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Wed Jul 27 22:40:33 2016 -0500

    RT#71525: welcome_msgnum / svc_acct_welcome_exclude deprecation [upgrade to export]

diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm
index b890717..0a16724 100644
--- a/FS/FS/msg_template.pm
+++ b/FS/FS/msg_template.pm
@@ -804,6 +804,59 @@ sub _upgrade_data {
   ###
   $self->_populate_initial_data;
 
+  ###
+  # Move welcome_msgnum to an export
+  ###
+
+  #upgrade_journal loaded by _populate_initial_data
+  unless (FS::upgrade_journal->is_done('msg_template__welcome_export')) {
+    if (my $msgnum = $conf->config('welcome_msgnum')) {
+      eval "use FS::part_export;";
+      die $@ if $@;
+      eval "use FS::part_svc;";
+      die $@ if $@;
+      eval "use FS::export_svc;";
+      die $@ if $@;
+      #create the export
+      my $part_export = new FS::part_export {
+        'exportname' => 'Welcome Email',
+        'exporttype' => 'send_email'
+      };
+      my $error = $part_export->insert({
+        'to_customer' => 1,
+        'insert_template' => $msgnum,
+        # replicate blank options that would be generated by UI,
+        # to avoid unexpected results from not having them exist
+        'to_address'  => '',
+        'replace_template' => 0,
+        'suspend_template' => 0,
+        'unsuspend_template' => 0,
+        'delete_template' => 0,
+      });
+      die $error if $error;
+      #attach it to part_svcs
+      my @welcome_exclude_svcparts = $conf->config('svc_acct_welcome_exclude');
+      foreach my $part_svc (
+        qsearch('part_svc',{ 'svcdb' => 'svc_acct', 'disabled' => '' })
+      ) {
+        next if grep { $_ eq $part_svc->svcpart } @welcome_exclude_svcparts;
+        my $export_svc = new FS::export_svc {
+          'exportnum' => $part_export->exportnum,
+          'svcpart'   => $part_svc->svcpart,
+        };
+        $error = $export_svc->insert;
+        die $error if $error;
+      }
+      #remove the old confs
+      $error = $conf->delete('welcome_msgnum');
+      die $error if $error;
+      $error = $conf->delete('svc_acct_welcome_exclude');
+      die $error if $error;
+    }
+    FS::upgrade_journal->set_done('msg_template__welcome_export');
+  }
+
+
   ### 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

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

Summary of changes:
 FS/FS/msg_template.pm |   53 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)




More information about the freeside-commits mailing list