remove cache
* remove cache, cache setup is not easy, todays servers do not really * need it anymore * add prototypes and fix parameter issues * suppress redefinition
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
@@ -8,7 +8,6 @@ use params();
|
||||
use config();
|
||||
use db();
|
||||
use markup();
|
||||
use cache();
|
||||
use comments();
|
||||
use template();
|
||||
use log();
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use utf8;
|
||||
|
||||
#use CGI qw(header param Vars);
|
||||
|
||||
use config();
|
||||
use params();
|
||||
use db();
|
||||
@@ -20,7 +17,7 @@ if ( $0 =~ /aggregate.*?\.cgi$/ ) {
|
||||
|
||||
my $params = {};
|
||||
my $r = shift;
|
||||
#print STDERR ref($r)."\n";
|
||||
|
||||
if ( ref($r) eq '' ) {
|
||||
for my $arg (@ARGV) {
|
||||
my ( $key, $value ) = split( /\=/, $arg, 2 );
|
||||
@@ -56,22 +53,12 @@ if ( $0 =~ /aggregate.*?\.cgi$/ ) {
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
my $mem = 0;
|
||||
|
||||
#get result from cache
|
||||
my $cache = aggregator::get_cache( $config, $request );
|
||||
|
||||
if ( ( defined $cache->{content} ) && ( $cache->{content} ne '' ) ) {
|
||||
my $content = $cache->{content};
|
||||
print $output_header;
|
||||
print $content;
|
||||
return;
|
||||
}
|
||||
|
||||
my $content = load_file( $base_dir . './index.html' );
|
||||
$content = $$content || '';
|
||||
|
||||
#replace HTML escaped calcms_title span by unescaped one
|
||||
$content =~ s/\<\;span id\="\;calcms_title"\;\>\;[^\&]*\<\;\/span\>\;/\<span id=\"calcms_title\" \>\<\/span\>/g;
|
||||
$content =~
|
||||
s/\<\;span id\="\;calcms_title"\;\>\;[^\&]*\<\;\/span\>\;/\<span id=\"calcms_title\" \>\<\/span\>/g;
|
||||
|
||||
# print $content;
|
||||
|
||||
@@ -130,7 +117,9 @@ if ( $0 =~ /aggregate.*?\.cgi$/ ) {
|
||||
$content =~ s/(<(div|span)\s+id="calcms_title".*?>).*?(<\/(div|span)>)/$list->{project_title}/g;
|
||||
|
||||
my $values = [];
|
||||
for my $value ( $list->{'series_name'}, $list->{'title'}, $list->{'location'}, 'Programm '. $list->{project_title} ) {
|
||||
for my $value ( $list->{'series_name'},
|
||||
$list->{'title'}, $list->{'location'}, 'Programm ' . $list->{project_title} . ' | In Gedenken an AB✝' )
|
||||
{
|
||||
next unless defined $value;
|
||||
next if $value eq '';
|
||||
push @$values, $value;
|
||||
@@ -156,14 +145,8 @@ if ( $0 =~ /aggregate.*?\.cgi$/ ) {
|
||||
print $output_header;
|
||||
print $content;
|
||||
|
||||
if ( $config->{cache}->{use_cache} eq '1' ) {
|
||||
$cache->{content} = $content;
|
||||
cache::save($cache);
|
||||
}
|
||||
|
||||
# $config=undef;
|
||||
$content = undef;
|
||||
$cache = undef;
|
||||
}
|
||||
|
||||
sub load_file {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
#use utf8;
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
use params();
|
||||
@@ -16,23 +16,23 @@ my $r = shift;
|
||||
binmode STDOUT, ":encoding(UTF-8)";
|
||||
|
||||
if ( $0 =~ /cal.*?\.cgi$/ ) {
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config = config::getFromScriptLocation();
|
||||
my $debug = $config->{system}->{debug};
|
||||
my $config = config::getFromScriptLocation();
|
||||
my $debug = $config->{system}->{debug};
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING},
|
||||
params => {
|
||||
original => $params,
|
||||
checked => calendar::check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
$params = $request->{params}->{checked};
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING},
|
||||
params => {
|
||||
original => $params,
|
||||
checked => calendar::check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
my $out = '';
|
||||
calendar::get_cached_or_render( $out, $config, $request );
|
||||
print $out. "\n";
|
||||
my $out = '';
|
||||
calendar::get_cached_or_render( $out, $config, $request );
|
||||
print $out. "\n";
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
use params();
|
||||
use db();
|
||||
use markup();
|
||||
use cache();
|
||||
use log();
|
||||
use config();
|
||||
use template();
|
||||
@@ -19,7 +20,7 @@ my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config = config::getFromScriptLocation();
|
||||
my $debug = $config->{system}->{debug};
|
||||
my $debug = $config->{system}->{debug};
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING},
|
||||
@@ -30,16 +31,6 @@ my $request = {
|
||||
};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
my $cache = {};
|
||||
if ( $config->{cache}->{use_cache} eq '1' ) {
|
||||
cache::configure('categories.html');
|
||||
$cache = cache::load( $config, $params );
|
||||
if ( defined $cache->{content} ) {
|
||||
print $cache->{content};
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
my $dbh = db::connect($config);
|
||||
|
||||
my $template_parameters = {};
|
||||
@@ -48,19 +39,14 @@ $template_parameters->{projects} = getProjects( $dbh, $config );
|
||||
#$template_parameters->{categories} = get_categories($dbh,$params->{project});
|
||||
$template_parameters->{debug} = $config->{system}->{debug};
|
||||
$template_parameters->{server_cache} = $config->{cache}->{server_cache} if ( $config->{cache}->{server_cache} );
|
||||
$template_parameters->{use_client_cache} = $config->{cache}->{use_client_cache} if ( $config->{cache}->{use_client_cache} );
|
||||
$template_parameters->{use_client_cache} = $config->{cache}->{use_client_cache}
|
||||
if ( $config->{cache}->{use_client_cache} );
|
||||
|
||||
my $template = $params->{template};
|
||||
my $out = '';
|
||||
template::process( $config, $out, $params->{template}, $template_parameters );
|
||||
print $out;
|
||||
|
||||
#write to cache
|
||||
if ( $config->{cache}->{use_cache} eq '1' ) {
|
||||
$cache->{content} = $out;
|
||||
cache::save($cache);
|
||||
}
|
||||
|
||||
sub getProjects {
|
||||
my $dbh = shift;
|
||||
my $config = shift;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
@@ -11,7 +12,6 @@ use comments();
|
||||
use db();
|
||||
use markup();
|
||||
use time();
|
||||
use cache();
|
||||
use log();
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
@@ -19,20 +19,20 @@ my $r = shift;
|
||||
binmode STDOUT, ":encoding(UTF-8)";
|
||||
|
||||
if ( $0 =~ /comments.*?\.cgi$/ ) {
|
||||
my $config = config::get('config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my $config = config::get('config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING},
|
||||
params => {
|
||||
original => $params,
|
||||
checked => comments::check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING},
|
||||
params => {
|
||||
original => $params,
|
||||
checked => comments::check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
|
||||
my $output = '';
|
||||
comments::get_cached_or_render( $output, $config, $request, 'filter_locked' );
|
||||
print $output;
|
||||
my $output = '';
|
||||
comments::get_cached_or_render( $output, $config, $request, 'filter_locked' );
|
||||
print $output;
|
||||
}
|
||||
|
||||
#do not delete last line
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
use URI::Escape();
|
||||
use Encode();
|
||||
@@ -61,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( $config, 'print', template::check($config, 'default.html'), $headerParams );
|
||||
template::process( $config, 'print', template::check( $config, 'default.html' ), $headerParams );
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
print q{
|
||||
@@ -95,11 +97,11 @@ sub show_events {
|
||||
|
||||
my $projects = project::get( $config, { project_id => $params->{project_id} } );
|
||||
my $project = $projects->[0];
|
||||
return unless scalar @$projects == 1 ;
|
||||
return unless scalar @$projects == 1;
|
||||
|
||||
my $studios = studios::get( $config, { project_id => $params->{project_id}, studio_id => $params->{studio_id} } );
|
||||
my $studio = $studios->[0];
|
||||
return unless scalar @$studios == 1 ;
|
||||
return unless scalar @$studios == 1;
|
||||
|
||||
my $project_name = $project->{name};
|
||||
my $studio_name = $studio->{location};
|
||||
@@ -140,7 +142,7 @@ sub show_events {
|
||||
$params->{project_name} = $project_name;
|
||||
$params->{studio_name} = $studio_name;
|
||||
|
||||
template::process($config, 'print', $params->{template}, $params );
|
||||
template::process( $config, 'print', $params->{template}, $params );
|
||||
}
|
||||
|
||||
sub assign_series {
|
||||
@@ -235,7 +237,7 @@ sub check_params {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
|
||||
$checked->{template} = template::check($config, $params->{template}, 'assign_series' );
|
||||
$checked->{template} = template::check( $config, $params->{template}, 'assign_series' );
|
||||
|
||||
return $checked;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use Data::Dumper;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use URI::Escape();
|
||||
use Encode();
|
||||
@@ -240,7 +240,11 @@ sub assign_events {
|
||||
"event not found for project $entry->{project_id}, studio $entry->{studio_id}, series $entry->{series_id}, event $entry->{event_id}\n";
|
||||
next;
|
||||
}
|
||||
print STDERR "'" . $event->{event_id} . "' '" . $event->{series_name} . "' '" . $event->{title} . "' '" . $event->{episode} . "'\n";
|
||||
print STDERR "'"
|
||||
. $event->{event_id} . "' '"
|
||||
. $event->{series_name} . "' '"
|
||||
. $event->{title} . "' '"
|
||||
. $event->{episode} . "'\n";
|
||||
|
||||
#next;
|
||||
|
||||
@@ -318,7 +322,8 @@ sub assign_events {
|
||||
# print STDERR "ok\n";
|
||||
}
|
||||
} else {
|
||||
print STDERR "no series title found for studio $entry->{studio_id} series $entry->{series_id}, event $entry->{event_id}\n";
|
||||
print STDERR
|
||||
"no series title found for studio $entry->{studio_id} series $entry->{series_id}, event $entry->{event_id}\n";
|
||||
next;
|
||||
}
|
||||
|
||||
@@ -392,7 +397,9 @@ sub check_params {
|
||||
$checked->{create_events} = 0;
|
||||
$checked->{publish_events} = 0;
|
||||
}
|
||||
for my $param ( 'frequency', 'duration', 'default_duration', 'create_events', 'publish_events', 'live', 'count_episodes' ) {
|
||||
for my $param ( 'frequency', 'duration', 'default_duration', 'create_events', 'publish_events', 'live',
|
||||
'count_episodes' )
|
||||
{
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /(\d+)/ ) ) {
|
||||
$checked->{$param} = $1;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
local $| = 0;
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
use CGI::Simple ();
|
||||
@@ -59,12 +58,12 @@ my ( $user, $expires ) = auth::get_user( $config, $params, $cgi );
|
||||
exit if ( !defined $user ) || ( $user eq '' );
|
||||
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$config,
|
||||
{
|
||||
user => $user,
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id}
|
||||
}
|
||||
$config,
|
||||
{
|
||||
user => $user,
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id}
|
||||
}
|
||||
);
|
||||
|
||||
$params->{default_studio_id} = $user_presets->{studio_id};
|
||||
@@ -72,11 +71,11 @@ $params = uac::setDefaultStudio( $params, $user_presets );
|
||||
$params = uac::setDefaultProject( $params, $user_presets );
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($config, $params),
|
||||
},
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
@@ -85,9 +84,9 @@ $params = $request->{params}->{checked};
|
||||
|
||||
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 );
|
||||
template::process( $config, 'print', template::check( $config, 'default.html' ), $headerParams );
|
||||
|
||||
exit unless defined uac::check( $config, $params, $user_presets );
|
||||
exit unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
print q{
|
||||
<script src="js/audio_recordings.js" type="text/javascript"></script>
|
||||
@@ -101,479 +100,481 @@ $params->{error} = $error || '';
|
||||
#print STDERR Dumper($params);
|
||||
|
||||
if ( $params->{action} eq 'upload' ) {
|
||||
uploadRecording( $config, $request );
|
||||
uploadRecording( $config, $request );
|
||||
} elsif ( $params->{action} eq 'delete' ) {
|
||||
deleteRecording( $config, $request );
|
||||
deleteRecording( $config, $request );
|
||||
}
|
||||
|
||||
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($config, 'print', $params->{template}, $params );
|
||||
template::process( $config, 'print', $params->{template}, $params );
|
||||
|
||||
exit;
|
||||
|
||||
sub uploadRecording {
|
||||
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};
|
||||
|
||||
unless ( $permissions->{upload_audio_recordings} == 1 ) {
|
||||
uac::permissions_denied('upload_audio_recordings');
|
||||
return;
|
||||
}
|
||||
unless ( $permissions->{upload_audio_recordings} == 1 ) {
|
||||
uac::permissions_denied('upload_audio_recordings');
|
||||
return;
|
||||
}
|
||||
|
||||
for my $attr ( 'project_id', 'studio_id', 'series_id', 'event_id' ) {
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( "missing " . $attr . " to upload productions" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
for my $attr ( 'project_id', 'studio_id', 'series_id', 'event_id' ) {
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( "missing " . $attr . " to upload productions" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( defined $fh ) {
|
||||
print STDERR "upload\n";
|
||||
if ( defined $fh ) {
|
||||
print STDERR "upload\n";
|
||||
|
||||
#print STDERR Dumper($fh)."<br>";
|
||||
my $fileInfo = uploadFile( $config, $fh, $params->{event_id}, $user, $params->{upload} );
|
||||
$params->{error} .= $fileInfo->{error} if defined $fileInfo->{error};
|
||||
$params->{path} = $fileInfo->{path};
|
||||
$params->{size} = $fileInfo->{size};
|
||||
#print STDERR Dumper($fh)."<br>";
|
||||
my $fileInfo = uploadFile( $config, $fh, $params->{event_id}, $user, $params->{upload} );
|
||||
$params->{error} .= $fileInfo->{error} if defined $fileInfo->{error};
|
||||
$params->{path} = $fileInfo->{path};
|
||||
$params->{size} = $fileInfo->{size};
|
||||
|
||||
#$params->{duration} = $fileInfo->{duration};
|
||||
$params = updateDatabase( $config, $params, $user ) if $params->{error} eq '';
|
||||
} else {
|
||||
$params->{error} .= 'Could not get file handle';
|
||||
}
|
||||
#$params->{duration} = $fileInfo->{duration};
|
||||
$params = updateDatabase( $config, $params, $user ) if $params->{error} eq '';
|
||||
} else {
|
||||
$params->{error} .= 'Could not get file handle';
|
||||
}
|
||||
|
||||
if ( $params->{error} ne '' ) {
|
||||
if ( $params->{error} =~ /limit/ ) {
|
||||
$params->{error} .=
|
||||
"audio file size is limited to " . int( $uploadLimit / 1000000 ) . " MB!" . "Please make it smaller and try again!";
|
||||
} else {
|
||||
$params->{error} .= "Error:'$error'";
|
||||
}
|
||||
}
|
||||
if ( $params->{error} ne '' ) {
|
||||
if ( $params->{error} =~ /limit/ ) {
|
||||
$params->{error} .=
|
||||
"audio file size is limited to "
|
||||
. int( $uploadLimit / 1000000 ) . " MB!"
|
||||
. "Please make it smaller and try again!";
|
||||
} else {
|
||||
$params->{error} .= "Error:'$error'";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# return 1 if file has been deleted
|
||||
sub deleteFile {
|
||||
my $file = shift;
|
||||
return 0 unless defined $file;
|
||||
my $file = shift;
|
||||
return 0 unless defined $file;
|
||||
|
||||
if ( -e $file ) {
|
||||
if ( -w $file ) {
|
||||
unlink $file;
|
||||
if ( -e $file ) {
|
||||
if ( -w $file ) {
|
||||
unlink $file;
|
||||
|
||||
# check if file has been deleted
|
||||
if ( -e $file ) {
|
||||
uac::print_error("could not delete audio file '$file', $!\n");
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
uac::print_error("cannot delete audio file '$file', missing permissions\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
# check if file has been deleted
|
||||
if ( -e $file ) {
|
||||
uac::print_error("could not delete audio file '$file', $!\n");
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
uac::print_error("cannot delete audio file '$file', missing permissions\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub deleteRecording {
|
||||
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};
|
||||
|
||||
unless ( $permissions->{delete_audio_recordings} == 1 ) {
|
||||
uac::permissions_denied('delete_audio_recordings');
|
||||
return;
|
||||
}
|
||||
unless ( $permissions->{delete_audio_recordings} == 1 ) {
|
||||
uac::permissions_denied('delete_audio_recordings');
|
||||
return;
|
||||
}
|
||||
|
||||
for my $attr (
|
||||
'project_id', 'studio_id',
|
||||
for my $attr (
|
||||
'project_id', 'studio_id',
|
||||
|
||||
#'series_id',
|
||||
'event_id', 'path'
|
||||
)
|
||||
{
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( "missing " . $attr . " to delete production" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
#'series_id',
|
||||
'event_id', 'path'
|
||||
)
|
||||
{
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( "missing " . $attr . " to delete production" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
my $dbh = db::connect($config);
|
||||
$config->{access}->{write} = 0;
|
||||
my $dbh = db::connect($config);
|
||||
$config->{access}->{write} = 0;
|
||||
|
||||
my $audioRecordings = audio_recordings::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
event_id => $params->{event_id},
|
||||
path => $params->{path}
|
||||
}
|
||||
);
|
||||
my $audioRecordings = audio_recordings::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
event_id => $params->{event_id},
|
||||
path => $params->{path}
|
||||
}
|
||||
);
|
||||
|
||||
unless ( ( defined $audioRecordings ) && ( scalar @$audioRecordings > 0 ) ) {
|
||||
uac::print_error("could not find audio file $params->{path} in database");
|
||||
return;
|
||||
}
|
||||
unless ( ( defined $audioRecordings ) && ( scalar @$audioRecordings > 0 ) ) {
|
||||
uac::print_error("could not find audio file $params->{path} in database");
|
||||
return;
|
||||
}
|
||||
|
||||
my $targetDir = $config->{locations}->{local_audio_recordings_dir};
|
||||
unless ( defined $targetDir ) {
|
||||
uac::print_error("'local_audio_recordings_dir' is not configured.");
|
||||
return;
|
||||
}
|
||||
unless ( -d $targetDir ) {
|
||||
uac::print_error("audio dir '$targetDir' does not exist");
|
||||
return;
|
||||
}
|
||||
my $targetDir = $config->{locations}->{local_audio_recordings_dir};
|
||||
unless ( defined $targetDir ) {
|
||||
uac::print_error("'local_audio_recordings_dir' is not configured.");
|
||||
return;
|
||||
}
|
||||
unless ( -d $targetDir ) {
|
||||
uac::print_error("audio dir '$targetDir' does not exist");
|
||||
return;
|
||||
}
|
||||
|
||||
my $file = $targetDir . '/' . $params->{path};
|
||||
print STDERR "ERROR: cannot delete audio file '$file', file does not exist\n" unless -e $file;
|
||||
my $file = $targetDir . '/' . $params->{path};
|
||||
print STDERR "ERROR: cannot delete audio file '$file', file does not exist\n" unless -e $file;
|
||||
|
||||
my $isDeleted = deleteFile($file);
|
||||
return unless $isDeleted;
|
||||
my $isDeleted = deleteFile($file);
|
||||
return unless $isDeleted;
|
||||
|
||||
$config->{access}->{write} = 1;
|
||||
$audioRecordings = audio_recordings::delete(
|
||||
$config, $dbh,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
event_id => $params->{event_id},
|
||||
path => $params->{path},
|
||||
}
|
||||
);
|
||||
$config->{access}->{write} = 0;
|
||||
$config->{access}->{write} = 1;
|
||||
$audioRecordings = audio_recordings::delete(
|
||||
$config, $dbh,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
event_id => $params->{event_id},
|
||||
path => $params->{path},
|
||||
}
|
||||
);
|
||||
$config->{access}->{write} = 0;
|
||||
|
||||
}
|
||||
|
||||
sub showAudioRecordings {
|
||||
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', 'series_id', 'event_id' ) {
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( "missing " . $attr . " to show productions" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
for my $attr ( 'project_id', 'studio_id', 'series_id', 'event_id' ) {
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( "missing " . $attr . " to show productions" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
my $event = series::get_event(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
series_id => $params->{series_id},
|
||||
event_id => $params->{event_id}
|
||||
}
|
||||
);
|
||||
unless ( defined $event ) {
|
||||
uac::print_error("event not found");
|
||||
return;
|
||||
}
|
||||
my $event = series::get_event(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
series_id => $params->{series_id},
|
||||
event_id => $params->{event_id}
|
||||
}
|
||||
);
|
||||
unless ( defined $event ) {
|
||||
uac::print_error("event not found");
|
||||
return;
|
||||
}
|
||||
|
||||
#print '<pre>'.Dumper($event).'</pre>';
|
||||
#print '<pre>'.Dumper($event).'</pre>';
|
||||
|
||||
my $audioRecordings = audio_recordings::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
event_id => $params->{event_id},
|
||||
}
|
||||
);
|
||||
my $audioRecordings = audio_recordings::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
event_id => $params->{event_id},
|
||||
}
|
||||
);
|
||||
|
||||
#print Dumper($audioRecordings);
|
||||
for my $recording (@$audioRecordings) {
|
||||
$recording->{size} =~ s/(\d)(\d\d\d)$/$1\.$2/g;
|
||||
$recording->{size} =~ s/(\d)(\d\d\d\.\d\d\d)$/$1\.$2/g;
|
||||
#print Dumper($audioRecordings);
|
||||
for my $recording (@$audioRecordings) {
|
||||
$recording->{size} =~ s/(\d)(\d\d\d)$/$1\.$2/g;
|
||||
$recording->{size} =~ s/(\d)(\d\d\d\.\d\d\d)$/$1\.$2/g;
|
||||
|
||||
$recording->{processed} = $recording->{processed} ? 'yes' : 'no';
|
||||
$recording->{mastered} = $recording->{mastered} ? 'yes' : 'no';
|
||||
$recording->{processed} = $recording->{processed} ? 'yes' : 'no';
|
||||
$recording->{mastered} = $recording->{mastered} ? 'yes' : 'no';
|
||||
|
||||
$recording->{eventDuration} = getDuration( $recording->{eventDuration} );
|
||||
$recording->{audioDuration} = getDuration( $recording->{audioDuration} );
|
||||
$recording->{eventDuration} = getDuration( $recording->{eventDuration} );
|
||||
$recording->{audioDuration} = getDuration( $recording->{audioDuration} );
|
||||
|
||||
$recording->{rmsLeft} ||= '-';
|
||||
$recording->{rmsRight} ||= '-';
|
||||
}
|
||||
$recording->{rmsLeft} ||= '-';
|
||||
$recording->{rmsRight} ||= '-';
|
||||
}
|
||||
|
||||
my $now = time();
|
||||
my $timeZone = $config->{date}->{time_zone};
|
||||
my $start = time::datetime_to_utc( $event->{start}, $timeZone );
|
||||
my $end = time::datetime_to_utc( $event->{end}, $timeZone );
|
||||
if ( $now > $end ) {
|
||||
uac::print_error("upload is expired due to the show is over");
|
||||
$params->{isOver} = 1;
|
||||
}
|
||||
my $days = 24 * 60 * 60;
|
||||
uac::print_warn("show is more than a week ahead") if ( $now + 7 * $days ) < $start;
|
||||
my $now = time();
|
||||
my $timeZone = $config->{date}->{time_zone};
|
||||
my $start = time::datetime_to_utc( $event->{start}, $timeZone );
|
||||
my $end = time::datetime_to_utc( $event->{end}, $timeZone );
|
||||
if ( $now > $end ) {
|
||||
uac::print_error("upload is expired due to the show is over");
|
||||
$params->{isOver} = 1;
|
||||
}
|
||||
my $days = 24 * 60 * 60;
|
||||
uac::print_warn("show is more than a week ahead") if ( $now + 7 * $days ) < $start;
|
||||
|
||||
$params->{event} = $event;
|
||||
$params->{audio_recordings} = $audioRecordings;
|
||||
$params->{event} = $event;
|
||||
$params->{audio_recordings} = $audioRecordings;
|
||||
|
||||
}
|
||||
|
||||
sub getDuration {
|
||||
my $duration = shift;
|
||||
my $hour = int( $duration / 3600 );
|
||||
$duration -= $hour * 3600;
|
||||
my $duration = shift;
|
||||
my $hour = int( $duration / 3600 );
|
||||
$duration -= $hour * 3600;
|
||||
|
||||
my $minutes = int( $duration / 60 );
|
||||
$duration -= $minutes * 60;
|
||||
my $minutes = int( $duration / 60 );
|
||||
$duration -= $minutes * 60;
|
||||
|
||||
my $seconds = int($duration);
|
||||
$duration -= $seconds;
|
||||
my $seconds = int($duration);
|
||||
$duration -= $seconds;
|
||||
|
||||
my $milli = int( 100 * $duration );
|
||||
return sprintf( "%02d:%02d:%02d.%02d", $hour, $minutes, $seconds, $milli );
|
||||
my $milli = int( 100 * $duration );
|
||||
return sprintf( "%02d:%02d:%02d.%02d", $hour, $minutes, $seconds, $milli );
|
||||
}
|
||||
|
||||
sub uploadFile {
|
||||
my $config = $_[0];
|
||||
my $fh = $_[1];
|
||||
my $eventId = $_[2];
|
||||
my $user = $_[3] || '';
|
||||
my $filename = $_[4] || '';
|
||||
my $config = $_[0];
|
||||
my $fh = $_[1];
|
||||
my $eventId = $_[2];
|
||||
my $user = $_[3] || '';
|
||||
my $filename = $_[4] || '';
|
||||
|
||||
# check target directory
|
||||
my $targetDir = $config->{locations}->{local_audio_recordings_dir};
|
||||
return { error => "could not find local_audio_recordings_dir" } unless defined $targetDir;
|
||||
return { error => "local_audio_recordings_dir does not exist" } unless -e $targetDir;
|
||||
# check target directory
|
||||
my $targetDir = $config->{locations}->{local_audio_recordings_dir};
|
||||
return { error => "could not find local_audio_recordings_dir" } unless defined $targetDir;
|
||||
return { error => "local_audio_recordings_dir does not exist" } unless -e $targetDir;
|
||||
|
||||
# save file to disk
|
||||
my $userName = $user;
|
||||
$userName =~ s/[^a-zA-Z0-9\.\-\_]//g;
|
||||
# save file to disk
|
||||
my $userName = $user;
|
||||
$userName =~ s/[^a-zA-Z0-9\.\-\_]//g;
|
||||
|
||||
my $time = time::time_to_datetime();
|
||||
$time =~ s/\:/\-/g;
|
||||
$time =~ s/\s/\_/g;
|
||||
$time =~ s/[^a-zA-Z0-9\.\-\_]//g;
|
||||
my $time = time::time_to_datetime();
|
||||
$time =~ s/\:/\-/g;
|
||||
$time =~ s/\s/\_/g;
|
||||
$time =~ s/[^a-zA-Z0-9\.\-\_]//g;
|
||||
|
||||
$filename =~ s/\.(mp3)$//g;
|
||||
$filename = join( '-', ( $time, 'id' . $eventId, $userName, $filename ) ) . '.mp3';
|
||||
$filename =~ s/[^a-zA-Z0-9\.\-\_]//g;
|
||||
$filename =~ s/\.(mp3)$//g;
|
||||
$filename = join( '-', ( $time, 'id' . $eventId, $userName, $filename ) ) . '.mp3';
|
||||
$filename =~ s/[^a-zA-Z0-9\.\-\_]//g;
|
||||
|
||||
my $tempFile = $targetDir . '/' . $filename;
|
||||
print STDERR "tempFile=$tempFile\n";
|
||||
my $tempFile = $targetDir . '/' . $filename;
|
||||
print STDERR "tempFile=$tempFile\n";
|
||||
|
||||
my $start = time();
|
||||
open DAT, '>', $tempFile or return { error => 'could not save upload. ' . $! . " " . $tempFile };
|
||||
binmode DAT;
|
||||
my $size = 0;
|
||||
my $data = '';
|
||||
while ( my $bytesRead = $fh->read( $data, 65000 ) ) {
|
||||
print DAT $data;
|
||||
$size += $bytesRead;
|
||||
$data = '';
|
||||
}
|
||||
close DAT;
|
||||
my $start = time();
|
||||
open DAT, '>', $tempFile or return { error => 'could not save upload. ' . $! . " " . $tempFile };
|
||||
binmode DAT;
|
||||
my $size = 0;
|
||||
my $data = '';
|
||||
while ( my $bytesRead = $fh->read( $data, 65000 ) ) {
|
||||
print DAT $data;
|
||||
$size += $bytesRead;
|
||||
$data = '';
|
||||
}
|
||||
close DAT;
|
||||
|
||||
return {
|
||||
dir => $targetDir,
|
||||
path => $filename,
|
||||
size => $size,
|
||||
};
|
||||
return {
|
||||
dir => $targetDir,
|
||||
path => $filename,
|
||||
size => $size,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
sub updateDatabase {
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
my $user = shift;
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
my $user = shift;
|
||||
|
||||
my $eventDuration = getEventDuration( $config, $params->{event_id} );
|
||||
my $eventDuration = getEventDuration( $config, $params->{event_id} );
|
||||
|
||||
my $entry = {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
event_id => $params->{event_id},
|
||||
path => $params->{path},
|
||||
size => $params->{size},
|
||||
created_by => $user,
|
||||
eventDuration => $eventDuration
|
||||
};
|
||||
my $entry = {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
event_id => $params->{event_id},
|
||||
path => $params->{path},
|
||||
size => $params->{size},
|
||||
created_by => $user,
|
||||
eventDuration => $eventDuration
|
||||
};
|
||||
|
||||
#print STDERR "updateDatabase:" . Dumper($entry);
|
||||
#print STDERR "updateDatabase:" . Dumper($entry);
|
||||
|
||||
#connect
|
||||
$config->{access}->{write} = 1;
|
||||
my $dbh = db::connect($config);
|
||||
#connect
|
||||
$config->{access}->{write} = 1;
|
||||
my $dbh = db::connect($config);
|
||||
|
||||
my $entries = audio_recordings::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $entry->{project_id},
|
||||
studio_id => $entry->{studio_id},
|
||||
event_id => $entry->{event_id},
|
||||
path => $entry->{path}
|
||||
}
|
||||
);
|
||||
my $entries = audio_recordings::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $entry->{project_id},
|
||||
studio_id => $entry->{studio_id},
|
||||
event_id => $entry->{event_id},
|
||||
path => $entry->{path}
|
||||
}
|
||||
);
|
||||
|
||||
if ( ( defined $entries ) && ( scalar @$entries > 0 ) ) {
|
||||
print STDERR "update\n";
|
||||
audio_recordings::update( $config, $dbh, $entry );
|
||||
my $entry = $entries->[0];
|
||||
$params->{id} = $entry->{id};
|
||||
} else {
|
||||
print STDERR "insert\n";
|
||||
$entry->{created_by} = $user;
|
||||
$entry->{processed} = 0;
|
||||
$entry->{mastered} = 0;
|
||||
$entry->{rmsLeft} = 0.0;
|
||||
$entry->{rmsRight} = 0.0;
|
||||
$entry->{audioDuration} = 0.0;
|
||||
$entry->{modified_at} = time();
|
||||
$params->{id} = audio_recordings::insert( $config, $dbh, $entry );
|
||||
}
|
||||
$config->{access}->{write} = 0;
|
||||
$params->{action_result} = 'done!';
|
||||
if ( ( defined $entries ) && ( scalar @$entries > 0 ) ) {
|
||||
print STDERR "update\n";
|
||||
audio_recordings::update( $config, $dbh, $entry );
|
||||
my $entry = $entries->[0];
|
||||
$params->{id} = $entry->{id};
|
||||
} else {
|
||||
print STDERR "insert\n";
|
||||
$entry->{created_by} = $user;
|
||||
$entry->{processed} = 0;
|
||||
$entry->{mastered} = 0;
|
||||
$entry->{rmsLeft} = 0.0;
|
||||
$entry->{rmsRight} = 0.0;
|
||||
$entry->{audioDuration} = 0.0;
|
||||
$entry->{modified_at} = time();
|
||||
$params->{id} = audio_recordings::insert( $config, $dbh, $entry );
|
||||
}
|
||||
$config->{access}->{write} = 0;
|
||||
$params->{action_result} = 'done!';
|
||||
|
||||
return $params;
|
||||
return $params;
|
||||
}
|
||||
|
||||
# return filename, filehandle and optionally error from upload
|
||||
sub getFilename {
|
||||
my $cgi = shift;
|
||||
my $upload = shift;
|
||||
my $cgi = shift;
|
||||
my $upload = shift;
|
||||
|
||||
if ( defined $upload ) {
|
||||
if ( defined $upload ) {
|
||||
|
||||
# try apache2 module
|
||||
my $filename = $upload->filename();
|
||||
return {
|
||||
filename => $filename,
|
||||
fh => $upload->fh(),
|
||||
error => ''
|
||||
};
|
||||
# try apache2 module
|
||||
my $filename = $upload->filename();
|
||||
return {
|
||||
filename => $filename,
|
||||
fh => $upload->fh(),
|
||||
error => ''
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#print STDERR "cgi:".Dumper($cgi);
|
||||
#print STDERR "cgi:".Dumper($cgi);
|
||||
|
||||
# fallback to CGI module
|
||||
my $file = $cgi->param("upload");
|
||||
return { error => "is no file" } if ( defined $file ) && ( $file =~ /\|/ );
|
||||
# fallback to CGI module
|
||||
my $file = $cgi->param("upload");
|
||||
return { error => "is no file" } if ( defined $file ) && ( $file =~ /\|/ );
|
||||
|
||||
#print STDERR "file:".Dumper($file);
|
||||
my $fileInfo = $cgi->uploadInfo($file);
|
||||
#print STDERR "file:".Dumper($file);
|
||||
my $fileInfo = $cgi->uploadInfo($file);
|
||||
|
||||
#print STDERR "fileInfo:".Dumper($fileInfo);
|
||||
#print STDERR "fileInfo:".Dumper($fileInfo);
|
||||
|
||||
if ( defined $fileInfo ) {
|
||||
my $filename = $fileInfo->{'Content-Disposition'} || '';
|
||||
if ( $filename =~ /filename=\"(.*?)\"/ ) {
|
||||
$filename = $1;
|
||||
return {
|
||||
filename => $filename,
|
||||
fh => $file,
|
||||
error => ''
|
||||
};
|
||||
if ( defined $fileInfo ) {
|
||||
my $filename = $fileInfo->{'Content-Disposition'} || '';
|
||||
if ( $filename =~ /filename=\"(.*?)\"/ ) {
|
||||
$filename = $1;
|
||||
return {
|
||||
filename => $filename,
|
||||
fh => $file,
|
||||
error => ''
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#error
|
||||
return { error => 'Could not detect file name!' };
|
||||
#error
|
||||
return { error => 'Could not detect file name!' };
|
||||
}
|
||||
|
||||
# get extension and optionally error
|
||||
sub checkFilename {
|
||||
my $filename = shift;
|
||||
my $filename = shift;
|
||||
|
||||
my @validExtensions = ('mp3');
|
||||
if ( $filename =~ /\.([a-zA-Z]{3,5})$/ ) {
|
||||
my $extension = lc $1;
|
||||
unless ( grep( /$extension/, @validExtensions ) ) {
|
||||
return { error => 'Following file formats are supported: ' . join( ",", @validExtensions ) . '!' };
|
||||
}
|
||||
return {
|
||||
extension => $extension,
|
||||
error => ''
|
||||
};
|
||||
}
|
||||
return { error => 'Not matching file extension found! Supported are: ' . join( ",", @validExtensions ) . '!' };
|
||||
my @validExtensions = ('mp3');
|
||||
if ( $filename =~ /\.([a-zA-Z]{3,5})$/ ) {
|
||||
my $extension = lc $1;
|
||||
unless ( grep( /$extension/, @validExtensions ) ) {
|
||||
return { error => 'Following file formats are supported: ' . join( ",", @validExtensions ) . '!' };
|
||||
}
|
||||
return {
|
||||
extension => $extension,
|
||||
error => ''
|
||||
};
|
||||
}
|
||||
return { error => 'Not matching file extension found! Supported are: ' . join( ",", @validExtensions ) . '!' };
|
||||
}
|
||||
|
||||
# return event duration in seconds
|
||||
sub getEventDuration {
|
||||
my $config = shift;
|
||||
my $eventId = shift;
|
||||
my $config = shift;
|
||||
my $eventId = shift;
|
||||
|
||||
if ( $eventId < 1 ) {
|
||||
print STDERR "invalid eventId $eventId\n";
|
||||
return 0;
|
||||
}
|
||||
if ( $eventId < 1 ) {
|
||||
print STDERR "invalid eventId $eventId\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
my $request = {
|
||||
params => {
|
||||
checked => events::check_params(
|
||||
$config,
|
||||
{
|
||||
event_id => $eventId,
|
||||
template => 'no',
|
||||
limit => 1,
|
||||
}
|
||||
)
|
||||
},
|
||||
config => $config
|
||||
};
|
||||
$request->{params}->{checked}->{published} = 'all';
|
||||
my $events = events::get( $config, $request );
|
||||
if ( scalar @$events == 0 ) {
|
||||
print STDERR "getEventDuration: no event found with event_id=$eventId\n";
|
||||
}
|
||||
my $event = $events->[0];
|
||||
my $duration = time::get_duration_seconds( $event->{start}, $event->{end}, $config->{date}->{time_zone} );
|
||||
return $duration;
|
||||
my $request = {
|
||||
params => {
|
||||
checked => events::check_params(
|
||||
$config,
|
||||
{
|
||||
event_id => $eventId,
|
||||
template => 'no',
|
||||
limit => 1,
|
||||
}
|
||||
)
|
||||
},
|
||||
config => $config
|
||||
};
|
||||
$request->{params}->{checked}->{published} = 'all';
|
||||
my $events = events::get( $config, $request );
|
||||
if ( scalar @$events == 0 ) {
|
||||
print STDERR "getEventDuration: no event found with event_id=$eventId\n";
|
||||
}
|
||||
my $event = $events->[0];
|
||||
my $duration = time::get_duration_seconds( $event->{start}, $event->{end}, $config->{date}->{time_zone} );
|
||||
return $duration;
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $checked = {};
|
||||
$checked->{error} = '';
|
||||
$checked->{template} = template::check($config, $params->{template}, 'upload_audio_recordings' );
|
||||
my $checked = {};
|
||||
$checked->{error} = '';
|
||||
$checked->{template} = template::check( $config, $params->{template}, 'upload_audio_recordings' );
|
||||
|
||||
#print Dumper($params);
|
||||
#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};
|
||||
}
|
||||
}
|
||||
#print Dumper($params);
|
||||
#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', 'name', 'description' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\s*(.+?)\s*$/ ) ) {
|
||||
$checked->{$param} = $1;
|
||||
}
|
||||
}
|
||||
#word
|
||||
for my $param ( 'debug', 'name', 'description' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\s*(.+?)\s*$/ ) ) {
|
||||
$checked->{$param} = $1;
|
||||
}
|
||||
}
|
||||
|
||||
# words
|
||||
for my $attr ( 'action', 'path' ) {
|
||||
if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /(\S+)/ ) ) {
|
||||
$checked->{$attr} = $params->{$attr};
|
||||
}
|
||||
}
|
||||
# words
|
||||
for my $attr ( 'action', 'path' ) {
|
||||
if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /(\S+)/ ) ) {
|
||||
$checked->{$attr} = $params->{$attr};
|
||||
}
|
||||
}
|
||||
|
||||
$checked->{upload} = $params->{upload};
|
||||
return $checked;
|
||||
$checked->{upload} = $params->{upload};
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
use URI::Escape();
|
||||
@@ -92,7 +93,7 @@ if (
|
||||
#process header
|
||||
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 );
|
||||
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" />
|
||||
@@ -167,7 +168,7 @@ sub showCalendar {
|
||||
my $end_of_day = $cal_options->{end_of_day};
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
my $permissions = $request->{permissions} || {};
|
||||
unless ( $permissions->{read_series} == 1 ) {
|
||||
uac::permissions_denied('read_series');
|
||||
return;
|
||||
@@ -233,7 +234,7 @@ sub showCalendar {
|
||||
|
||||
if ( $params->{search} =~ /\S/ ) {
|
||||
if ( $params->{list} == 1 ) {
|
||||
$options->{search} = $params->{search};
|
||||
$options->{search} = $params->{search};
|
||||
delete $options->{from_date};
|
||||
delete $options->{till_date};
|
||||
delete $options->{date_range_include};
|
||||
@@ -372,7 +373,9 @@ sub showCalendar {
|
||||
my $format = undef;
|
||||
if ( defined $date->{'format'} ) {
|
||||
$format =
|
||||
( $date->{'format'} || '' ) . " " . ( $date->{'format_version'} || '' ) . " " . ( $date->{'format_profile'} || '' );
|
||||
( $date->{'format'} || '' ) . " "
|
||||
. ( $date->{'format_version'} || '' ) . " "
|
||||
. ( $date->{'format_profile'} || '' );
|
||||
$format =~ s/MPEG Audio Version 1 Layer 3/MP3/g;
|
||||
$format .= ' ' . ( $date->{'format_settings'} || '' ) if defined $date->{'format_settings'};
|
||||
$format .= '<br>';
|
||||
@@ -383,20 +386,27 @@ sub showCalendar {
|
||||
$date->{series_id} = -1;
|
||||
$date->{event_id} = $id;
|
||||
$date->{title} = '';
|
||||
$date->{title} .= '<b>errors</b>: ' . $date->{errors} . '<br>' if defined $date->{errors};
|
||||
$date->{title} .= '<b>errors</b>: ' . $date->{errors} . '<br>' if defined $date->{errors};
|
||||
$date->{title} .= formatDuration( $date->{duration} ) . "<br>" if defined $date->{duration};
|
||||
$date->{title} .= formatLoudness( "L:", $date->{rms_left} ) . ', ' if defined $date->{rms_left};
|
||||
$date->{title} .= formatLoudness( "R:", $date->{rms_right} ) . '<br>' if defined $date->{rms_right};
|
||||
$date->{title} .= formatBitrate( $date->{bitrate} ) . ' ' . $date->{bitrate_mode} . '<br>' if defined $date->{bitrate};
|
||||
$date->{title} .= '<b>replay gain</b> ' . sprintf( "%.1f", $date->{replay_gain} ) . '<br>' if defined $date->{replay_gain};
|
||||
$date->{title} .= ( ( $date->{sampling_rate} || '0' ) / 1000 ) . ' kHz<br>' if defined $date->{sampling_rate};
|
||||
$date->{title} .= formatBitrate( $date->{bitrate} ) . ' ' . $date->{bitrate_mode} . '<br>'
|
||||
if defined $date->{bitrate};
|
||||
$date->{title} .= '<b>replay gain</b> ' . sprintf( "%.1f", $date->{replay_gain} ) . '<br>'
|
||||
if defined $date->{replay_gain};
|
||||
$date->{title} .= ( ( $date->{sampling_rate} || '0' ) / 1000 ) . ' kHz<br>'
|
||||
if defined $date->{sampling_rate};
|
||||
$date->{title} .= ( $date->{channels} || '' ) . ' channels<br>' if defined $date->{channels};
|
||||
$date->{title} .= int( ( $date->{'stream_size'} || '0' ) / ( 1024 * 1024 ) ) . 'MB<br>' if defined $date->{'stream_size'};
|
||||
$date->{title} .= int( ( $date->{'stream_size'} || '0' ) / ( 1024 * 1024 ) ) . 'MB<br>'
|
||||
if defined $date->{'stream_size'};
|
||||
$date->{title} .= $format if defined $format;
|
||||
$date->{title} .= '<b>library</b>: ' . ( $date->{writing_library} || '' ) . '<br>' if defined $date->{'writing_library'};
|
||||
$date->{title} .= '<b>path</b>: ' . ( $date->{file} || '' ) . '<br>' if defined $date->{file};
|
||||
$date->{title} .= '<b>updated_at</b>: ' . ( $date->{updated_at} || '' ) . '<br>' if defined $date->{updated_at};
|
||||
$date->{title} .= '<b>modified_at</b>: ' . ( $date->{modified_at} || '' ) . '<br>' if defined $date->{modified_at};
|
||||
$date->{title} .= '<b>library</b>: ' . ( $date->{writing_library} || '' ) . '<br>'
|
||||
if defined $date->{'writing_library'};
|
||||
$date->{title} .= '<b>path</b>: ' . ( $date->{file} || '' ) . '<br>' if defined $date->{file};
|
||||
$date->{title} .= '<b>updated_at</b>: ' . ( $date->{updated_at} || '' ) . '<br>'
|
||||
if defined $date->{updated_at};
|
||||
$date->{title} .= '<b>modified_at</b>: ' . ( $date->{modified_at} || '' ) . '<br>'
|
||||
if defined $date->{modified_at};
|
||||
|
||||
#print STDERR Dumper($date) if $date->{file}=~/180503/;
|
||||
#$date->{title}.= '<b>rms_image</b>: ' .($date->{rms_image}||'').'<br>' if defined $date->{rms_image};
|
||||
@@ -540,7 +550,7 @@ sub formatLoudness {
|
||||
return '' if $value eq '';
|
||||
|
||||
#print STDERR "'$value'\n";
|
||||
$value = sprintf( "%d", $value+0.5 );
|
||||
$value = sprintf( "%d", $value + 0.5 );
|
||||
my $class = 'ok';
|
||||
$class = 'warn' if $value > -18.5;
|
||||
$class = 'error' if $value > -16.0;
|
||||
@@ -553,7 +563,7 @@ sub formatDuration {
|
||||
my $duration = shift;
|
||||
return '' unless defined $duration;
|
||||
return '' if $duration eq '';
|
||||
my $result = int( ( $duration +30.5 ) % 60)-30;
|
||||
my $result = int( ( $duration + 30.5 ) % 60 ) - 30;
|
||||
my $class = "ok";
|
||||
$class = "warn" if abs($result) > 1;
|
||||
$class = "error" if abs($result) > 2;
|
||||
@@ -720,10 +730,10 @@ sub showEventList {
|
||||
my $events_by_day = shift;
|
||||
my $language = $params->{language};
|
||||
|
||||
my $rerunIcon='<i class="fas fa-redo" title="$params->{loc}->{label_rerun}"></i>';
|
||||
my $liveIcon='<i class="fas fa-microphone-alt" title="$params->{loc}->{label_live}"></i>';
|
||||
my $draftIcon='<i class="fas fa-drafting-compass" title="$params->{loc}->{label_draft}"></i>';
|
||||
my $archiveIcon='<i class="fas fa-archive" title="$params->{loc}->{label_archived}"></i>';
|
||||
my $rerunIcon = '<i class="fas fa-redo" title="$params->{loc}->{label_rerun}"></i>';
|
||||
my $liveIcon = '<i class="fas fa-microphone-alt" title="$params->{loc}->{label_live}"></i>';
|
||||
my $draftIcon = '<i class="fas fa-drafting-compass" title="$params->{loc}->{label_draft}"></i>';
|
||||
my $archiveIcon = '<i class="fas fa-archive" title="$params->{loc}->{label_archived}"></i>';
|
||||
|
||||
my $out = '';
|
||||
$out = qq{
|
||||
@@ -762,7 +772,12 @@ sub showEventList {
|
||||
$event->{studio_id} = $params->{studio_id};
|
||||
$event->{series_id} = '-1' unless defined $event->{series_id};
|
||||
$event->{event_id} = '-1' unless defined $event->{event_id};
|
||||
my $id = 'event_' . $event->{project_id} . '_' . $event->{studio_id} . '_' . $event->{series_id} . '_' . $event->{event_id};
|
||||
my $id =
|
||||
'event_'
|
||||
. $event->{project_id} . '_'
|
||||
. $event->{studio_id} . '_'
|
||||
. $event->{series_id} . '_'
|
||||
. $event->{event_id};
|
||||
|
||||
my $class = 'event';
|
||||
$class = $event->{class} if defined $event->{class};
|
||||
@@ -795,20 +810,22 @@ sub showEventList {
|
||||
$class ||= '';
|
||||
|
||||
my $archived = $event->{archived} || '-';
|
||||
$archived = '-' if $archived eq '0';
|
||||
$archived = '-' if $archived eq '0';
|
||||
$archived = $archiveIcon if $archived eq '1';
|
||||
|
||||
my $live = $event->{live} || '-';
|
||||
$live = '-' if $live eq '0';
|
||||
$live = '-' if $live eq '0';
|
||||
$live = $liveIcon if $live eq '1';
|
||||
|
||||
my $rerun = $event->{rerun} || '-';
|
||||
|
||||
$rerun = " [" . markup::base26( $event->{recurrence_count} + 1 ) . "]"
|
||||
if ( defined $event->{recurrence_count} ) && ( $event->{recurrence_count} ne '' ) && ( $event->{recurrence_count} > 0 );
|
||||
if ( defined $event->{recurrence_count} )
|
||||
&& ( $event->{recurrence_count} ne '' )
|
||||
&& ( $event->{recurrence_count} > 0 );
|
||||
|
||||
my $draft = $event->{draft} || '0';
|
||||
$draft = '-' if $draft eq '0';
|
||||
$draft = '-' if $draft eq '0';
|
||||
$draft = $draftIcon if $draft eq '1';
|
||||
|
||||
my $title = $event->{title};
|
||||
@@ -858,7 +875,8 @@ sub showEventList {
|
||||
$out .= q{<div id="event_no_series" style="display:none">};
|
||||
$out .= addEventsToSeries( $series, $params )
|
||||
if ( defined $permissions->{assign_series_events} ) && ( $permissions->{assign_series_events} eq '1' );
|
||||
$out .= createSeries($params) if ( defined $permissions->{create_series} ) && ( $permissions->{create_series} eq '1' );
|
||||
$out .= createSeries($params)
|
||||
if ( defined $permissions->{create_series} ) && ( $permissions->{create_series} eq '1' );
|
||||
$out .= q{</div>};
|
||||
}
|
||||
|
||||
@@ -1115,13 +1133,14 @@ sub printTableBody {
|
||||
if ( ( defined $event->{title} ) && ( defined $event->{title} ne '' ) ) {
|
||||
$content .= $event->{title};
|
||||
unless ( $event->{title} =~ /\#\d+/ ) {
|
||||
$content .= ' #' . $event->{episode} if ( ( defined $event->{episode} ) && ( $event->{episode} ne '' ) );
|
||||
$content .= ' #' . $event->{episode}
|
||||
if ( ( defined $event->{episode} ) && ( $event->{episode} ne '' ) );
|
||||
}
|
||||
}
|
||||
$content = $event->{start} if $day eq '0';
|
||||
$event->{project_id} = $project_id unless defined $event->{project_id};
|
||||
$event->{studio_id} = $studio_id unless defined $event->{studio_id};
|
||||
$event->{content} = $content unless ( ( defined $event->{class} ) && ( $event->{class} eq 'time now' ) );
|
||||
$event->{content} = $content unless ( ( defined $event->{class} ) && ( $event->{class} eq 'time now' ) );
|
||||
$event->{class} = 'event' if $day ne '0';
|
||||
$event->{class} = 'grid' if ( ( defined $event->{grid} ) && ( $event->{grid} == 1 ) );
|
||||
$event->{class} = 'schedule' if ( ( defined $event->{schedule} ) && ( $event->{schedule} == 1 ) );
|
||||
@@ -1133,6 +1152,7 @@ sub printTableBody {
|
||||
$event->{content} .= formatDuration( $event->{duration} ) . ' ' if defined $event->{duration};
|
||||
$event->{content} .= formatLoudness( 'L', $event->{rms_left} ) . ' ' if defined $event->{rms_left};
|
||||
$event->{content} .= formatLoudness( 'R', $event->{rms_right} ) if defined $event->{rms_right};
|
||||
|
||||
#$event->{content} .= formatBitrate( $event->{bitrate} ) if defined $event->{bitrate};
|
||||
$event->{content} .= '</span>';
|
||||
}
|
||||
@@ -1173,7 +1193,10 @@ sub printSeries {
|
||||
my $out = '';
|
||||
|
||||
#add schedule entry for series
|
||||
if ( ( defined $permissions->{update_schedule} ) && ( $permissions->{update_schedule} eq '1' ) && ( scalar(@$series) > 0 ) ) {
|
||||
if ( ( defined $permissions->{update_schedule} )
|
||||
&& ( $permissions->{update_schedule} eq '1' )
|
||||
&& ( scalar(@$series) > 0 ) )
|
||||
{
|
||||
$out .= q{<div id="series" style="display:none">};
|
||||
$out .= addSeries( $series, $params );
|
||||
$out .= q{</div>};
|
||||
@@ -1183,7 +1206,8 @@ sub printSeries {
|
||||
$out .= q{<div id="event_no_series" style="display:none">};
|
||||
$out .= addEventsToSeries( $series, $params )
|
||||
if ( ( defined $permissions->{assign_series_events} ) && ( $permissions->{assign_series_events} eq '1' ) );
|
||||
$out .= createSeries($params) if ( ( defined $permissions->{create_series} ) && ( $permissions->{create_series} eq '1' ) );
|
||||
$out .= createSeries($params)
|
||||
if ( ( defined $permissions->{create_series} ) && ( $permissions->{create_series} eq '1' ) );
|
||||
$out .= q{</div>};
|
||||
}
|
||||
|
||||
@@ -1349,11 +1373,14 @@ sub createSeries {
|
||||
<input type="hidden" name="project_id" value="$project_id">
|
||||
<input type="hidden" name="studio_id" value="$studio_id">
|
||||
<table>
|
||||
<tr><td class="label">} . $params->{loc}->{label_name} . qq{</td> <td><input name="series_name"></td></tr>
|
||||
<tr><td class="label">} . $params->{loc}->{label_title} . qq{</td> <td><input name="title"></td></tr>
|
||||
<tr><td class="label">}
|
||||
. $params->{loc}->{label_name} . qq{</td> <td><input name="series_name"></td></tr>
|
||||
<tr><td class="label">}
|
||||
. $params->{loc}->{label_title} . qq{</td> <td><input name="title"></td></tr>
|
||||
<tr><td></td>
|
||||
<td>
|
||||
<button type="submit" name="action" value="create">} . $params->{loc}->{button_create_series} . qq{</button>
|
||||
<button type="submit" name="action" value="create">}
|
||||
. $params->{loc}->{button_create_series} . qq{</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -1374,10 +1401,17 @@ sub print_event {
|
||||
$event->{series_id} = '-1' unless defined $event->{series_id};
|
||||
$event->{event_id} = '-1' unless defined $event->{event_id};
|
||||
|
||||
my $id = 'event_' . $event->{project_id} . '_' . $event->{studio_id} . '_' . $event->{series_id} . '_' . $event->{event_id};
|
||||
$id = 'grid_' . $event->{project_id} . '_' . $event->{studio_id} . '_' . $event->{series_id} if defined $event->{grid};
|
||||
$id = 'work_' . $event->{project_id} . '_' . $event->{studio_id} . '_' . $event->{schedule_id} if defined $event->{work};
|
||||
$id = 'play_' . $event->{project_id} . '_' . $event->{studio_id} if defined $event->{play};
|
||||
my $id =
|
||||
'event_'
|
||||
. $event->{project_id} . '_'
|
||||
. $event->{studio_id} . '_'
|
||||
. $event->{series_id} . '_'
|
||||
. $event->{event_id};
|
||||
$id = 'grid_' . $event->{project_id} . '_' . $event->{studio_id} . '_' . $event->{series_id}
|
||||
if defined $event->{grid};
|
||||
$id = 'work_' . $event->{project_id} . '_' . $event->{studio_id} . '_' . $event->{schedule_id}
|
||||
if defined $event->{work};
|
||||
$id = 'play_' . $event->{project_id} . '_' . $event->{studio_id} if defined $event->{play};
|
||||
|
||||
my $class = $event->{class} || '';
|
||||
my $showIcons = 0;
|
||||
@@ -1400,7 +1434,7 @@ sub print_event {
|
||||
|
||||
$ystart = int( $ystart * $yzoom );
|
||||
$yend = int( $yend * $yzoom );
|
||||
my $height = $yend - $ystart +1;
|
||||
my $height = $yend - $ystart + 1;
|
||||
|
||||
if ( $ypos > 0 ) {
|
||||
$height = q{height:} . ($height) . 'px;';
|
||||
@@ -1418,6 +1452,7 @@ sub print_event {
|
||||
|
||||
my $attr = '';
|
||||
if ( $class =~ /play/ ) {
|
||||
|
||||
#$event->{rms_image}=~s/\.png/.svg/;
|
||||
$attr .= ' rms="' . $event->{rms_image} . '"' if defined $event->{rms_image};
|
||||
$attr .= ' start="' . $event->{start} . '"' if defined $event->{start};
|
||||
@@ -1476,11 +1511,10 @@ sub calc_positions {
|
||||
my ( $start_hour, $start_min ) = getTime( $event->{start_time} );
|
||||
my ( $end_hour, $end_min ) = getTime( $event->{end_time} );
|
||||
|
||||
$start_hour += 24 if $start_hour < $start_of_day;
|
||||
$end_hour += 24 if $end_hour < $start_of_day;
|
||||
$end_hour += 24 if $start_hour > $end_hour;
|
||||
$end_hour += 24 if ($start_hour == $end_hour) && ($start_min == $end_min);
|
||||
|
||||
$start_hour += 24 if $start_hour < $start_of_day;
|
||||
$end_hour += 24 if $end_hour < $start_of_day;
|
||||
$end_hour += 24 if $start_hour > $end_hour;
|
||||
$end_hour += 24 if ( $start_hour == $end_hour ) && ( $start_min == $end_min );
|
||||
|
||||
$event->{ystart} = $start_hour * 60 + $start_min;
|
||||
$event->{yend} = $end_hour * 60 + $end_min;
|
||||
@@ -1623,7 +1657,10 @@ sub printToolbar {
|
||||
<select id="filter" name="filter" onchange="reloadCalendar()">
|
||||
};
|
||||
|
||||
for my $filter ( 'no markup', 'conflicts', 'rerun', 'archived', 'playout', 'published', 'live', 'disable_event_sync', 'draft' ) {
|
||||
for
|
||||
my $filter ( 'no markup', 'conflicts', 'rerun', 'archived', 'playout', 'published', 'live', 'disable_event_sync',
|
||||
'draft' )
|
||||
{
|
||||
my $key = $filter;
|
||||
$key =~ s/ /_/g;
|
||||
|
||||
@@ -1641,7 +1678,8 @@ sub printToolbar {
|
||||
<input type="hidden" name="studio_id" value="$params->{studio_id}">
|
||||
<input type="hidden" name="date" value="$params->{date}">
|
||||
<input type="hidden" name="list" value="1">
|
||||
<input class="search" name="search" value="$params->{search}" placeholder="} . $params->{loc}->{button_search} . qq{">
|
||||
<input class="search" name="search" value="$params->{search}" placeholder="}
|
||||
. $params->{loc}->{button_search} . qq{">
|
||||
<button type="submit" name="action" value="search">} . $params->{loc}->{button_search} . qq{</button>
|
||||
</form>
|
||||
};
|
||||
@@ -1678,7 +1716,8 @@ sub getCalendar {
|
||||
my $previous = '';
|
||||
my $next = '';
|
||||
if ( $range eq 'month' ) {
|
||||
$previous = time::get_datetime( $from_date, $config->{date}->{time_zone} )->subtract( months => 1 )->set_day(1)->date();
|
||||
$previous =
|
||||
time::get_datetime( $from_date, $config->{date}->{time_zone} )->subtract( months => 1 )->set_day(1)->date();
|
||||
$next = time::get_datetime( $from_date, $config->{date}->{time_zone} )->add( months => 1 )->set_day(1)->date();
|
||||
} else {
|
||||
$previous = time::get_datetime( $from_date, $config->{date}->{time_zone} )->subtract( days => $range )->date();
|
||||
@@ -1741,7 +1780,8 @@ sub getTillDate {
|
||||
if ( $params->{range} eq 'month' ) {
|
||||
|
||||
#get last day of month
|
||||
return time::get_datetime( $date, $config->{date}->{time_zone} )->set_day(1)->add( months => 1 )->subtract( days => 1 )->date();
|
||||
return time::get_datetime( $date, $config->{date}->{time_zone} )->set_day(1)->add( months => 1 )
|
||||
->subtract( days => 1 )->date();
|
||||
}
|
||||
|
||||
#add range to date
|
||||
@@ -1810,7 +1850,7 @@ sub check_params {
|
||||
|
||||
my $checked = {};
|
||||
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\_\,]+)/ ) {
|
||||
@@ -1821,7 +1861,10 @@ sub check_params {
|
||||
#numeric values
|
||||
$checked->{part} = 0;
|
||||
$checked->{list} = 0;
|
||||
for my $param ( 'id', 'project_id', 'studio_id', 'default_studio_id', 'user_id', 'series_id', 'event_id', 'part', 'list', 'day_start' )
|
||||
for my $param (
|
||||
'id', 'project_id', 'studio_id', 'default_studio_id', 'user_id', 'series_id',
|
||||
'event_id', 'part', 'list', 'day_start'
|
||||
)
|
||||
{
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#! /usr/bin/perl -w
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use URI::Escape();
|
||||
use Encode();
|
||||
@@ -71,7 +72,7 @@ if ( ( params::isJson() ) || ( defined $params->{action} ) ) {
|
||||
<script src="js/datetime.js" type="text/javascript"></script>
|
||||
} unless (params::isJson);
|
||||
}
|
||||
return unless defined uac::check( $config, $params, $user_presets );
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} eq 'get_json' ) {
|
||||
@@ -155,7 +156,8 @@ sub showComments {
|
||||
$template_parameters->{projects} = project::get_with_dates($config);
|
||||
$template_parameters->{controllers} = $config->{controllers};
|
||||
$template_parameters->{allow} = $permissions;
|
||||
$template_parameters->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'comment' } );
|
||||
$template_parameters->{loc} =
|
||||
localization::get( $config, { user => $params->{presets}->{user}, file => 'comment' } );
|
||||
|
||||
#fill and output template
|
||||
template::process( $config, 'print', $params->{template}, $template_parameters );
|
||||
@@ -252,7 +254,8 @@ sub check_params {
|
||||
#template
|
||||
my $template = '';
|
||||
if ( defined $checked->{action} ) {
|
||||
$template = template::check( $config, $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( $config, $params->{template}, 'comments' );
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
use params();
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
td,th,input {
|
||||
line-height:100%;
|
||||
ffont-size:10px;
|
||||
}
|
||||
td,th{
|
||||
display:table-cell;
|
||||
font-weight:normal;
|
||||
}
|
||||
|
||||
td.level0, td.level1, td.level2, td.level3, td.level4, td.level5{
|
||||
opacity:0.8;
|
||||
border:0;
|
||||
}
|
||||
|
||||
td.host{
|
||||
color:gray;
|
||||
}
|
||||
|
||||
td.level0{
|
||||
padding-left:0px;
|
||||
}
|
||||
td.level1{
|
||||
padding-left:20px;
|
||||
}
|
||||
td.level2{
|
||||
padding-left:40px;
|
||||
}
|
||||
td.level3{
|
||||
padding-left:60px;
|
||||
}
|
||||
td.level4{
|
||||
padding-left:80px;
|
||||
}
|
||||
td.level5{
|
||||
padding-left:100px;
|
||||
}
|
||||
|
||||
img.level0{
|
||||
margin-left:0px;
|
||||
}
|
||||
img.level1{
|
||||
margin-left:20px;
|
||||
}
|
||||
img.level2{
|
||||
margin-left:40px;
|
||||
}
|
||||
img.level3{
|
||||
margin-left:60px;
|
||||
}
|
||||
img.level4{
|
||||
margin-left:80px;
|
||||
}
|
||||
img.level5{
|
||||
margin-left:100px;
|
||||
}
|
||||
|
||||
tr{
|
||||
vertical-align:middle;
|
||||
}
|
||||
|
||||
tr.show{
|
||||
color:#030;
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
#content tr.show td{
|
||||
padding-top:0px;
|
||||
padding-bottom:0px;
|
||||
}
|
||||
|
||||
tr.blocked{
|
||||
color:#a33;
|
||||
text-decoration:break-through;
|
||||
}
|
||||
|
||||
td.content.unread{
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
td.content.received{
|
||||
font-weight:normal;
|
||||
}
|
||||
|
||||
|
||||
table.event_comments{
|
||||
width:800px;
|
||||
}
|
||||
|
||||
table.event_comments td{
|
||||
padding:3px;
|
||||
background-color:#ccc;
|
||||
}
|
||||
|
||||
.event th{
|
||||
text-align:left;
|
||||
opacity:0.8;
|
||||
}
|
||||
.event td{
|
||||
padding:3px;
|
||||
border-right:1px solid #fff;
|
||||
}
|
||||
|
||||
.event button{
|
||||
text-align:right;
|
||||
opacity:0.8;
|
||||
}
|
||||
|
||||
.event_start{
|
||||
width:200px;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.event_title{
|
||||
width:400px;
|
||||
}
|
||||
|
||||
.event_show_comments{
|
||||
height:2em;
|
||||
}
|
||||
|
||||
.event_excerpt{
|
||||
opacity:0.8;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
@@ -75,7 +75,7 @@ unless ( params::isJson() ) {
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( $config, 'print', template::check( $config, 'default.html' ), $headerParams );
|
||||
}
|
||||
return unless defined uac::check( $config, $params, $user_presets );
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
print q{
|
||||
<script src="js/datetime.js" type="text/javascript"></script>
|
||||
@@ -296,7 +296,8 @@ sub show_event {
|
||||
$params->{event_edited} = 1 if ( ( $params->{action} eq 'save' ) && ( !( defined $params->{error} ) ) );
|
||||
$params->{event_edited} = 1 if ( $params->{action} eq 'delete' );
|
||||
$params->{event_edited} = 1 if ( ( $params->{action} eq 'create_event' ) && ( !( defined $params->{error} ) ) );
|
||||
$params->{event_edited} = 1 if ( ( $params->{action} eq 'create_event_from_schedule' ) && ( !( defined $params->{error} ) ) );
|
||||
$params->{event_edited} = 1
|
||||
if ( ( $params->{action} eq 'create_event_from_schedule' ) && ( !( defined $params->{error} ) ) );
|
||||
$params->{user} = $params->{presets}->{user};
|
||||
|
||||
# remove all edit permissions if event is over for more than 2 weeks
|
||||
@@ -782,7 +783,10 @@ sub check_params {
|
||||
$checked->{debug} = $debug;
|
||||
|
||||
#numeric values
|
||||
for my $param ( 'id', 'project_id', 'studio_id', 'default_studio_id', 'user_id', 'series_id', 'event_id', 'source_event_id', 'episode' )
|
||||
for my $param (
|
||||
'id', 'project_id', 'studio_id', 'default_studio_id', 'user_id', 'series_id',
|
||||
'event_id', 'source_event_id', 'episode'
|
||||
)
|
||||
{
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
@@ -820,8 +824,9 @@ sub check_params {
|
||||
|
||||
#strings
|
||||
for my $param (
|
||||
'series_name', 'title', 'excerpt', 'content', 'topic', 'program', 'category', 'image',
|
||||
'series_image', 'user_content', 'user_title', 'user_excerpt', 'podcast_url', 'archive_url', 'setImage'
|
||||
'series_name', 'title', 'excerpt', 'content', 'topic', 'program',
|
||||
'category', 'image', 'series_image', 'user_content', 'user_title', 'user_excerpt',
|
||||
'podcast_url', 'archive_url', 'setImage'
|
||||
)
|
||||
{
|
||||
if ( defined $params->{$param} ) {
|
||||
@@ -844,7 +849,8 @@ sub check_params {
|
||||
$checked->{action} = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~
|
||||
/^(save|delete|download|show_new_event|show_new_event_from_schedule|create_event|create_event_from_schedule|get_json)$/ )
|
||||
/^(save|delete|download|show_new_event|show_new_event_from_schedule|create_event|create_event_from_schedule|get_json)$/
|
||||
)
|
||||
{
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use URI::Escape();
|
||||
use Data::Dumper;
|
||||
use MIME::Base64();
|
||||
use Text::Diff::FormattedHTML();
|
||||
|
||||
#use Text::Diff::FormattedHTML();
|
||||
use Text::Diff::Unified::XS;
|
||||
|
||||
use params();
|
||||
use config();
|
||||
@@ -23,7 +26,7 @@ use events();
|
||||
use series_events();
|
||||
use localization();
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
#binmode STDOUT, ":utf8";
|
||||
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
@@ -61,7 +64,10 @@ return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
print q{
|
||||
<script src="js/datetime.js" type="text/javascript"></script>
|
||||
<script src="js/event.js" type="text/javascript"></script>
|
||||
<link rel="stylesheet" href="css/event.css" type="text/css" />
|
||||
<link rel="stylesheet" href="css/event.css" type="text/css" />
|
||||
|
||||
<script src="js/diff2html.min.js" type="text/javascript"></script>
|
||||
<link rel="stylesheet" href="css/diff2html.min.css" type="text/css" />
|
||||
};
|
||||
|
||||
$config->{access}->{write} = 0;
|
||||
@@ -167,14 +173,59 @@ sub compare {
|
||||
return;
|
||||
}
|
||||
|
||||
print '<textarea>' . $t1 . '</textarea>';
|
||||
print '<textarea>' . $t2 . '</textarea>';
|
||||
|
||||
#log::save_file('/tmp/diff-a.txt', $t1);
|
||||
#log::save_file('/tmp/diff-b.txt', $t2);
|
||||
#my $diff=`/usr/bin/diff /tmp/diff-a.txt /tmp/diff-b.txt`;
|
||||
|
||||
my $diff = diff( \$t1, \$t2 );
|
||||
|
||||
#$diff=~s/\&/\&/g;
|
||||
#$diff=~s/\</\</g;
|
||||
#$diff=~s/\>/\>/g;
|
||||
#$diff=~s/\"/\"/g;
|
||||
#$diff=~s/\'/\'/g;
|
||||
$diff =~ s/\'/\\\'/g;
|
||||
|
||||
#$diff=~s/\n/\'+\'/g;
|
||||
$diff = join( qq{\\n' + '}, split( /\r?\n/, $diff ) );
|
||||
|
||||
#<pre id="diff">$diff</pre>
|
||||
print qq!
|
||||
<div id="result"></div>
|
||||
<script>
|
||||
var diff='$diff';
|
||||
\$(document).ready(function(){
|
||||
//var diff=\$('#diff').html();
|
||||
console.log(diff)
|
||||
var diffHtml = Diff2Html.getPrettyHtml(
|
||||
diff,
|
||||
{
|
||||
inputFormat: 'diff',
|
||||
showFiles: true,
|
||||
matching: 'words',
|
||||
outputFormat: 'side-by-side'
|
||||
}
|
||||
);
|
||||
document.getElementById("result").innerHTML = diffHtml;
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</body>
|
||||
!;
|
||||
|
||||
#print '<script>var a="'.$diff.'";</script>';
|
||||
|
||||
#print "<style>".diff_css."</style>";
|
||||
#print '<pre>';
|
||||
#my $diff=diff_strings( { vertical => 1 }, $t1, $t2);
|
||||
my $diff = diff_strings( {}, $t1, $t2 );
|
||||
#my $diff = Text::Diff::FormattedHTML::diff_strings( {}, $t1, $t2 );
|
||||
|
||||
#print Text::Diff::diff(\$t1, \$t2, { STYLE => "Table" });
|
||||
#print Text::Diff::diff($v1, $v2, { STYLE => "Table" });
|
||||
print $diff;
|
||||
#print $diff;
|
||||
|
||||
#print '</pre>';
|
||||
}
|
||||
@@ -208,7 +259,9 @@ sub check_params {
|
||||
$checked->{debug} = $debug;
|
||||
|
||||
#numeric values
|
||||
for my $param ( 'id', 'project_id', 'studio_id', 'default_studio_id', 'user_id', 'series_id', 'event_id', 'v1', 'v2' ) {
|
||||
for
|
||||
my $param ( '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};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# !/usr/bin/perl -w
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
use URI::Escape();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
@@ -62,13 +62,13 @@ $params = $request->{params}->{checked};
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
|
||||
if ($params->{search}){
|
||||
template::process( $config, 'print', template::check( $config, 'default.html' ), $headerParams );
|
||||
}else{
|
||||
template::process( $config, 'print', template::check( $config, 'ajax_header.html' ), $headerParams );
|
||||
if ( $params->{search} ) {
|
||||
template::process( $config, 'print', template::check( $config, 'default.html' ), $headerParams );
|
||||
} else {
|
||||
template::process( $config, 'print', template::check( $config, 'ajax_header.html' ), $headerParams );
|
||||
}
|
||||
|
||||
return unless defined uac::check( $config, $params, $user_presets );
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
my $local_media_dir = $config->{locations}->{local_media_dir};
|
||||
my $local_media_url = $config->{locations}->{local_media_url};
|
||||
@@ -220,10 +220,10 @@ sub show_image {
|
||||
'projects' => project::get_with_dates($config),
|
||||
'project_id' => $params->{project_id},
|
||||
'studio_id' => $params->{studio_id},
|
||||
'series_id' => $params->{series_id},
|
||||
'event_id' => $params->{event_id},
|
||||
'pid' => $params->{pid},
|
||||
'target' => $params->{target},
|
||||
'series_id' => $params->{series_id},
|
||||
'event_id' => $params->{event_id},
|
||||
'pid' => $params->{pid},
|
||||
'target' => $params->{target},
|
||||
'filename' => $params->{filename}
|
||||
};
|
||||
|
||||
@@ -340,6 +340,7 @@ sub delete_image {
|
||||
my $result = images::delete( $dbh, $image );
|
||||
|
||||
return;
|
||||
|
||||
#my $action_result = '';
|
||||
#my $errors = '';
|
||||
#$result = images::delete_files( $config, $local_media_dir, $params->{delete_image}, $action_result, $errors );
|
||||
@@ -393,9 +394,13 @@ sub modify_results {
|
||||
|
||||
#reduce
|
||||
for my $permission ( 'update_image', 'delete_image' ) {
|
||||
if ( ( defined $permissions->{ $permission . '_others' } ) && ( $permissions->{ $permission . '_others' } eq '1' ) ) {
|
||||
if ( ( defined $permissions->{ $permission . '_others' } )
|
||||
&& ( $permissions->{ $permission . '_others' } eq '1' ) )
|
||||
{
|
||||
$result->{$permission} = 1;
|
||||
} elsif ( ( defined $permissions->{ $permission . '_own' } ) && ( $permissions->{ $permission . '_own' } eq '1' ) ) {
|
||||
} elsif ( ( defined $permissions->{ $permission . '_own' } )
|
||||
&& ( $permissions->{ $permission . '_own' } eq '1' ) )
|
||||
{
|
||||
next if ( $user eq '' );
|
||||
$result->{$permission} = 1 if ( $user eq $result->{created_by} );
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#! /usr/bin/perl
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
use Apache2::Request;
|
||||
@@ -43,14 +45,15 @@ my $error = '';
|
||||
|
||||
#get image from multiform before anything else
|
||||
if ( defined $r ) {
|
||||
|
||||
#$cgi = new CGI();
|
||||
|
||||
|
||||
#Apache2::Request
|
||||
my $apr = Apache2::Request->new( $r, POST_MAX => $upload_limit, TEMP_DIR => $tmp_dir );
|
||||
|
||||
$params = {
|
||||
studio_id => $apr->param('studio_id'),
|
||||
project_id => $apr->param('project_id'),
|
||||
project_id => $apr->param('project_id'),
|
||||
};
|
||||
|
||||
#copy params to hash
|
||||
@@ -108,7 +111,7 @@ my $request = {
|
||||
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
$params = $request->{params}->{checked};
|
||||
return unless defined uac::check( $config, $params, $user_presets );
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
my $permissions = $request->{permissions};
|
||||
|
||||
@@ -122,7 +125,10 @@ if ( $permissions->{create_image} ne '1' ) {
|
||||
my $file_info = undef;
|
||||
if ( $error ne '' ) {
|
||||
if ( $error =~ /limit/ ) {
|
||||
$params->{error} .= "Image size is limited to " . int( $upload_limit / 1000000 ) . " MB!" . "Please make it smaller and try again!";
|
||||
$params->{error} .=
|
||||
"Image size is limited to "
|
||||
. int( $upload_limit / 1000000 ) . " MB!"
|
||||
. "Please make it smaller and try again!";
|
||||
} else {
|
||||
$params->{error} .= "Error:'$error'";
|
||||
}
|
||||
@@ -132,7 +138,7 @@ if ( $error ne '' ) {
|
||||
$params = update_database( $config, $params, $file_info, $user ) if $params->{error} eq '';
|
||||
}
|
||||
|
||||
print STDERR "upload error: $params->{error}\n" if $params->{error} ;
|
||||
print STDERR "upload error: $params->{error}\n" if $params->{error};
|
||||
my $out = '';
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'image' } );
|
||||
template::process( $config, 'print', $params->{template}, $params );
|
||||
@@ -145,7 +151,6 @@ $params->{filename} ||= '';
|
||||
$params->{image_id} ||= '';
|
||||
$params->{name} ||= '';
|
||||
|
||||
|
||||
sub upload_file {
|
||||
my $config = shift;
|
||||
my $cgi = shift;
|
||||
@@ -215,11 +220,14 @@ sub update_database {
|
||||
$config->{access}->{write} = 1;
|
||||
my $dbh = db::connect($config);
|
||||
|
||||
my $entries = images::get( $config, {
|
||||
filename => $image->{filename},
|
||||
project_id => $image->{project_id} ,
|
||||
studio_id => $image->{studio_id}
|
||||
} );
|
||||
my $entries = images::get(
|
||||
$config,
|
||||
{
|
||||
filename => $image->{filename},
|
||||
project_id => $image->{project_id},
|
||||
studio_id => $image->{studio_id}
|
||||
}
|
||||
);
|
||||
if ( ( defined $entries ) && ( scalar(@$entries) > 0 ) ) {
|
||||
print STDERR "update image\n";
|
||||
images::update( $dbh, $image );
|
||||
@@ -300,10 +308,11 @@ sub process_image {
|
||||
my $md5_filename = shift;
|
||||
my $content = shift;
|
||||
|
||||
my $upload_path = images::getInternalPath( $config, { type => 'upload', filename => $md5_filename . '.' . $extension } );
|
||||
my $thumb_path = images::getInternalPath( $config, { type => 'thumbs', filename => $md5_filename . '.jpg' } );
|
||||
my $icon_path = images::getInternalPath( $config, { type => 'icons', filename => $md5_filename . '.jpg' } );
|
||||
my $image_path = images::getInternalPath( $config, { type => 'images', filename => $md5_filename . '.jpg' } );
|
||||
my $upload_path =
|
||||
images::getInternalPath( $config, { type => 'upload', filename => $md5_filename . '.' . $extension } );
|
||||
my $thumb_path = images::getInternalPath( $config, { type => 'thumbs', filename => $md5_filename . '.jpg' } );
|
||||
my $icon_path = images::getInternalPath( $config, { type => 'icons', filename => $md5_filename . '.jpg' } );
|
||||
my $image_path = images::getInternalPath( $config, { type => 'images', filename => $md5_filename . '.jpg' } );
|
||||
|
||||
#copy file to upload space
|
||||
my $result = images::writeFile( $upload_path, $content );
|
||||
@@ -397,4 +406,3 @@ sub check_params {
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
|
||||
16617
website/agenda/planung/js/jquery-ui.js
vendored
16617
website/agenda/planung/js/jquery-ui.js
vendored
File diff suppressed because it is too large
Load Diff
5
website/agenda/planung/js/jquery.js
vendored
5
website/agenda/planung/js/jquery.js
vendored
File diff suppressed because one or more lines are too long
5
website/agenda/planung/js/jquery.min.js
vendored
5
website/agenda/planung/js/jquery.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,211 +0,0 @@
|
||||
/*
|
||||
* jQuery RTE plugin 0.3 - create a rich text form for Mozilla, Opera, and Internet Explorer
|
||||
*
|
||||
* Copyright (c) 2007 Batiste Bieler
|
||||
* Distributed under the GPL (GPL-LICENSE.txt) licenses.
|
||||
*/
|
||||
|
||||
// define the rte light plugin
|
||||
jQuery.fn.rte = function(css_url, media_url) {
|
||||
|
||||
if(document.designMode || document.contentEditable)
|
||||
{
|
||||
$(this).each( function(){
|
||||
var textarea = $(this);
|
||||
enableDesignMode(textarea);
|
||||
});
|
||||
}
|
||||
|
||||
function formatText(iframe, command, option) {
|
||||
iframe.contentWindow.focus();
|
||||
$('#editor_menu:visible').hide();
|
||||
try{
|
||||
iframe.contentWindow.document.execCommand(command, false, option);
|
||||
}catch(e){console.log(e)}
|
||||
iframe.contentWindow.focus();
|
||||
}
|
||||
|
||||
function tryEnableDesignMode(iframe, doc, callback) {
|
||||
try {
|
||||
iframe.contentWindow.document.open();
|
||||
iframe.contentWindow.document.write(doc);
|
||||
iframe.contentWindow.document.close();
|
||||
} catch(error) {
|
||||
console.log(error)
|
||||
}
|
||||
if (document.contentEditable) {
|
||||
iframe.contentWindow.document.designMode = "On";
|
||||
callback();
|
||||
return true;
|
||||
}
|
||||
else if (document.designMode != null) {
|
||||
try {
|
||||
iframe.contentWindow.document.designMode = "on";
|
||||
callback();
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
setTimeout(function(){tryEnableDesignMode(iframe, doc, callback)}, 250);
|
||||
return false;
|
||||
}
|
||||
|
||||
function enableDesignMode(textarea) {
|
||||
// need to be created this way
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.frameBorder=0;
|
||||
iframe.frameMargin=0;
|
||||
iframe.framePadding=0;
|
||||
iframe.height=200;
|
||||
if(textarea.attr('class'))
|
||||
iframe.className = textarea.attr('class');
|
||||
if(textarea.attr('id'))
|
||||
iframe.id = textarea.attr('id');
|
||||
if(textarea.attr('name'))
|
||||
iframe.title = textarea.attr('name');
|
||||
textarea.after(iframe);
|
||||
var css = "";
|
||||
if(css_url)
|
||||
var css = "<link type='text/css' rel='stylesheet' href='"+css_url+"' />"
|
||||
var content = textarea.val();
|
||||
// Mozilla need this to display caret
|
||||
if($.trim(content)=='')
|
||||
content = '<br>';
|
||||
var doc = "<html><head>"+css+"</head><body class='frameBody'>"+content+"</body></html>";
|
||||
tryEnableDesignMode(iframe, doc, function() {
|
||||
$("#toolbar-"+iframe.title).remove();
|
||||
$(iframe).before(toolbar(iframe));
|
||||
textarea.remove();
|
||||
});
|
||||
}
|
||||
|
||||
function disableDesignMode(iframe, submit) {
|
||||
var content = iframe.contentWindow.document.getElementsByTagName("body")[0].innerHTML;
|
||||
if(submit==true)
|
||||
var textarea = $('<input type="hidden" />');
|
||||
else
|
||||
var textarea = $('<textarea cols="40" rows="10"></textarea>');
|
||||
textarea.val(content);
|
||||
t = textarea.get(0);
|
||||
if(iframe.className)
|
||||
t.className = iframe.className;
|
||||
if(iframe.id)
|
||||
t.id = iframe.id;
|
||||
if(iframe.title)
|
||||
t.name = iframe.title;
|
||||
$(iframe).before(textarea);
|
||||
if(submit!=true)
|
||||
$(iframe).remove();
|
||||
return textarea;
|
||||
}
|
||||
|
||||
/**
|
||||
<a href='#' class='link'><img src='"+media_url+"link.png' alt='link' /></a>\
|
||||
<a href='#' class='image'><img src='"+media_url+"image.png' alt='image' /></a>\
|
||||
<a href='#' class='disable'><img src='"+media_url+"close.gif' alt='close rte' /></a>\
|
||||
|
||||
*/
|
||||
function toolbar(iframe) {
|
||||
|
||||
var tb = $("<div class='rte-toolbar' id='toolbar-"+iframe.title+"'><div>\
|
||||
<select>\
|
||||
<option value=''>Bloc style</option>\
|
||||
<option value='p'>Paragraph</option>\
|
||||
<option value='h3'>Title</option>\
|
||||
</select>\
|
||||
<a href='#' class='bold'><img src='"+media_url+"bold.gif' alt='bold' /></a>\
|
||||
<a href='#' class='italic'><img src='"+media_url+"italic.gif' alt='italic' /></a>\
|
||||
<a href='#' class='unorderedlist'><img src='"+media_url+"unordered.gif' alt='unordered list' /></a>\
|
||||
</div></div>");
|
||||
$('select', tb).change(function(){
|
||||
var index = this.selectedIndex;
|
||||
if( index!=0 ) {
|
||||
var selected = this.options[index].value;
|
||||
formatText(iframe, "formatblock", '<'+selected+'>');
|
||||
}
|
||||
});
|
||||
$('.bold', tb).click(function(){ formatText(iframe, 'bold');return false; });
|
||||
$('.italic', tb).click(function(){ formatText(iframe, 'italic');return false; });
|
||||
$('.unorderedlist', tb).click(function(){ formatText(iframe, 'insertunorderedlist');return false; });
|
||||
$('.link', tb).click(function(){
|
||||
var p=prompt("URL:");
|
||||
if(p)
|
||||
formatText(iframe, 'CreateLink', p);
|
||||
return false; });
|
||||
$('.image', tb).click(function(){
|
||||
var p=prompt("image URL:");
|
||||
if(p)
|
||||
formatText(iframe, 'InsertImage', p);
|
||||
return false; });
|
||||
$('.disable', tb).click(function() {
|
||||
var txt = disableDesignMode(iframe);
|
||||
var edm = $('<a href="#">Enable design mode</a>');
|
||||
tb.empty().append(edm);
|
||||
edm.click(function(){
|
||||
enableDesignMode(txt);
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
});
|
||||
$(iframe).parents('form').submit(function(){
|
||||
disableDesignMode(iframe, true); });
|
||||
var iframeDoc = $(iframe.contentWindow.document);
|
||||
|
||||
var select = $('select', tb)[0];
|
||||
iframeDoc.mouseup(function(){
|
||||
setSelectedType(getSelectionElement(iframe), select);
|
||||
return true;
|
||||
});
|
||||
iframeDoc.keyup(function(){
|
||||
setSelectedType(getSelectionElement(iframe), select);
|
||||
var body = $('body', iframeDoc);
|
||||
if(body.scrollTop()>0)
|
||||
iframe.height = Math.min(350, parseInt(iframe.height)+body.scrollTop());
|
||||
return true;
|
||||
});
|
||||
|
||||
return tb;
|
||||
}
|
||||
|
||||
function setSelectedType(node, select) {
|
||||
while(node.parentNode) {
|
||||
var nName = node.nodeName.toLowerCase();
|
||||
for(var i=0;i<select.options.length;i++) {
|
||||
if(nName==select.options[i].value){
|
||||
select.selectedIndex=i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
node = node.parentNode;
|
||||
}
|
||||
select.selectedIndex=0;
|
||||
return true;
|
||||
}
|
||||
|
||||
function getSelectionElement(iframe) {
|
||||
if (iframe.contentWindow.document.selection) {
|
||||
// IE selections
|
||||
selection = iframe.contentWindow.document.selection;
|
||||
range = selection.createRange();
|
||||
try {
|
||||
node = range.parentElement();
|
||||
}
|
||||
catch (e) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Mozilla selections
|
||||
try {
|
||||
selection = iframe.contentWindow.getSelection();
|
||||
range = selection.getRangeAt(0);
|
||||
}
|
||||
catch(e){
|
||||
return false;
|
||||
}
|
||||
node = range.commonAncestorContainer;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#! /usr/bin/perl -w
|
||||
#! /usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use URI::Escape();
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
#use Encode();
|
||||
use URI::Escape();
|
||||
use Data::Dumper;
|
||||
use MIME::Lite();
|
||||
|
||||
@@ -216,7 +216,8 @@ sub getMail {
|
||||
|
||||
$mail->{Data} .= "nur zur Erinnerung...\n\n";
|
||||
$mail->{Data} .= "am $event->{weekday_name} ist die naechste '$event->{series_name}'-Sendung.\n\n";
|
||||
$mail->{Data} .= "$event->{source_base_url}$event->{cache_base_url}/$config->{controllers}->{event}/$event->{event_id}.html\n\n";
|
||||
$mail->{Data} .=
|
||||
"$event->{source_base_url}$event->{cache_base_url}/$config->{controllers}->{event}/$event->{event_id}.html\n\n";
|
||||
$mail->{Data} .= "Gruss, $request->{user}\n";
|
||||
return $mail;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use Data::Dumper;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
use URI::Escape();
|
||||
|
||||
#use Encode();
|
||||
use localization();
|
||||
|
||||
use params();
|
||||
use config();
|
||||
use log();
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
use config();
|
||||
@@ -230,7 +232,8 @@ sub show_projects {
|
||||
for my $project (@$projects) {
|
||||
|
||||
# get assigned studios
|
||||
my $project_studio_assignements = project::get_studio_assignments( $config, { project_id => $project->{project_id} } );
|
||||
my $project_studio_assignements =
|
||||
project::get_studio_assignments( $config, { project_id => $project->{project_id} } );
|
||||
$project->{pid} = $project->{project_id};
|
||||
|
||||
# get assigned studios by id
|
||||
@@ -255,8 +258,8 @@ sub show_projects {
|
||||
$project->{assigned_studios} = $assigned_studios;
|
||||
$project->{unassigned_studios} = $unassigned_studios;
|
||||
|
||||
if ( (defined $params->{setImage}) && ($project->{pid} eq $params->{pid}) ){
|
||||
$project->{image} = $params->{setImage};
|
||||
if ( ( defined $params->{setImage} ) && ( $project->{pid} eq $params->{pid} ) ) {
|
||||
$project->{image} = $params->{setImage};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
use config();
|
||||
@@ -123,7 +125,12 @@ sub save_roles {
|
||||
for my $id ( keys %$values ) {
|
||||
if ( update_allowed( $permissions, $role_by_id, $id ) ) {
|
||||
for my $column ( keys %$columns ) {
|
||||
next if ( $column eq 'level' || $column eq 'role' || $column eq 'id' || $column eq 'project_id' || $column eq 'studio_id' );
|
||||
next
|
||||
if ( $column eq 'level'
|
||||
|| $column eq 'role'
|
||||
|| $column eq 'id'
|
||||
|| $column eq 'project_id'
|
||||
|| $column eq 'studio_id' );
|
||||
$values->{$id}->{$column} = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
use params();
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
use params();
|
||||
@@ -24,23 +26,23 @@ my ( $user, $expires ) = auth::get_user( $config, $params, $cgi );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
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 = uac::setDefaultStudio( $params, $user_presets );
|
||||
$params = uac::setDefaultProject( $params, $user_presets );
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($config, $params),
|
||||
},
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
|
||||
@@ -55,100 +57,100 @@ return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{read_series} == 1 ) {
|
||||
uac::permissions_denied('read_series');
|
||||
return;
|
||||
uac::permissions_denied('read_series');
|
||||
return;
|
||||
}
|
||||
|
||||
show_series( $config, $request );
|
||||
|
||||
sub show_series {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{read_series} == 1 ) {
|
||||
uac::permissions_denied('read_series');
|
||||
return;
|
||||
}
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{read_series} == 1 ) {
|
||||
uac::permissions_denied('read_series');
|
||||
return;
|
||||
}
|
||||
|
||||
# get user projects
|
||||
my $user_projects = uac::get_projects_by_user( $config, { user => $request->{user} } );
|
||||
my $projects = {};
|
||||
for my $project (@$user_projects) {
|
||||
$projects->{ $project->{project_id} } = $project;
|
||||
}
|
||||
# get user projects
|
||||
my $user_projects = uac::get_projects_by_user( $config, { user => $request->{user} } );
|
||||
my $projects = {};
|
||||
for my $project (@$user_projects) {
|
||||
$projects->{ $project->{project_id} } = $project;
|
||||
}
|
||||
|
||||
# get user studios
|
||||
my $user_studios = uac::get_studios_by_user( $config, { user => $request->{user} } );
|
||||
for my $studio (@$user_studios) {
|
||||
my $project_id = $studio->{project_id};
|
||||
my $studio_id = $studio->{id};
|
||||
$studio->{project_name} = $projects->{$project_id}->{name};
|
||||
$studio->{selected} = 1 if ( $project_id eq $params->{p_id} ) && ( $studio_id eq $params->{s_id} );
|
||||
}
|
||||
# get user studios
|
||||
my $user_studios = uac::get_studios_by_user( $config, { user => $request->{user} } );
|
||||
for my $studio (@$user_studios) {
|
||||
my $project_id = $studio->{project_id};
|
||||
my $studio_id = $studio->{id};
|
||||
$studio->{project_name} = $projects->{$project_id}->{name};
|
||||
$studio->{selected} = 1 if ( $project_id eq $params->{p_id} ) && ( $studio_id eq $params->{s_id} );
|
||||
}
|
||||
|
||||
# get series
|
||||
my $options = {};
|
||||
$options->{project_id} = $params->{p_id} if defined $params->{p_id};
|
||||
$options->{studio_id} = $params->{s_id} if defined $params->{s_id};
|
||||
my $series = series::get( $config, $options );
|
||||
# get series
|
||||
my $options = {};
|
||||
$options->{project_id} = $params->{p_id} if defined $params->{p_id};
|
||||
$options->{studio_id} = $params->{s_id} if defined $params->{s_id};
|
||||
my $series = series::get( $config, $options );
|
||||
|
||||
for my $serie (@$series) {
|
||||
$serie->{selected} = 1 if ( defined $params->{series_id} ) && ( $serie->{series_id} eq $params->{series_id} );
|
||||
$serie->{series_name} = 'Einzelsendung' if $serie->{series_name} eq '_single_';
|
||||
}
|
||||
for my $serie (@$series) {
|
||||
$serie->{selected} = 1 if ( defined $params->{series_id} ) && ( $serie->{series_id} eq $params->{series_id} );
|
||||
$serie->{series_name} = 'Einzelsendung' if $serie->{series_name} eq '_single_';
|
||||
}
|
||||
|
||||
$params->{studios} = $user_studios;
|
||||
$params->{series} = $series;
|
||||
$params->{studios} = $user_studios;
|
||||
$params->{series} = $series;
|
||||
|
||||
template::process( $config, 'print', $params->{template}, $params );
|
||||
return;
|
||||
template::process( $config, 'print', $params->{template}, $params );
|
||||
return;
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $checked = {};
|
||||
my $checked = {};
|
||||
|
||||
my $debug = $params->{debug} || '';
|
||||
if ( $debug =~ /([a-z\_\,]+)/ ) {
|
||||
$debug = $1;
|
||||
}
|
||||
$checked->{debug} = $debug;
|
||||
my $debug = $params->{debug} || '';
|
||||
if ( $debug =~ /([a-z\_\,]+)/ ) {
|
||||
$debug = $1;
|
||||
}
|
||||
$checked->{debug} = $debug;
|
||||
|
||||
#numeric values
|
||||
for my $param ( 'id', 'project_id', 'studio_id', 'series_id', 'p_id', 's_id' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^[\-\d]+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
#numeric values
|
||||
for my $param ( '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' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} eq '1' ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
for my $param ( 'selectProjectStudio', 'selectSeries', 'selectRange' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} eq '1' ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
for my $param ('resultElemId') {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^[a-zA-ZöäüÖÄÜß_\d]+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
for my $param ('resultElemId') {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^[a-zA-ZöäüÖÄÜß_\d]+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
# set defaults for project and studio id if not given
|
||||
$checked->{s_id} = $params->{studio_id} || '-1' unless defined $params->{s_id};
|
||||
$checked->{p_id} = $params->{project_id} || '-1' unless defined $params->{p_id};
|
||||
# set defaults for project and studio id if not given
|
||||
$checked->{s_id} = $params->{studio_id} || '-1' unless defined $params->{s_id};
|
||||
$checked->{p_id} = $params->{project_id} || '-1' unless defined $params->{p_id};
|
||||
|
||||
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($config, $params->{template}, 'selectSeries' );
|
||||
$checked->{template} = template::check( $config, $params->{template}, 'selectSeries' );
|
||||
|
||||
return $checked;
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
|
||||
#no warnings 'redefine';
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
use URI::Escape();
|
||||
@@ -137,8 +136,9 @@ sub save_schedule {
|
||||
|
||||
my $entry = {};
|
||||
for my $attr (
|
||||
'project_id', 'studio_id', 'series_id', 'start', 'duration', 'exclude', 'period_type', 'end',
|
||||
'frequency', 'weekday', 'week_of_month', 'month', 'nextDay'
|
||||
'project_id', 'studio_id', 'series_id', 'start', 'duration', 'exclude',
|
||||
'period_type', 'end', 'frequency', 'weekday', 'week_of_month', 'month',
|
||||
'nextDay'
|
||||
)
|
||||
{
|
||||
$entry->{$attr} = $params->{$attr} if ( defined $params->{$attr} );
|
||||
@@ -723,7 +723,8 @@ sub assign_event {
|
||||
# print STDERR "ok\n";
|
||||
}
|
||||
} else {
|
||||
print STDERR "no series title found for studio $entry->{studio_id} series $entry->{series_id}, event $entry->{event_id}\n";
|
||||
print STDERR
|
||||
"no series title found for studio $entry->{studio_id} series $entry->{series_id}, event $entry->{event_id}\n";
|
||||
}
|
||||
|
||||
$config->{access}->{write} = 0;
|
||||
@@ -852,7 +853,14 @@ sub reassign_event {
|
||||
|
||||
#print STDERR " event\n";
|
||||
my $url =
|
||||
'event.cgi?project_id=' . $project_id . '&studio_id=' . $studio_id . '&series_id=' . $new_series_id . '&event_id=' . $event_id;
|
||||
'event.cgi?project_id='
|
||||
. $project_id
|
||||
. '&studio_id='
|
||||
. $studio_id
|
||||
. '&series_id='
|
||||
. $new_series_id
|
||||
. '&event_id='
|
||||
. $event_id;
|
||||
print qq{<meta http-equiv="refresh" content="0; url=$url" />} . "\n";
|
||||
delete $params->{getBack};
|
||||
return 1;
|
||||
@@ -1265,7 +1273,9 @@ sub check_params {
|
||||
$checked->{create_events} = 0;
|
||||
$checked->{publish_events} = 0;
|
||||
}
|
||||
for my $param ( 'frequency', 'duration', 'default_duration', 'create_events', 'publish_events', 'live', 'count_episodes' ) {
|
||||
for my $param ( 'frequency', 'duration', 'default_duration', 'create_events', 'publish_events', 'live',
|
||||
'count_episodes' )
|
||||
{
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /(\d+)/ ) ) {
|
||||
$checked->{$param} = $1;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
local $| = 0;
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
use ModPerl::Util ();
|
||||
@@ -88,15 +87,15 @@ sub showPlayout {
|
||||
}
|
||||
}
|
||||
|
||||
my $today=time::time_to_date(time());
|
||||
my $startDate=time::add_days_to_date( $today, -14 );
|
||||
my $events = playout::get(
|
||||
my $today = time::time_to_date( time() );
|
||||
my $startDate = time::add_days_to_date( $today, -14 );
|
||||
my $events = playout::get(
|
||||
$config,
|
||||
{
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
order => 'modified_at asc, start asc',
|
||||
from => $startDate
|
||||
from => $startDate
|
||||
}
|
||||
);
|
||||
|
||||
@@ -105,17 +104,17 @@ sub showPlayout {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for my $event (@$events) {
|
||||
$event->{stream_size} ||= '';
|
||||
$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->{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);
|
||||
if ($event->{start} lt $today){
|
||||
if ( $event->{start} lt $today ) {
|
||||
$event->{class} = "past";
|
||||
}
|
||||
}
|
||||
@@ -128,7 +127,7 @@ sub formatDuration {
|
||||
my $duration = $event->{duration};
|
||||
return '' unless defined $duration;
|
||||
return '' if $duration eq '';
|
||||
my $result = ( ( $duration +30 ) % 60)-30;
|
||||
my $result = ( ( $duration + 30 ) % 60 ) - 30;
|
||||
my $class = "ok";
|
||||
$class = "warn" if abs($result) > 1;
|
||||
$class = "error" if abs($result) > 2;
|
||||
@@ -137,8 +136,8 @@ sub formatDuration {
|
||||
|
||||
sub formatBitrate {
|
||||
my $event = $_[0];
|
||||
my $bitrate = $event->{bitrate};
|
||||
my $mode = $event->{bitrate_mode};
|
||||
my $bitrate = $event->{bitrate} || '';
|
||||
my $mode = $event->{bitrate_mode} || '';
|
||||
if ( $bitrate ne '' ) {
|
||||
if ( $bitrate >= 200 ) {
|
||||
$bitrate = '<div class="warn">' . $bitrate . ' ' . $mode . '</div>';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
@@ -37,7 +37,6 @@ $params->{default_studio_id} = $user_presets->{studio_id};
|
||||
$params = uac::setDefaultStudio( $params, $user_presets );
|
||||
$params = uac::setDefaultProject( $params, $user_presets );
|
||||
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
@@ -60,6 +59,7 @@ sub showImage {
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
|
||||
unless ( $permissions->{read_event} == 1 ) {
|
||||
uac::permissions_denied('read_image');
|
||||
return;
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
use URI::Escape();
|
||||
|
||||
#use Encode();
|
||||
|
||||
use params();
|
||||
use config();
|
||||
use log();
|
||||
@@ -208,7 +207,8 @@ sub showTimeslotSchedule {
|
||||
$params->{'allow'}->{$permission} = $request->{permissions}->{$permission};
|
||||
}
|
||||
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'all,studio_timeslots' } );
|
||||
$params->{loc} =
|
||||
localization::get( $config, { user => $params->{presets}->{user}, file => 'all,studio_timeslots' } );
|
||||
|
||||
my $studio_id = $params->{studio_id};
|
||||
my $project_id = $params->{project_id};
|
||||
@@ -309,7 +309,8 @@ sub showDates {
|
||||
}
|
||||
);
|
||||
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'all,studio_timeslots' } );
|
||||
$params->{loc} =
|
||||
localization::get( $config, { user => $params->{presets}->{user}, file => 'all,studio_timeslots' } );
|
||||
my $language = $params->{loc}->{region};
|
||||
|
||||
# translate weekday names to selected language
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
use config();
|
||||
@@ -194,10 +196,10 @@ sub show_studios {
|
||||
}
|
||||
);
|
||||
|
||||
if ($params->{setImage}){
|
||||
for my $studio (@$studios){
|
||||
if ( $params->{setImage} ) {
|
||||
for my $studio (@$studios) {
|
||||
next unless $studio->{id} eq $params->{studio_id};
|
||||
$studio->{image}=$params->{setImage};
|
||||
$studio->{image} = $params->{setImage};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<option value="14">2 weeks</option>
|
||||
<option value="21">3 weeks</option>
|
||||
<option value="28">4 weeks</option>
|
||||
<option value="56">8 weeks</option>
|
||||
</select>
|
||||
|
||||
<TMPL_IF .allow.read_event>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#! /usr/bin/perl -w
|
||||
#! /usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
use config();
|
||||
@@ -92,7 +94,7 @@ sub show_settings {
|
||||
$params->{colors} = \@colors;
|
||||
$params->{css} = user_settings::getColorCss( $config, { user => $user } );
|
||||
$params->{permissions} = $permissions;
|
||||
$params->{errors} = $errors;
|
||||
$params->{errors} = $errors if scalar @$errors > 0;
|
||||
|
||||
my $user_settings = user_settings::get( $config, { user => $user } );
|
||||
my $language = $user_settings->{language} || 'en';
|
||||
@@ -134,7 +136,7 @@ sub updateDefaultProjectStudio {
|
||||
user_settings::update( $config, $settings );
|
||||
} else {
|
||||
uac::print_info("insert user settings, as missing on updating default project and studio");
|
||||
update_settings($config, $request);
|
||||
update_settings( $config, $request );
|
||||
}
|
||||
$config->{access}->{write} = 0;
|
||||
}
|
||||
@@ -160,14 +162,14 @@ sub update_settings {
|
||||
}
|
||||
|
||||
my $settings = {
|
||||
user => $user,
|
||||
colors => join( "\n", @colors ),
|
||||
language => $params->{language},
|
||||
period => $params->{period},
|
||||
user => $user,
|
||||
colors => join( "\n", @colors ),
|
||||
language => $params->{language},
|
||||
period => $params->{period},
|
||||
};
|
||||
|
||||
my $results = user_settings::get( $config, { user => $user } );
|
||||
if ( defined $results ) {
|
||||
if ( defined $results ) {
|
||||
uac::print_info("update user settings");
|
||||
$config->{access}->{write} = 1;
|
||||
user_settings::update( $config, $settings );
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
use config();
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
use config();
|
||||
@@ -22,23 +24,23 @@ my $debug = $config->{system}->{debug};
|
||||
my ( $user, $expires ) = auth::get_user( $config, $params, $cgi );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$config,
|
||||
{
|
||||
user => $user,
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id}
|
||||
}
|
||||
$config,
|
||||
{
|
||||
user => $user,
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id}
|
||||
}
|
||||
);
|
||||
$params->{default_studio_id} = $user_presets->{studio_id};
|
||||
$params = uac::setDefaultStudio( $params, $user_presets );
|
||||
$params = uac::setDefaultProject( $params, $user_presets );
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($config, $params),
|
||||
},
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
$params = $request->{params}->{checked};
|
||||
@@ -46,414 +48,417 @@ $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($config, 'print', template::check($config, 'default.html'), $headerParams );
|
||||
template::process( $config, 'print', template::check( $config, 'default.html' ), $headerParams );
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
our $errors = [];
|
||||
|
||||
if ( defined $params->{action} ) {
|
||||
update_user_roles( $config, $request ) if ( $params->{action} eq 'assign' );
|
||||
update_user( $config, $request ) if ( $params->{action} eq 'save' );
|
||||
delete_user( $config, $request ) if ( $params->{action} eq 'delete' );
|
||||
if ( $params->{action} eq 'change_password' ) {
|
||||
change_password( $config, $request, $user );
|
||||
$config->{access}->{write} = 0;
|
||||
return;
|
||||
}
|
||||
update_user_roles( $config, $request ) if ( $params->{action} eq 'assign' );
|
||||
update_user( $config, $request ) if ( $params->{action} eq 'save' );
|
||||
delete_user( $config, $request ) if ( $params->{action} eq 'delete' );
|
||||
if ( $params->{action} eq 'change_password' ) {
|
||||
change_password( $config, $request, $user );
|
||||
$config->{access}->{write} = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
$config->{access}->{write} = 0;
|
||||
show_users( $config, $request );
|
||||
|
||||
sub show_users {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $params = $request->{params}->{checked};
|
||||
|
||||
my $permissions = $request->{permissions};
|
||||
my $permissions = $request->{permissions};
|
||||
|
||||
unless ( ( defined $permissions->{read_user} ) && ( $permissions->{read_user} == 1 ) ) {
|
||||
uac::permissions_denied('read_user');
|
||||
return;
|
||||
}
|
||||
unless ( ( defined $permissions->{read_user} ) && ( $permissions->{read_user} == 1 ) ) {
|
||||
uac::permissions_denied('read_user');
|
||||
return;
|
||||
}
|
||||
|
||||
my $max_level = $permissions->{level};
|
||||
my $project_id = $params->{project_id};
|
||||
my $studio_id = $params->{studio_id};
|
||||
my $max_level = $permissions->{level};
|
||||
my $project_id = $params->{project_id};
|
||||
my $studio_id = $params->{studio_id};
|
||||
|
||||
#TODO: get from presets
|
||||
my $studios = studios::get( $config, { project_id => $project_id } );
|
||||
my $users = uac::get_users($config);
|
||||
my $roles = uac::get_roles(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id
|
||||
}
|
||||
);
|
||||
#TODO: get from presets
|
||||
my $studios = studios::get( $config, { project_id => $project_id } );
|
||||
my $users = uac::get_users($config);
|
||||
my $roles = uac::get_roles(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id
|
||||
}
|
||||
);
|
||||
|
||||
# print "max level:$max_level<br>";
|
||||
# print "max level:$max_level<br>";
|
||||
|
||||
#user roles
|
||||
for my $user (@$users) {
|
||||
$user->{disabled_checked} = 'selected="selected"' if ( $user->{disabled} eq '1' );
|
||||
#user roles
|
||||
for my $user (@$users) {
|
||||
$user->{disabled_checked} = 'selected="selected"' if ( $user->{disabled} eq '1' );
|
||||
|
||||
#print Dumper($user);
|
||||
my $user_roles = uac::get_user_roles(
|
||||
$config,
|
||||
{
|
||||
user => $user->{name},
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id
|
||||
}
|
||||
);
|
||||
my @user_roles = ( map { { role => $_->{role} } } @$user_roles );
|
||||
#print Dumper($user);
|
||||
my $user_roles = uac::get_user_roles(
|
||||
$config,
|
||||
{
|
||||
user => $user->{name},
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id
|
||||
}
|
||||
);
|
||||
my @user_roles = ( map { { role => $_->{role} } } @$user_roles );
|
||||
|
||||
#print Dumper(\@user_roles);
|
||||
#@user_roles[-1]->{__last__}=1 unless(@user_roles==0);
|
||||
$user->{user_roles} = \@user_roles;
|
||||
#print Dumper(\@user_roles);
|
||||
#@user_roles[-1]->{__last__}=1 unless(@user_roles==0);
|
||||
$user->{user_roles} = \@user_roles;
|
||||
|
||||
#mark all roles assigned to user
|
||||
my $has_roles = 0;
|
||||
my @assignable_roles = ();
|
||||
for my $role ( reverse sort { $a->{level} <=> $b->{level} } @$roles ) {
|
||||
#mark all roles assigned to user
|
||||
my $has_roles = 0;
|
||||
my @assignable_roles = ();
|
||||
for my $role ( reverse sort { $a->{level} <=> $b->{level} } @$roles ) {
|
||||
|
||||
#next if ($role->{level}>$max_level);
|
||||
$role->{assigned} = 0;
|
||||
my %role = %$role;
|
||||
for my $user_role (@user_roles) {
|
||||
if ( $role->{role} eq $user_role->{role} ) {
|
||||
$role{assigned} = 1;
|
||||
#next if ($role->{level}>$max_level);
|
||||
$role->{assigned} = 0;
|
||||
my %role = %$role;
|
||||
for my $user_role (@user_roles) {
|
||||
if ( $role->{role} eq $user_role->{role} ) {
|
||||
$role{assigned} = 1;
|
||||
|
||||
# print "if ($role->{role} eq $user_role->{role}<br>";
|
||||
$has_roles = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
push @assignable_roles, \%role;
|
||||
}
|
||||
$user->{has_roles} = $has_roles;
|
||||
$user->{roles} = \@assignable_roles;
|
||||
$user->{studio_id} = $studio_id;
|
||||
$user->{project_id} = $project_id;
|
||||
uac::set_template_permissions( $permissions, $user );
|
||||
}
|
||||
# print "if ($role->{role} eq $user_role->{role}<br>";
|
||||
$has_roles = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
push @assignable_roles, \%role;
|
||||
}
|
||||
$user->{has_roles} = $has_roles;
|
||||
$user->{roles} = \@assignable_roles;
|
||||
$user->{studio_id} = $studio_id;
|
||||
$user->{project_id} = $project_id;
|
||||
uac::set_template_permissions( $permissions, $user );
|
||||
}
|
||||
|
||||
my $sort_by = 'name';
|
||||
my @users = sort { lc( $a->{$sort_by} ) cmp lc( $b->{$sort_by} ) } @$users;
|
||||
my $sort_by = 'name';
|
||||
my @users = sort { lc( $a->{$sort_by} ) cmp lc( $b->{$sort_by} ) } @$users;
|
||||
|
||||
my @users_with_roles = ();
|
||||
my @users_without_roles = ();
|
||||
for my $user (@users) {
|
||||
if ( $user->{has_roles} == 1 ) {
|
||||
push @users_with_roles, $user;
|
||||
} else {
|
||||
push @users_without_roles, $user;
|
||||
}
|
||||
}
|
||||
my @users_with_roles = ();
|
||||
my @users_without_roles = ();
|
||||
for my $user (@users) {
|
||||
if ( $user->{has_roles} == 1 ) {
|
||||
push @users_with_roles, $user;
|
||||
} else {
|
||||
push @users_without_roles, $user;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $permissions->{update_user_role} == 1 ) {
|
||||
@users = ( @users_with_roles, @users_without_roles );
|
||||
} else {
|
||||
@users = (@users_with_roles);
|
||||
}
|
||||
if ( $permissions->{update_user_role} == 1 ) {
|
||||
@users = ( @users_with_roles, @users_without_roles );
|
||||
} else {
|
||||
@users = (@users_with_roles);
|
||||
}
|
||||
|
||||
$params->{users} = \@users;
|
||||
$params->{studios} = $studios;
|
||||
$params->{permissions} = $permissions;
|
||||
$params->{errors} = $errors;
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'users' } );
|
||||
uac::set_template_permissions( $permissions, $params );
|
||||
$params->{users} = \@users;
|
||||
$params->{studios} = $studios;
|
||||
$params->{permissions} = $permissions;
|
||||
$params->{errors} = $errors;
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'users' } );
|
||||
uac::set_template_permissions( $permissions, $params );
|
||||
|
||||
#print Dumper($permissions);
|
||||
template::process($config, 'print', $params->{template}, $params );
|
||||
#print Dumper($permissions);
|
||||
template::process( $config, 'print', $params->{template}, $params );
|
||||
|
||||
# template::process($config, 'print', template::check($config, 'users'), $params);
|
||||
# template::process($config, 'print', template::check($config, 'users'), $params);
|
||||
|
||||
}
|
||||
|
||||
sub update_user {
|
||||
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};
|
||||
|
||||
my $user = {
|
||||
full_name => $params->{user_full_name},
|
||||
email => $params->{user_email},
|
||||
id => $params->{user_id}
|
||||
};
|
||||
$user->{name} = $params->{user_name} if ( ( defined $params->{user_name} ) && ( $params->{user_name} ne '' ) );
|
||||
my $user = {
|
||||
full_name => $params->{user_full_name},
|
||||
email => $params->{user_email},
|
||||
id => $params->{user_id}
|
||||
};
|
||||
$user->{name} = $params->{user_name} if ( ( defined $params->{user_name} ) && ( $params->{user_name} ne '' ) );
|
||||
|
||||
if ( $permissions->{disable_user} == 1 ) {
|
||||
$user->{disabled} = $params->{disabled} || 0;
|
||||
}
|
||||
if ( $permissions->{disable_user} == 1 ) {
|
||||
$user->{disabled} = $params->{disabled} || 0;
|
||||
}
|
||||
|
||||
if ( ( !defined $user->{id} ) || ( $user->{id} eq '' ) ) {
|
||||
unless ( $permissions->{create_user} == 1 ) {
|
||||
uac::permissions_denied('create_user');
|
||||
return;
|
||||
}
|
||||
if ( ( !defined $user->{id} ) || ( $user->{id} eq '' ) ) {
|
||||
unless ( $permissions->{create_user} == 1 ) {
|
||||
uac::permissions_denied('create_user');
|
||||
return;
|
||||
}
|
||||
|
||||
#print Dumper($params);
|
||||
my $users = uac::get_users( $config, { email => $params->{user_email} } );
|
||||
if ( scalar(@$users) > 0 ) {
|
||||
#print Dumper($params);
|
||||
my $users = uac::get_users( $config, { email => $params->{user_email} } );
|
||||
if ( scalar(@$users) > 0 ) {
|
||||
|
||||
#print Dumper($users);
|
||||
error('There is already a user registered for the given email address');
|
||||
return;
|
||||
}
|
||||
#print Dumper($users);
|
||||
error('There is already a user registered for the given email address');
|
||||
return;
|
||||
}
|
||||
|
||||
return unless password_requests::checkPassword( $params->{user_password} );
|
||||
return unless password_requests::checkPassword( $params->{user_password} );
|
||||
|
||||
if ( $params->{user_password} ne $params->{user_password2} ) {
|
||||
error('password mismatch');
|
||||
return;
|
||||
}
|
||||
my $crypt = auth::crypt_password( $params->{user_password} );
|
||||
$user->{salt} = $crypt->{salt};
|
||||
$user->{pass} = $crypt->{crypt};
|
||||
if ( $params->{user_password} ne $params->{user_password2} ) {
|
||||
error('password mismatch');
|
||||
return;
|
||||
}
|
||||
my $crypt = auth::crypt_password( $params->{user_password} );
|
||||
$user->{salt} = $crypt->{salt};
|
||||
$user->{pass} = $crypt->{crypt};
|
||||
|
||||
#print '<pre>'.Dumper($user).'</pre>';
|
||||
$user->{created_at} = time::time_to_datetime( time() );
|
||||
$user->{modified_at} = time::time_to_datetime( time() );
|
||||
$user->{created_by} = $params->{presets}->{user};
|
||||
#print '<pre>'.Dumper($user).'</pre>';
|
||||
$user->{created_at} = time::time_to_datetime( time() );
|
||||
$user->{modified_at} = time::time_to_datetime( time() );
|
||||
$user->{created_by} = $params->{presets}->{user};
|
||||
|
||||
$config->{access}->{write} = 1;
|
||||
uac::insert_user( $config, $user );
|
||||
} else {
|
||||
unless ( $permissions->{update_user} == 1 ) {
|
||||
uac::permissions_denied('update_user');
|
||||
return;
|
||||
}
|
||||
$user->{modified_at} = time::time_to_datetime( time() );
|
||||
$config->{access}->{write} = 1;
|
||||
uac::update_user( $config, $user );
|
||||
}
|
||||
$config->{access}->{write} = 1;
|
||||
uac::insert_user( $config, $user );
|
||||
} else {
|
||||
unless ( $permissions->{update_user} == 1 ) {
|
||||
uac::permissions_denied('update_user');
|
||||
return;
|
||||
}
|
||||
$user->{modified_at} = time::time_to_datetime( time() );
|
||||
$config->{access}->{write} = 1;
|
||||
uac::update_user( $config, $user );
|
||||
}
|
||||
}
|
||||
|
||||
sub change_password {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $userName = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $userName = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
|
||||
my $result = password_requests::changePassword( $config, $request, $userName );
|
||||
my $result = password_requests::changePassword( $config, $request, $userName );
|
||||
|
||||
$params->{errors} = $result->{error} if defined $result->{error};
|
||||
$params->{info} = $result->{success} if defined $result->{success};
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'users' } );
|
||||
uac::set_template_permissions( $permissions, $params );
|
||||
$params->{errors} = $result->{error} if defined $result->{error};
|
||||
$params->{info} = $result->{success} if defined $result->{success};
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'users' } );
|
||||
uac::set_template_permissions( $permissions, $params );
|
||||
|
||||
#print Dumper($permissions);
|
||||
template::process( $config, 'print', template::check($config, 'change_password'), $params );
|
||||
#print Dumper($permissions);
|
||||
template::process( $config, 'print', template::check( $config, 'change_password' ), $params );
|
||||
}
|
||||
|
||||
sub delete_user {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{delete_user} == 1 ) {
|
||||
uac::permissions_denied('delete_user');
|
||||
return;
|
||||
}
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{delete_user} == 1 ) {
|
||||
uac::permissions_denied('delete_user');
|
||||
return;
|
||||
}
|
||||
|
||||
$config->{access}->{write} = 1;
|
||||
my $params = $request->{params}->{checked};
|
||||
uac::delete_user( $config, $params->{user_id} );
|
||||
$config->{access}->{write} = 1;
|
||||
my $params = $request->{params}->{checked};
|
||||
uac::delete_user( $config, $params->{user_id} );
|
||||
}
|
||||
|
||||
# add or remove user from role for given studio_id
|
||||
# todo: assign/unassign role oly if max(change user rank) is < max(users rank)
|
||||
sub update_user_roles {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
# print Dumper($params).'<br>';
|
||||
# print Dumper($request->{params}->{checked});
|
||||
# print Dumper($params).'<br>';
|
||||
# print Dumper($request->{params}->{checked});
|
||||
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{update_user_role} == 1 ) {
|
||||
uac::permissions_denied('update_user_role');
|
||||
return;
|
||||
}
|
||||
my $params = $request->{params}->{checked};
|
||||
my $project_id = $params->{project_id};
|
||||
my $studio_id = $params->{studio_id};
|
||||
my $user_id = $params->{user_id} || '';
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{update_user_role} == 1 ) {
|
||||
uac::permissions_denied('update_user_role');
|
||||
return;
|
||||
}
|
||||
my $params = $request->{params}->{checked};
|
||||
my $project_id = $params->{project_id};
|
||||
my $studio_id = $params->{studio_id};
|
||||
my $user_id = $params->{user_id} || '';
|
||||
|
||||
# return undef if ($user_id eq '');
|
||||
# return undef if ($user_id eq '');
|
||||
|
||||
#get all roles
|
||||
my $roles = uac::get_roles(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id
|
||||
}
|
||||
);
|
||||
#get all roles
|
||||
my $roles = uac::get_roles(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id
|
||||
}
|
||||
);
|
||||
|
||||
#get roles for the selected user
|
||||
my $user_roles = uac::get_user_roles(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
user_id => $user_id
|
||||
}
|
||||
);
|
||||
#get roles for the selected user
|
||||
my $user_roles = uac::get_user_roles(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
user_id => $user_id
|
||||
}
|
||||
);
|
||||
|
||||
#maximum level of the user who wants to perform the update (given by $permissions)
|
||||
my $max_level = $permissions->{level};
|
||||
#maximum level of the user who wants to perform the update (given by $permissions)
|
||||
my $max_level = $permissions->{level};
|
||||
|
||||
#maximum level of the user to be changed (given by $user_id)
|
||||
my $max_user_level = 0;
|
||||
#maximum level of the user to be changed (given by $user_id)
|
||||
my $max_user_level = 0;
|
||||
|
||||
#get all roles by id
|
||||
my $role_by_id = {};
|
||||
for my $role (@$roles) {
|
||||
$role_by_id->{ $role->{id} } = $role;
|
||||
}
|
||||
#get all roles by id
|
||||
my $role_by_id = {};
|
||||
for my $role (@$roles) {
|
||||
$role_by_id->{ $role->{id} } = $role;
|
||||
}
|
||||
|
||||
#get user role by id
|
||||
my $user_role_by_id = {};
|
||||
for my $role (@$user_roles) {
|
||||
$user_role_by_id->{ $role->{id} } = $role;
|
||||
$max_user_level = $role->{level} if $max_user_level < $role->{level};
|
||||
}
|
||||
#get user role by id
|
||||
my $user_role_by_id = {};
|
||||
for my $role (@$user_roles) {
|
||||
$user_role_by_id->{ $role->{id} } = $role;
|
||||
$max_user_level = $role->{level} if $max_user_level < $role->{level};
|
||||
}
|
||||
|
||||
$config->{access}->{write} = 1;
|
||||
$config->{access}->{write} = 1;
|
||||
|
||||
#remove unchecked user roles
|
||||
for my $user_role_id ( keys %$user_role_by_id ) {
|
||||
my $user_role = $user_role_by_id->{$user_role_id};
|
||||
my $role = $role_by_id->{$user_role_id};
|
||||
#remove unchecked user roles
|
||||
for my $user_role_id ( keys %$user_role_by_id ) {
|
||||
my $user_role = $user_role_by_id->{$user_role_id};
|
||||
my $role = $role_by_id->{$user_role_id};
|
||||
|
||||
# print "$user_role_id - $params->{role_ids}->{$user_role_id} ($studio_id)<br>";
|
||||
unless ( defined $params->{role_ids}->{$user_role_id} ) {
|
||||
my $message =
|
||||
# print "$user_role_id - $params->{role_ids}->{$user_role_id} ($studio_id)<br>";
|
||||
unless ( defined $params->{role_ids}->{$user_role_id} ) {
|
||||
my $message =
|
||||
"remove role '$role->{role}' (level $role->{level}) from user $user_id (level $max_user_level) for studio_id=$studio_id, project_id=$project_id. Your level is $max_level";
|
||||
my $update = 0;
|
||||
$update = 1 if ( defined $permissions->{is_admin} );
|
||||
$update = 1 if ( ( $role_by_id->{ $user_role->{role_id} }->{level} < $max_level )
|
||||
&& ( $max_user_level < $max_level ) );
|
||||
if ( $update == 0 ) {
|
||||
uac::permissions_denied($message);
|
||||
next;
|
||||
}
|
||||
my $result = uac::remove_user_role(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
user_id => $user_id,
|
||||
role_id => $user_role_id
|
||||
}
|
||||
);
|
||||
unless ( defined $result ) {
|
||||
uac::print_error("missing parameter on remove user role");
|
||||
return;
|
||||
}
|
||||
if ( $result == 0 ) {
|
||||
uac::print_error("no changes");
|
||||
return;
|
||||
}
|
||||
uac::print_info($message);
|
||||
}
|
||||
}
|
||||
my $update = 0;
|
||||
$update = 1 if ( defined $permissions->{is_admin} );
|
||||
$update = 1
|
||||
if ( ( $role_by_id->{ $user_role->{role_id} }->{level} < $max_level )
|
||||
&& ( $max_user_level < $max_level ) );
|
||||
if ( $update == 0 ) {
|
||||
uac::permissions_denied($message);
|
||||
next;
|
||||
}
|
||||
my $result = uac::remove_user_role(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
user_id => $user_id,
|
||||
role_id => $user_role_id
|
||||
}
|
||||
);
|
||||
unless ( defined $result ) {
|
||||
uac::print_error("missing parameter on remove user role");
|
||||
return;
|
||||
}
|
||||
if ( $result == 0 ) {
|
||||
uac::print_error("no changes");
|
||||
return;
|
||||
}
|
||||
uac::print_info($message);
|
||||
}
|
||||
}
|
||||
|
||||
#insert/update user roles
|
||||
for my $role_id ( keys %{ $params->{role_ids} } ) {
|
||||
my $role = $role_by_id->{$role_id};
|
||||
unless ( defined $user_role_by_id->{$role_id} ) {
|
||||
my $message = "assign role $role->{role} (level $role->{level}) to user (level $max_user_level). Your level is $max_level";
|
||||
#insert/update user roles
|
||||
for my $role_id ( keys %{ $params->{role_ids} } ) {
|
||||
my $role = $role_by_id->{$role_id};
|
||||
unless ( defined $user_role_by_id->{$role_id} ) {
|
||||
my $message =
|
||||
"assign role $role->{role} (level $role->{level}) to user (level $max_user_level). Your level is $max_level";
|
||||
|
||||
# print "user role id: $role->{id}<br>\n";
|
||||
my $update = 0;
|
||||
$update = 1 if ( defined $permissions->{is_admin} );
|
||||
$update = 1 if ( ( $role_by_id->{ $role->{id} }->{level} < $max_level )
|
||||
&& ( $max_user_level < $max_level ) );
|
||||
if ( $update == 0 ) {
|
||||
uac::permissions_denied($message);
|
||||
next;
|
||||
}
|
||||
uac::assign_user_role(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
user_id => $user_id,
|
||||
role_id => $role_id
|
||||
}
|
||||
);
|
||||
uac::print_info($message);
|
||||
}
|
||||
}
|
||||
$config->{access}->{write} = 0;
|
||||
# print "user role id: $role->{id}<br>\n";
|
||||
my $update = 0;
|
||||
$update = 1 if ( defined $permissions->{is_admin} );
|
||||
$update = 1
|
||||
if ( ( $role_by_id->{ $role->{id} }->{level} < $max_level )
|
||||
&& ( $max_user_level < $max_level ) );
|
||||
if ( $update == 0 ) {
|
||||
uac::permissions_denied($message);
|
||||
next;
|
||||
}
|
||||
uac::assign_user_role(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
user_id => $user_id,
|
||||
role_id => $role_id
|
||||
}
|
||||
);
|
||||
uac::print_info($message);
|
||||
}
|
||||
}
|
||||
$config->{access}->{write} = 0;
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $checked = {};
|
||||
my $checked = {};
|
||||
|
||||
#template
|
||||
my $template = '';
|
||||
$template = template::check($config, $params->{template}, 'users' );
|
||||
$checked->{template} = $template;
|
||||
#template
|
||||
my $template = '';
|
||||
$template = template::check( $config, $params->{template}, 'users' );
|
||||
$checked->{template} = $template;
|
||||
|
||||
#numeric values
|
||||
for my $param ( '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} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
#numeric values
|
||||
for my $param ( '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} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
|
||||
for my $param ( 'user_name', 'user_full_name', 'user_email' ) {
|
||||
if ( defined $params->{$param} ) {
|
||||
my $value = $params->{$param};
|
||||
$value =~ s/^\s+//g;
|
||||
$value =~ s/\s+$//g;
|
||||
$checked->{$param} = $value;
|
||||
}
|
||||
}
|
||||
for my $param ( 'user_name', 'user_full_name', 'user_email' ) {
|
||||
if ( defined $params->{$param} ) {
|
||||
my $value = $params->{$param};
|
||||
$value =~ s/^\s+//g;
|
||||
$value =~ s/\s+$//g;
|
||||
$checked->{$param} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
for my $param ( 'user_password', 'user_password2' ) {
|
||||
if ( defined $params->{$param} ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
for my $param ( 'user_password', 'user_password2' ) {
|
||||
if ( defined $params->{$param} ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
#actions and roles
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(save|assign|delete|change_password)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
#actions and roles
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(save|assign|delete|change_password)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
|
||||
if ( $params->{action} eq 'assign' ) {
|
||||
$checked->{action} = $params->{action};
|
||||
for my $param ( keys %$params ) {
|
||||
$checked->{role_ids}->{$1} = 1 if ( $param =~ /^role_(\d+)$/ );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $params->{action} eq 'assign' ) {
|
||||
$checked->{action} = $params->{action};
|
||||
for my $param ( keys %$params ) {
|
||||
$checked->{role_ids}->{$1} = 1 if ( $param =~ /^role_(\d+)$/ );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#print Dumper($params);
|
||||
#print '<pre>'.Dumper($checked).'</pre>';
|
||||
return $checked;
|
||||
#print Dumper($params);
|
||||
#print '<pre>'.Dumper($checked).'</pre>';
|
||||
return $checked;
|
||||
}
|
||||
|
||||
sub error {
|
||||
push @$errors, { error => $_[0] };
|
||||
push @$errors, { error => $_[0] };
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
use URI::Escape();
|
||||
|
||||
#use Encode();
|
||||
|
||||
use params();
|
||||
use config();
|
||||
use log();
|
||||
@@ -20,7 +18,6 @@ use studios();
|
||||
use work_schedule();
|
||||
use work_dates();
|
||||
use localization();
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
|
||||
my $r = shift;
|
||||
@@ -93,8 +90,9 @@ sub save_schedule {
|
||||
|
||||
my $entry = {};
|
||||
for my $attr (
|
||||
'project_id', 'studio_id', 'start', 'duration', 'exclude', 'period_type', 'end', 'frequency',
|
||||
'weekday', 'week_of_month', 'month', 'title', 'type'
|
||||
'project_id', 'studio_id', 'start', 'duration', 'exclude', 'period_type',
|
||||
'end', 'frequency', 'weekday', 'week_of_month', 'month', 'title',
|
||||
'type'
|
||||
)
|
||||
{
|
||||
$entry->{$attr} = $params->{$attr} if ( defined $params->{$attr} );
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
use params();
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
#use utf8;
|
||||
use warnings "all";
|
||||
|
||||
#use diagnostics;
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
use params();
|
||||
use db();
|
||||
use markup();
|
||||
use cache();
|
||||
use log();
|
||||
use config();
|
||||
use template();
|
||||
@@ -21,7 +19,7 @@ binmode STDOUT, ":utf8";
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
my $config = config::getFromScriptLocation();
|
||||
my $debug = $config->{system}->{debug};
|
||||
my $debug = $config->{system}->{debug};
|
||||
|
||||
#get request
|
||||
my $request = {
|
||||
@@ -34,17 +32,6 @@ my $request = {
|
||||
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
#read cache
|
||||
my $cache = {};
|
||||
if ( $config->{cache}->{use_cache} eq '1' ) {
|
||||
cache::configure('series_names.html');
|
||||
$cache = cache::load( $config, $params );
|
||||
if ( defined $cache->{content} ) {
|
||||
print $cache->{content};
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#connect
|
||||
my $dbh = db::connect($config);
|
||||
|
||||
@@ -61,13 +48,7 @@ my $out = '';
|
||||
template::process( $config, $out, $params->{template}, $template_parameters );
|
||||
print $out;
|
||||
|
||||
#write to cache
|
||||
if ( $config->{cache}->{use_cache} eq '1' ) {
|
||||
$cache->{content} = $out;
|
||||
cache::save($cache);
|
||||
}
|
||||
$cache = undef;
|
||||
$out = undef;
|
||||
$out = undef;
|
||||
|
||||
sub getProjects {
|
||||
my $dbh = shift;
|
||||
@@ -101,8 +82,9 @@ sub getProjects {
|
||||
#mark last series_name entry of all non empty projects
|
||||
if ( ( defined $series_names ) && ( scalar @$series_names > 0 ) ) {
|
||||
$series_names->[-1]->{last} = 1;
|
||||
$prev_series_names->[-1]->{last} = 0 if ( defined $prev_series_names ) && ( scalar @$prev_series_names > 0 );
|
||||
$prev_series_names = $series_names;
|
||||
$prev_series_names->[-1]->{last} = 0
|
||||
if ( defined $prev_series_names ) && ( scalar @$prev_series_names > 0 );
|
||||
$prev_series_names = $series_names;
|
||||
}
|
||||
push @$results, $project;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#! /usr/bin/perl -w
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'redefine';
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user