if ( !$error ) {
if ( $old_pkey ) {
+
+ &{ $opt{'edit_callback'} }( $new, $old ) if $opt{'edit_callback'};
+
$error = $new->replace($old, @args);
} else {
$error = $new->insert(@args);
'table' => 'svc_phone',
'args_callback' => $args_callback,
'value_callback' => $value_callback,
+ 'edit_callback' => $edit_callback,
%opt,
&>
<%init>
};
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>
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>
% 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);
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>';
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 ) {
},
},
{ 'field'=>'certificate',
- 'value'=> sub {
+ 'value_callback'=> sub {
my $svc_cert = shift;
if ( $svc_cert->certificate ) {
},
},
{ 'field'=>'cacert',
- 'value'=> sub {
+ 'value_callback'=> sub {
my $svc_cert = shift;
if ( $svc_cert->cacert ) {
} 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 = (
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',