|
Lines 470-473
sub guarantors_can_see_checkouts {
Link Here
|
| 470 |
}; |
470 |
}; |
| 471 |
} |
471 |
} |
| 472 |
|
472 |
|
|
|
473 |
sub _parse_dbic_query_for_dt { |
| 474 |
my ($q_params,$collector) = @_; |
| 475 |
my %allowed_keys = ( |
| 476 |
'me.phone' => 1, |
| 477 |
'me.phonepro' => 1, |
| 478 |
'me.B_phone' => 1, |
| 479 |
'me.altcontactphone' => 1, |
| 480 |
'me.mobile' => 1, |
| 481 |
); |
| 482 |
if(ref($q_params) && ref($q_params) eq 'HASH') { |
| 483 |
foreach my $key (keys %{$q_params}) { |
| 484 |
if ($allowed_keys{$key}){ |
| 485 |
my $query = $q_params->{$key}; |
| 486 |
if ($query->{'like'}){ |
| 487 |
my $like = $query->{'like'}; |
| 488 |
#NOTE: Remove the hashref, and add a data structure to add to the WHERE clause via the attributes... |
| 489 |
delete $q_params->{$key}; |
| 490 |
my $collection = \["regexp_replace($key,?,?) LIKE ?","[^0-9]","",$like]; |
| 491 |
push(@$collector,$collection); |
| 492 |
} |
| 493 |
} |
| 494 |
else { |
| 495 |
$q_params->{$key} = _parse_dbic_query_for_dt($q_params->{$key},$collector); |
| 496 |
} |
| 497 |
} |
| 498 |
return $q_params; |
| 499 |
} elsif (ref($q_params) && ref($q_params) eq 'ARRAY') { |
| 500 |
foreach my $param (@$q_params){ |
| 501 |
$param = _parse_dbic_query_for_dt($param,$collector); |
| 502 |
} |
| 503 |
return $q_params; |
| 504 |
} else { |
| 505 |
return $q_params; |
| 506 |
} |
| 507 |
} |
| 508 |
|
| 509 |
=head3 preprocess_dbic_for_datatables |
| 510 |
|
| 511 |
Method for preprocessing DBIC queries sent from DataTables, so a WHERE |
| 512 |
clause can be injected into the query if one doesn't already exist. |
| 513 |
|
| 514 |
=cut |
| 515 |
|
| 516 |
sub preprocess_dbic_for_datatables { |
| 517 |
my ($c,$q_params,$attributes) = @_; |
| 518 |
my @collector = (); |
| 519 |
my $rewritten_q_params = _parse_dbic_query_for_dt($q_params,\@collector); |
| 520 |
unless ($attributes->{where}){ |
| 521 |
foreach my $collection (@collector){ |
| 522 |
push(@{$attributes->{where}},$collection); |
| 523 |
} |
| 524 |
} |
| 525 |
return 1; |
| 526 |
} |
| 527 |
|
| 473 |
1; |
528 |
1; |