set numbered parameters using entry::set_numbers
This commit is contained in:
38
lib/calcms/entry.pm
Normal file
38
lib/calcms/entry.pm
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package entry;
|
||||||
|
|
||||||
|
use warnings;
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
sub from_valid($$) {
|
||||||
|
my ( $params, $attrs ) = @_;
|
||||||
|
return { map { defined $params->{$_} ? { $_ => $params->{$_} } : () } @$attrs };
|
||||||
|
}
|
||||||
|
|
||||||
|
sub set_numbers($$$) {
|
||||||
|
my ( $entry, $params, $fields ) = @_;
|
||||||
|
for my $field (@$fields) {
|
||||||
|
next unless defined $params->{$field};
|
||||||
|
if ( $params->{$field} =~ /([\-\d]+)/ ){
|
||||||
|
$entry->{$field} = $1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub set_strings($$$) {
|
||||||
|
my ( $entry, $params, $attrs ) = @_;
|
||||||
|
for my $field (@$attrs) {
|
||||||
|
next unless defined $params->{$field};
|
||||||
|
$entry->{$field} = $params->{$field};
|
||||||
|
$entry->{$field} =~ s/^\s+//g;
|
||||||
|
$entry->{$field} =~ s/\s+$//g;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub element_of($$) {
|
||||||
|
my ( $value, $attrs ) = @_;
|
||||||
|
return { map { $_ => $_ } @$attrs }->{$value};
|
||||||
|
}
|
||||||
|
|
||||||
|
# do not delete last line
|
||||||
|
1;
|
||||||
@@ -222,11 +222,9 @@ sub check_params {
|
|||||||
|
|
||||||
#numeric values
|
#numeric values
|
||||||
$checked->{exclude} = 0;
|
$checked->{exclude} = 0;
|
||||||
for my $param ( 'id', 'project_id', 'studio_id', 'series_id' ) {
|
entry::set_numbers( $checked, $params, [
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
'id', 'project_id', 'studio_id', 'series_id'
|
||||||
$checked->{$param} = $params->{$param};
|
]);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( defined $checked->{studio_id} ) {
|
if ( defined $checked->{studio_id} ) {
|
||||||
$checked->{default_studio_id} = $checked->{studio_id};
|
$checked->{default_studio_id} = $checked->{studio_id};
|
||||||
|
|||||||
@@ -368,11 +368,9 @@ sub check_params {
|
|||||||
|
|
||||||
#numeric values
|
#numeric values
|
||||||
$checked->{exclude} = 0;
|
$checked->{exclude} = 0;
|
||||||
for my $param ( 'id', 'project_id', 'studio_id', 'series_id', 'event_id' ) {
|
entry::set_numbers( $checked, $params, [
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
'id', 'project_id', 'studio_id', 'series_id', 'event_id'
|
||||||
$checked->{$param} = $params->{$param};
|
]);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for my $param ('event_ids') {
|
for my $param ('event_ids') {
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^[\d,]+$/ ) ) {
|
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^[\d,]+$/ ) ) {
|
||||||
|
|||||||
@@ -545,13 +545,8 @@ sub check_params {
|
|||||||
$checked->{template} =
|
$checked->{template} =
|
||||||
template::check( $config, $params->{template}, 'upload-audio-recordings' );
|
template::check( $config, $params->{template}, 'upload-audio-recordings' );
|
||||||
|
|
||||||
#numeric values
|
entry::set_numbers( $checked, $params, [
|
||||||
for my $param ( 'project_id', 'studio_id', 'default_studio_id', 'series_id', 'event_id', 'id' )
|
'project_id', 'studio_id', 'default_studio_id', 'series_id', 'event_id', 'id']);
|
||||||
{
|
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
|
||||||
$checked->{$param} = $params->{$param};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( defined $checked->{studio_id} ) {
|
if ( defined $checked->{studio_id} ) {
|
||||||
$checked->{default_studio_id} = $checked->{studio_id};
|
$checked->{default_studio_id} = $checked->{studio_id};
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use utf8();
|
|||||||
use params();
|
use params();
|
||||||
use config();
|
use config();
|
||||||
use log();
|
use log();
|
||||||
|
use entry();
|
||||||
use template();
|
use template();
|
||||||
use calendar();
|
use calendar();
|
||||||
use auth();
|
use auth();
|
||||||
@@ -1871,25 +1872,15 @@ sub check_params {
|
|||||||
my $template = '';
|
my $template = '';
|
||||||
$checked->{template} = template::check( $config, $params->{template}, 'series' );
|
$checked->{template} = template::check( $config, $params->{template}, 'series' );
|
||||||
|
|
||||||
my $debug = $params->{debug} || '';
|
|
||||||
if ( $debug =~ /([a-z\_\,]+)/ ) {
|
|
||||||
$debug = $1;
|
|
||||||
}
|
|
||||||
$checked->{debug} = $debug;
|
|
||||||
|
|
||||||
#numeric values
|
#numeric values
|
||||||
$checked->{part} = 0;
|
$checked->{part} = 0;
|
||||||
$checked->{list} = 0;
|
$checked->{list} = 0;
|
||||||
for my $param (
|
$checked->{open_end} = 1;
|
||||||
|
entry::set_numbers( $checked, $params, [
|
||||||
'id', 'project_id', 'studio_id', 'default_studio_id',
|
'id', 'project_id', 'studio_id', 'default_studio_id',
|
||||||
'user_id', 'series_id', 'event_id', 'part',
|
'user_id', 'series_id', 'event_id', 'part',
|
||||||
'list', 'day_start'
|
'list', 'day_start', 'open_end'
|
||||||
)
|
]);
|
||||||
{
|
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
|
||||||
$checked->{$param} = $params->{$param};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$checked->{day_start} = $config->{date}->{day_starting_hour}
|
$checked->{day_start} = $config->{date}->{day_starting_hour}
|
||||||
unless defined $checked->{day_start};
|
unless defined $checked->{day_start};
|
||||||
@@ -1909,56 +1900,27 @@ sub check_params {
|
|||||||
$checked->{studio_id} = $checked->{default_studio_id};
|
$checked->{studio_id} = $checked->{default_studio_id};
|
||||||
}
|
}
|
||||||
|
|
||||||
$checked->{open_end} = 1;
|
for my $param ('expires') {
|
||||||
for my $param ('open_end') {
|
$checked->{$param} = time::check_datetime( $params->{$param} );
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
|
||||||
$checked->{$param} = $params->{$param};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#scalars
|
#scalars
|
||||||
$checked->{search} = '';
|
$checked->{search} = '';
|
||||||
$checked->{filter} = '';
|
$checked->{filter} = '';
|
||||||
|
|
||||||
#$checked->{range}='month';
|
|
||||||
for my $param ( 'search', 'filter', 'range' ) {
|
|
||||||
if ( defined $params->{$param} ) {
|
|
||||||
$checked->{$param} = $params->{$param};
|
|
||||||
$checked->{$param} =~ s/^\s+//g;
|
|
||||||
$checked->{$param} =~ s/\s+$//g;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for my $param ('expires') {
|
|
||||||
$checked->{$param} = time::check_datetime( $params->{$param} );
|
|
||||||
}
|
|
||||||
|
|
||||||
for my $param ( 'date', 'from_date', 'till_date' ) {
|
for my $param ( 'date', 'from_date', 'till_date' ) {
|
||||||
$checked->{$param} = time::check_date( $params->{$param} );
|
$checked->{$param} = time::check_date( $params->{$param} );
|
||||||
}
|
}
|
||||||
|
|
||||||
for my $param (
|
entry::set_strings( $checked, $params, [
|
||||||
|
'search', 'filter', 'range',
|
||||||
'series_name', 'title', 'excerpt', 'content',
|
'series_name', 'title', 'excerpt', 'content',
|
||||||
'program', 'category', 'image', 'user_content'
|
'program', 'category', 'image', 'user_content'
|
||||||
)
|
]);
|
||||||
{
|
|
||||||
if ( defined $params->{$param} ) {
|
|
||||||
|
|
||||||
#$checked->{$param}=uri_unescape();
|
$checked->{action} = entry::element_of( $params->{action},
|
||||||
$checked->{$param} = $params->{$param};
|
[ 'add_user', 'remove_user', 'delete', 'save', 'details', 'show', 'edit_event', 'save_event' ]
|
||||||
$checked->{$param} =~ s/^\s+//g;
|
);
|
||||||
$checked->{$param} =~ s/\s+$//g;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#actions and roles
|
|
||||||
if ( defined $params->{action} ) {
|
|
||||||
if ( $params->{action} =~
|
|
||||||
/^(add_user|remove_user|delete|save|details|show|edit_event|save_event)$/ )
|
|
||||||
{
|
|
||||||
$checked->{action} = $params->{action};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $checked;
|
return $checked;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,12 +260,9 @@ sub check_params {
|
|||||||
}
|
}
|
||||||
$checked->{template} = $template;
|
$checked->{template} = $template;
|
||||||
|
|
||||||
#numeric values
|
entry::set_numbers( $checked, $params, [
|
||||||
for my $param ( 'project_id', 'studio_id', 'default_studio_id' ) {
|
'project_id', 'studio_id', 'default_studio_id']);
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
|
||||||
$checked->{$param} = $params->{$param};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( defined $checked->{studio_id} ) {
|
if ( defined $checked->{studio_id} ) {
|
||||||
$checked->{default_studio_id} = $checked->{studio_id};
|
$checked->{default_studio_id} = $checked->{studio_id};
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -219,11 +219,8 @@ sub check_params {
|
|||||||
#numeric values
|
#numeric values
|
||||||
$checked->{exclude} = 0;
|
$checked->{exclude} = 0;
|
||||||
$checked->{duration} = 28;
|
$checked->{duration} = 28;
|
||||||
for my $param ( 'id', 'project_id', 'studio_id', 'duration' ) {
|
entry::set_numbers( $checked, $params, [
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
'id', 'project_id', 'studio_id', 'duration']);
|
||||||
$checked->{$param} = $params->{$param};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( defined $checked->{studio_id} ) {
|
if ( defined $checked->{studio_id} ) {
|
||||||
$checked->{default_studio_id} = $checked->{studio_id};
|
$checked->{default_studio_id} = $checked->{studio_id};
|
||||||
|
|||||||
@@ -254,13 +254,9 @@ sub check_params {
|
|||||||
$checked->{debug} = $debug;
|
$checked->{debug} = $debug;
|
||||||
|
|
||||||
#numeric values
|
#numeric values
|
||||||
for
|
entry::set_numbers( $checked, $params, [
|
||||||
my $param ( 'id', 'project_id', 'studio_id', 'default_studio_id', 'user_id', 'series_id', 'event_id', 'v1', 'v2' )
|
'id', 'project_id', 'studio_id', 'default_studio_id', 'user_id', 'series_id', 'event_id', 'v1', 'v2' )
|
||||||
{
|
]);
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
|
||||||
$checked->{$param} = $params->{$param};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( defined $checked->{studio_id} ) {
|
if ( defined $checked->{studio_id} ) {
|
||||||
$checked->{default_studio_id} = $checked->{studio_id};
|
$checked->{default_studio_id} = $checked->{studio_id};
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use Encode::Locale();
|
|||||||
use params();
|
use params();
|
||||||
use config();
|
use config();
|
||||||
use log();
|
use log();
|
||||||
|
use entry();
|
||||||
use template();
|
use template();
|
||||||
use db();
|
use db();
|
||||||
use auth();
|
use auth();
|
||||||
@@ -807,17 +808,11 @@ sub check_params {
|
|||||||
}
|
}
|
||||||
$checked->{debug} = $debug;
|
$checked->{debug} = $debug;
|
||||||
|
|
||||||
#numeric values
|
entry::set_numbers( $checked, $params, [
|
||||||
for my $param (
|
|
||||||
'id', 'project_id', 'studio_id', 'default_studio_id',
|
'id', 'project_id', 'studio_id', 'default_studio_id',
|
||||||
'user_id', 'series_id', 'event_id', 'source_event_id',
|
'user_id', 'series_id', 'event_id', 'source_event_id',
|
||||||
'episode'
|
'episode'
|
||||||
)
|
]);
|
||||||
{
|
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
|
||||||
$checked->{$param} = $params->{$param};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( defined $checked->{studio_id} ) {
|
if ( defined $checked->{studio_id} ) {
|
||||||
$checked->{default_studio_id} = $checked->{studio_id};
|
$checked->{default_studio_id} = $checked->{studio_id};
|
||||||
|
|||||||
@@ -628,11 +628,9 @@ sub check_params {
|
|||||||
|
|
||||||
#numeric values
|
#numeric values
|
||||||
$checked->{exclude} = 0;
|
$checked->{exclude} = 0;
|
||||||
for my $param ( 'id', 'project_id', 'studio_id', 'default_studio_id' ) {
|
entry::set_numbers( $checked, $params, [
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
'id', 'project_id', 'studio_id', 'default_studio_id' ]);
|
||||||
$checked->{$param} = $params->{$param};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( defined $checked->{studio_id} ) {
|
if ( defined $checked->{studio_id} ) {
|
||||||
$checked->{default_studio_id} = $checked->{studio_id};
|
$checked->{default_studio_id} = $checked->{studio_id};
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -371,9 +371,9 @@ sub check_params {
|
|||||||
$checked->{template} = template::check( $config, $params->{template}, 'image-upload' );
|
$checked->{template} = template::check( $config, $params->{template}, 'image-upload' );
|
||||||
|
|
||||||
#numeric values
|
#numeric values
|
||||||
for my $param ( 'project_id', 'studio_id', 'default_studio_id' ) {
|
entry::set_numbers( $checked, $params, [
|
||||||
$checked->{$param} = $params->{$param} if ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ );
|
'project_id', 'studio_id', 'default_studio_id'
|
||||||
}
|
]);
|
||||||
|
|
||||||
if ( defined $checked->{studio_id} ) {
|
if ( defined $checked->{studio_id} ) {
|
||||||
$checked->{default_studio_id} = $checked->{studio_id};
|
$checked->{default_studio_id} = $checked->{studio_id};
|
||||||
|
|||||||
@@ -418,11 +418,10 @@ sub check_params {
|
|||||||
|
|
||||||
#numeric values
|
#numeric values
|
||||||
$checked->{limit} = 100;
|
$checked->{limit} = 100;
|
||||||
for my $param ( 'project_id', 'studio_id', 'series_id', 'event_id', 'pid', 'default_studio_id', 'limit' ) {
|
entry::set_numbers( $checked, $params, [
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
'project_id', 'studio_id', 'series_id', 'event_id', 'pid', 'default_studio_id', 'limit'
|
||||||
$checked->{$param} = $params->{$param};
|
]);
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( defined $checked->{studio_id} ) {
|
if ( defined $checked->{studio_id} ) {
|
||||||
$checked->{default_studio_id} = $checked->{studio_id};
|
$checked->{default_studio_id} = $checked->{studio_id};
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -248,12 +248,9 @@ sub check_params {
|
|||||||
}
|
}
|
||||||
$checked->{debug} = $debug;
|
$checked->{debug} = $debug;
|
||||||
|
|
||||||
#numeric values
|
entry::set_numbers( $checked, $params, [
|
||||||
for my $param ( 'event_id', 'project_id', 'studio_id', 'default_studio_id', 'user_id', 'series_id', 'duration' ) {
|
'event_id', 'project_id', 'studio_id', 'default_studio_id', 'user_id', 'series_id', 'duration'
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
]);
|
||||||
$checked->{$param} = $params->{$param};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for my $param ( 'subject', 'to', 'cc', 'content' ) {
|
for my $param ( 'subject', 'to', 'cc', 'content' ) {
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /\S/ ) ) {
|
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /\S/ ) ) {
|
||||||
|
|||||||
@@ -131,11 +131,8 @@ sub check_params {
|
|||||||
|
|
||||||
#numeric values
|
#numeric values
|
||||||
$checked->{exclude} = 0;
|
$checked->{exclude} = 0;
|
||||||
for my $param ( 'project_id', 'studio_id' ) {
|
entry::set_numbers( $checked, $params, [
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
'project_id', 'studio_id']);
|
||||||
$checked->{$param} = $params->{$param};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#dates
|
#dates
|
||||||
for my $param ('start_date') {
|
for my $param ('start_date') {
|
||||||
|
|||||||
@@ -291,12 +291,9 @@ sub check_params {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#numeric values
|
entry::set_numbers( $checked, $params, [
|
||||||
for my $param ( 'project_id', 'studio_id', 'default_studio_id', 'pid', 'sid' ) {
|
'project_id', 'studio_id', 'default_studio_id', 'pid', 'sid']);
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
|
||||||
$checked->{$param} = $params->{$param};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( defined $checked->{studio_id} ) {
|
if ( defined $checked->{studio_id} ) {
|
||||||
$checked->{default_studio_id} = $checked->{studio_id};
|
$checked->{default_studio_id} = $checked->{studio_id};
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -441,12 +441,10 @@ sub check_params {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#numeric values
|
entry::set_numbers( $checked, $params, [
|
||||||
for my $param ( 'project_id', 'studio_id', 'default_studio_id' ) {
|
'project_id', 'studio_id', 'default_studio_id'
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
]);
|
||||||
$checked->{$param} = $params->{$param};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( defined $checked->{studio_id} ) {
|
if ( defined $checked->{studio_id} ) {
|
||||||
$checked->{default_studio_id} = $checked->{studio_id};
|
$checked->{default_studio_id} = $checked->{studio_id};
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use Data::Dumper;
|
|||||||
|
|
||||||
use params();
|
use params();
|
||||||
use config();
|
use config();
|
||||||
|
use entry();
|
||||||
use log();
|
use log();
|
||||||
use template();
|
use template();
|
||||||
use auth();
|
use auth();
|
||||||
@@ -130,12 +131,9 @@ sub check_params {
|
|||||||
}
|
}
|
||||||
$checked->{debug} = $debug;
|
$checked->{debug} = $debug;
|
||||||
|
|
||||||
#numeric values
|
entry::set_numbers( $checked, $params, [
|
||||||
for my $param ( 'id', 'project_id', 'studio_id', 'series_id', 'event_id', 'p_id', 's_id' ) {
|
'id', 'project_id', 'studio_id', 'series_id', 'event_id', 'p_id', 's_id'
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^[\-\d]+$/ ) ) {
|
]);
|
||||||
$checked->{$param} = $params->{$param};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for my $param ( 'selectProjectStudio', 'selectSeries', 'selectRange' ) {
|
for my $param ( 'selectProjectStudio', 'selectSeries', 'selectRange' ) {
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} eq '1' ) ) {
|
if ( ( defined $params->{$param} ) && ( $params->{$param} eq '1' ) ) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use Data::Dumper;
|
|||||||
|
|
||||||
use params();
|
use params();
|
||||||
use config();
|
use config();
|
||||||
|
use entry();
|
||||||
use log();
|
use log();
|
||||||
use template();
|
use template();
|
||||||
use auth();
|
use auth();
|
||||||
@@ -120,12 +121,9 @@ sub check_params {
|
|||||||
}
|
}
|
||||||
$checked->{debug} = $debug;
|
$checked->{debug} = $debug;
|
||||||
|
|
||||||
#numeric values
|
entry::set_numbers( $checked, $params, [
|
||||||
for my $param ( 'id', 'project_id', 'studio_id', 'series_id', 'p_id', 's_id' ) {
|
'id', 'project_id', 'studio_id', 'series_id', 'p_id', 's_id'
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^[\-\d]+$/ ) ) {
|
]);
|
||||||
$checked->{$param} = $params->{$param};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for my $param ( 'selectProjectStudio', 'selectSeries', 'selectRange' ) {
|
for my $param ( 'selectProjectStudio', 'selectSeries', 'selectRange' ) {
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} eq '1' ) ) {
|
if ( ( defined $params->{$param} ) && ( $params->{$param} eq '1' ) ) {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use Encode();
|
|||||||
use utf8();
|
use utf8();
|
||||||
use params();
|
use params();
|
||||||
use config();
|
use config();
|
||||||
|
use entry();
|
||||||
use log();
|
use log();
|
||||||
use template();
|
use template();
|
||||||
use auth();
|
use auth();
|
||||||
@@ -1432,7 +1433,7 @@ sub check_params {
|
|||||||
#numeric values
|
#numeric values
|
||||||
$checked->{exclude} = 0;
|
$checked->{exclude} = 0;
|
||||||
$checked->{action} = $params->{action};
|
$checked->{action} = $params->{action};
|
||||||
for my $param (
|
entry::set_numbers( $checked, $params, [
|
||||||
'id', 'project_id',
|
'id', 'project_id',
|
||||||
'studio_id', 'default_studio_id',
|
'studio_id', 'default_studio_id',
|
||||||
'user_id', 'new_series_id',
|
'user_id', 'new_series_id',
|
||||||
@@ -1441,12 +1442,8 @@ sub check_params {
|
|||||||
'event_id', 'weekday',
|
'event_id', 'weekday',
|
||||||
'week_of_month', 'month',
|
'week_of_month', 'month',
|
||||||
'nextDay', 'predecessor_id'
|
'nextDay', 'predecessor_id'
|
||||||
)
|
]);
|
||||||
{
|
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
|
||||||
$checked->{$param} = $params->{$param};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( defined $checked->{studio_id} ) {
|
if ( defined $checked->{studio_id} ) {
|
||||||
$checked->{default_studio_id} = $checked->{studio_id};
|
$checked->{default_studio_id} = $checked->{studio_id};
|
||||||
} else {
|
} else {
|
||||||
@@ -1465,15 +1462,11 @@ sub check_params {
|
|||||||
$checked->{create_events} = 0;
|
$checked->{create_events} = 0;
|
||||||
$checked->{publish_events} = 0;
|
$checked->{publish_events} = 0;
|
||||||
}
|
}
|
||||||
for my $param (
|
|
||||||
|
entry::set_numbers( $checked, $params, [
|
||||||
'frequency', 'duration', 'default_duration', 'create_events',
|
'frequency', 'duration', 'default_duration', 'create_events',
|
||||||
'publish_events', 'live', 'count_episodes'
|
'publish_events', 'live', 'count_episodes'
|
||||||
)
|
]);
|
||||||
{
|
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /(\d+)/ ) ) {
|
|
||||||
$checked->{$param} = $1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#scalars
|
#scalars
|
||||||
for my $param ( 'search', 'from', 'till', 'period_type' ) {
|
for my $param ( 'search', 'from', 'till', 'period_type' ) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use Data::Dumper;
|
|||||||
|
|
||||||
use params();
|
use params();
|
||||||
use config();
|
use config();
|
||||||
|
use entry();
|
||||||
use log();
|
use log();
|
||||||
use template();
|
use template();
|
||||||
use auth();
|
use auth();
|
||||||
@@ -121,11 +122,9 @@ sub check_params {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#numeric values
|
#numeric values
|
||||||
for my $param ( 'project_id', 'studio_id', 'series_id', 'event_id' ) {
|
entry::set_numbers( $checked, $params, [
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^[\-\d]+$/ ) ) {
|
'project_id', 'studio_id', 'series_id', 'event_id'
|
||||||
$checked->{$param} = $params->{$param};
|
])
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( defined $checked->{studio_id} ) {
|
if ( defined $checked->{studio_id} ) {
|
||||||
$checked->{default_studio_id} = $checked->{studio_id};
|
$checked->{default_studio_id} = $checked->{studio_id};
|
||||||
|
|||||||
@@ -139,13 +139,9 @@ sub check_params {
|
|||||||
$checked->{error} = '';
|
$checked->{error} = '';
|
||||||
$checked->{template} = template::check( $config, $params->{template}, 'show-playout' );
|
$checked->{template} = template::check( $config, $params->{template}, 'show-playout' );
|
||||||
|
|
||||||
#numeric values
|
entry::set_numbers( $checked, $params, [
|
||||||
for my $param ( 'project_id', 'studio_id', 'default_studio_id', 'series_id', 'event_id', 'id' )
|
'project_id', 'studio_id', 'default_studio_id', 'series_id', 'event_id', 'id'
|
||||||
{
|
]);
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
|
||||||
$checked->{$param} = $params->{$param};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( defined $checked->{studio_id} ) {
|
if ( defined $checked->{studio_id} ) {
|
||||||
$checked->{default_studio_id} = $checked->{studio_id};
|
$checked->{default_studio_id} = $checked->{studio_id};
|
||||||
|
|||||||
@@ -373,11 +373,9 @@ sub check_params {
|
|||||||
|
|
||||||
#numeric values
|
#numeric values
|
||||||
$checked->{exclude} = 0;
|
$checked->{exclude} = 0;
|
||||||
for my $param ( 'id', 'project_id', 'studio_id', 'default_studio_id', 'schedule_id', 'schedule_studio_id' ) {
|
entry::set_numbers( $checked, $params, [
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
'id', 'project_id', 'studio_id', 'default_studio_id', 'schedule_id', 'schedule_studio_id'
|
||||||
$checked->{$param} = $params->{$param};
|
]);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ( defined $params->{show_date} ) && ( $params->{show_date} =~ /^(\d\d\d\d)/ ) ) {
|
if ( ( defined $params->{show_date} ) && ( $params->{show_date} =~ /^(\d\d\d\d)/ ) ) {
|
||||||
$checked->{show_date} = $1;
|
$checked->{show_date} = $1;
|
||||||
|
|||||||
@@ -235,12 +235,10 @@ sub check_params {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#numeric values
|
entry::set_numbers( $checked, $params, [
|
||||||
for my $param ( 'project_id', 'studio_id', 'default_studio_id', 'id' ) {
|
'project_id', 'studio_id', 'default_studio_id', 'id'
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
]);
|
||||||
$checked->{$param} = $params->{$param};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( defined $checked->{studio_id} ) {
|
if ( defined $checked->{studio_id} ) {
|
||||||
$checked->{default_studio_id} = $checked->{studio_id};
|
$checked->{default_studio_id} = $checked->{studio_id};
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -221,13 +221,10 @@ sub check_params {
|
|||||||
$checked->{template} = $template;
|
$checked->{template} = $template;
|
||||||
|
|
||||||
#numeric values
|
#numeric values
|
||||||
for my $param ( 'project_id', 'default_studio_id', 'studio_id', 'default_studio',
|
entry::set_numbers( $checked, $params, [
|
||||||
'default_project' )
|
'project_id', 'default_studio_id', 'studio_id', 'default_studio',
|
||||||
{
|
'default_project' ]);
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
|
||||||
$checked->{$param} = $params->{$param};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( defined $checked->{studio_id} ) {
|
if ( defined $checked->{studio_id} ) {
|
||||||
$checked->{default_studio_id} = $checked->{studio_id};
|
$checked->{default_studio_id} = $checked->{studio_id};
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -124,12 +124,9 @@ sub check_params {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#numeric values
|
entry::set_numbers( $checked, $params, [
|
||||||
for my $param ( 'project_id', 'default_studio_id', 'studio_id', 'series_id' ) {
|
'project_id', 'default_studio_id', 'studio_id', 'series_id']);
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
|
||||||
$checked->{$param} = $params->{$param};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( defined $checked->{studio_id} ) {
|
if ( defined $checked->{studio_id} ) {
|
||||||
$checked->{default_studio_id} = $checked->{studio_id};
|
$checked->{default_studio_id} = $checked->{studio_id};
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -399,12 +399,9 @@ sub check_params {
|
|||||||
$template = template::check( $config, $params->{template}, 'users' );
|
$template = template::check( $config, $params->{template}, 'users' );
|
||||||
$checked->{template} = $template;
|
$checked->{template} = $template;
|
||||||
|
|
||||||
#numeric values
|
entry::set_numbers( $checked, $params, [
|
||||||
for my $param ( 'project_id', 'user_id', 'default_studio_id', 'studio_id', 'disabled' ) {
|
'project_id', 'user_id', 'default_studio_id', 'studio_id', 'disabled']);
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
|
||||||
$checked->{$param} = $params->{$param};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( defined $checked->{studio_id} ) {
|
if ( defined $checked->{studio_id} ) {
|
||||||
$checked->{default_studio_id} = $checked->{studio_id};
|
$checked->{default_studio_id} = $checked->{studio_id};
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -280,15 +280,11 @@ sub check_params {
|
|||||||
|
|
||||||
#numeric values
|
#numeric values
|
||||||
$checked->{exclude} = 0;
|
$checked->{exclude} = 0;
|
||||||
for my $param (
|
entry::set_numbers( $checked, $params, [
|
||||||
'project_id', 'studio_id', 'default_studio_id', 'schedule_id',
|
'project_id', 'studio_id', 'default_studio_id', 'schedule_id',
|
||||||
'exclude', 'show_hint_to_add_schedule', 'weekday week_of_month', 'month'
|
'exclude', 'show_hint_to_add_schedule', 'weekday week_of_month', 'month'
|
||||||
)
|
]);
|
||||||
{
|
|
||||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
|
||||||
$checked->{$param} = $params->{$param};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( defined $checked->{studio_id} ) {
|
if ( defined $checked->{studio_id} ) {
|
||||||
$checked->{default_studio_id} = $checked->{studio_id};
|
$checked->{default_studio_id} = $checked->{studio_id};
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user