[freeside-commits] branch FREESIDE_4_BRANCH updated. 4c05e1c2e356908d926bfcd40ad8957a7dfe47bb

Mitch Jackson mitch at freeside.biz
Wed Jul 18 12:09:37 PDT 2018


The branch, FREESIDE_4_BRANCH has been updated
       via  4c05e1c2e356908d926bfcd40ad8957a7dfe47bb (commit)
       via  8cd612ba6ddfda69ee5af2b557a943c73a5c95be (commit)
       via  81fe2b6311b181a32a81fa81fcccfff1c7d471d1 (commit)
       via  ea2858e409d074c635288824300de542c7615862 (commit)
       via  7ca76f46076f7be7ed43453b88ca558b325e13e5 (commit)
      from  e6e941b0f73452f6207bb74bdda244630cda9e1e (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 4c05e1c2e356908d926bfcd40ad8957a7dfe47bb
Author: Mitch Jackson <mitch at freeside.biz>
Date:   Wed Jul 18 19:03:57 2018 +0000

    RT# 32234 unmask_ss deprecated - drop from templates

diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi
index 05bf4377a..56c396271 100755
--- a/httemplate/edit/cust_main.cgi
+++ b/httemplate/edit/cust_main.cgi
@@ -286,7 +286,7 @@ if ( $cgi->param('error') ) {
     $cust_main->paycvv($paycvv);
   }
   @invoicing_list = $cust_main->invoicing_list;
-  $ss = $conf->exists('unmask_ss') ? $cust_main->ss : $cust_main->masked('ss');
+  $ss = $cust_main->masked('ss');
   $stateid = $cust_main->masked('stateid');
 
 } else { #new customer
diff --git a/httemplate/edit/cust_main/name.html b/httemplate/edit/cust_main/name.html
index 120475b92..0319cf027 100644
--- a/httemplate/edit/cust_main/name.html
+++ b/httemplate/edit/cust_main/name.html
@@ -5,7 +5,6 @@
 % if (
 %   $value
 %   && ref $unmask_field
-%   && !$unmask_field->{unmask_ss}
 %   && $FS::CurrentUser::CurrentUser->access_right( $unmask_field->{access_right} )
 % ) {
   <& /elements/link-replace_element_text.html, {
@@ -28,7 +27,6 @@
           target_id    => 'ss',
           replace_text => $cust_main->ss,
           access_right => 'Unmask customer SSN',
-          unmask_ss    => $conf->exists('unmask_ss'),
         } &>
 % } else  {
         <INPUT TYPE="hidden" NAME="ss" VALUE="<% $ss %>">
@@ -63,7 +61,7 @@ my $agentnum = $cust_main->agentnum if $cust_main->custnum;
 my $conf = FS::Conf->new;
 my $ss;
 
-if ( $cgi->param('error') or $conf->exists('unmask_ss') ) {
+if ( $cgi->param('error') ) {
   $ss = $cust_main->ss;
 } else {
   $ss = $cust_main->masked('ss');
diff --git a/httemplate/view/cust_main/contacts.html b/httemplate/view/cust_main/contacts.html
index 11efcd568..efcf48ecc 100644
--- a/httemplate/view/cust_main/contacts.html
+++ b/httemplate/view/cust_main/contacts.html
@@ -31,12 +31,9 @@
     <TH ALIGN="right"><% mt('SS#') |h %></TH>
     <TD>
       <span id="ss_span" style="white-space:nowrap;">
-      <% $conf->exists('unmask_ss')
-           ? $cust_main->ss
-           : $cust_main->masked('ss') || ' ' %>
+      <% $cust_main->masked('ss') || ' ' %>
 %   if (
 %         $cust_main->ss
-%         && !$conf->exists('unmask_ss')
 %         && $FS::CurrentUser::CurrentUser->access_right('Unmask customer SSN')
 %   ) {
       <& /elements/link-replace_element_text.html, {

commit 8cd612ba6ddfda69ee5af2b557a943c73a5c95be
Author: Mitch Jackson <mitch at freeside.biz>
Date:   Tue Jul 17 22:31:00 2018 -0500

    freeside-upgrade - fix uninitalized value warnings

diff --git a/FS/FS/Upgrade.pm b/FS/FS/Upgrade.pm
index 1f4721754..f998a816e 100644
--- a/FS/FS/Upgrade.pm
+++ b/FS/FS/Upgrade.pm
@@ -153,7 +153,7 @@ If you need to continue using the old Form 477 report, turn on the
 
   # boolean+text previous_balance-exclude_from_total is now two separate options
   my $total_new_charges = $conf->config('previous_balance-exclude_from_total');
-  if (length($total_new_charges) > 0) {
+  if ( defined $total_new_charges && length($total_new_charges) > 0 ) {
     $conf->set('previous_balance-text-total_new_charges', $total_new_charges);
     $conf->set('previous_balance-exclude_from_total', '');
   }
@@ -174,8 +174,8 @@ If you need to continue using the old Form 477 report, turn on the
     $conf->delete('unsuspendauto');
   }
 
-  if ($conf->config('cust-fields') =~ / \| Payment Type/) {
-    my $cust_fields = $conf->config('cust-fields');
+  my $cust_fields = $conf->config('cust-fields');
+  if ( defined $cust_fields && $cust_fields =~ / \| Payment Type/ ) {
     # so we can potentially use 'Payment Types' or somesuch in the future
     $cust_fields =~ s/ \| Payment Type( \|)/$1/;
     $cust_fields =~ s/ \| Payment Type$//;

commit 81fe2b6311b181a32a81fa81fcccfff1c7d471d1
Author: Mitch Jackson <mitch at freeside.biz>
Date:   Tue Jul 17 22:14:07 2018 -0500

    RT# 32234 Change unmask_ss from global conf to group access right

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 9bdd67f7a..1b25cb5f0 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -2193,7 +2193,7 @@ and customer address. Include units.',
 
   {
     'key'         => 'unmask_ss',
-    'section'     => 'e-checks',
+    'section'     => 'deprecated',
     'description' => "Don't mask social security numbers in the web interface.",
     'type'        => 'checkbox',
   },
diff --git a/FS/FS/Upgrade.pm b/FS/FS/Upgrade.pm
index 3e0412795..1f4721754 100644
--- a/FS/FS/Upgrade.pm
+++ b/FS/FS/Upgrade.pm
@@ -192,6 +192,19 @@ If you need to continue using the old Form 477 report, turn on the
       $lh->maketext($_) if length($_);
     }
   }
+
+  unless ( FS::upgrade_journal->is_done('deprecate_unmask_ss') ) {
+    if ( $conf->config_bool( 'unmask_ss' )) {
+      warn "'unmask_ssn' deprecated from global configuration\n";
+      for my $access_group ( qsearch( access_group => {} )) {
+        $access_group->grant_access_right( 'Unmask customer SSN' );
+        warn " - 'Unmask customer SSN' access right granted to '" .
+             $access_group->groupname . "' employee group\n";
+      }
+    }
+    FS::upgrade_journal->set_done('deprecate_unmask_ss');
+  }
+
 }
 
 sub upgrade_overlimit_groups {
diff --git a/FS/FS/access_group.pm b/FS/FS/access_group.pm
index a2b977409..4f6c85b45 100644
--- a/FS/FS/access_group.pm
+++ b/FS/FS/access_group.pm
@@ -2,6 +2,7 @@ package FS::access_group;
 use base qw( FS::m2m_Common FS::m2name_Common FS::Record );
 
 use strict;
+use Carp qw( croak );
 use FS::Record qw( qsearch qsearchs );
 use FS::access_right;
 
@@ -137,6 +138,54 @@ sub access_right {
           );
 }
 
+=item grant_access_right RIGHTNAME
+
+Grant the specified specified FS::access_right record to this group.
+Return the FS::access_right record.
+
+=cut
+
+sub grant_access_right {
+  my ( $self, $rightname ) = @_;
+
+  croak "grant_access_right() requires \$rightname"
+    unless $rightname;
+
+  my $access_right = $self->access_right( $rightname );
+  return $access_right if $access_right;
+
+  $access_right = FS::access_right->new({
+    righttype   => 'FS::access_group',
+    rightobjnum => $self->groupnum,
+    rightname   => $rightname,
+  });
+  if ( my $error = $access_right->insert ) {
+    die "grant_access_right() error: $error";
+  }
+
+  $access_right;
+}
+
+=item revoke_access_right RIGHTNAME
+
+Revoke the specified FS::access_right record from this group.
+
+=cut
+
+sub revoke_access_right {
+  my ( $self, $rightname ) = @_;
+
+  croak "revoke_access_right() requires \$rightname"
+    unless $rightname;
+
+  my $access_right = $self->access_right( $rightname )
+    or return;
+
+  if ( my $error = $access_right->delete ) {
+    die "revoke_access_right() error: $error";
+  }
+}
+
 =back
 
 =head1 BUGS
@@ -148,4 +197,3 @@ L<FS::Record>, schema.html from the base documentation.
 =cut
 
 1;
-

commit ea2858e409d074c635288824300de542c7615862
Author: Mitch Jackson <mitch at freeside.biz>
Date:   Fri Jun 15 21:14:44 2018 -0500

    RT# 32234 Show unmask widget only if a value exists to unmask

diff --git a/httemplate/edit/cust_main/name.html b/httemplate/edit/cust_main/name.html
index c1078d46a..120475b92 100644
--- a/httemplate/edit/cust_main/name.html
+++ b/httemplate/edit/cust_main/name.html
@@ -3,7 +3,8 @@
 <DIV STYLE="display: inline-block" ID="<% $field %>_input">
   <INPUT TYPE="text" NAME="<% $field %>" VALUE="<% $value |h %>" <%$extra%>>
 % if (
-%   ref $unmask_field
+%   $value
+%   && ref $unmask_field
 %   && !$unmask_field->{unmask_ss}
 %   && $FS::CurrentUser::CurrentUser->access_right( $unmask_field->{access_right} )
 % ) {
diff --git a/httemplate/edit/cust_main/stateid.html b/httemplate/edit/cust_main/stateid.html
index cc0890fe1..0f288099b 100644
--- a/httemplate/edit/cust_main/stateid.html
+++ b/httemplate/edit/cust_main/stateid.html
@@ -3,7 +3,7 @@
   <TH ALIGN="right"><% $stateid_label %></TH>
   <TD>
     <INPUT TYPE="text" NAME="stateid" VALUE="<% $stateid %>" SIZE=12 ID="stateid">
-% if ( $FS::CurrentUser::CurrentUser->access_right( 'Unmask customer DL' )) {
+% if ( $stateid && $FS::CurrentUser::CurrentUser->access_right( 'Unmask customer DL' )) {
     <& /elements/link-replace_element_text.html, {target_id => 'stateid', replace_text => $cust_main->stateid} &>
 % }
   </TD>
diff --git a/httemplate/view/cust_main/contacts.html b/httemplate/view/cust_main/contacts.html
index 367659293..11efcd568 100644
--- a/httemplate/view/cust_main/contacts.html
+++ b/httemplate/view/cust_main/contacts.html
@@ -34,7 +34,11 @@
       <% $conf->exists('unmask_ss')
            ? $cust_main->ss
            : $cust_main->masked('ss') || ' ' %>
-%   if ( !$conf->exists('unmask_ss') && $FS::CurrentUser::CurrentUser->access_right('Unmask customer SSN')) {
+%   if (
+%         $cust_main->ss
+%         && !$conf->exists('unmask_ss')
+%         && $FS::CurrentUser::CurrentUser->access_right('Unmask customer SSN')
+%   ) {
       <& /elements/link-replace_element_text.html, {
            target_id    => 'ss_span',
            replace_text => $cust_main->ss,
@@ -186,7 +190,10 @@
     <TD>
       <span id="stateid_span" style="white-space:nowrap;">
       <% $cust_main->masked('stateid') || '&nbsp' %>
-%   if ( $FS::CurrentUser::CurrentUser->access_right('Unmask customer DL')) {
+%   if (
+%         $cust_main->stateid
+%         && $FS::CurrentUser::CurrentUser->access_right('Unmask customer DL')
+%   ) {
       <& /elements/link-replace_element_text.html, {
            target_id => 'stateid_span',
            replace_text => $cust_main->stateid,

commit 7ca76f46076f7be7ed43453b88ca558b325e13e5
Author: Mitch Jackson <mitch at freeside.biz>
Date:   Wed Jun 13 02:25:09 2018 -0500

    RT# 32234 Allow unmask of SSN/DL#

diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm
index db4ff1a85..65b9b0f88 100644
--- a/FS/FS/AccessRight.pm
+++ b/FS/FS/AccessRight.pm
@@ -156,6 +156,8 @@ tie my %rights, 'Tie::IxHash',
     'View package definition costs', #NEWNEW
     'Change package start date',
     'Change package contract end date',
+    'Unmask customer DL',
+    'Unmask customer SSN',
   ],
   
   ###
diff --git a/httemplate/edit/cust_main/name.html b/httemplate/edit/cust_main/name.html
index 713f54cdb..c1078d46a 100644
--- a/httemplate/edit/cust_main/name.html
+++ b/httemplate/edit/cust_main/name.html
@@ -1,7 +1,17 @@
 <%def .namepart>
-% my ($field, $value, $label, $extra) = @_;
+% my ($field, $value, $label, $extra, $unmask_field) = @_;
 <DIV STYLE="display: inline-block" ID="<% $field %>_input">
   <INPUT TYPE="text" NAME="<% $field %>" VALUE="<% $value |h %>" <%$extra%>>
+% if (
+%   ref $unmask_field
+%   && !$unmask_field->{unmask_ss}
+%   && $FS::CurrentUser::CurrentUser->access_right( $unmask_field->{access_right} )
+% ) {
+  <& /elements/link-replace_element_text.html, {
+      target_id    => $unmask_field->{target_id},
+      replace_text => $unmask_field->{replace_text},
+  } &>
+% }
   <BR><FONT SIZE="-1" COLOR="#333333"><% emt($label) %></FONT>
 </DIV>
 </%def>
@@ -13,7 +23,12 @@
         <& .namepart, 'first', $cust_main->first, 'First' &>
 % if ( $conf->exists('show_ss') ) {
          
-        <& .namepart, 'ss', $ss, 'SS#', "SIZE=11" &>
+        <& .namepart, 'ss', $ss, 'SS#', "SIZE=11 ID='ss'", {
+          target_id    => 'ss',
+          replace_text => $cust_main->ss,
+          access_right => 'Unmask customer SSN',
+          unmask_ss    => $conf->exists('unmask_ss'),
+        } &>
 % } else  {
         <INPUT TYPE="hidden" NAME="ss" VALUE="<% $ss %>">
 % }
diff --git a/httemplate/edit/cust_main/stateid.html b/httemplate/edit/cust_main/stateid.html
index 3500d631c..cc0890fe1 100644
--- a/httemplate/edit/cust_main/stateid.html
+++ b/httemplate/edit/cust_main/stateid.html
@@ -1,7 +1,12 @@
 % if ( $conf->exists('show_stateid') ) {
 <TR>
   <TH ALIGN="right"><% $stateid_label %></TH>
-  <TD><INPUT TYPE="text" NAME="stateid" VALUE="<% $stateid %>" SIZE=12></TD>
+  <TD>
+    <INPUT TYPE="text" NAME="stateid" VALUE="<% $stateid %>" SIZE=12 ID="stateid">
+% if ( $FS::CurrentUser::CurrentUser->access_right( 'Unmask customer DL' )) {
+    <& /elements/link-replace_element_text.html, {target_id => 'stateid', replace_text => $cust_main->stateid} &>
+% }
+  </TD>
   <TD><& /elements/select-state.html,
           state   => $cust_main->stateid_state,
           country => $cust_main->country, # how does this work on new customer?
diff --git a/httemplate/elements/link-replace_element_text.html b/httemplate/elements/link-replace_element_text.html
new file mode 100644
index 000000000..8e611954c
--- /dev/null
+++ b/httemplate/elements/link-replace_element_text.html
@@ -0,0 +1,45 @@
+<%doc>
+
+Display a link with javascript to replace text within a element.
+
+Usage:
+
+<& /elements/link-replace_element_text.html, {
+      target_id    => 'input_id',
+      replace_text => 'hello',
+
+      element_type => 'input', # Uses jquery val()  method to replace text
+      element_type => 'div',   # Uses jquery text() method to replace text
+
+      href  => ...
+      style => ...
+      class => ...
+   }
+&>
+
+</%doc>
+<a href="<% $param{href} %>"
+   style="<% $param{style} %>"
+% if ($param{class}) {
+   class="<% $param{class} %>"
+% }
+   onClick="$('#<% $param{target_id} %>').<% $param{jmethod} %>('<% $param{replace_text} |h %>');">&#x25C1;</a>
+<%init>
+
+die "template call requires a parameter hashref" unless ref $_[0];
+
+# Defaults that can be overridden in param hashref
+my %param = (
+    target_id    => 'SPECIFY_AN_INPUT_ELEMENT_ID',
+    replace_text => 'REPLACEMENT_TEXT_FOR_INPUT_ELEMENT',
+    element_type => 'input',
+
+    link_text    => '%#x25C1;', # ◁
+    href         => 'javascript:void(0)',
+    style        => 'text-decoration:none;',
+    class        => undef,
+
+    %{ $_[0] },
+);
+$param{jmethod} = $param{element_type} eq 'input' ? 'val' : 'text';
+</%init>
diff --git a/httemplate/view/cust_main/contacts.html b/httemplate/view/cust_main/contacts.html
index 1660c1c22..367659293 100644
--- a/httemplate/view/cust_main/contacts.html
+++ b/httemplate/view/cust_main/contacts.html
@@ -29,9 +29,20 @@
     <TD COLSPAN=5><% $cust_main->contact |h %></TD>
 %   if ( $conf->exists('show_ss') ) {
     <TH ALIGN="right"><% mt('SS#') |h %></TH>
-    <TD><% $conf->exists('unmask_ss')
-                              ? $cust_main->ss
-                              : $cust_main->masked('ss') || ' ' %></TD>
+    <TD>
+      <span id="ss_span" style="white-space:nowrap;">
+      <% $conf->exists('unmask_ss')
+           ? $cust_main->ss
+           : $cust_main->masked('ss') || ' ' %>
+%   if ( !$conf->exists('unmask_ss') && $FS::CurrentUser::CurrentUser->access_right('Unmask customer SSN')) {
+      <& /elements/link-replace_element_text.html, {
+           target_id    => 'ss_span',
+           replace_text => $cust_main->ss,
+           element_type => 'span'
+      } &>
+%   }
+      </span>
+    </TD>
 %   }
   </TR>
 %   if ( $conf->exists('cust_main-enable_spouse') and
@@ -172,7 +183,18 @@
 
 <TR>
     <TH ALIGN="right"><% $stateid_label %></TH>
-    <TD><% $cust_main->masked('stateid') || '&nbsp' %></TD>
+    <TD>
+      <span id="stateid_span" style="white-space:nowrap;">
+      <% $cust_main->masked('stateid') || '&nbsp' %>
+%   if ( $FS::CurrentUser::CurrentUser->access_right('Unmask customer DL')) {
+      <& /elements/link-replace_element_text.html, {
+           target_id => 'stateid_span',
+           replace_text => $cust_main->stateid,
+           element_type => 'span'
+      } &>
+%   }
+      </span>
+    </TD>
     <TH ALIGN="right"><% $stateid_state_label %></TH>
     <TD><% $cust_main->stateid_state || '&nbsp' %></TD>
   </TR>

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

Summary of changes:
 FS/FS/AccessRight.pm                               |  2 +
 FS/FS/Conf.pm                                      |  2 +-
 FS/FS/Upgrade.pm                                   | 19 ++++++--
 FS/FS/access_group.pm                              | 50 +++++++++++++++++++++-
 httemplate/edit/cust_main.cgi                      |  2 +-
 httemplate/edit/cust_main/name.html                | 20 +++++++--
 httemplate/edit/cust_main/stateid.html             |  7 ++-
 httemplate/elements/link-replace_element_text.html | 45 +++++++++++++++++++
 httemplate/view/cust_main/contacts.html            | 34 +++++++++++++--
 9 files changed, 167 insertions(+), 14 deletions(-)
 create mode 100644 httemplate/elements/link-replace_element_text.html




More information about the freeside-commits mailing list