diff --git a/lib/NGCP/Panel/Form/CallForward/CFBNumberSetSubAPI.pm b/lib/NGCP/Panel/Form/CallForward/CFBNumberSetSubAPI.pm index 7d6e83db83..c4017e24b3 100644 --- a/lib/NGCP/Panel/Form/CallForward/CFBNumberSetSubAPI.pm +++ b/lib/NGCP/Panel/Form/CallForward/CFBNumberSetSubAPI.pm @@ -15,6 +15,11 @@ has_field 'name' => ( }, ); +has_field 'own' => ( + type => 'PosInteger', + do_label => 0, +); + has_field 'mode' => ( type => 'Select', options => [ diff --git a/lib/NGCP/Panel/Form/CallForward/CFDestinationSetSubAPI.pm b/lib/NGCP/Panel/Form/CallForward/CFDestinationSetSubAPI.pm index 97aafc2ffd..e96a982d9c 100644 --- a/lib/NGCP/Panel/Form/CallForward/CFDestinationSetSubAPI.pm +++ b/lib/NGCP/Panel/Form/CallForward/CFDestinationSetSubAPI.pm @@ -17,6 +17,11 @@ has_field 'name' => ( }, ); +has_field 'own' => ( + type => 'PosInteger', + do_label => 0, +); + has_field 'destinations' => ( type => 'Repeatable', element_attr => { diff --git a/lib/NGCP/Panel/Form/CallForward/CFSourceSetSubAPI.pm b/lib/NGCP/Panel/Form/CallForward/CFSourceSetSubAPI.pm index 29e96056bf..0b753446ca 100644 --- a/lib/NGCP/Panel/Form/CallForward/CFSourceSetSubAPI.pm +++ b/lib/NGCP/Panel/Form/CallForward/CFSourceSetSubAPI.pm @@ -15,6 +15,11 @@ has_field 'name' => ( }, ); +has_field 'own' => ( + type => 'PosInteger', + do_label => 0, +); + has_field 'mode' => ( type => 'Select', options => [ diff --git a/lib/NGCP/Panel/Form/CallForward/CFTimeSetSubAPI.pm b/lib/NGCP/Panel/Form/CallForward/CFTimeSetSubAPI.pm index b3c685bd0e..aea29b4dc2 100644 --- a/lib/NGCP/Panel/Form/CallForward/CFTimeSetSubAPI.pm +++ b/lib/NGCP/Panel/Form/CallForward/CFTimeSetSubAPI.pm @@ -12,6 +12,11 @@ has_field 'name' => ( required => 1, ); +has_field 'own' => ( + type => 'PosInteger', + do_label => 0, +); + has_field 'times' => ( type => 'Repeatable', do_wrapper => 1, diff --git a/lib/NGCP/Panel/Role/API/CFBNumberSets.pm b/lib/NGCP/Panel/Role/API/CFBNumberSets.pm index cc29bb0af4..9ce4da267d 100644 --- a/lib/NGCP/Panel/Role/API/CFBNumberSets.pm +++ b/lib/NGCP/Panel/Role/API/CFBNumberSets.pm @@ -89,6 +89,10 @@ sub resource_from_item { } $resource->{bnumbers} = \@bnumbers; + if ($c->user->roles eq 'subscriber' || $c->user->roles eq 'subscriberadmin') { + $resource->{own} = $item->subscriber_id == $c->user->id ? 1 : 0; + } + return $resource; } diff --git a/lib/NGCP/Panel/Role/API/CFDestinationSets.pm b/lib/NGCP/Panel/Role/API/CFDestinationSets.pm index 5a927b268c..38f83a7ac0 100644 --- a/lib/NGCP/Panel/Role/API/CFDestinationSets.pm +++ b/lib/NGCP/Panel/Role/API/CFDestinationSets.pm @@ -51,6 +51,10 @@ sub hal_from_item { my $b_subs_id = $item->subscriber->voip_subscriber->id; $resource{subscriber_id} = $b_subs_id; + if ($c->user->roles eq 'subscriber' || $c->user->roles eq 'subscriberadmin') { + $resource{own} = $item->subscriber_id == $c->user->id ? 1 : 0; + } + my $hal = Data::HAL->new( links => [ Data::HAL::Link->new( diff --git a/lib/NGCP/Panel/Role/API/CFSourceSets.pm b/lib/NGCP/Panel/Role/API/CFSourceSets.pm index d85e2d4e62..e1abdda394 100644 --- a/lib/NGCP/Panel/Role/API/CFSourceSets.pm +++ b/lib/NGCP/Panel/Role/API/CFSourceSets.pm @@ -41,6 +41,10 @@ sub hal_from_item { my $b_subs_id = $item->subscriber->voip_subscriber->id; $resource{subscriber_id} = $b_subs_id; + if ($c->user->roles eq 'subscriber' || $c->user->roles eq 'subscriberadmin') { + $resource{own} = $item->subscriber_id == $c->user->id ? 1 : 0; + } + my $hal = Data::HAL->new( links => [ Data::HAL::Link->new( diff --git a/lib/NGCP/Panel/Role/API/CFTimeSets.pm b/lib/NGCP/Panel/Role/API/CFTimeSets.pm index 07c2f4acfd..351a30a1bb 100644 --- a/lib/NGCP/Panel/Role/API/CFTimeSets.pm +++ b/lib/NGCP/Panel/Role/API/CFTimeSets.pm @@ -318,6 +318,10 @@ sub hal_from_item { my $b_subs_id = $item->subscriber->voip_subscriber->id; $resource{subscriber_id} = $b_subs_id; + if ($c->user->roles eq 'subscriber' || $c->user->roles eq 'subscriberadmin') { + $resource{own} = $item->subscriber_id == $c->user->id ? 1 : 0; + } + my $hal = Data::HAL->new( links => [ Data::HAL::Link->new( diff --git a/lib/NGCP/Panel/Role/API/CallForwards.pm b/lib/NGCP/Panel/Role/API/CallForwards.pm index f02c9e5cf2..61a1641ecd 100644 --- a/lib/NGCP/Panel/Role/API/CallForwards.pm +++ b/lib/NGCP/Panel/Role/API/CallForwards.pm @@ -52,7 +52,7 @@ sub hal_from_item { prov_subscriber => $prov_subs, pref_list => [qw/cfu cfb cft cfna cfs cfr cfo/], ); - @resource{qw/cfu cfb cft cfna cfs cfr cfo/} = ({}) x 5; + @resource{qw/cfu cfb cft cfna cfs cfr cfo/} = ({}) x 7; for my $item_cf ($item->provisioning_voip_subscriber->voip_cf_mappings->all) { next unless ($allowed_prefs->{$item_cf->type}); $resource{$item_cf->type} = $self->_contents_from_cfm($c, $item_cf, $item); @@ -435,6 +435,24 @@ sub _contents_from_cfm { my $dset = $dset_item ? { $dset_item->get_inflated_columns } : undef; my $bnumberset = $bnumberset_item ? { $bnumberset_item->get_inflated_columns } : undef; my $timeset = $timeset_item ? { $timeset_item->get_inflated_columns } : undef; + + if ($dset) { + $dset->{own} = + $dset_item->subscriber_id == $cfm_item->subscriber_id ? 1 : 0; + } + if ($sourceset) { + $sourceset->{own} = + $sourceset_item->subscriber_id == $cfm_item->subscriber_id ? 1 : 0; + } + if ($bnumberset) { + $bnumberset->{own} = + $bnumberset_item->subscriber_id == $cfm_item->subscriber_id ? 1 : 0; + } + if ($timeset) { + $timeset->{own} = + $timeset_item->subscriber_id == $cfm_item->subscriber_id ? 1 : 0; + } + for my $time ($timeset_item ? $timeset_item->voip_cf_periods->all : () ) { push @times, {$time->get_inflated_columns}; delete @{$times[-1]}{'time_set_id', 'id'};