MT#6497 API: callforwards, better validation

agranig/subprof
Gerhard Jungwirth 11 years ago
parent 237ebdad95
commit a7483ca351

@ -17,7 +17,7 @@ has_field 'cfu' => (
type => 'Compound',
do_wrapper => 1,
do_label => 0,
required => 1,
required => 0,
element_attr => {
rel => ['tooltip'],
title => ['Call Forward Unconditional']
@ -28,7 +28,7 @@ has_field 'cfb' => (
type => 'Compound',
do_wrapper => 1,
do_label => 0,
required => 1,
required => 0,
element_attr => {
rel => ['tooltip'],
title => ['Call Forward Busy']
@ -39,7 +39,7 @@ has_field 'cft' => (
type => 'Compound',
do_wrapper => 1,
do_label => 0,
required => 1,
required => 0,
element_attr => {
rel => ['tooltip'],
title => ['Call Forward Timeout']
@ -50,7 +50,7 @@ has_field 'cfna' => (
type => 'Compound',
do_wrapper => 1,
do_label => 0,
required => 1,
required => 0,
element_attr => {
rel => ['tooltip'],
title => ['Call Forward Unavailable']
@ -68,7 +68,7 @@ has_field 'cfu.destinations.destination' => (
);
has_field 'cfu.destinations.timeout' => (
type => 'Text',
type => 'PosInteger',
);
has_field 'cfu.times' => (
@ -88,7 +88,7 @@ has_field 'cfb.destinations.destination' => (
);
has_field 'cfb.destinations.timeout' => (
type => 'Text',
type => 'PosInteger',
);
has_field 'cfb.times' => (
@ -108,7 +108,7 @@ has_field 'cft.destinations.destination' => (
);
has_field 'cft.destinations.timeout' => (
type => 'Text',
type => 'PosInteger',
);
has_field 'cft.times' => (
@ -128,7 +128,7 @@ has_field 'cfna.destinations.destination' => (
);
has_field 'cfna.destinations.timeout' => (
type => 'Text',
type => 'PosInteger',
);
has_field 'cfna.times' => (

@ -115,6 +115,24 @@ sub update_item {
die "need provisioning_voip_subscriber" unless $prov_subs;
my $prov_subscriber_id = $prov_subs->id;
return unless $self->validate_form(
c => $c,
form => $form,
resource => $resource,
run => 1,
);
for my $type (qw/cfu cfb cft cfna/) {
next unless "ARRAY" eq ref $resource->{$type}{destinations};
for my $d (@{ $resource->{$type}{destinations} }) {
if (exists $d->{timeout} && ! $d->{timeout}->is_integer) {
$c->log->error("Invalid timeout in '$type'");
$self->error($c, HTTP_UNPROCESSABLE_ENTITY, "Invalid timeout in '$type'");
return;
}
}
}
for my $type (qw/cfu cfb cft cfna/) {
my $mapping = $c->model('DB')->resultset('voip_cf_mappings')->search_rs({
subscriber_id => $prov_subscriber_id,
@ -215,13 +233,6 @@ sub update_item {
}
}
return unless $self->validate_form(
c => $c,
form => $form,
resource => $resource,
run => 0,
);
return $item;
}

Loading…
Cancel
Save