hide svc_phone.sip_password like svc_acct._password unless showpasswords config is...
authorIvan Kohler <ivan@freeside.biz>
Mon, 11 Mar 2013 05:28:34 +0000 (22:28 -0700)
committerIvan Kohler <ivan@freeside.biz>
Mon, 11 Mar 2013 05:28:34 +0000 (22:28 -0700)
httemplate/edit/process/elements/process.html
httemplate/edit/process/svc_phone.html
httemplate/edit/svc_phone.cgi
httemplate/view/elements/svc_Common.html
httemplate/view/svc_cert.cgi
httemplate/view/svc_hardware.cgi
httemplate/view/svc_phone.cgi

index 2d39e9d..fb1ee7a 100644 (file)
@@ -263,6 +263,9 @@ foreach my $value ( @values ) {
 
     if ( !$error ) {
       if ( $old_pkey ) {
+
+        &{ $opt{'edit_callback'} }( $new, $old ) if $opt{'edit_callback'};
+
         $error = $new->replace($old, @args);
       } else {
         $error = $new->insert(@args);
index 611b514..27e9755 100644 (file)
@@ -2,6 +2,7 @@
                'table'          => 'svc_phone',
                'args_callback'  => $args_callback,
               'value_callback' => $value_callback,
+               'edit_callback'  => $edit_callback,
                %opt,
 &>
 <%init>
@@ -51,8 +52,13 @@ my $args_callback = sub {
 };
 
 my $value_callback = sub {
-     my ($field, $value) = @_;
-     ($field =~ /_date$/) ? parse_datetime($value) : $value;
+  my ($field, $value) = @_;
+  ($field =~ /_date$/) ? parse_datetime($value) : $value;
+};
+
+my $edit_callback = sub {
+  my( $new, $old ) = @_;
+  $new->sip_password( $old->sip_password ) if $new->sip_password eq '*HIDDEN*';
 };
 
 </%init>
index 8ee71b8..13bbe82 100644 (file)
@@ -6,6 +6,11 @@
        my( $cgi, $svc_x, $part_svc, $cust_pkg, $fields, $opt ) = @_;
        $svc_x->locationnum($cust_pkg->locationnum) if $cust_pkg;
      },
+     'svc_edit_callback' => sub {
+       my( $cgi, $svc_x, $part_svc, $cust_pkg, $fields, $opt) = @_;
+       my $conf = new FS::Conf;
+       $svc_x->sip_password('*HIDDEN*') unless $conf->exists('showpasswords');
+     },
 &>
 <%init>
 
index 46b9c28..a7f8f6d 100644 (file)
@@ -59,16 +59,20 @@ function areyousure(href) {
 
 % foreach my $f ( @$fields ) {
 %
-%   my($field, $type, $value, $hack_strict_refs);
+%   my($field, $type, $value);
 %   if ( ref($f) ) {
 %     $field = $f->{'field'};
-%     $hack_strict_refs = \&{ $f->{'value'} } if $f->{'value'};
-%     $value = $f->{'value'} ? &$hack_strict_refs($svc_x) : $svc_x->$field;
 %     $type  = $f->{'type'} || 'text';
+%     if ( $f->{'value_callback'} ) {
+%       my $hack_strict_refs = \&{ $f->{'value_callback'} };
+%       $value = &$hack_strict_refs($svc_x);
+%     } else {
+%       $value = exists($f->{'value'}) ? $f->{'value'} : $svc_x->$field;
+%     }
 %   } else {
 %     $field = $f;
-%     $value = $svc_x->$field;
 %     $type = 'text';
+%     $value = $svc_x->$field;
 %   }
 %
 %   my $columndef = $part_svc->part_svc_column($field);
index 0cd66b4..964b808 100644 (file)
@@ -17,7 +17,7 @@ my %labels = map { $_ =>  ( ref($fields->{$_})
 
 my @fields = (
   { field=>'privatekey',
-    value=> sub {
+    value_callback=> sub {
       my $svc_cert = shift;
       if ( $svc_cert->privatekey && $svc_cert->check_privatekey ) {
         '<FONT COLOR="#33ff33">Verification OK</FONT>';
@@ -31,7 +31,7 @@ my @fields = (
   qw( common_name organization organization_unit city state country cert_contact
     ),
   { 'field'=>'csr',
-    'value'=> sub {
+    'value_callback'=> sub {
       my $svc_cert = shift;
       if ( $svc_cert->csr ) {
 
@@ -67,7 +67,7 @@ my @fields = (
     },
   },
   { 'field'=>'certificate',
-    'value'=> sub {
+    'value_callback'=> sub {
       my $svc_cert = shift;
       if ( $svc_cert->certificate ) {
 
@@ -137,7 +137,7 @@ my @fields = (
     },
   },
   { 'field'=>'cacert',
-    'value'=> sub {
+    'value_callback'=> sub {
       my $svc_cert = shift;
       if ( $svc_cert->cacert ) {
 
index 7f5e889..aa3ff00 100644 (file)
@@ -15,15 +15,15 @@ my %labels = map { $_ =>  ( ref($fields->{$_})
                  } keys %$fields;
 my $model =  { field => 'typenum',
                type  => 'text',
-               value => sub { $_[0]->hardware_type->description }
+               value_callback => sub { $_[0]->hardware_type->description }
              };
 my $status = { field => 'statusnum',
                type  => 'text',
-               value => sub { $_[0]->status_label }
+               value_callback => sub { $_[0]->status_label }
              };
 my $note =   { field => 'note',
                type  => 'text',
-               value => sub { encode_entities($_[0]->note) }
+               value_callback => sub { encode_entities($_[0]->note) }
              };
 
 my @fields = (
index e956e7d..ed95c4c 100644 (file)
@@ -18,7 +18,18 @@ my %labels = map { $_ =>  ( ref($fields->{$_})
 
 my @fields = qw( countrycode phonenum sim_imsi );
 push @fields, 'domain' if $conf->exists('svc_phone-domain');
-push @fields, qw( pbx_title sip_password pin phone_name forwarddst email );
+push @fields, qw( pbx_title );
+
+if ( $conf->exists('showpasswords') ) {
+  push @fields, qw( sip_password );
+} else {
+  push @fields, { 'field' => 'sip_password', #'_HIDDEN_sip_password',
+                  'type'  => 'fixed',
+                  'value' => '<I>('. mt('hidden') .')</I>',
+                };
+}
+
+push @fields, qw( pin phone_name forwarddst email );
 
 if ( $conf->exists('svc_phone-lnp') ) {
 push @fields, 'lnp_status',