[freeside-commits] branch FREESIDE_2_3_BRANCH updated. b3738526127db6306b8457212b08a5763108bae1

Mark Wells mark at 420.am
Fri Aug 23 15:25:01 PDT 2013


The branch, FREESIDE_2_3_BRANCH has been updated
       via  b3738526127db6306b8457212b08a5763108bae1 (commit)
       via  4c0066949409448d9104fd7f7c05ccff0573e2a8 (commit)
      from  8a8089a9580bece258da2c0852acfd2c53b49ff0 (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 b3738526127db6306b8457212b08a5763108bae1
Author: Mark Wells <mark at freeside.biz>
Date:   Fri Aug 23 15:24:36 2013 -0700

    pass correct arguments to msg_template::prepare, #24659

diff --git a/FS/FS/Cron/alert_expiration.pm b/FS/FS/Cron/alert_expiration.pm
index eb53ea8..5961e61 100644
--- a/FS/FS/Cron/alert_expiration.pm
+++ b/FS/FS/Cron/alert_expiration.pm
@@ -100,7 +100,8 @@ sub alert_expiration {
       if ( $msgnum ) { # new hotness
         my $msg_template = qsearchs('msg_template', { msgnum => $msgnum } );
         $customer->setfield('expdate', $expire_time);
-        $error = $msg_template->send('cust_main' => $customer);
+        $error = $msg_template->send('cust_main' => $customer,
+                                     'object'    => $customer);
       }
       else { #!$msgnum, the hard way
         $mail_sender = $conf->config('invoice_from', $agentnum);
diff --git a/FS/FS/Cron/notify.pm b/FS/FS/Cron/notify.pm
index 9ad7a49..1859fca 100644
--- a/FS/FS/Cron/notify.pm
+++ b/FS/FS/Cron/notify.pm
@@ -108,7 +108,8 @@ END
       my $msg_template = qsearchs('msg_template', { msgnum => $msgnum });
       $cust_main->setfield('packages', \\@packages);
       $cust_main->setfield('recurdates', \\@recurdates);
-      $error = $msg_template->send('cust_main' => $cust_main);
+      $error = $msg_template->send('cust_main' => $cust_main,
+                                   'object'    => $cust_main);
     }
     else {
       $error = $cust_main->notify( 'impending_recur_template',
diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm
index 0b3d1ee..3ad590a 100644
--- a/FS/FS/msg_template.pm
+++ b/FS/FS/msg_template.pm
@@ -16,6 +16,7 @@ use Date::Format qw( time2str );
 use HTML::Entities qw( decode_entities encode_entities ) ;
 use HTML::FormatText;
 use HTML::TreeBuilder;
+use Encode;
 
 use File::Temp;
 use IPC::Run qw(run);
@@ -410,6 +411,10 @@ sub prepare {
 #    @cust_msg = ('cust_msg' => $cust_msg);
 #  }
 
+  my $text_body = encode('UTF-8',
+                  HTML::FormatText->new(leftmargin => 0, rightmargin => 70)
+                      ->format( HTML::TreeBuilder->new_from_content($body) )
+                  );
   (
     'custnum' => $cust_main->custnum,
     'msgnum'  => $self->msgnum,
@@ -418,8 +423,7 @@ sub prepare {
     'bcc'  => $self->bcc_addr || undef,
     'subject'   => $subject,
     'html_body' => $body,
-    'text_body' => HTML::FormatText->new(leftmargin => 0, rightmargin => 70
-                    )->format( HTML::TreeBuilder->new_from_content($body) ),
+    'text_body' => $text_body
   );
 
 }

commit 4c0066949409448d9104fd7f7c05ccff0573e2a8
Author: Mark Wells <mark at freeside.biz>
Date:   Thu Aug 22 17:14:01 2013 -0700

    better locale support in message template UI, #24659

diff --git a/FS/FS/Locales.pm b/FS/FS/Locales.pm
index 10bf72a..bf10990 100644
--- a/FS/FS/Locales.pm
+++ b/FS/FS/Locales.pm
@@ -37,6 +37,9 @@ tie our %locales, 'Tie::IxHash',
   'iw_IL', { name => 'Hebrew',         country => 'Israel', rtl=>1, },
 ;
 
+$_->{label} = $_->{name} . ' (' . $_->{country} . ')'
+  foreach values %locales;
+
 sub locales {
   keys %locales;
 }
diff --git a/httemplate/browse/msg_template.html b/httemplate/browse/msg_template.html
index 50afc28..bb5ac94 100644
--- a/httemplate/browse/msg_template.html
+++ b/httemplate/browse/msg_template.html
@@ -36,7 +36,7 @@ my (@locales, @locale_links);
 foreach my $l ( FS::Locales->locales ) {
   push @locales, sub {
     exists ( $_[0]->content_locales->{$l} )
-    ? +{ FS::Locales->locale_info($l) }->{'name'} 
+    ? +{ FS::Locales->locale_info($l) }->{'label'} 
     : '';
   };
   push @locale_links, sub {
diff --git a/httemplate/edit/msg_template.html b/httemplate/edit/msg_template.html
index f50d66d..5171289 100644
--- a/httemplate/edit/msg_template.html
+++ b/httemplate/edit/msg_template.html
@@ -15,13 +15,14 @@
                              'msgname'   => 'Template name',
                              'from_addr' => 'From: ',
                              'bcc_addr'  => 'Bcc: ',
-                             'locale'    => 'Language',
+                             'locale'    => 'Locale',
                              'subject'   => 'Subject: ',
                              'body'      => 'Message body',
                            },
      'edit_callback'    => \&edit_callback,
      'error_callback'   => \&edit_callback,
      'html_bottom'      => '</DIV>',
+     'html_table_bottom'=> \&html_table_bottom,
      'html_foot'        => ( $no_submit ? '' : "</TD>$sidebar</TR></TABLE>" ),
      'no_submit'        => $no_submit,
 &>
@@ -120,11 +121,12 @@ sub edit_callback {
 
     # make a list of available locales
     my $content_locales = $object->content_locales;
-    my @locales = grep { !exists($content_locales->{$_}) } FS::Locales->locales;
+    my @locales = grep { !exists($content_locales->{$_}) } 
+                         FS::Conf->new->config('available-locales');
     my %labels;
     foreach (@locales) {
       my %info = FS::Locales->locale_info($_);
-      $labels{$_} = $info{'name'}; # ignoring country for now
+      $labels{$_} = $info{'label'};
     }
     unshift @locales, 'new';
     $labels{'new'} = 'Select language';
@@ -145,7 +147,7 @@ sub edit_callback {
       curr_value  => 'new',
       onchange    => $onchange_locale,
     );
-  } # else it's already set up correctly
+  }
 }
 
 sub menubar_opt_callback {
@@ -159,10 +161,10 @@ sub menubar_opt_callback {
   foreach my $l (FS::Locales->locales) {
     if ( exists $object->content_locales->{$l} ) {
       my %info = FS::Locales->locale_info($l);
-      push @tabs,
-           $info{'name'},
+      push @tabs, 
+           $info{'label'},
            ';locale='.$l;
-      $selected = $info{'name'} if $object->locale eq $l;
+      $selected = $info{'label'} if $object->locale eq $l;
     }
     else {
       $display_new = 1; # there is at least one unused locale left
@@ -325,6 +327,11 @@ function insertHtml(what) {
   var oEditor = FCKeditorAPI.GetInstance("body");
   oEditor.InsertHtml(what);
 };
+
+function areyousure(url, message) {
+  if (confirm(message))
+    window.location.href = url;
+}
 </SCRIPT>
 <TD valign="top"><FORM name="dummy">
 Substitutions: '
@@ -336,4 +343,22 @@ Substitutions: '
 </FONT></TD>
 ';
 
+sub html_table_bottom {
+  my $object = shift;
+  $cgi->param('locale') =~ /^(\w+)$/;
+  my $locale = $1;
+  my $html;
+  if ( $locale and $locale ne 'new' ) {
+    # set up a delete link
+    my $msgnum = $object->msgnum;
+    my $url = $p."misc/delete-template_content.html?msgnum=$msgnum;locale=$1";
+    my $link = qq!<A HREF="javascript:areyousure('$url','Really delete this template?')">! .
+      'Delete this template' .
+      '</A>';
+    $html = qq!<TR><TD></TD>
+      <TD STYLE="font-style: italic; font-size: small">$link</TD></TR>!;
+  }
+  $html;
+}
+
 </%init>
diff --git a/httemplate/misc/delete-template_content.html b/httemplate/misc/delete-template_content.html
new file mode 100644
index 0000000..e77878c
--- /dev/null
+++ b/httemplate/misc/delete-template_content.html
@@ -0,0 +1,18 @@
+<%init>
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right(['Edit templates', 'Edit global templates']);
+
+my ($msgnum, $locale);
+$cgi->param('msgnum') =~ /^(\d+)$/ or die "bad msgnum";
+$msgnum = $1;
+$cgi->param('locale') =~ /^(\w+)$/ or die "bad locale";
+$locale = $1;
+my $content = qsearchs('template_content',
+              { msgnum => $msgnum, locale => $locale })
+  or die "couldn't find $locale version of template #$msgnum";
+
+my $error = $content->delete;
+my $url = $p.'edit/msg_template.html?msgnum='.$msgnum;
+$url .= ";locale=$locale;error=$error" if $error;
+</%init>
+<% $cgi->redirect($url) %>

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

Summary of changes:
 FS/FS/Cron/alert_expiration.pm               |    3 +-
 FS/FS/Cron/notify.pm                         |    3 +-
 FS/FS/Locales.pm                             |    3 ++
 FS/FS/msg_template.pm                        |    8 ++++-
 httemplate/browse/msg_template.html          |    2 +-
 httemplate/edit/msg_template.html            |   39 +++++++++++++++++++++----
 httemplate/misc/delete-template_content.html |   18 ++++++++++++
 7 files changed, 64 insertions(+), 12 deletions(-)
 create mode 100644 httemplate/misc/delete-template_content.html




More information about the freeside-commits mailing list