refactoring

update package definition
fix dependencies
remove global variables
This commit is contained in:
Milan
2018-09-02 09:39:24 +02:00
parent 3e338758e9
commit a6b656779b
71 changed files with 2135 additions and 2297 deletions

View File

@@ -26,8 +26,6 @@ my $r=shift;
my $config = config::get('./config/config.cgi');
my $debug = $config->{system}->{debug};
$cache::debug=$debug;
my $request={
url => $ENV{QUERY_STRING},
params => {
@@ -174,7 +172,7 @@ sub check_params{
my $config=shift;
my $params=shift;
my $template=template::check($params->{'template'}, 'comments.html');
my $template = template::check($config, $params->{'template'}, 'comments.html' );
my $comment={};

View File

@@ -3,15 +3,8 @@
use warnings "all";
use strict;
#use Data::Dumper;
#use DBI;
use CGI qw(header param Vars);
#use Time::Local qw(timelocal);
#use Benchmark;
#use Devel::Profiler;
use db();
use events();
use time();
@@ -20,9 +13,6 @@ use markup();
use log();
use config();
#use params;
#my $r=shift;
if ( $0 =~ /aggregate.*?\.cgi$/ ) {
binmode STDOUT, ":encoding(UTF-8)";

View File

@@ -56,7 +56,7 @@ $template_parameters->{use_client_cache} = $config->{cache}->{use_client_cache}
my $template = $params->{template};
my $out = '';
template::process( $out, $params->{template}, $template_parameters );
template::process($config, $out, $params->{template}, $template_parameters );
print $out;
#write to cache
@@ -127,7 +127,7 @@ sub check_params {
my $config = $_[0];
my $params = $_[1];
my $template = template::check( $params->{template}, 'categories.html' );
my $template = template::check($config, $params->{template}, 'categories.html' );
my $debug = $params->{debug} || '';
if ( $debug =~ /([a-z\_\,]+)/ ) {

View File

@@ -23,7 +23,6 @@ binmode STDOUT, ":encoding(UTF-8)";
my $r = shift;
( my $cgi, my $params, my $error ) = params::get($r);
if ( $0 =~ /events.*?\.cgi$/ ) {
#my $cgi=new CGI();

View File

@@ -63,7 +63,7 @@ $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 );
template::process( $config, 'print', template::check($config, 'default.html'), $headerParams );
return unless uac::check( $config, $params, $user_presets ) == 1;
print q{
@@ -142,7 +142,7 @@ sub show_events {
$params->{project_name} = $project_name;
$params->{studio_name} = $studio_name;
template::process( 'print', $params->{template}, $params );
template::process($config, 'print', $params->{template}, $params );
}
sub assign_series {
@@ -201,6 +201,7 @@ sub assign_series {
$config->{access}->{write} = 0;
uac::print_info("event successfully assigned to series");
return;
}
sub check_params {
@@ -236,7 +237,7 @@ sub check_params {
$checked->{studio_id} = -1;
}
$checked->{template} = template::check( $params->{template}, 'assign_series' );
$checked->{template} = template::check($config, $params->{template}, 'assign_series' );
return $checked;
}

View File

@@ -1,4 +1,4 @@
#! /usr/bin/perl -w
#! /usr/bin/perl -w
use warnings "all";
use strict;
@@ -64,7 +64,7 @@ $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 );
template::process( $config, 'print', template::check( $config, 'default.html' ), $headerParams );
return unless uac::check( $config, $params, $user_presets ) == 1;
print q{
@@ -167,6 +167,7 @@ sub show_events {
$results = db::get( $dbh, $query, $bind_values );
# detect title and episode
my $weekdayNamesShort = time::getWeekdayNamesShort('de');
for my $result (@$results) {
$result->{rerun} .= '';
if ( $result->{title} =~ /\#(\d+)([a-z])?\s*$/ ) {
@@ -179,7 +180,7 @@ sub show_events {
#print STDERR "($a->[0],$a->[1],$a->[2])\n";
$result->{weekday} = time::weekday( $a->[0], $a->[1], $a->[2] );
$result->{weekday} = $time::names->{de}->{weekdays_abbr}->[ $result->{weekday} - 1 ];
$result->{weekday} = $weekdayNamesShort->[ $result->{weekday} - 1 ];
}
#fill template
@@ -188,7 +189,7 @@ sub show_events {
$params->{project_name} = $project_name;
$params->{studio_name} = $studio_name;
template::process( 'print', $params->{template}, $params );
template::process( $config, 'print', $params->{template}, $params );
}
sub assign_events {
@@ -385,7 +386,7 @@ sub check_params {
$checked->{studio_id} = -1;
}
$checked->{template} = template::check( $params->{template}, 'assignments' );
$checked->{template} = template::check( $config, $params->{template}, 'assignments' );
if ( ( defined $checked->{action} ) && ( $checked->{action} eq 'save_schedule' ) ) {

View File

@@ -87,7 +87,7 @@ $params = $request->{params}->{checked};
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 );
template::process( $config, 'print', template::check($config, 'default.html'), $headerParams );
exit unless defined uac::check( $config, $params, $user_presets );
@@ -112,7 +112,7 @@ showAudioRecordings( $config, $request );
print STDERR "$0 ERROR: " . $params->{error} . "\n" if $params->{error} ne '';
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'event,comment' } );
template::process( 'print', $params->{template}, $params );
template::process($config, 'print', $params->{template}, $params );
exit;
@@ -544,7 +544,7 @@ sub check_params {
my $checked = {};
$checked->{error} = '';
$checked->{template} = template::check( $params->{template}, 'upload_audio_recordings' );
$checked->{template} = template::check($config, $params->{template}, 'upload_audio_recordings' );
#print Dumper($params);
#numeric values

8
website/agenda/planung/calendar.cgi Normal file → Executable file
View File

@@ -98,7 +98,7 @@ if (
#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 );
template::process( $config, 'print', template::check($config, 'default.html'), $headerParams );
print q{
<link href="css/jquery-ui-timepicker.css" type="text/css" rel="stylesheet" />
<link rel="stylesheet" href="css/calendar.css" type="text/css" />
@@ -1682,14 +1682,14 @@ sub getCalendar {
$next = time::get_datetime( $from_date, $config->{date}->{time_zone} )->add( days => $range )->date();
}
my ( $year, $month, $day ) = split( /\-/, $from_date );
$month = $time::names->{$language}->{months_abbr}->[ $month - 1 ] || '';
my $monthName = time::getMonthNamesShort($language)->[ $month - 1 ] || '';
return {
from_date => $from_date,
till_date => $till_date,
next_date => $next,
previous_date => $previous,
month => $month,
month => $monthName,
year => $year
};
@@ -1807,7 +1807,7 @@ sub check_params {
my $checked = {};
my $template = '';
$checked->{template} = template::check( $params->{template}, 'series' );
$checked->{template} = template::check($config, $params->{template}, 'series' );
my $debug = $params->{debug} || '';
if ( $debug =~ /([a-z\_\,]+)/ ) {

View File

@@ -32,7 +32,7 @@ my $r = shift;
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 '' ) );
return if ( !defined $user ) || ( $user eq '' ) ;
my $user_presets = uac::get_user_presets(
$config,
@@ -68,7 +68,7 @@ if ( ( params::isJson() ) || ( defined $params->{action} ) ) {
} else {
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 );
template::process($config, 'print', template::check($config, 'default.html'), $headerParams );
print q{
<script src="js/datetime.js" type="text/javascript"></script>
} unless (params::isJson);
@@ -132,16 +132,16 @@ sub showComments {
my $events = [];
my $comment_count = 0;
if ( scalar(@$results) > 0 ) {
my $comments = modify_comments( $request, $results );
my $comments = modify_comments( $config, $request, $results );
$comments = comments::sort( $config, $comments );
$events = comments::get_events( $dbh, $config, $request, $comments );
my $language = $config::config->{date}->{language} || 'en';
my $language = $config->{date}->{language} || 'en';
for my $event (@$events) {
$event->{start} = time::date_time_format( $event->{start}, $language );
$event->{start} = time::date_time_format($config, $event->{start}, $language );
$comment_count += $event->{comment_count} if ( defined $event->{comment_count} );
$event->{cache_base_url} = $config::config->{cache}->{base_url};
$event->{cache_base_url} = $config->{cache}->{base_url};
}
}
for my $param (%$comment) {
@@ -160,16 +160,17 @@ sub showComments {
$template_parameters->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'comment' } );
#fill and output template
template::process( 'print', $params->{template}, $template_parameters );
template::process($config, 'print', $params->{template}, $template_parameters );
}
sub modify_comments {
my $config = shift;
my $request = shift;
my $results = shift;
my $language = $config::config->{date}->{language} || 'en';
my $language = $config->{date}->{language} || 'en';
for my $result (@$results) {
$result->{start_date_name} = time::date_format( $result->{created_at}, $language );
$result->{start_date_name} = time::date_format($config, $result->{created_at}, $language );
$result->{start_time_name} = time::time_format( $result->{created_at} );
$result->{ $result->{lock_status} } = 1;
$result->{ $result->{news_status} } = 1;
@@ -252,9 +253,9 @@ sub check_params {
#template
my $template = '';
if ( defined $checked->{action} ) {
$template = template::check( $params->{template}, 'edit_comment' ) if $checked->{action} eq 'showComment';
$template = template::check($config, $params->{template}, 'edit_comment' ) if $checked->{action} eq 'showComment';
} else {
$template = template::check( $params->{template}, 'comments' );
$template = template::check($config, $params->{template}, 'comments' );
}
$checked->{template} = $template;

View File

@@ -58,7 +58,7 @@ $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 );
template::process($config, 'print', template::check($config, 'default.html'), $headerParams );
return unless uac::check( $config, $params, $user_presets ) == 1;
print q{
@@ -90,7 +90,7 @@ sub show_events {
uac::permissions_denied('assign_series_events');
return;
}
template::process( 'print', $params->{template}, $params );
template::process($config, 'print', $params->{template}, $params );
}
@@ -147,7 +147,7 @@ sub create_events {
}
$params->{created_events} = $events;
$params->{created_total} = scalar(@$events);
template::process( 'print', $params->{template}, $params );
template::process($config, 'print', $params->{template}, $params );
}
sub createEvent {
@@ -210,7 +210,7 @@ sub check_params {
$checked->{studio_id} = -1;
}
$checked->{template} = template::check( $params->{template}, 'create_events' );
$checked->{template} = template::check($config, $params->{template}, 'create_events' );
return $checked;
}

View File

@@ -1,84 +0,0 @@
#! /usr/bin/perl -I../lib
use warnings "all";
use strict;
use Data::Dumper;
use HTML::Template();
use config();
use log();
use template();
use params();
use config();
use auth();
use localization();
use studios();
binmode STDOUT, ":utf8";
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_presets = uac::get_user_presets( $config, { user => $user, studio_id => $params->{studio_id} } );
my $request = {
url => $ENV{QUERY_STRING} || '',
params => {
original => $params,
checked => $params
# checked => check_params($params),
},
};
$request = uac::prepare_request( $request, $user_presets );
#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 );
#filter
my $lines = $cgi->param('lines');
$lines = 100 if $lines eq '';
my $filter = '';
$filter = ' |grep -v "Use of uninitialized value in | grep -v redefined " ' if ( $cgi->param('warn') eq '1' );
#get file
my $file = $config->{system}->{log_file};
if ( $cgi->param('log') eq 'app' ) {
$file = $config->{system}->{log_debug_file};
}
if ( $cgi->param('log') eq 'mem' ) {
$file = $config->{system}->{log_debug_memory_file};
}
if ( $cgi->param('log') eq 'job' ) {
$file = $config->{system}->{job_log};
}
#output header
my $out = '';
template::process( 'print', 'templates/error_log.html', $params );
#get log
my $cmd = "tail -$lines " . $file . $filter;
print '<pre>' . $cmd . '</pre>';
my $log = `$cmd`;
$log = join( "\n", reverse( split( "\n", $log ) ) );
#replace
if ( $cgi->param('log') eq 'app' ) {
$log =~ s/\\n/<br>/gi;
} else {
$log =~ s/</\&lt;/gi;
$log =~
s/\\n/<\/pre><pre>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/gi;
}
#output content
print $log;

View File

@@ -75,7 +75,7 @@ $params = $request->{params}->{checked};
unless ( params::isJson() ) {
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 );
template::process($config, 'print', template::check($config, 'default.html'), $headerParams );
}
return unless defined uac::check( $config, $params, $user_presets );
@@ -148,7 +148,7 @@ sub show_event {
#TODO: move to JS
my @durations = ();
for my $duration ( @{ time::get_durations() } ) {
for my $duration ( @{ time::getDurations() } ) {
my $entry = {
name => sprintf( "%02d:%02d", $duration / 60, $duration % 60 ),
value => $duration
@@ -311,7 +311,7 @@ sub show_event {
#print STDERR Dumper($params);
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'event' } );
template::process( 'print', template::check('edit_event'), $params );
template::process($config, 'print', template::check($config, 'edit_event'), $params );
}
sub getJson {
@@ -394,7 +394,7 @@ sub getJson {
}
#print to_json($event);
template::process( 'print', 'json-p', $event );
template::process($config, 'print', 'json-p', $event );
}
#show new event from schedule
@@ -432,7 +432,7 @@ sub show_new_event {
#add duration selectbox
#TODO: move to javascript
my @durations = ();
for my $duration ( @{ time::get_durations() } ) {
for my $duration ( @{ time::getDurations() } ) {
my $entry = {
name => sprintf( "%02d:%02d", $duration / 60, $duration % 60 ),
value => $duration
@@ -455,7 +455,7 @@ sub show_new_event {
}
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'event,comment' } );
template::process( 'print', template::check('edit_event'), $params );
template::process( $config, 'print', template::check($config, 'edit_event'), $params );
#print '<pre>'.Dumper($params).'</pre>';
}
@@ -773,7 +773,7 @@ sub check_params {
my $checked = {};
my $template = '';
$checked->{template} = template::check( $params->{template}, 'series' );
$checked->{template} = template::check($config, $params->{template}, 'series' );
my $debug = $params->{debug} || '';
if ( $debug =~ /([a-z\_\,]+)/ ) {

View File

@@ -57,7 +57,7 @@ $params = $request->{params}->{checked};
#show 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 );
template::process( $config, 'print', template::check($config, 'default.html'), $headerParams );
return unless uac::check( $config, $params, $user_presets ) == 1;
print q{
@@ -113,7 +113,7 @@ sub show_history {
#print STDERR Dumper($params);
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'event_history' } );
template::process( 'print', template::check('event_history'), $params );
template::process($config, 'print', template::check($config, 'event_history'), $params );
}
#show existing event history
@@ -200,7 +200,7 @@ sub check_params {
my $checked = {};
my $template = '';
$checked->{template} = template::check( $params->{template}, 'event_history' );
$checked->{template} = template::check($config, $params->{template}, 'event_history' );
my $debug = $params->{debug} || '';
if ( $debug =~ /([a-z\_\,]+)/ ) {

View File

@@ -56,7 +56,7 @@ $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 );
template::process($config, 'print', template::check($config, 'default.html'), $headerParams );
return unless uac::check( $config, $params, $user_presets ) == 1;
my $toc = $headerParams->{loc}->{toc};

View File

@@ -65,7 +65,7 @@ $params = $request->{params}->{checked};
#show header
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
template::process( 'print', template::check('ajax_header.html'), $headerParams );
template::process($config, 'print', template::check($config, 'ajax_header.html'), $headerParams );
return unless defined uac::check( $config, $params, $user_presets );
my $local_media_dir = $config->{locations}->{local_media_dir};
@@ -231,7 +231,7 @@ sub show_image {
$template_params->{allow}->{update_image_own} || $template_params->{allow}->{seriesupdate_image_others};
$template_params->{allow}->{delete_image} =
$template_params->{allow}->{delete_image_own} || $template_params->{allow}->{delete_image_others};
template::process( 'print', $params->{template}, $template_params );
template::process($config, 'print', $params->{template}, $template_params );
}
sub print_js_error {
@@ -408,7 +408,7 @@ sub modify_results {
sub check_params {
my $params = shift;
my $checked = { template => template::check( $params->{template}, 'image.html' ) };
my $checked = { template => template::check($config, $params->{template}, 'image.html' ) };
#numeric values
$checked->{limit} = 100;

View File

@@ -142,7 +142,7 @@ if ( $error ne '' ) {
}
print STDERR $params->{error} . "\n" if defined $params->{error};
my $out = '';
template::process( 'print', $params->{template}, $params );
template::process( $config, 'print', $params->{template}, $params );
print $cgi->cgi_error() if defined $cgi;
@@ -388,7 +388,7 @@ sub check_params {
my $params = shift;
my $checked = {};
$checked->{template} = template::check( $params->{template}, 'imageUpload' );
$checked->{template} = template::check($config, $params->{template}, 'imageUpload' );
#numeric values
for my $param ( 'project_id', 'studio_id', 'default_studio_id' ) {

View File

@@ -63,7 +63,7 @@ $params = $request->{params}->{checked};
unless ( params::isJson() || ( $params->{template} =~ /\.txt/ ) ) {
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 );
template::process( $config, 'print', template::check($config, 'default.html'), $headerParams );
}
return unless uac::check( $config, $params, $user_presets ) == 1;
@@ -122,7 +122,7 @@ sub show_events {
}
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'notify_events' } );
template::process( 'print', $params->{template}, $params );
template::process($config, 'print', $params->{template}, $params );
}
@@ -241,7 +241,7 @@ sub check_params {
my $checked = {};
my $template = '';
$checked->{template} = template::check( $params->{template}, 'notify_events' );
$checked->{template} = template::check($config, $params->{template}, 'notify_events' );
my $debug = $params->{debug} || '';
if ( $debug =~ /([a-z\_\,]+)/ ) {

4
website/agenda/planung/playout.cgi Normal file → Executable file
View File

@@ -70,7 +70,7 @@ $params = $request->{params}->{checked};
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);
#template::process($config, 'print', template::check($config, 'default.html'), $headerParams);
return unless uac::check( $config, $params, $user_presets ) == 1;
if ( defined $params->{action} ) {
@@ -154,7 +154,7 @@ sub check_params {
$checked->{studio_id} = -1;
}
#$checked->{template}=template::check($params->{template},'playout');
#$checked->{template}=template::check($config, $params->{template},'playout');
return $checked;
}

View File

@@ -24,7 +24,7 @@ my $debug = $config->{system}->{debug};
my ( $user, $expires ) = auth::get_user( $cgi, $config );
return if ( $user eq '' );
my $permissions = roles::get_user_permissions();
my $permissions = roles::get_user_permissions($config);
my $user_presets = uac::get_user_presets(
$config,
{
@@ -53,7 +53,7 @@ $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 );
template::process($config, 'print', template::check($config, 'default.html'), $headerParams );
return unless uac::check( $config, $params, $user_presets ) == 1;
print q{
@@ -262,7 +262,7 @@ sub show_projects {
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'projects' } );
uac::set_template_permissions( $permissions, $params );
template::process( 'print', $params->{template}, $params );
template::process($config, 'print', $params->{template}, $params );
}
sub check_params {
@@ -272,7 +272,7 @@ sub check_params {
#template
my $template = '';
$template = template::check( $params->{template}, 'projects' );
$template = template::check($config, $params->{template}, 'projects' );
$checked->{template} = $template;
#actions

2
website/agenda/planung/requestPassword.cgi Normal file → Executable file
View File

@@ -141,7 +141,7 @@ sub check_params {
my $checked = {};
#my $template = '';
#$checked->{template} = template::check( $params->{template}, 'requestPassword' );
#$checked->{template} = template::check($config, $params->{template}, 'requestPassword' );
my $debug = $params->{debug} || '';
if ( $debug =~ /([a-z\_\,]+)/ ) {

View File

@@ -62,7 +62,7 @@ $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('roles.html'), $headerParams );
template::process($config, 'print', template::check($config, 'roles.html'), $headerParams );
return unless uac::check( $config, $params, $user_presets ) == 1;
if ( defined $params->{action} ) {
@@ -431,7 +431,7 @@ sub check_params {
#template
my $template = '';
$template = template::check( $params->{template}, 'roles.html' );
$template = template::check($config, $params->{template}, 'roles.html' );
$checked->{template} = $template;
#actions

View File

@@ -117,7 +117,7 @@ sub show_events {
$params->{years} = $years;
#print STDERR Dumper($params);
template::process( 'print', $params->{template}, $params );
template::process($config, 'print', $params->{template}, $params );
return;
}
@@ -171,7 +171,7 @@ sub check_params {
$checked->{studio_id} = -1;
}
$checked->{template} = template::check( $params->{template}, 'selectEvent' );
$checked->{template} = template::check($config, $params->{template}, 'selectEvent' );
return $checked;
}

View File

@@ -104,7 +104,7 @@ sub show_series {
$params->{studios} = $user_studios;
$params->{series} = $series;
template::process( 'print', $params->{template}, $params );
template::process( $config, 'print', $params->{template}, $params );
return;
}
@@ -148,7 +148,7 @@ sub check_params {
$checked->{studio_id} = -1;
}
$checked->{template} = template::check( $params->{template}, 'selectSeries' );
$checked->{template} = template::check($config, $params->{template}, 'selectSeries' );
return $checked;
}

View File

@@ -66,7 +66,7 @@ $params = $request->{params}->{checked};
unless ( params::isJson() ) {
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 );
template::process($config, 'print', template::check($config, 'default.html'), $headerParams );
}
return unless uac::check( $config, $params, $user_presets ) == 1;
@@ -989,7 +989,7 @@ sub list_series {
#print STDERR Dumper $params->{image};
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'all,series' } );
template::process( 'print', $params->{template}, $params );
template::process($config, 'print', $params->{template}, $params );
}
sub show_series {
@@ -1207,7 +1207,7 @@ sub show_series {
#print STDERR '<pre>'.Dumper($params).'</pre>';
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'all,series' } );
template::process( 'print', $params->{template}, $params );
template::process($config, 'print', $params->{template}, $params );
}
sub check_params {
@@ -1252,9 +1252,9 @@ sub check_params {
}
if ( defined $checked->{series_id} ) {
$checked->{template} = template::check( $params->{template}, 'edit_series' );
$checked->{template} = template::check($config, $params->{template}, 'edit_series' );
} else {
$checked->{template} = template::check( $params->{template}, 'series' );
$checked->{template} = template::check($config, $params->{template}, 'series' );
}
if ( ( defined $checked->{action} ) && ( $checked->{action} eq 'save_schedule' ) ) {

View File

@@ -30,12 +30,12 @@ return if ( ( !defined $user ) || ( $user eq '' ) );
#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
}
$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}
@@ -45,20 +45,20 @@ $params->{project_id} = $user_presets->{project_id}
#print STDERR $params->{project_id}."\n";
my $request = {
url => $ENV{QUERY_STRING} || '',
params => {
original => $params,
checked => check_params($params),
},
url => $ENV{QUERY_STRING} || '',
params => {
original => $params,
checked => check_params($params),
},
};
$request = uac::prepare_request( $request, $user_presets );
$params = $request->{params}->{checked};
#process header
unless ( params::isJson() ) {
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 );
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
template::process($config, 'print', template::check($config, 'default.html'), $headerParams );
}
return unless uac::check( $config, $params, $user_presets ) == 1;
@@ -75,127 +75,127 @@ showPlayout( $config, $request );
print STDERR "$0 ERROR: " . $params->{error} . "\n" if $params->{error} ne '';
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'event,comment' } );
template::process( 'print', $params->{template}, $params );
template::process($config, 'print', $params->{template}, $params );
exit;
sub showPlayout {
my $config = shift;
my $request = shift;
my $config = shift;
my $request = shift;
my $params = $request->{params}->{checked};
my $permissions = $request->{permissions};
my $params = $request->{params}->{checked};
my $permissions = $request->{permissions};
for my $attr ( 'project_id', 'studio_id' ) {
unless ( defined $params->{$attr} ) {
uac::print_error( "missing " . $attr . " to show playout" );
return;
}
}
for my $attr ( 'project_id', 'studio_id' ) {
unless ( defined $params->{$attr} ) {
uac::print_error( "missing " . $attr . " to show playout" );
return;
}
}
my $events = playout::get(
$config,
{
project_id => $params->{project_id},
studio_id => $params->{studio_id},
order => 'modified_at desc, start desc',
limit => 500
}
);
my $events = playout::get(
$config,
{
project_id => $params->{project_id},
studio_id => $params->{studio_id},
order => 'modified_at desc, start desc',
limit => 500
}
);
# print '<pre>'.Dumper($events).'</pre>';
unless ( defined $events ) {
uac::print_error("not found");
return;
}
# print '<pre>'.Dumper($events).'</pre>';
unless ( defined $events ) {
uac::print_error("not found");
return;
}
for my $event (@$events) {
$event->{stream_size} =~ s/(\d)(\d\d\d)$/$1\.$2/g;
$event->{stream_size} =~ s/(\d)(\d\d\d\.\d\d\d)$/$1\.$2/g;
$event->{duration} =~ s/(\d\.\d)(\d+)$/$1/g;
$event->{duration} =~ s/(\d)\.0/$1/g;
$event->{rms_left} = formatLoudness( $event->{rms_left} );
$event->{rms_right} = formatLoudness( $event->{rms_right} );
$event->{bitrate} = formatBitrate($event);
$event->{duration} = formatDuration($event);
}
for my $event (@$events) {
$event->{stream_size} =~ s/(\d)(\d\d\d)$/$1\.$2/g;
$event->{stream_size} =~ s/(\d)(\d\d\d\.\d\d\d)$/$1\.$2/g;
$event->{duration} =~ s/(\d\.\d)(\d+)$/$1/g;
$event->{duration} =~ s/(\d)\.0/$1/g;
$event->{rms_left} = formatLoudness( $event->{rms_left} );
$event->{rms_right} = formatLoudness( $event->{rms_right} );
$event->{bitrate} = formatBitrate($event);
$event->{duration} = formatDuration($event);
}
$params->{events} = $events;
$params->{events} = $events;
#print Dumper($events);
#print Dumper($events);
}
sub formatDuration {
my $event = $_[0];
my $duration = $event->{duration};
return '' unless defined $duration;
return '' if $duration eq '';
my $result = int( ( $duration + 3600 ) * 10 ) % 600;
my $class = "ok";
$class = "warn" if $result > 1;
$class = "error" if $result > 10;
return sprintf( qq{<div class="%s">%.01f</div>}, $class, $duration );
my $event = $_[0];
my $duration = $event->{duration};
return '' unless defined $duration;
return '' if $duration eq '';
my $result = int( ( $duration + 3600 ) * 10 ) % 600;
my $class = "ok";
$class = "warn" if $result > 1;
$class = "error" if $result > 10;
return sprintf( qq{<div class="%s">%.01f</div>}, $class, $duration );
}
sub formatBitrate {
my $event = $_[0];
my $bitrate = $event->{bitrate};
my $mode = $event->{bitrate_mode};
if ( $bitrate ne '' ) {
if ( $bitrate >= 200 ) {
$bitrate = '<div class="warn">' . $bitrate . ' ' . $mode . '</div>';
} elsif ( $bitrate < 190 ) {
$bitrate = '<div class="error">' . $bitrate . ' ' . $mode . '</div>';
} else {
$bitrate .= ' ' . $mode;
}
}
return $bitrate;
my $event = $_[0];
my $bitrate = $event->{bitrate};
my $mode = $event->{bitrate_mode};
if ( $bitrate ne '' ) {
if ( $bitrate >= 200 ) {
$bitrate = '<div class="warn">' . $bitrate . ' ' . $mode . '</div>';
} elsif ( $bitrate < 190 ) {
$bitrate = '<div class="error">' . $bitrate . ' ' . $mode . '</div>';
} else {
$bitrate .= ' ' . $mode;
}
}
return $bitrate;
}
sub formatLoudness {
my $value = shift;
return '' unless defined $value;
return '' if $value == 0;
return '' if $value eq '';
my $value = shift;
return '' unless defined $value;
return '' if $value == 0;
return '' if $value eq '';
$value = sprintf( "%.1f", $value );
my $class = 'ok';
$class = 'warn' if $value > -18.5;
$class = 'error' if $value > -16.0;
$class = 'warn' if $value < -24.0;
$class = 'error' if $value < -27.0;
$value = sprintf( "%.1f", $value );
my $class = 'ok';
$class = 'warn' if $value > -18.5;
$class = 'error' if $value > -16.0;
$class = 'warn' if $value < -24.0;
$class = 'error' if $value < -27.0;
return qq{<div class="$class">$value dB</div>};
return qq{<div class="$class">$value dB</div>};
}
sub check_params {
my $params = shift;
my $params = shift;
my $checked = {};
$checked->{error} = '';
$checked->{template} = template::check( $params->{template}, 'show_playout' );
my $checked = {};
$checked->{error} = '';
$checked->{template} = template::check($config, $params->{template}, 'show_playout' );
#numeric values
for my $param ( 'project_id', 'studio_id', 'default_studio_id', 'series_id', 'event_id', 'id' ) {
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
$checked->{$param} = $params->{$param};
}
}
#numeric values
for my $param ( '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} ) {
$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;
}
#word
for my $param ('debug') {
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\s*(.+?)\s*$/ ) ) {
$checked->{$param} = $1;
}
}
#word
for my $param ('debug') {
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\s*(.+?)\s*$/ ) ) {
$checked->{$param} = $1;
}
}
return $checked;
return $checked;
}

View File

@@ -64,7 +64,7 @@ if ( $action eq 'show_dates' ) {
#print "Content-type:text/html\n\n";
} else {
template::process( 'print', template::check('default.html'), $headerParams );
template::process($config, 'print', template::check($config, 'default.html'), $headerParams );
}
return unless uac::check( $config, $params, $user_presets ) == 1;
@@ -259,7 +259,7 @@ sub showTimeslotSchedule {
}
#print '<pre>'.Dumper($params).'</pre>';
template::process( 'print', $params->{template}, $params );
template::process($config, 'print', $params->{template}, $params );
}
sub showDates {
@@ -350,8 +350,8 @@ sub showDates {
$params->{$key} = $result->{$key};
}
my $template = template::check('studio_timeslot_dates');
template::process( 'print', $template, $params );
my $template = template::check($config, 'studio_timeslot_dates');
template::process($config, 'print', $template, $params );
}
sub check_params {
@@ -393,7 +393,7 @@ sub check_params {
$checked->{studio_id} = -1;
}
$checked->{template} = template::check( $params->{template}, 'studio_timeslots' );
$checked->{template} = template::check($config, $params->{template}, 'studio_timeslots' );
for my $param ('frequency') {
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /(\d+)/ ) ) {

View File

@@ -24,7 +24,7 @@ my $debug = $config->{system}->{debug};
my ( $user, $expires ) = auth::get_user( $cgi, $config );
return if ( $user eq '' );
my $permissions = roles::get_user_permissions();
my $permissions = roles::get_user_permissions($config);
my $user_presets = uac::get_user_presets(
$config,
{
@@ -52,7 +52,7 @@ $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 );
template::process($config, 'print', template::check($config, 'default.html'), $headerParams );
return unless uac::check( $config, $params, $user_presets ) == 1;
print q{
@@ -199,7 +199,7 @@ sub show_studios {
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'studios' } );
uac::set_template_permissions( $permissions, $params );
template::process( 'print', $params->{template}, $params );
template::process($config, 'print', $params->{template}, $params );
}
sub check_params {
@@ -209,7 +209,7 @@ sub check_params {
#template
my $template = '';
$template = template::check( $params->{template}, 'studios' );
$template = template::check($config, $params->{template}, 'studios' );
$checked->{template} = $template;
#actions

View File

@@ -51,7 +51,7 @@ $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 );
template::process($config, 'print', template::check($config, 'default.html'), $headerParams );
return unless uac::check( $config, $params, $user_presets ) == 1;
our $errors = [];
@@ -113,7 +113,7 @@ sub show_settings {
uac::set_template_permissions( $permissions, $params );
#print Dumper($permissions);
template::process( 'print', $params->{template}, $params );
template::process($config, 'print', $params->{template}, $params );
#print '<pre>'.Dumper($user_settings);
}
@@ -165,7 +165,7 @@ sub check_params {
#template
my $template = '';
$template = template::check( $params->{template}, 'user_settings' );
$template = template::check($config, $params->{template}, 'user_settings' );
$checked->{template} = $template;
#numeric values

View File

@@ -52,7 +52,7 @@ $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 );
template::process($config, 'print', template::check($config, 'default.html'), $headerParams );
return unless uac::check( $config, $params, $user_presets ) == 1;
our $errors = [];
@@ -76,7 +76,7 @@ sub show_stats {
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'user_stats' } );
uac::set_template_permissions( $permissions, $params );
template::process( 'print', $params->{template}, $params );
template::process($config, 'print', $params->{template}, $params );
}
sub check_params {
@@ -86,7 +86,7 @@ sub check_params {
#template
my $template = '';
$template = template::check( $params->{template}, 'user_stats' );
$template = template::check($config, $params->{template}, 'user_stats' );
$checked->{template} = $template;
#numeric values

View File

@@ -48,7 +48,7 @@ $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 );
template::process($config, 'print', template::check($config, 'default.html'), $headerParams );
return unless uac::check( $config, $params, $user_presets ) == 1;
our $errors = [];
@@ -168,9 +168,9 @@ sub show_users {
uac::set_template_permissions( $permissions, $params );
#print Dumper($permissions);
template::process( 'print', $params->{template}, $params );
template::process($config, 'print', $params->{template}, $params );
# template::process('print', template::check('users'), $params);
# template::process($config, 'print', template::check($config, 'users'), $params);
}
@@ -251,7 +251,7 @@ sub change_password {
uac::set_template_permissions( $permissions, $params );
#print Dumper($permissions);
template::process( 'print', template::check('change_password'), $params );
template::process( $config, 'print', template::check($config, 'change_password'), $params );
}
sub delete_user {
@@ -405,7 +405,7 @@ sub check_params {
#template
my $template = '';
$template = template::check( $params->{template}, 'users' );
$template = template::check($config, $params->{template}, 'users' );
$checked->{template} = $template;
#numeric values

View File

@@ -59,7 +59,7 @@ $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 );
template::process($config, 'print', template::check($config, 'default.html'), $headerParams );
return unless uac::check( $config, $params, $user_presets ) == 1;
if ( defined $params->{action} ) {
@@ -261,7 +261,7 @@ sub show_work_schedule {
#print STDERR '<pre>'.Dumper($params).'</pre>';
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'work_time' } );
template::process( 'print', $params->{template}, $params );
template::process($config, 'print', $params->{template}, $params );
}
sub check_params {
@@ -300,7 +300,7 @@ sub check_params {
$checked->{studio_id} = -1;
}
$checked->{template} = template::check( $params->{template}, 'edit_work_time' );
$checked->{template} = template::check($config, $params->{template}, 'edit_work_time' );
if ( ( defined $checked->{action} ) && ( $checked->{action} eq 'save_schedule' ) ) {

View File

@@ -68,7 +68,7 @@ sub list_series {
$params->{info}.="no results found" if scalar(@$series)==0;
$params->{info}='';
template::process( 'print', 'templates/series.html', $params );
template::process($config, 'print', 'templates/series.html', $params );
}
sub check_params {

View File

@@ -62,7 +62,7 @@ $template_parameters->{use_client_cache} = $config->{cache}->{use_client_cache}
#output template
my $template = $params->{template};
my $out = '';
template::process( $out, $params->{template}, $template_parameters );
template::process($config, $out, $params->{template}, $template_parameters );
print $out;
#write to cache
@@ -184,7 +184,7 @@ sub check_params {
my $config = shift;
my $params = shift;
my $template = template::check( $params->{template}, 'series_names.html' );
my $template = template::check($config, $params->{template}, 'series_names.html' );
my $debug = $params->{debug} || '';
if ( $debug =~ /([a-z\_\,]+)/ ) {