MT#8547 - Fix smartmatch ~~ usage

changes/94/294/1
Kirill Solomko 11 years ago
parent 8b5e80ca53
commit e4ecca76e9

@ -72,7 +72,7 @@ sub GET : Allow {
my $actions = []; my $actions = [];
if($c->user->read_only) { if($c->user->read_only) {
foreach my $m(keys %{ $full_mod->config->{action} }) { foreach my $m(keys %{ $full_mod->config->{action} }) {
next unless $m ~~ [qw/GET HEAD OPTIONS/]; next unless $m =~ /^(GET|HEAD|OPTIONS)$/;
push @{ $actions }, $m; push @{ $actions }, $m;
} }
} else { } else {
@ -82,7 +82,7 @@ sub GET : Allow {
if($full_item_mod->can('config')) { if($full_item_mod->can('config')) {
if($c->user->read_only) { if($c->user->read_only) {
foreach my $m(keys %{ $full_item_mod->config->{action} }) { foreach my $m(keys %{ $full_item_mod->config->{action} }) {
next unless $m ~~ [qw/GET HEAD OPTIONS/]; next unless $m =~ /^(GET|HEAD|OPTIONS)$/;
push @{ $item_actions }, $m; push @{ $item_actions }, $m;
} }
} else { } else {

@ -80,7 +80,7 @@ sub auto :Private {
} else { } else {
$c->log->debug("++++++ admin '".$c->user->login."' authenticated via api_admin_cert"); $c->log->debug("++++++ admin '".$c->user->login."' authenticated via api_admin_cert");
} }
if($c->user->read_only && !($c->req->method ~~ [qw/GET HEAD OPTIONS/])) { if($c->user->read_only && !($c->req->method =~ /^(GET|HEAD|OPTIONS)$/)) {
$c->log->error("invalid method '".$c->req->method."' for read-only user '".$c->user->login."', rejecting"); $c->log->error("invalid method '".$c->req->method."' for read-only user '".$c->user->login."', rejecting");
$c->user->logout; $c->user->logout;
$c->response->status(403); $c->response->status(403);
@ -108,7 +108,7 @@ sub auto :Private {
} else { } else {
$c->log->debug("++++++ admin '".$c->user->login."' authenticated via api_admin_http"); $c->log->debug("++++++ admin '".$c->user->login."' authenticated via api_admin_http");
} }
if($c->user->read_only && !($c->req->method ~~ [qw/GET HEAD OPTIONS/])) { if($c->user->read_only && !($c->req->method =~ /^(GET|HEAD|OPTIONS)$/)) {
$c->log->error("invalid method '".$c->req->method."' for read-only user '".$c->user->login."', rejecting"); $c->log->error("invalid method '".$c->req->method."' for read-only user '".$c->user->login."', rejecting");
$c->user->logout; $c->user->logout;
$c->response->status(403); $c->response->status(403);
@ -153,7 +153,7 @@ sub auto :Private {
$c->req->uri->path =~ /create/ $c->req->uri->path =~ /create/
|| $c->req->uri->path =~ /edit/ || $c->req->uri->path =~ /edit/
|| $c->req->uri->path =~ /delete/ || $c->req->uri->path =~ /delete/
|| !($c->req->method ~~ [qw/GET HEAD OPTIONS/]) || !($c->req->method =~ /^(GET|HEAD|OPTIONS)$/)
)) { )) {
$c->detach('/denied_page'); $c->detach('/denied_page');
} }
@ -227,7 +227,7 @@ sub end :Private {
sub _prune_row { sub _prune_row {
my ($columns, %row) = @_; my ($columns, %row) = @_;
while (my ($k,$v) = each %row) { while (my ($k,$v) = each %row) {
unless ($k ~~ $columns) { unless (grep { $k eq $_ } @$columns) {
delete $row{$k}; delete $row{$k};
next; next;
} }

@ -30,7 +30,7 @@ sub index :Chained('/') :PathPart('statistics') :Args(0) {
my $hosts = NGCP::Panel::Utils::Statistics::get_host_list(); my $hosts = NGCP::Panel::Utils::Statistics::get_host_list();
unless($posted) { unless($posted) {
my $ownhost = hostname; my $ownhost = hostname;
if($ownhost ~~ @{ $hosts }) { if(grep { $ownhost eq $_ } @$hosts) {
$selected_host = $ownhost; $selected_host = $ownhost;
} else { } else {
$selected_host = $hosts->[0]; $selected_host = $hosts->[0];

@ -748,10 +748,11 @@ sub preferences :Chained('base') :PathPart('preferences') :Args(0) {
}); });
next unless $preference; next unless $preference;
my $pref_id = $preference->id; my $pref_id = $preference->id;
if($pref =~ /^cf/ && $pref_id ~~ [@attribute_ids]) { my $pref_id_exists = grep { $pref_id eq $_ } @attribute_ids;
if($pref =~ /^cf/ && $pref_id_exists) {
$special_prefs->{callforward}->{active} = 1; $special_prefs->{callforward}->{active} = 1;
$special_prefs->{callforward}->{$pref} = 1; $special_prefs->{callforward}->{$pref} = 1;
} elsif($pref_id ~~ [@attribute_ids]) { } elsif($pref_id_exists) {
$special_prefs->{$pref}->{active} = 1; $special_prefs->{$pref}->{active} = 1;
} }
} }
@ -2389,7 +2390,7 @@ sub edit_master :Chained('master') :PathPart('edit') :Args(0) :Does(ACL) :ACLDet
my $group = $schema->resultset('voip_subscribers')->find($group_id); my $group = $schema->resultset('voip_subscribers')->find($group_id);
next unless($group && $group->provisioning_voip_subscriber && $group->provisioning_voip_subscriber->is_pbx_group); next unless($group && $group->provisioning_voip_subscriber && $group->provisioning_voip_subscriber->is_pbx_group);
push @new_groups, $group->provisioning_voip_subscriber->id; push @new_groups, $group->provisioning_voip_subscriber->id;
unless($group->provisioning_voip_subscriber->id ~~ [ @old_groups ]) { unless(grep { $group->provisioning_voip_subscriber->id eq $_ } @old_groups) {
$prov_subscriber->voip_pbx_groups->create({ $prov_subscriber->voip_pbx_groups->create({
group_id => $group->provisioning_voip_subscriber->id, group_id => $group->provisioning_voip_subscriber->id,
}); });
@ -2405,7 +2406,7 @@ sub edit_master :Chained('master') :PathPart('edit') :Args(0) :Does(ACL) :ACLDet
} }
foreach my $group_id(@old_groups) { foreach my $group_id(@old_groups) {
# remove subscriber from group if not there anymore # remove subscriber from group if not there anymore
unless($group_id ~~ [ @new_groups ]) { unless(grep { $group_id eq $_ } @new_groups) {
my $group = $schema->resultset('provisioning_voip_subscribers')->find($group_id); my $group = $schema->resultset('provisioning_voip_subscribers')->find($group_id);
NGCP::Panel::Utils::Subscriber::update_pbx_group_prefs( NGCP::Panel::Utils::Subscriber::update_pbx_group_prefs(
c => $c, c => $c,

@ -39,7 +39,7 @@ sub set_slots {
} }
foreach my $s(@{ $self->form->ctx->config->{speed_dial_vsc_presets}->{vsc} }) foreach my $s(@{ $self->form->ctx->config->{speed_dial_vsc_presets}->{vsc} })
{ {
if($s ~~ @used) { if(grep { $s eq $_ } @used) {
next unless(defined $current && $s eq $current); next unless(defined $current && $s eq $current);
} }
push @options, { label => $s, value => $s }; push @options, { label => $s, value => $s };

@ -203,7 +203,7 @@ sub valid_media_type {
my $type; my $type;
if(ref $media_type eq "ARRAY") { if(ref $media_type eq "ARRAY") {
$type = join ' or ', @{ $media_type }; $type = join ' or ', @{ $media_type };
return 1 if $ctype && $ctype ~~ $media_type; return 1 if $ctype && grep { $ctype eq $_ } @$media_type;
} else { } else {
$type = $media_type; $type = $media_type;
return 1 if($ctype && index($ctype, $media_type) == 0); return 1 if($ctype && index($ctype, $media_type) == 0);
@ -258,7 +258,7 @@ sub allowed_methods_filtered {
if($c->user->read_only) { if($c->user->read_only) {
my @methods = (); my @methods = ();
foreach my $m(@{ $self->allowed_methods }) { foreach my $m(@{ $self->allowed_methods }) {
next unless $m ~~ [qw/GET HEAD OPTIONS/]; next unless $m =~ /^(GET|HEAD|OPTIONS)$/;
push @methods, $m; push @methods, $m;
} }
return \@methods; return \@methods;
@ -274,7 +274,7 @@ sub allowed_methods {
for my $method ($meta->get_method_list) { for my $method ($meta->get_method_list) {
push @allow, $meta->get_method($method)->name push @allow, $meta->get_method($method)->name
if $meta->get_method($method)->can('attributes') && if $meta->get_method($method)->can('attributes') &&
'Allow' ~~ $meta->get_method($method)->attributes; grep { 'Allow' eq $_ } @{ $meta->get_method($method)->attributes };
} }
return [sort @allow]; return [sort @allow];
} }

@ -623,7 +623,7 @@ sub update_item {
my @new_groups = (); my @new_groups = ();
foreach my $group(@{ $groups }) { foreach my $group(@{ $groups }) {
push @new_groups, $group->provisioning_voip_subscriber->id; push @new_groups, $group->provisioning_voip_subscriber->id;
unless($group->provisioning_voip_subscriber->id ~~ [ @old_groups ]) { unless(grep { $group->provisioning_voip_subscriber->id eq $_ } @old_groups) {
$subscriber->provisioning_voip_subscriber->voip_pbx_groups->create({ $subscriber->provisioning_voip_subscriber->voip_pbx_groups->create({
group_id => $group->provisioning_voip_subscriber->id, group_id => $group->provisioning_voip_subscriber->id,
}); });
@ -643,7 +643,7 @@ sub update_item {
} }
foreach my $group_id(@old_groups) { foreach my $group_id(@old_groups) {
# remove subscriber from group if not there anymore # remove subscriber from group if not there anymore
unless($group_id ~~ [ @new_groups ]) { unless(grep { $group_id eq $_ } @new_groups) {
my $group = $schema->resultset('provisioning_voip_subscribers')->find($group_id); my $group = $schema->resultset('provisioning_voip_subscribers')->find($group_id);
NGCP::Panel::Utils::Subscriber::update_pbx_group_prefs( NGCP::Panel::Utils::Subscriber::update_pbx_group_prefs(
c => $c, c => $c,

@ -697,7 +697,7 @@ sub update_subadmin_sub_aliases {
my $cli = $num->cc . ($num->ac // '') . $num->sn; my $cli = $num->cc . ($num->ac // '') . $num->sn;
my $tmpsubscriber; my $tmpsubscriber;
if ($num->id ~~ $alias_selected) { if (grep { $num->id eq $_ } @$alias_selected) {
# assign number from someone to this subscriber # assign number from someone to this subscriber
# since the number could be assigned to any sub within the pbx, # since the number could be assigned to any sub within the pbx,
@ -973,7 +973,7 @@ sub apply_rewrite {
my $subscriber = $params{subscriber}; my $subscriber = $params{subscriber};
my $callee = $params{number}; my $callee = $params{number};
my $dir = $params{direction}; my $dir = $params{direction};
return $callee unless $dir ~~ [qw/caller_in callee_in caller_out callee_out/]; return $callee unless $dir =~ /^(caller_in|callee_in|caller_out|callee_out)$/;
my ($field, $direction) = split /_/, $dir; my ($field, $direction) = split /_/, $dir;
$dir = "rewrite_".$dir."_dpid"; $dir = "rewrite_".$dir."_dpid";
@ -1019,7 +1019,7 @@ sub apply_rewrite {
foreach my $sub($subscriber->contract->voip_subscribers->all) { foreach my $sub($subscriber->contract->voip_subscribers->all) {
foreach my $num($sub->voip_numbers->search({ status => 'active' })->all) { foreach my $num($sub->voip_numbers->search({ status => 'active' })->all) {
my $v = $num->cc . ($num->ac // '') . $num->sn; my $v = $num->cc . ($num->ac // '') . $num->sn;
unless($v ~~ $cache->{$avp}) { unless(grep { $v eq $_ } @{ $cache->{$avp} }) {
push @{ $cache->{$avp} }, $v; push @{ $cache->{$avp} }, $v;
} }
} }

Loading…
Cancel
Save