add playout section
This commit is contained in:
@@ -4,6 +4,10 @@ use warnings "all";
|
||||
use strict;
|
||||
use Data::Dumper;
|
||||
|
||||
use URI::Escape;
|
||||
use Encode;
|
||||
use localization;
|
||||
|
||||
use params;
|
||||
use config;
|
||||
use log;
|
||||
@@ -19,134 +23,139 @@ use series_schedule;
|
||||
use series_events;
|
||||
use series_dates;
|
||||
use markup;
|
||||
use URI::Escape;
|
||||
use Encode;
|
||||
use localization;
|
||||
use playout;
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my ($user,$expires) = auth::get_user($cgi, $config);
|
||||
return if ((!defined $user) || ($user eq ''));
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
print "Content-type:text/html; charset=UTF-8;\n\n";
|
||||
|
||||
#print STDERR $params->{project_id}."\n";
|
||||
my $user_presets=uac::get_user_presets($config, {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
user => $user
|
||||
});
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
user => $user
|
||||
}
|
||||
);
|
||||
|
||||
$params->{default_studio_id} = $user_presets->{studio_id};
|
||||
$params->{studio_id} = $params->{default_studio_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
$params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
$params->{default_studio_id}=$user_presets->{studio_id};
|
||||
$params->{studio_id} = $params->{default_studio_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
$params->{project_id} = $user_presets->{project_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
#print STDERR $params->{project_id}."\n";
|
||||
|
||||
my $request={
|
||||
url => $ENV{QUERY_STRING}||'',
|
||||
params => {
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
$params=$request->{params}->{checked};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
#process header
|
||||
my $headerParams=uac::set_template_permissions($request->{permissions}, $params);
|
||||
$headerParams->{loc} = localization::get($config, {user=>$user, file=>'menu'});
|
||||
#template::process('print', template::check('default.html'), $headerParams);
|
||||
return unless uac::check($config, $params, $user_presets)==1;
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
|
||||
if (defined $params->{action}){
|
||||
deleteFromPlayout ($config, $request) if ($params->{action} eq 'delete');
|
||||
}else{
|
||||
print "missing action\n";
|
||||
#template::process('print', template::check('default.html'), $headerParams);
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
if ( defined $params->{action} ) {
|
||||
deleteFromPlayout( $config, $request ) if ( $params->{action} eq 'delete' );
|
||||
} else {
|
||||
print "missing action\n";
|
||||
}
|
||||
return;
|
||||
|
||||
sub deleteFromPlayout{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub deleteFromPlayout {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{update_event_status_playout}==1){
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{update_event_status_playout} == 1 ) {
|
||||
uac::permissions_denied('update_event_status_playout');
|
||||
return;
|
||||
}
|
||||
|
||||
for my $attr ('project_id', 'studio_id', 'start_date'){
|
||||
unless (defined $params->{$attr}){
|
||||
uac::print_error("missing ".$attr." to show event");
|
||||
return;
|
||||
}
|
||||
}
|
||||
for my $attr ( 'project_id', 'studio_id', 'start_date' ) {
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( "missing " . $attr . " to show event" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$config->{access}->{write}=1;
|
||||
my $dbh=db::connect($config);
|
||||
$config->{access}->{write} = 1;
|
||||
my $dbh = db::connect($config);
|
||||
|
||||
my $result=playout::delete(
|
||||
$config, $dbh, {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
start => $params->{start_date}
|
||||
});
|
||||
$config->{access}->{write}=0;
|
||||
|
||||
print "result:$result\n";
|
||||
my $result = playout::delete(
|
||||
$config, $dbh,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
start => $params->{start_date}
|
||||
}
|
||||
);
|
||||
$config->{access}->{write} = 0;
|
||||
|
||||
print "result:$result\n";
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
my $checked = {};
|
||||
|
||||
my $checked={};
|
||||
|
||||
my $debug=$params->{debug} || '';
|
||||
if ($debug=~/([a-z\_\,]+)/){
|
||||
$debug=$1;
|
||||
my $debug = $params->{debug} || '';
|
||||
if ( $debug =~ /([a-z\_\,]+)/ ) {
|
||||
$debug = $1;
|
||||
}
|
||||
$checked->{debug}=$debug;
|
||||
$checked->{debug} = $debug;
|
||||
|
||||
#actions and roles
|
||||
$checked->{action}='';
|
||||
if (defined $params->{action}){
|
||||
if ($params->{action}=~/^(delete)$/){
|
||||
$checked->{action}=$params->{action};
|
||||
$checked->{action} = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(delete)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
|
||||
#numeric values
|
||||
$checked->{exclude}=0;
|
||||
for my $param ('project_id', 'studio_id'){
|
||||
if ((defined $params->{$param})&&($params->{$param}=~/^\d+$/)){
|
||||
$checked->{$param}=$params->{$param};
|
||||
$checked->{exclude} = 0;
|
||||
for my $param ( 'project_id', 'studio_id' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#dates
|
||||
for my $param ('start_date'){
|
||||
if((defined $params->{$param})&&($params->{$param}=~/(\d\d\d\d\-\d\d\-\d\d \d\d\:\d\d)/)){
|
||||
$checked->{$param}=$1.':00';
|
||||
}
|
||||
}
|
||||
for my $param ('start_date') {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /(\d\d\d\d\-\d\d\-\d\d \d\d\:\d\d)/ ) ) {
|
||||
$checked->{$param} = $1 . ':00';
|
||||
}
|
||||
}
|
||||
|
||||
if ( defined $checked->{studio_id} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
|
||||
if (defined $checked->{studio_id}){
|
||||
$checked->{default_studio_id}=$checked->{studio_id};
|
||||
}else{
|
||||
$checked->{studio_id}=-1;
|
||||
}
|
||||
|
||||
#$checked->{template}=template::check($params->{template},'playout');
|
||||
#$checked->{template}=template::check($params->{template},'playout');
|
||||
|
||||
return $checked;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user