fix template configuration
This commit is contained in:
@@ -77,7 +77,7 @@ my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params($config, $params),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -540,6 +540,7 @@ sub getEventDuration {
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $checked = {};
|
||||
|
||||
@@ -4,7 +4,7 @@ use warnings "all";
|
||||
use strict;
|
||||
use Data::Dumper;
|
||||
use URI::Escape();
|
||||
use Encode();
|
||||
#use Encode();
|
||||
use utf8();
|
||||
use params();
|
||||
use config();
|
||||
@@ -52,8 +52,6 @@ $params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
$params->{expires} = $expires;
|
||||
|
||||
#print STDERR Dumper($params);
|
||||
|
||||
my $scriptName = 'calendar.cgi';
|
||||
|
||||
#add "all" studio to select box
|
||||
@@ -75,7 +73,7 @@ my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $params, $config ),
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -83,7 +81,6 @@ $request = uac::prepare_request( $request, $user_presets );
|
||||
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
#print STDERR Dumper($request);
|
||||
if (
|
||||
(
|
||||
( defined $params->{action} ) && ( ( $params->{action} eq 'show' )
|
||||
@@ -1802,8 +1799,8 @@ sub getSeriesEvents {
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $checked = {};
|
||||
my $template = '';
|
||||
|
||||
@@ -32,7 +32,7 @@ my $r = shift;
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( !defined $user ) || ( $user eq '' ) ;
|
||||
return if ( !defined $user ) || ( $user eq '' );
|
||||
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$config,
|
||||
@@ -52,7 +52,7 @@ my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -68,7 +68,7 @@ if ( ( params::isJson() ) || ( defined $params->{action} ) ) {
|
||||
} else {
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process($config, 'print', template::check($config, 'default.html'), $headerParams );
|
||||
template::process( $config, 'print', template::check( $config, 'default.html' ), $headerParams );
|
||||
print q{
|
||||
<script src="js/datetime.js" type="text/javascript"></script>
|
||||
} unless (params::isJson);
|
||||
@@ -139,7 +139,7 @@ sub showComments {
|
||||
$events = comments::get_events( $dbh, $config, $request, $comments );
|
||||
my $language = $config->{date}->{language} || 'en';
|
||||
for my $event (@$events) {
|
||||
$event->{start} = time::date_time_format($config, $event->{start}, $language );
|
||||
$event->{start} = time::date_time_format( $config, $event->{start}, $language );
|
||||
$comment_count += $event->{comment_count} if ( defined $event->{comment_count} );
|
||||
$event->{cache_base_url} = $config->{cache}->{base_url};
|
||||
}
|
||||
@@ -157,20 +157,20 @@ 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 );
|
||||
template::process( $config, 'print', $params->{template}, $template_parameters );
|
||||
}
|
||||
|
||||
sub modify_comments {
|
||||
my $config = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $results = shift;
|
||||
|
||||
my $language = $config->{date}->{language} || 'en';
|
||||
for my $result (@$results) {
|
||||
$result->{start_date_name} = time::date_format($config, $result->{created_at}, $language );
|
||||
$result->{start_date_name} = time::date_format( $config, $result->{created_at}, $language );
|
||||
$result->{start_time_name} = time::time_format( $result->{created_at} );
|
||||
$result->{ $result->{lock_status} } = 1;
|
||||
$result->{ $result->{news_status} } = 1;
|
||||
@@ -238,6 +238,7 @@ sub setRead {
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $checked = {};
|
||||
@@ -253,9 +254,9 @@ 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' );
|
||||
$template = template::check( $config, $params->{template}, 'comments' );
|
||||
}
|
||||
$checked->{template} = $template;
|
||||
|
||||
|
||||
@@ -30,12 +30,12 @@ return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
#print STDERR $params->{project_id}."\n";
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
user => $user
|
||||
}
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
user => $user
|
||||
}
|
||||
);
|
||||
$params->{default_studio_id} = $user_presets->{studio_id};
|
||||
$params->{studio_id} = $params->{default_studio_id}
|
||||
@@ -45,11 +45,11 @@ $params->{project_id} = $user_presets->{project_id}
|
||||
|
||||
#print STDERR $params->{project_id}."\n";
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
|
||||
@@ -58,7 +58,7 @@ $params = $request->{params}->{checked};
|
||||
#process header
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process($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{
|
||||
@@ -70,148 +70,149 @@ print q{
|
||||
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{create_event_from_schedule} == 1 ) {
|
||||
uac::permissions_denied('create_event_from_schedule');
|
||||
return;
|
||||
uac::permissions_denied('create_event_from_schedule');
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $params->{action} eq 'create_events' ) {
|
||||
create_events( $config, $request );
|
||||
create_events( $config, $request );
|
||||
} else {
|
||||
show_events( $config, $request );
|
||||
show_events( $config, $request );
|
||||
}
|
||||
|
||||
sub show_events {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{assign_series_events} == 1 ) {
|
||||
uac::permissions_denied('assign_series_events');
|
||||
return;
|
||||
}
|
||||
template::process($config, 'print', $params->{template}, $params );
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{assign_series_events} == 1 ) {
|
||||
uac::permissions_denied('assign_series_events');
|
||||
return;
|
||||
}
|
||||
template::process( $config, 'print', $params->{template}, $params );
|
||||
|
||||
}
|
||||
|
||||
sub create_events {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{assign_series_events} == 1 ) {
|
||||
uac::permissions_denied('assign_series_events');
|
||||
return;
|
||||
}
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{assign_series_events} == 1 ) {
|
||||
uac::permissions_denied('assign_series_events');
|
||||
return;
|
||||
}
|
||||
|
||||
print STDERR "create events\n";
|
||||
print STDERR "create events\n";
|
||||
|
||||
my $project_id = $params->{project_id};
|
||||
my $studio_id = $params->{studio_id};
|
||||
my $from_date = $params->{from_date};
|
||||
my $till_date = $params->{till_date};
|
||||
my $duration = $params->{duration};
|
||||
my $project_id = $params->{project_id};
|
||||
my $studio_id = $params->{studio_id};
|
||||
my $from_date = $params->{from_date};
|
||||
my $till_date = $params->{till_date};
|
||||
my $duration = $params->{duration};
|
||||
|
||||
$from_date = time::time_to_datetime();
|
||||
if ( $from_date =~ /(\d\d\d\d\-\d\d\-\d\d \d\d)/ ) {
|
||||
$from_date = $1 . ':00';
|
||||
}
|
||||
$till_date = time::add_days_to_datetime( $from_date, $duration );
|
||||
if ( $from_date =~ /(\d\d\d\d\-\d\d\-\d\d)/ ) {
|
||||
$from_date = $1;
|
||||
}
|
||||
if ( $till_date =~ /(\d\d\d\d\-\d\d\-\d\d)/ ) {
|
||||
$till_date = $1;
|
||||
}
|
||||
$params->{from_date} = $from_date;
|
||||
$params->{till_date} = $till_date;
|
||||
$from_date = time::time_to_datetime();
|
||||
if ( $from_date =~ /(\d\d\d\d\-\d\d\-\d\d \d\d)/ ) {
|
||||
$from_date = $1 . ':00';
|
||||
}
|
||||
$till_date = time::add_days_to_datetime( $from_date, $duration );
|
||||
if ( $from_date =~ /(\d\d\d\d\-\d\d\-\d\d)/ ) {
|
||||
$from_date = $1;
|
||||
}
|
||||
if ( $till_date =~ /(\d\d\d\d\-\d\d\-\d\d)/ ) {
|
||||
$till_date = $1;
|
||||
}
|
||||
$params->{from_date} = $from_date;
|
||||
$params->{till_date} = $till_date;
|
||||
|
||||
print STDERR "create events from $from_date to $till_date\n";
|
||||
print STDERR "create events from $from_date to $till_date\n";
|
||||
|
||||
my $dates = series_dates::getDatesWithoutEvent(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
from => $from_date,
|
||||
till => $till_date
|
||||
}
|
||||
);
|
||||
print STDERR "<pre>found " . ( scalar @$dates ) . " dates\n";
|
||||
my $events = [];
|
||||
for my $date (@$dates) {
|
||||
my $dates = series_dates::getDatesWithoutEvent(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
from => $from_date,
|
||||
till => $till_date
|
||||
}
|
||||
);
|
||||
print STDERR "<pre>found " . ( scalar @$dates ) . " dates\n";
|
||||
my $events = [];
|
||||
for my $date (@$dates) {
|
||||
|
||||
#print STDERR $date->{start}."\n";
|
||||
push @$events, createEvent( $config, $request, $date );
|
||||
}
|
||||
$params->{created_events} = $events;
|
||||
$params->{created_total} = scalar(@$events);
|
||||
template::process($config, 'print', $params->{template}, $params );
|
||||
#print STDERR $date->{start}."\n";
|
||||
push @$events, createEvent( $config, $request, $date );
|
||||
}
|
||||
$params->{created_events} = $events;
|
||||
$params->{created_total} = scalar(@$events);
|
||||
template::process( $config, 'print', $params->{template}, $params );
|
||||
}
|
||||
|
||||
sub createEvent {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $date = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $date = shift;
|
||||
|
||||
my $permissions = $request->{permissions};
|
||||
my $user = $request->{user};
|
||||
my $permissions = $request->{permissions};
|
||||
my $user = $request->{user};
|
||||
|
||||
$date->{show_new_event_from_schedule} = 1;
|
||||
unless ( $permissions->{create_event_from_schedule} == 1 ) {
|
||||
uac::permissions_denied('create_event_from_schedule');
|
||||
return;
|
||||
}
|
||||
$date->{show_new_event_from_schedule} = 1;
|
||||
unless ( $permissions->{create_event_from_schedule} == 1 ) {
|
||||
uac::permissions_denied('create_event_from_schedule');
|
||||
return;
|
||||
}
|
||||
|
||||
$date->{start_date} = $date->{start};
|
||||
my $event = eventOps::getNewEvent( $config, $date, 'show_new_event_from_schedule' );
|
||||
$date->{start_date} = $date->{start};
|
||||
my $event = eventOps::getNewEvent( $config, $date, 'show_new_event_from_schedule' );
|
||||
|
||||
return undef unless defined $event;
|
||||
return undef unless defined $event;
|
||||
|
||||
$event->{start_date} = $event->{start};
|
||||
eventOps::createEvent( $request, $event, 'create_event_from_schedule' );
|
||||
print STDERR Dumper($date);
|
||||
return $event;
|
||||
$event->{start_date} = $event->{start};
|
||||
eventOps::createEvent( $request, $event, 'create_event_from_schedule' );
|
||||
print STDERR Dumper($date);
|
||||
return $event;
|
||||
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
my $config = 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;
|
||||
|
||||
#actions and roles
|
||||
$checked->{action} = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(create_events)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
#actions and roles
|
||||
$checked->{action} = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(create_events)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
|
||||
#numeric values
|
||||
$checked->{exclude} = 0;
|
||||
$checked->{duration} = 28;
|
||||
for my $param ( 'id', 'project_id', 'studio_id', 'duration' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
#numeric values
|
||||
$checked->{exclude} = 0;
|
||||
$checked->{duration} = 28;
|
||||
for my $param ( 'id', 'project_id', 'studio_id', 'duration' ) {
|
||||
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;
|
||||
}
|
||||
|
||||
$checked->{template} = template::check($config, $params->{template}, 'create_events' );
|
||||
$checked->{template} = template::check( $config, $params->{template}, 'create_events' );
|
||||
|
||||
return $checked;
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,6 @@ use warnings "all";
|
||||
use strict;
|
||||
|
||||
use URI::Escape();
|
||||
use Encode();
|
||||
use Data::Dumper;
|
||||
use MIME::Base64();
|
||||
use Text::Diff::FormattedHTML();
|
||||
@@ -40,11 +39,11 @@ $params->{studio_id} = $params->{default_studio_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
|
||||
#print STDERR Dumper($request)."\n";
|
||||
@@ -57,7 +56,7 @@ $params = $request->{params}->{checked};
|
||||
#show header
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( $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{
|
||||
@@ -68,168 +67,169 @@ print q{
|
||||
|
||||
$config->{access}->{write} = 0;
|
||||
if ( $params->{action} eq 'diff' ) {
|
||||
compare( $config, $request );
|
||||
return;
|
||||
compare( $config, $request );
|
||||
return;
|
||||
}
|
||||
show_history( $config, $request );
|
||||
|
||||
#show existing event history
|
||||
sub show_history {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
for my $attr ('studio_id') { # 'series_id','event_id'
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( "missing " . $attr . " to show changes" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
for my $attr ('studio_id') { # 'series_id','event_id'
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( "missing " . $attr . " to show changes" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
unless ( $permissions->{read_event} == 1 ) {
|
||||
uac::print_error("missing permissions to show changes");
|
||||
return;
|
||||
}
|
||||
unless ( $permissions->{read_event} == 1 ) {
|
||||
uac::print_error("missing permissions to show changes");
|
||||
return;
|
||||
}
|
||||
|
||||
my $options = {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
limit => 200
|
||||
};
|
||||
$options->{series_id} = $params->{series_id} if defined $params->{series_id};
|
||||
$options->{event_id} = $params->{event_id} if defined $params->{event_id};
|
||||
my $options = {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
limit => 200
|
||||
};
|
||||
$options->{series_id} = $params->{series_id} if defined $params->{series_id};
|
||||
$options->{event_id} = $params->{event_id} if defined $params->{event_id};
|
||||
|
||||
my $events = event_history::get( $config, $options );
|
||||
my $events = event_history::get( $config, $options );
|
||||
|
||||
#print STDERR Dumper($events);
|
||||
return unless defined $events;
|
||||
$params->{events} = $events;
|
||||
#print STDERR Dumper($events);
|
||||
return unless defined $events;
|
||||
$params->{events} = $events;
|
||||
|
||||
for my $permission ( keys %{$permissions} ) {
|
||||
$params->{'allow'}->{$permission} = $request->{permissions}->{$permission};
|
||||
}
|
||||
for my $permission ( keys %{$permissions} ) {
|
||||
$params->{'allow'}->{$permission} = $request->{permissions}->{$permission};
|
||||
}
|
||||
|
||||
#print STDERR Dumper($params);
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'event_history' } );
|
||||
#print STDERR Dumper($params);
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'event_history' } );
|
||||
|
||||
template::process($config, 'print', template::check($config, 'event_history'), $params );
|
||||
template::process( $config, 'print', template::check( $config, 'event_history' ), $params );
|
||||
}
|
||||
|
||||
#show existing event history
|
||||
sub compare {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
for my $attr ( 'project_id', 'studio_id', 'event_id', 'v1', 'v2' ) {
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( "missing " . $attr . " to show changes" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
for my $attr ( 'project_id', 'studio_id', 'event_id', 'v1', 'v2' ) {
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( "missing " . $attr . " to show changes" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
unless ( $permissions->{read_event} == 1 ) {
|
||||
uac::print_error("missing permissions to show changes");
|
||||
return;
|
||||
}
|
||||
unless ( $permissions->{read_event} == 1 ) {
|
||||
uac::print_error("missing permissions to show changes");
|
||||
return;
|
||||
}
|
||||
|
||||
print qq{<link href="css/diff.css" rel="stylesheet">} . "\n";
|
||||
print qq{<link href="css/diff.css" rel="stylesheet">} . "\n";
|
||||
|
||||
if ( $params->{v1} > $params->{v2} ) {
|
||||
my $t = $params->{v1};
|
||||
$params->{v1} = $params->{v2};
|
||||
$params->{v2} = $t;
|
||||
}
|
||||
if ( $params->{v1} > $params->{v2} ) {
|
||||
my $t = $params->{v1};
|
||||
$params->{v1} = $params->{v2};
|
||||
$params->{v2} = $t;
|
||||
}
|
||||
|
||||
my $options = {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
series_id => $params->{series_id},
|
||||
event_id => $params->{event_id},
|
||||
change_id => $params->{v1},
|
||||
limit => 2
|
||||
};
|
||||
my $options = {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
series_id => $params->{series_id},
|
||||
event_id => $params->{event_id},
|
||||
change_id => $params->{v1},
|
||||
limit => 2
|
||||
};
|
||||
|
||||
my $events = event_history::get( $config, $options );
|
||||
return unless @$events == 1;
|
||||
my $v1 = $events->[0];
|
||||
my $events = event_history::get( $config, $options );
|
||||
return unless @$events == 1;
|
||||
my $v1 = $events->[0];
|
||||
|
||||
$options->{change_id} = $params->{v2};
|
||||
$events = event_history::get( $config, $options );
|
||||
return unless @$events == 1;
|
||||
my $v2 = $events->[0];
|
||||
$options->{change_id} = $params->{v2};
|
||||
$events = event_history::get( $config, $options );
|
||||
return unless @$events == 1;
|
||||
my $v2 = $events->[0];
|
||||
|
||||
my $t1 = eventToText($v1);
|
||||
my $t2 = eventToText($v2);
|
||||
my $t1 = eventToText($v1);
|
||||
my $t2 = eventToText($v2);
|
||||
|
||||
if ( $t1 eq $t2 ) {
|
||||
print "no changes\n";
|
||||
return;
|
||||
}
|
||||
if ( $t1 eq $t2 ) {
|
||||
print "no changes\n";
|
||||
return;
|
||||
}
|
||||
|
||||
#print "<style>".diff_css."</style>";
|
||||
#print '<pre>';
|
||||
#my $diff=diff_strings( { vertical => 1 }, $t1, $t2);
|
||||
my $diff = diff_strings( {}, $t1, $t2 );
|
||||
#print "<style>".diff_css."</style>";
|
||||
#print '<pre>';
|
||||
#my $diff=diff_strings( { vertical => 1 }, $t1, $t2);
|
||||
my $diff = diff_strings( {}, $t1, $t2 );
|
||||
|
||||
#print Text::Diff::diff(\$t1, \$t2, { STYLE => "Table" });
|
||||
#print Text::Diff::diff($v1, $v2, { STYLE => "Table" });
|
||||
print $diff;
|
||||
#print Text::Diff::diff(\$t1, \$t2, { STYLE => "Table" });
|
||||
#print Text::Diff::diff($v1, $v2, { STYLE => "Table" });
|
||||
print $diff;
|
||||
|
||||
#print '</pre>';
|
||||
#print '</pre>';
|
||||
}
|
||||
|
||||
sub eventToText {
|
||||
my $event = shift;
|
||||
my $event = shift;
|
||||
|
||||
my $s = events::get_keys($event)->{full_title} . "\n";
|
||||
$s .= $event->{excerpt} . "\n";
|
||||
$s .= $event->{user_excerpt} . "\n";
|
||||
$s .= $event->{topic} . "\n";
|
||||
$s .= $event->{content} . "\n";
|
||||
my $s = events::get_keys($event)->{full_title} . "\n";
|
||||
$s .= $event->{excerpt} . "\n";
|
||||
$s .= $event->{user_excerpt} . "\n";
|
||||
$s .= $event->{topic} . "\n";
|
||||
$s .= $event->{content} . "\n";
|
||||
|
||||
#print STDERR "DUMP\n$s";
|
||||
return $s;
|
||||
#print STDERR "DUMP\n$s";
|
||||
return $s;
|
||||
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $checked = {};
|
||||
my $template = '';
|
||||
$checked->{template} = template::check($config, $params->{template}, 'event_history' );
|
||||
my $checked = {};
|
||||
my $template = '';
|
||||
$checked->{template} = template::check( $config, $params->{template}, 'event_history' );
|
||||
|
||||
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', 'default_studio_id', 'user_id', 'series_id', 'event_id', 'v1', 'v2' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
#numeric values
|
||||
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};
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
#actions and roles
|
||||
$checked->{action} = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(show|diff)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
#actions and roles
|
||||
$checked->{action} = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(show|diff)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
|
||||
#print STDERR Dumper($checked);
|
||||
return $checked;
|
||||
#print STDERR Dumper($checked);
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ use strict;
|
||||
|
||||
use Data::Dumper;
|
||||
use URI::Escape();
|
||||
use Encode();
|
||||
|
||||
use params();
|
||||
use config();
|
||||
@@ -29,12 +28,12 @@ my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
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->{studio_id} = $params->{default_studio_id}
|
||||
@@ -43,11 +42,11 @@ $params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
|
||||
@@ -56,7 +55,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;
|
||||
|
||||
my $toc = $headerParams->{loc}->{toc};
|
||||
@@ -129,13 +128,13 @@ $( document ).ready(function() {
|
||||
print markup::creole_to_html( getHelp( $headerParams->{loc}->{region} ) );
|
||||
|
||||
sub getHelp {
|
||||
my $region = shift;
|
||||
return getGermanHelp() if $region eq 'de';
|
||||
return getEnglishHelp();
|
||||
my $region = shift;
|
||||
return getGermanHelp() if $region eq 'de';
|
||||
return getEnglishHelp();
|
||||
}
|
||||
|
||||
sub getGermanHelp {
|
||||
return q{
|
||||
return q{
|
||||
|
||||
<div id="toc"><h1 class="hide">Inhaltsverzeichnis</h1></div>
|
||||
|
||||
@@ -379,7 +378,7 @@ Folgende Status-Felder gibt es:
|
||||
}
|
||||
|
||||
sub getEnglishHelp {
|
||||
return q{
|
||||
return q{
|
||||
<div id="toc"><h1 class="hide">Table of Contents</h1></div>
|
||||
|
||||
= Menu
|
||||
@@ -617,29 +616,30 @@ There are following status fields:
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
my $config = 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
|
||||
$checked->{exclude} = 0;
|
||||
for my $param ( 'id', 'project_id', 'studio_id', 'default_studio_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;
|
||||
}
|
||||
#numeric values
|
||||
$checked->{exclude} = 0;
|
||||
for my $param ( 'id', 'project_id', 'studio_id', 'default_studio_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;
|
||||
}
|
||||
|
||||
return $checked;
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,12 +39,12 @@ my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
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->{studio_id} = $params->{default_studio_id}
|
||||
@@ -53,11 +53,11 @@ $params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
}
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $config, $params ),
|
||||
}
|
||||
};
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
$params = $request->{params}->{checked};
|
||||
@@ -65,7 +65,7 @@ $params = $request->{params}->{checked};
|
||||
#show header
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process($config, 'print', template::check($config, 'ajax_header.html'), $headerParams );
|
||||
template::process( $config, 'print', template::check( $config, 'ajax_header.html' ), $headerParams );
|
||||
return unless defined uac::check( $config, $params, $user_presets );
|
||||
|
||||
my $local_media_dir = $config->{locations}->{local_media_dir};
|
||||
@@ -76,400 +76,401 @@ uac::permissions_denied('reading from local media dir') unless -r $local_media_d
|
||||
uac::permissions_denied('writing to local media dir') unless -w $local_media_dir;
|
||||
|
||||
if ( $params->{delete_image} ne '' ) {
|
||||
delete_image( $config, $request, $user, $local_media_dir );
|
||||
return;
|
||||
delete_image( $config, $request, $user, $local_media_dir );
|
||||
return;
|
||||
} elsif ( $params->{save_image} ne '' ) {
|
||||
save_image( $config, $request, $user );
|
||||
return;
|
||||
save_image( $config, $request, $user );
|
||||
return;
|
||||
}
|
||||
show_image( $config, $request, $user, $local_media_url );
|
||||
|
||||
sub show_image {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $user = shift;
|
||||
my $local_media_url = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $user = shift;
|
||||
my $local_media_url = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
|
||||
unless ( defined $params->{project_id} ) {
|
||||
uac::print_error("missing project id");
|
||||
return undef;
|
||||
}
|
||||
unless ( defined $params->{studio_id} ) {
|
||||
uac::print_error("missing studio id");
|
||||
return undef;
|
||||
}
|
||||
unless ( defined $params->{project_id} ) {
|
||||
uac::print_error("missing project id");
|
||||
return undef;
|
||||
}
|
||||
unless ( defined $params->{studio_id} ) {
|
||||
uac::print_error("missing studio id");
|
||||
return undef;
|
||||
}
|
||||
|
||||
if ( $permissions->{read_image} ne '1' ) {
|
||||
uac::permissions_denied("read image");
|
||||
return 0;
|
||||
}
|
||||
if ( $permissions->{read_image} ne '1' ) {
|
||||
uac::permissions_denied("read image");
|
||||
return 0;
|
||||
}
|
||||
|
||||
$config->{access}->{write} = 0;
|
||||
my $dbh = db::connect( $config, undef );
|
||||
$config->{access}->{write} = 0;
|
||||
my $dbh = db::connect( $config, undef );
|
||||
|
||||
my $projectId = $params->{project_id};
|
||||
my $studioId = $params->{studio_id};
|
||||
my $selectedFilename = $params->{filename} || '';
|
||||
my $projectId = $params->{project_id};
|
||||
my $studioId = $params->{studio_id};
|
||||
my $selectedFilename = $params->{filename} || '';
|
||||
|
||||
my $filenames = {};
|
||||
my $results = [];
|
||||
my $filenames = {};
|
||||
my $results = [];
|
||||
|
||||
# add images from series
|
||||
if ( defined $params->{series_id} ) {
|
||||
my $seriesImages = series::get_images(
|
||||
$config,
|
||||
{
|
||||
project_id => $projectId,
|
||||
studio_id => $studioId,
|
||||
series_id => $params->{series_id}
|
||||
}
|
||||
);
|
||||
# add images from series
|
||||
if ( defined $params->{series_id} ) {
|
||||
my $seriesImages = series::get_images(
|
||||
$config,
|
||||
{
|
||||
project_id => $projectId,
|
||||
studio_id => $studioId,
|
||||
series_id => $params->{series_id}
|
||||
}
|
||||
);
|
||||
|
||||
for my $image (@$seriesImages) {
|
||||
my $filename = $image->{filename};
|
||||
next if defined $filenames->{$filename};
|
||||
$filenames->{$filename} = $image;
|
||||
push @$results, $image;
|
||||
}
|
||||
}
|
||||
for my $image (@$seriesImages) {
|
||||
my $filename = $image->{filename};
|
||||
next if defined $filenames->{$filename};
|
||||
$filenames->{$filename} = $image;
|
||||
push @$results, $image;
|
||||
}
|
||||
}
|
||||
|
||||
#load images matching by search
|
||||
if ( $params->{search} =~ /\S/ ) {
|
||||
#load images matching by search
|
||||
if ( $params->{search} =~ /\S/ ) {
|
||||
|
||||
#remove filename from search
|
||||
#delete $params->{filename};
|
||||
#delete $params->{series_id};
|
||||
my $searchImages = images::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $projectId,
|
||||
studio_id => $studioId,
|
||||
search => $params->{search}
|
||||
}
|
||||
);
|
||||
#remove filename from search
|
||||
#delete $params->{filename};
|
||||
#delete $params->{series_id};
|
||||
my $searchImages = images::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $projectId,
|
||||
studio_id => $studioId,
|
||||
search => $params->{search}
|
||||
}
|
||||
);
|
||||
|
||||
for my $image (@$searchImages) {
|
||||
my $filename = $image->{filename};
|
||||
next if defined $filenames->{$filename};
|
||||
$filenames->{$filename} = $image;
|
||||
push @$results, $image;
|
||||
}
|
||||
}
|
||||
for my $image (@$searchImages) {
|
||||
my $filename = $image->{filename};
|
||||
next if defined $filenames->{$filename};
|
||||
$filenames->{$filename} = $image;
|
||||
push @$results, $image;
|
||||
}
|
||||
}
|
||||
|
||||
#load selected image, if not already loaded
|
||||
my $selectedImage = undef;
|
||||
if ( $selectedFilename ne '' ) {
|
||||
if ( defined $filenames->{$selectedFilename} ) {
|
||||
$selectedImage = $filenames->{$selectedFilename};
|
||||
} else {
|
||||
#load selected image, if not already loaded
|
||||
my $selectedImage = undef;
|
||||
if ( $selectedFilename ne '' ) {
|
||||
if ( defined $filenames->{$selectedFilename} ) {
|
||||
$selectedImage = $filenames->{$selectedFilename};
|
||||
} else {
|
||||
|
||||
#print STDERR "getByName:".Dumper($params);
|
||||
#print STDERR "getByName:".Dumper($params);
|
||||
|
||||
#put selected image to the top
|
||||
my $imagesByNames = images::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $projectId,
|
||||
studio_id => $studioId,
|
||||
filename => $selectedFilename
|
||||
}
|
||||
);
|
||||
#put selected image to the top
|
||||
my $imagesByNames = images::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $projectId,
|
||||
studio_id => $studioId,
|
||||
filename => $selectedFilename
|
||||
}
|
||||
);
|
||||
|
||||
#print STDERR Dumper($imagesByNames);
|
||||
$selectedImage = $imagesByNames->[0] if scalar @$imagesByNames > 0;
|
||||
}
|
||||
#print STDERR Dumper($imagesByNames);
|
||||
$selectedImage = $imagesByNames->[0] if scalar @$imagesByNames > 0;
|
||||
}
|
||||
|
||||
my $finalResults = [];
|
||||
my $finalResults = [];
|
||||
|
||||
# put selected image first
|
||||
$selectedFilename = 'not-found';
|
||||
if ( defined $selectedImage ) {
|
||||
push @$finalResults, $selectedImage;
|
||||
$selectedFilename = $selectedImage->{filename};
|
||||
}
|
||||
# put selected image first
|
||||
$selectedFilename = 'not-found';
|
||||
if ( defined $selectedImage ) {
|
||||
push @$finalResults, $selectedImage;
|
||||
$selectedFilename = $selectedImage->{filename};
|
||||
}
|
||||
|
||||
# then other images
|
||||
for my $image (@$results) {
|
||||
push @$finalResults, $image if $image->{filename} ne $selectedFilename;
|
||||
}
|
||||
$results = $finalResults;
|
||||
}
|
||||
# then other images
|
||||
for my $image (@$results) {
|
||||
push @$finalResults, $image if $image->{filename} ne $selectedFilename;
|
||||
}
|
||||
$results = $finalResults;
|
||||
}
|
||||
|
||||
if ( scalar @$results != 0 ) {
|
||||
if ( $params->{template} =~ /edit/ ) {
|
||||
my $result = $results->[0];
|
||||
$result->{missing_licence} = 1 if ( !defined $result->{licence} ) || ( $result->{licence} !~ /\S/ );
|
||||
$results = [$result];
|
||||
}
|
||||
if ( scalar @$results != 0 ) {
|
||||
if ( $params->{template} =~ /edit/ ) {
|
||||
my $result = $results->[0];
|
||||
$result->{missing_licence} = 1 if ( !defined $result->{licence} ) || ( $result->{licence} !~ /\S/ );
|
||||
$results = [$result];
|
||||
}
|
||||
|
||||
$results = modify_results( $results, $permissions, $user, $local_media_url );
|
||||
}
|
||||
$results = modify_results( $results, $permissions, $user, $local_media_url );
|
||||
}
|
||||
|
||||
my $search = $params->{search} || '';
|
||||
$search =~ s/\%+/ /g;
|
||||
my $search = $params->{search} || '';
|
||||
$search =~ s/\%+/ /g;
|
||||
|
||||
my $template_params = {
|
||||
'search' => $search,
|
||||
'images' => $results,
|
||||
'count' => scalar @$results,
|
||||
'projects' => project::get_with_dates($config),
|
||||
'project_id' => $params->{project_id},
|
||||
'studio_id' => $params->{studio_id},
|
||||
'filename' => $params->{filename}
|
||||
};
|
||||
my $template_params = {
|
||||
'search' => $search,
|
||||
'images' => $results,
|
||||
'count' => scalar @$results,
|
||||
'projects' => project::get_with_dates($config),
|
||||
'project_id' => $params->{project_id},
|
||||
'studio_id' => $params->{studio_id},
|
||||
'filename' => $params->{filename}
|
||||
};
|
||||
|
||||
# print STDERR
|
||||
$template_params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'image' } );
|
||||
$template_params = uac::set_template_permissions( $permissions, $template_params );
|
||||
$template_params->{no_results} = 1 if scalar @$results == 0;
|
||||
# print STDERR
|
||||
$template_params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'image' } );
|
||||
$template_params = uac::set_template_permissions( $permissions, $template_params );
|
||||
$template_params->{no_results} = 1 if scalar @$results == 0;
|
||||
|
||||
#set global values for update and delete, per image values are evaluated later
|
||||
$template_params->{allow}->{update_image} =
|
||||
$template_params->{allow}->{update_image_own} || $template_params->{allow}->{seriesupdate_image_others};
|
||||
$template_params->{allow}->{delete_image} =
|
||||
$template_params->{allow}->{delete_image_own} || $template_params->{allow}->{delete_image_others};
|
||||
template::process($config, 'print', $params->{template}, $template_params );
|
||||
#set global values for update and delete, per image values are evaluated later
|
||||
$template_params->{allow}->{update_image} =
|
||||
$template_params->{allow}->{update_image_own} || $template_params->{allow}->{seriesupdate_image_others};
|
||||
$template_params->{allow}->{delete_image} =
|
||||
$template_params->{allow}->{delete_image_own} || $template_params->{allow}->{delete_image_others};
|
||||
template::process( $config, 'print', $params->{template}, $template_params );
|
||||
}
|
||||
|
||||
sub print_js_error {
|
||||
my $message = shift;
|
||||
print qq{<!--
|
||||
my $message = shift;
|
||||
print qq{<!--
|
||||
ERROR: $message
|
||||
-->
|
||||
};
|
||||
print STDERR $message . "\n";
|
||||
print STDERR $message . "\n";
|
||||
}
|
||||
|
||||
sub save_image {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $user = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $user = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
|
||||
unless ( check_permission( $config, $user, $permissions, 'update_image', $params->{save_image} ) eq '1' ) {
|
||||
print_js_error("missing permission to update image");
|
||||
return 0;
|
||||
}
|
||||
unless ( check_permission( $config, $user, $permissions, 'update_image', $params->{save_image} ) eq '1' ) {
|
||||
print_js_error("missing permission to update image");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( ( $params->{update_name} eq '' ) && ( $params->{update_description} eq '' ) ) {
|
||||
print_js_error("empty name or empty description!");
|
||||
return 0;
|
||||
}
|
||||
if ( ( $params->{update_name} eq '' ) && ( $params->{update_description} eq '' ) ) {
|
||||
print_js_error("empty name or empty description!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
my $image = {};
|
||||
$image->{filename} = $params->{save_image};
|
||||
$image->{name} = $params->{update_name} if $params->{update_name} ne '';
|
||||
$image->{description} = $params->{update_description} if $params->{update_description} ne '';
|
||||
$image->{project_id} = $params->{project_id};
|
||||
$image->{studio_id} = $params->{studio_id};
|
||||
$image->{licence} = $params->{licence};
|
||||
$image->{public} = $params->{public};
|
||||
$image->{modified_by} = $user;
|
||||
my $image = {};
|
||||
$image->{filename} = $params->{save_image};
|
||||
$image->{name} = $params->{update_name} if $params->{update_name} ne '';
|
||||
$image->{description} = $params->{update_description} if $params->{update_description} ne '';
|
||||
$image->{project_id} = $params->{project_id};
|
||||
$image->{studio_id} = $params->{studio_id};
|
||||
$image->{licence} = $params->{licence};
|
||||
$image->{public} = $params->{public};
|
||||
$image->{modified_by} = $user;
|
||||
|
||||
$image->{name} = 'new' if $image->{name} eq '';
|
||||
$image->{name} = 'new' if $image->{name} eq '';
|
||||
|
||||
images::checkLicence( $config, $image );
|
||||
images::checkLicence( $config, $image );
|
||||
|
||||
$config->{access}->{write} = 1;
|
||||
my $dbh = db::connect($config);
|
||||
$config->{access}->{write} = 1;
|
||||
my $dbh = db::connect($config);
|
||||
|
||||
print STDERR "going to save\n";
|
||||
print STDERR "going to save\n";
|
||||
|
||||
#print STDERR Dumper($image);
|
||||
#print STDERR Dumper($image);
|
||||
|
||||
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 ( scalar @$entries > 1 ) {
|
||||
print_js_error('more than one matching result found');
|
||||
return 0;
|
||||
}
|
||||
if ( scalar @$entries == 0 ) {
|
||||
print_js_error('image not found in database (for this studio)');
|
||||
return 0;
|
||||
}
|
||||
my $entry = $entries->[0];
|
||||
if ( defined $entry ) {
|
||||
images::update( $dbh, $image );
|
||||
images::publish( $config, $image->{filename} ) if ( ( $image->{public} == 1 ) && ( $entry->{public} == 0 ) );
|
||||
images::depublish( $config, $image->{filename} ) if ( ( $image->{public} == 0 ) && ( $entry->{public} == 1 ) );
|
||||
} else {
|
||||
$image->{created_by} = $user;
|
||||
images::insert( $dbh, $image );
|
||||
}
|
||||
if ( scalar @$entries > 1 ) {
|
||||
print_js_error('more than one matching result found');
|
||||
return 0;
|
||||
}
|
||||
if ( scalar @$entries == 0 ) {
|
||||
print_js_error('image not found in database (for this studio)');
|
||||
return 0;
|
||||
}
|
||||
my $entry = $entries->[0];
|
||||
if ( defined $entry ) {
|
||||
images::update( $dbh, $image );
|
||||
images::publish( $config, $image->{filename} ) if ( ( $image->{public} == 1 ) && ( $entry->{public} == 0 ) );
|
||||
images::depublish( $config, $image->{filename} ) if ( ( $image->{public} == 0 ) && ( $entry->{public} == 1 ) );
|
||||
} else {
|
||||
$image->{created_by} = $user;
|
||||
images::insert( $dbh, $image );
|
||||
}
|
||||
}
|
||||
|
||||
sub delete_image {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $user = shift;
|
||||
my $local_media_dir = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $user = shift;
|
||||
my $local_media_dir = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
|
||||
unless ( check_permission( $config, $user, $permissions, 'delete_image', $params->{delete_image} ) eq '1' ) {
|
||||
uac::permissions_denied('delete image');
|
||||
return 0;
|
||||
}
|
||||
unless ( check_permission( $config, $user, $permissions, 'delete_image', $params->{delete_image} ) eq '1' ) {
|
||||
uac::permissions_denied('delete image');
|
||||
return 0;
|
||||
}
|
||||
|
||||
#print $cgi->header();
|
||||
#print "Content-type:text/html; charset=UTF-8;\n\n";
|
||||
#print $cgi->header();
|
||||
#print "Content-type:text/html; charset=UTF-8;\n\n";
|
||||
|
||||
$config->{access}->{write} = 1;
|
||||
my $dbh = db::connect($config);
|
||||
my $image = {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
filename => $params->{delete_image},
|
||||
};
|
||||
my $result = images::delete( $dbh, $image );
|
||||
$config->{access}->{write} = 1;
|
||||
my $dbh = db::connect($config);
|
||||
my $image = {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
filename => $params->{delete_image},
|
||||
};
|
||||
my $result = images::delete( $dbh, $image );
|
||||
|
||||
#print STDERR "delete result=" . Dumper($result);
|
||||
#print STDERR "delete result=" . Dumper($result);
|
||||
|
||||
return;
|
||||
my $action_result = '';
|
||||
my $errors = '';
|
||||
$result = images::delete_files( $config, $local_media_dir, $params->{delete_image}, $action_result, $errors );
|
||||
return;
|
||||
my $action_result = '';
|
||||
my $errors = '';
|
||||
$result = images::delete_files( $config, $local_media_dir, $params->{delete_image}, $action_result, $errors );
|
||||
|
||||
#use Data::Dumper;print STDERR "delete\n".Dumper($params);
|
||||
print "deleted<br />$action_result<br />$errors\n";
|
||||
#use Data::Dumper;print STDERR "delete\n".Dumper($params);
|
||||
print "deleted<br />$action_result<br />$errors\n";
|
||||
}
|
||||
|
||||
sub check_permission {
|
||||
my $config = shift;
|
||||
my $user = shift;
|
||||
my $permissions = shift;
|
||||
my $permission = shift;
|
||||
my $filename = shift;
|
||||
my $config = shift;
|
||||
my $user = shift;
|
||||
my $permissions = shift;
|
||||
my $permission = shift;
|
||||
my $filename = shift;
|
||||
|
||||
return 0 unless defined $user;
|
||||
return 0 if ( $user eq '' );
|
||||
return 0 unless defined $user;
|
||||
return 0 if ( $user eq '' );
|
||||
|
||||
if ( $permissions->{ $permission . '_others' } eq '1' ) {
|
||||
print STDERR "$user has update_image_others\n";
|
||||
return 1;
|
||||
} elsif ( $permissions->{ $permission . '_own' } eq '1' ) {
|
||||
print STDERR "$user has update_image_own\n";
|
||||
if ( $permissions->{ $permission . '_others' } eq '1' ) {
|
||||
print STDERR "$user has update_image_others\n";
|
||||
return 1;
|
||||
} elsif ( $permissions->{ $permission . '_own' } eq '1' ) {
|
||||
print STDERR "$user has update_image_own\n";
|
||||
|
||||
#check if image was created by user
|
||||
my $results = images::get(
|
||||
$config,
|
||||
{
|
||||
filename => $filename,
|
||||
created_by => $user
|
||||
}
|
||||
);
|
||||
return 1 if ( @$results == 1 );
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
#check if image was created by user
|
||||
my $results = images::get(
|
||||
$config,
|
||||
{
|
||||
filename => $filename,
|
||||
created_by => $user
|
||||
}
|
||||
);
|
||||
return 1 if ( @$results == 1 );
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub modify_results {
|
||||
my $results = shift;
|
||||
my $permissions = shift;
|
||||
my $user = shift;
|
||||
my $local_media_url = shift;
|
||||
my $results = shift;
|
||||
my $permissions = shift;
|
||||
my $user = shift;
|
||||
my $local_media_url = shift;
|
||||
|
||||
for my $result (@$results) {
|
||||
unless ( defined $result->{filename} ) {
|
||||
$result = undef;
|
||||
next;
|
||||
}
|
||||
$result->{image_url} = $local_media_url . '/images/' . $result->{filename};
|
||||
$result->{thumb_url} = $local_media_url . '/thumbs/' . $result->{filename};
|
||||
$result->{icon_url} = $local_media_url . '/icons/' . $result->{filename};
|
||||
for my $result (@$results) {
|
||||
unless ( defined $result->{filename} ) {
|
||||
$result = undef;
|
||||
next;
|
||||
}
|
||||
$result->{image_url} = $local_media_url . '/images/' . $result->{filename};
|
||||
$result->{thumb_url} = $local_media_url . '/thumbs/' . $result->{filename};
|
||||
$result->{icon_url} = $local_media_url . '/icons/' . $result->{filename};
|
||||
|
||||
#reduce
|
||||
for my $permission ( 'update_image', 'delete_image' ) {
|
||||
if ( ( defined $permissions->{ $permission . '_others' } ) && ( $permissions->{ $permission . '_others' } eq '1' ) ) {
|
||||
$result->{$permission} = 1;
|
||||
} elsif ( ( defined $permissions->{ $permission . '_own' } ) && ( $permissions->{ $permission . '_own' } eq '1' ) ) {
|
||||
next if ( $user eq '' );
|
||||
$result->{$permission} = 1 if ( $user eq $result->{created_by} );
|
||||
}
|
||||
}
|
||||
}
|
||||
return $results;
|
||||
#reduce
|
||||
for my $permission ( 'update_image', 'delete_image' ) {
|
||||
if ( ( defined $permissions->{ $permission . '_others' } ) && ( $permissions->{ $permission . '_others' } eq '1' ) ) {
|
||||
$result->{$permission} = 1;
|
||||
} elsif ( ( defined $permissions->{ $permission . '_own' } ) && ( $permissions->{ $permission . '_own' } eq '1' ) ) {
|
||||
next if ( $user eq '' );
|
||||
$result->{$permission} = 1 if ( $user eq $result->{created_by} );
|
||||
}
|
||||
}
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $checked = { template => template::check($config, $params->{template}, 'image.html' ) };
|
||||
my $checked = { template => template::check( $config, $params->{template}, 'image.html' ) };
|
||||
|
||||
#numeric values
|
||||
$checked->{limit} = 100;
|
||||
for my $param ( 'project_id', 'studio_id', 'series_id', 'default_studio_id', 'limit' ) {
|
||||
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
|
||||
$checked->{limit} = 100;
|
||||
for my $param ( 'project_id', 'studio_id', 'series_id', 'default_studio_id', 'limit' ) {
|
||||
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;
|
||||
}
|
||||
|
||||
$checked->{limit} = 100 unless defined $checked->{limit};
|
||||
$checked->{limit} = 100 if ( $checked->{limit} > 100 );
|
||||
$checked->{limit} = 100 unless defined $checked->{limit};
|
||||
$checked->{limit} = 100 if ( $checked->{limit} > 100 );
|
||||
|
||||
#string
|
||||
$checked->{search} = '';
|
||||
if ( ( defined $params->{search} ) && ( $params->{search} =~ /^\s*(.+?)\s*$/ ) ) {
|
||||
$checked->{search} = $1;
|
||||
}
|
||||
#string
|
||||
$checked->{search} = '';
|
||||
if ( ( defined $params->{search} ) && ( $params->{search} =~ /^\s*(.+?)\s*$/ ) ) {
|
||||
$checked->{search} = $1;
|
||||
}
|
||||
|
||||
for my $attr ( 'update_name', 'update_description', 'licence' ) {
|
||||
$checked->{$attr} = '';
|
||||
if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /^\s*(.+?)\s*$/ ) ) {
|
||||
$checked->{$attr} = $params->{$attr};
|
||||
}
|
||||
}
|
||||
for my $attr ( 'update_name', 'update_description', 'licence' ) {
|
||||
$checked->{$attr} = '';
|
||||
if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /^\s*(.+?)\s*$/ ) ) {
|
||||
$checked->{$attr} = $params->{$attr};
|
||||
}
|
||||
}
|
||||
|
||||
#Words
|
||||
$checked->{delete_image} = '';
|
||||
$checked->{save_image} = '';
|
||||
for my $attr ( 'save_image', 'delete_image', 'show', 'filename' ) {
|
||||
$checked->{$attr} = '';
|
||||
if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /(\S+)/ ) ) {
|
||||
$checked->{$attr} = $params->{$attr};
|
||||
}
|
||||
}
|
||||
#Words
|
||||
$checked->{delete_image} = '';
|
||||
$checked->{save_image} = '';
|
||||
for my $attr ( 'save_image', 'delete_image', 'show', 'filename' ) {
|
||||
$checked->{$attr} = '';
|
||||
if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /(\S+)/ ) ) {
|
||||
$checked->{$attr} = $params->{$attr};
|
||||
}
|
||||
}
|
||||
|
||||
#checkboxes
|
||||
for my $param ('public') {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /([01])/ ) ) {
|
||||
$checked->{$param} = $1;
|
||||
}
|
||||
}
|
||||
#checkboxes
|
||||
for my $param ('public') {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /([01])/ ) ) {
|
||||
$checked->{$param} = $1;
|
||||
}
|
||||
}
|
||||
|
||||
#map show to filename, but overwrite if filename given
|
||||
if ( $checked->{show} ne '' ) {
|
||||
$checked->{filename} = $checked->{show};
|
||||
delete $checked->{show};
|
||||
$checked->{limit} = 1;
|
||||
} elsif ( $checked->{filename} ne '' ) {
|
||||
delete $checked->{show};
|
||||
}
|
||||
#map show to filename, but overwrite if filename given
|
||||
if ( $checked->{show} ne '' ) {
|
||||
$checked->{filename} = $checked->{show};
|
||||
delete $checked->{show};
|
||||
$checked->{limit} = 1;
|
||||
} elsif ( $checked->{filename} ne '' ) {
|
||||
delete $checked->{show};
|
||||
}
|
||||
|
||||
$checked->{from} = time::check_date( $params->{from} );
|
||||
$checked->{till} = time::check_date( $params->{till} );
|
||||
$checked->{from} = time::check_date( $params->{from} );
|
||||
$checked->{till} = time::check_date( $params->{till} );
|
||||
|
||||
#print STDERR 'checked:'.Dumper ($checked);
|
||||
#print STDERR 'checked:'.Dumper ($checked);
|
||||
|
||||
return $checked;
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ require 'CGI.pm';
|
||||
use Date::Calc();
|
||||
use Time::Local();
|
||||
use Image::Magick();
|
||||
use Image::Magick::Square();
|
||||
use Image::Magick::Square;
|
||||
|
||||
use config();
|
||||
use auth();
|
||||
@@ -43,76 +43,60 @@ my $error = '';
|
||||
#get image from multiform before anything else
|
||||
if ( defined $r ) {
|
||||
|
||||
#Apache2::Request
|
||||
# print "Content-type:text/html; charset=UTF-8; \n\n<br><br><br>Apache2::Request<br>\n";
|
||||
my $apr = Apache2::Request->new( $r, POST_MAX => $upload_limit, TEMP_DIR => $tmp_dir );
|
||||
#Apache2::Request
|
||||
my $apr = Apache2::Request->new( $r, POST_MAX => $upload_limit, TEMP_DIR => $tmp_dir );
|
||||
|
||||
#copy params to hash
|
||||
my $body = $apr->body();
|
||||
if ( defined $body ) {
|
||||
for my $key ( keys %$body ) {
|
||||
#copy params to hash
|
||||
my $body = $apr->body();
|
||||
if ( defined $body ) {
|
||||
for my $key ( keys %$body ) {
|
||||
$params->{ scalar($key) } = scalar( $apr->param($key) );
|
||||
}
|
||||
}
|
||||
|
||||
# print "$key=".$apr->param($key)."<br>\n";
|
||||
$params->{ scalar($key) } = scalar( $apr->param($key) ); # unless ($key eq'image');
|
||||
}
|
||||
}
|
||||
my $status = $apr->parse;
|
||||
$status = '' if ( $status =~ /missing input data/i );
|
||||
if ( $status =~ /limit/i ) {
|
||||
$error = $status;
|
||||
} else {
|
||||
$upload = $apr->upload('image') if ( defined $params->{image} );
|
||||
}
|
||||
|
||||
# print Dumper($params);
|
||||
|
||||
# print Dumper($apr);
|
||||
my $status = $apr->parse;
|
||||
|
||||
# print "Status:$status<br>";
|
||||
$status = '' if ( $status =~ /missing input data/i );
|
||||
if ( $status =~ /limit/i ) {
|
||||
$error = $status;
|
||||
} else {
|
||||
$upload = $apr->upload('image') if ( defined $params->{image} );
|
||||
}
|
||||
|
||||
#dont get params parsed
|
||||
# $CGI::POST_MAX = $upload_limit;
|
||||
# $CGI::TMPDIRECTORY=$tmp_dir;
|
||||
$cgi = new CGI();
|
||||
|
||||
# my %params=$cgi->Vars();
|
||||
# $params=\%params;
|
||||
# $error=$cgi->cgi_error()||$error;
|
||||
$cgi = new CGI();
|
||||
} else {
|
||||
|
||||
#CGI fallback
|
||||
# print "Content-type:text/html; charset=UTF-8; \n\n<br><br><br>CGI<br>\n";
|
||||
$CGI::POST_MAX = $upload_limit;
|
||||
$CGI::TMPDIRECTORY = $tmp_dir;
|
||||
$cgi = new CGI();
|
||||
$error = $cgi->cgi_error() || $error;
|
||||
my %params = $cgi->Vars();
|
||||
$params = \%params;
|
||||
#CGI fallback
|
||||
$CGI::POST_MAX = $upload_limit;
|
||||
$CGI::TMPDIRECTORY = $tmp_dir;
|
||||
$cgi = new CGI();
|
||||
$error = $cgi->cgi_error() || $error;
|
||||
my %params = $cgi->Vars();
|
||||
$params = \%params;
|
||||
}
|
||||
print "Content-type:text/html; charset=UTF-8;\n\n";
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
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->{studio_id} = $params->{default_studio_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
if ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' );
|
||||
$params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
if ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' );
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
@@ -121,37 +105,40 @@ return unless defined uac::check( $config, $params, $user_presets );
|
||||
|
||||
my $permissions = $request->{permissions};
|
||||
|
||||
$params->{action} = '' unless ( defined $params->{action} );
|
||||
$params->{action} = '' unless defined $params->{action};
|
||||
|
||||
if ( $permissions->{create_image} ne '1' ) {
|
||||
uac::permissions_denied("create image");
|
||||
return 0;
|
||||
uac::permissions_denied("create image");
|
||||
return 0;
|
||||
}
|
||||
|
||||
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!";
|
||||
} else {
|
||||
$params->{error} .= "Error:'$error'";
|
||||
}
|
||||
if ( $error =~ /limit/ ) {
|
||||
$params->{error} .= "Image size is limited to " . int( $upload_limit / 1000000 ) . " MB!" . "Please make it smaller and try again!";
|
||||
} else {
|
||||
$params->{error} .= "Error:'$error'";
|
||||
}
|
||||
} elsif ( $params->{action} eq 'upload' ) {
|
||||
$file_info = upload_file( $config, $cgi, $upload, $user );
|
||||
$params->{error} .= $file_info->{error};
|
||||
$params = update_database( $config, $params, $file_info, $user ) if ( $params->{error} eq '' );
|
||||
$file_info = upload_file( $config, $cgi, $upload, $user );
|
||||
$params->{error} .= $file_info->{error};
|
||||
$params = update_database( $config, $params, $file_info, $user ) if $params->{error} eq '';
|
||||
}
|
||||
print STDERR $params->{error} . "\n" if defined $params->{error};
|
||||
|
||||
print STDERR "upload error: $params->{error}\n" if $params->{error} ne '';
|
||||
my $out = '';
|
||||
template::process( $config, 'print', $params->{template}, $params );
|
||||
|
||||
print $cgi->cgi_error() if defined $cgi;
|
||||
print $cgi->cgi_error() if (defined $cgi) && (defined $cgi->cgi_error());
|
||||
return if $params->{action} eq '';
|
||||
|
||||
#return;
|
||||
|
||||
return if ( $params->{action} eq '' );
|
||||
$params->{action_result} ||= '';
|
||||
$params->{filename} ||= '';
|
||||
$params->{image_id} ||= '';
|
||||
$params->{name} ||= '';
|
||||
|
||||
if ( $params->{error} eq '' ) {
|
||||
print qq{
|
||||
print qq{
|
||||
<div id="output">success</div>
|
||||
<div id="message">
|
||||
$params->{action_result}
|
||||
@@ -165,256 +152,244 @@ if ( $params->{error} eq '' ) {
|
||||
|
||||
};
|
||||
} else {
|
||||
print qq{
|
||||
print qq{
|
||||
<div id="output">failed</div>
|
||||
<div id="message">$params->{error}</div>
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
sub upload_file {
|
||||
my $config = shift;
|
||||
my $cgi = shift;
|
||||
my $upload = shift;
|
||||
my $user = shift;
|
||||
my $config = shift;
|
||||
my $cgi = shift;
|
||||
my $upload = shift;
|
||||
my $user = shift;
|
||||
|
||||
my $result = get_filename( $cgi, $upload );
|
||||
return $result if ( $result->{error} ne '' );
|
||||
my $result = get_filename( $cgi, $upload );
|
||||
return $result if ( $result->{error} ne '' );
|
||||
|
||||
my $file = $result->{fh};
|
||||
my $filename = $result->{filename};
|
||||
my $file = $result->{fh};
|
||||
my $filename = $result->{filename};
|
||||
|
||||
$result = check_filename($filename);
|
||||
print STDERR $result . "\n";
|
||||
return $result if ( $result->{error} ne '' );
|
||||
$result = check_filename($filename);
|
||||
#print STDERR $result . "\n";
|
||||
return $result if ( $result->{error} ne '' );
|
||||
|
||||
my $extension = $result->{extension} || '';
|
||||
my $extension = $result->{extension} || '';
|
||||
|
||||
#read file from handle
|
||||
my $data;
|
||||
my $content = '';
|
||||
print STDERR $file . "\n";
|
||||
#read file from handle
|
||||
my $data;
|
||||
my $content = '';
|
||||
#print STDERR $file . "\n";
|
||||
|
||||
#unless (-e $file){}
|
||||
binmode $file;
|
||||
while ( read $file, $data, 1024 ) {
|
||||
$content .= $data;
|
||||
}
|
||||
binmode $file;
|
||||
while ( read $file, $data, 1024 ) {
|
||||
$content .= $data;
|
||||
}
|
||||
|
||||
#set filename to MD5 from content
|
||||
my $md5_filename = Digest::MD5::md5_base64($content);
|
||||
$md5_filename =~ s/[\/\+]/_/gi;
|
||||
#set filename to MD5 from content
|
||||
my $md5_filename = Digest::MD5::md5_base64($content);
|
||||
$md5_filename =~ s/[\/\+]/_/gi;
|
||||
|
||||
return process_image( $config, $filename, $extension, $md5_filename, $content );
|
||||
return process_image( $config, $filename, $extension, $md5_filename, $content );
|
||||
}
|
||||
|
||||
sub update_database {
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
my $file_info = shift;
|
||||
my $user = shift;
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
my $file_info = shift;
|
||||
my $user = shift;
|
||||
|
||||
$params->{upload_path} = $file_info->{upload_path};
|
||||
$params->{upload_filename} = $file_info->{upload_filename};
|
||||
$params->{filename} = $file_info->{filename};
|
||||
$params->{thumb_path} = $file_info->{thumb_path};
|
||||
$params->{image_path} = $file_info->{image_path};
|
||||
$params->{icon_path} = $file_info->{icon_path};
|
||||
$params->{local_media_url} = $config->{locations}->{local_media_url};
|
||||
$params->{upload_path} = $file_info->{upload_path};
|
||||
$params->{upload_filename} = $file_info->{upload_filename};
|
||||
$params->{filename} = $file_info->{filename};
|
||||
$params->{thumb_path} = $file_info->{thumb_path};
|
||||
$params->{image_path} = $file_info->{image_path};
|
||||
$params->{icon_path} = $file_info->{icon_path};
|
||||
$params->{local_media_url} = $config->{locations}->{local_media_url};
|
||||
|
||||
my $name = $params->{name} || '';
|
||||
$name = 'neu' unless $params =~ /\S/;
|
||||
my $name = $params->{name} || '';
|
||||
$name = 'neu' unless $params =~ /\S/;
|
||||
|
||||
my $image = {
|
||||
filename => $params->{filename},
|
||||
name => $name,
|
||||
description => $params->{description},
|
||||
modified_by => $user,
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
licence => $params->{licence}
|
||||
};
|
||||
my $image = {
|
||||
filename => $params->{filename},
|
||||
name => $name,
|
||||
description => $params->{description},
|
||||
modified_by => $user,
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
licence => $params->{licence}
|
||||
};
|
||||
|
||||
#connect
|
||||
$config->{access}->{write} = 1;
|
||||
my $dbh = db::connect($config);
|
||||
#connect
|
||||
$config->{access}->{write} = 1;
|
||||
my $dbh = db::connect($config);
|
||||
|
||||
my $entries = images::get( $config, { filename => $image->{filename} } );
|
||||
if ( ( defined $entries ) && ( scalar(@$entries) > 0 ) ) {
|
||||
images::update( $dbh, $image );
|
||||
my $entry = $entries->[0];
|
||||
$params->{image_id} = $entry->{id};
|
||||
} else {
|
||||
$image->{created_by} = $user;
|
||||
$params->{image_id} = images::insert( $dbh, $image );
|
||||
}
|
||||
$config->{access}->{write} = 0;
|
||||
$params->{action_result} = 'done!';
|
||||
my $entries = images::get( $config, { filename => $image->{filename} } );
|
||||
if ( ( defined $entries ) && ( scalar(@$entries) > 0 ) ) {
|
||||
images::update( $dbh, $image );
|
||||
my $entry = $entries->[0];
|
||||
$params->{image_id} = $entry->{id};
|
||||
} else {
|
||||
$image->{created_by} = $user;
|
||||
$params->{image_id} = images::insert( $dbh, $image );
|
||||
}
|
||||
$config->{access}->{write} = 0;
|
||||
$params->{action_result} = 'done!';
|
||||
|
||||
return $params;
|
||||
return $params;
|
||||
}
|
||||
|
||||
#get filename and filehandle from upload
|
||||
sub get_filename {
|
||||
my $cgi = shift;
|
||||
my $upload = shift;
|
||||
my $cgi = shift;
|
||||
my $upload = shift;
|
||||
|
||||
if ( defined $upload ) {
|
||||
# try apache2 module
|
||||
if ( defined $upload ) {
|
||||
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 => ''
|
||||
};
|
||||
# fallback to CGI module
|
||||
my $file = $cgi->param("image");
|
||||
if ( $file =~ /\|/ ) {
|
||||
return { error => "is no file" };
|
||||
}
|
||||
|
||||
}
|
||||
my $file_info = $cgi->uploadInfo($file);
|
||||
if ( defined $file_info ) {
|
||||
my $filename = $file_info->{'Content-Disposition'} || '';
|
||||
if ( $filename =~ /filename=\"(.*?)\"/ ) {
|
||||
$filename = $1;
|
||||
return {
|
||||
filename => $filename,
|
||||
fh => $file,
|
||||
error => ''
|
||||
};
|
||||
|
||||
# fallback to CGI module
|
||||
my $file = $cgi->param("image");
|
||||
if ( $file =~ /\|/ ) {
|
||||
return { error => "is no file" };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $file_info = $cgi->uploadInfo($file);
|
||||
if ( defined $file_info ) {
|
||||
my $filename = $file_info->{'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!' };
|
||||
}
|
||||
|
||||
sub check_filename {
|
||||
my $filename = shift;
|
||||
my $filename = shift;
|
||||
|
||||
my @valid_extensions = ( 'png', 'jpeg', 'jpg', 'gif', 'pdf', 'txt', 'bmp', 'ps', 'eps', 'wmf' );
|
||||
if ( $filename =~ /\.([a-zA-Z]{3,5})$/ ) {
|
||||
my $extension = lc $1;
|
||||
unless ( grep( /$extension/, @valid_extensions ) ) {
|
||||
return { error => 'Following file formats are supported: ' . join( ",", @valid_extensions ) . '!' };
|
||||
}
|
||||
return {
|
||||
extension => $extension,
|
||||
error => ''
|
||||
};
|
||||
} else {
|
||||
return { error => 'Not matching file extension found! Supported are: ' . join( ",", @valid_extensions ) . '!' };
|
||||
}
|
||||
my @valid_extensions = ( 'png', 'jpeg', 'jpg', 'gif', 'pdf', 'txt', 'bmp', 'ps', 'eps', 'wmf' );
|
||||
if ( $filename =~ /\.([a-zA-Z]{3,5})$/ ) {
|
||||
my $extension = lc $1;
|
||||
unless ( grep( /$extension/, @valid_extensions ) ) {
|
||||
return { error => 'Following file formats are supported: ' . join( ",", @valid_extensions ) . '!' };
|
||||
}
|
||||
return {
|
||||
extension => $extension,
|
||||
error => ''
|
||||
};
|
||||
} else {
|
||||
return { error => 'Not matching file extension found! Supported are: ' . join( ",", @valid_extensions ) . '!' };
|
||||
}
|
||||
}
|
||||
|
||||
sub process_image {
|
||||
my $config = shift;
|
||||
my $filename = shift;
|
||||
my $extension = shift;
|
||||
my $md5_filename = shift;
|
||||
my $content = shift;
|
||||
my $config = shift;
|
||||
my $filename = shift;
|
||||
my $extension = shift;
|
||||
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 );
|
||||
return $result if defined $result->{error};
|
||||
#copy file to upload space
|
||||
my $result = images::writeFile( $upload_path, $content );
|
||||
return $result if defined $result->{error};
|
||||
|
||||
#write image
|
||||
my $image = new Image::Magick;
|
||||
$image->Read($upload_path);
|
||||
my $x = $image->Get('width') || 0;
|
||||
my $y = $image->Get('height') || 0;
|
||||
if ( ( $x == 0 ) || ( $y == 0 ) ) {
|
||||
return { error => 'Could not read image!' };
|
||||
log::error( $config, 'Cannot read image $filename!' );
|
||||
}
|
||||
#write image
|
||||
my $image = new Image::Magick;
|
||||
$image->Read($upload_path);
|
||||
my $x = $image->Get('width') || 0;
|
||||
my $y = $image->Get('height') || 0;
|
||||
if ( ( $x == 0 ) || ( $y == 0 ) ) {
|
||||
return { error => 'Could not read image!' };
|
||||
log::error( $config, 'Cannot read image $filename!' );
|
||||
}
|
||||
|
||||
#set max size image
|
||||
if ( $x > 0 && $y > 0 ) {
|
||||
if ( $x > $y ) {
|
||||
$image->Resize( width => '600', height => int( 600 * $y / $x ) );
|
||||
} else {
|
||||
$image->Resize( width => int( 600 * $x / $y ), height => '600' );
|
||||
}
|
||||
}
|
||||
#set max size image
|
||||
if ( $x > 0 && $y > 0 ) {
|
||||
if ( $x > $y ) {
|
||||
$image->Resize( width => '600', height => int( 600 * $y / $x ) );
|
||||
} else {
|
||||
$image->Resize( width => int( 600 * $x / $y ), height => '600' );
|
||||
}
|
||||
}
|
||||
|
||||
#$image->Normalize();
|
||||
$image->Write( 'jpg:' . $image_path );
|
||||
#$image->Normalize();
|
||||
$image->Write( 'jpg:' . $image_path );
|
||||
|
||||
#write thumb
|
||||
my $thumb = $image;
|
||||
$thumb->Trim2Square;
|
||||
$thumb->Resize( width => 150, height => 150 );
|
||||
$thumb->Write( 'jpg:' . $thumb_path );
|
||||
#write thumb
|
||||
my $thumb = $image;
|
||||
$thumb->Trim2Square;
|
||||
$thumb->Resize( width => 150, height => 150 );
|
||||
$thumb->Write( 'jpg:' . $thumb_path );
|
||||
|
||||
my $icon = $image;
|
||||
$icon->Trim2Square;
|
||||
$icon->Resize( width => 25, height => 25 );
|
||||
$icon->Write( 'jpg:' . $icon_path );
|
||||
my $icon = $image;
|
||||
$icon->Trim2Square;
|
||||
$icon->Resize( width => 25, height => 25 );
|
||||
$icon->Write( 'jpg:' . $icon_path );
|
||||
|
||||
unless ( -e $thumb_path ) {
|
||||
return { error => 'could not create thumb file!' };
|
||||
}
|
||||
unless ( -e $icon_path ) {
|
||||
return { error => 'could not create icon file!' };
|
||||
}
|
||||
unless ( -e $image_path ) {
|
||||
return { error => 'could not create image file!' };
|
||||
}
|
||||
return { error => 'could not create thumb file!' } unless -e $thumb_path;
|
||||
return { error => 'could not create icon file!' } unless -e $icon_path;
|
||||
return { error => 'could not create image file!' } unless -e $image_path;
|
||||
|
||||
return {
|
||||
upload_filename => $filename,
|
||||
|
||||
filename => $md5_filename . '.jpg',
|
||||
thumb_path => $thumb_path,
|
||||
icon_path => $icon_path,
|
||||
image_path => $image_path,
|
||||
|
||||
error => ''
|
||||
};
|
||||
return {
|
||||
upload_filename => $filename,
|
||||
filename => $md5_filename . '.jpg',
|
||||
thumb_path => $thumb_path,
|
||||
icon_path => $icon_path,
|
||||
image_path => $image_path,
|
||||
error => ''
|
||||
};
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $checked = {};
|
||||
$checked->{template} = template::check($config, $params->{template}, 'imageUpload' );
|
||||
my $checked = {};
|
||||
$checked->{template} = template::check( $config, $params->{template}, 'imageUpload' );
|
||||
|
||||
#numeric values
|
||||
for my $param ( 'project_id', 'studio_id', 'default_studio_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;
|
||||
}
|
||||
#numeric values
|
||||
for my $param ( 'project_id', 'studio_id', 'default_studio_id' ) {
|
||||
$checked->{$param} = $params->{$param} if ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ );
|
||||
}
|
||||
|
||||
#string
|
||||
for my $param ( 'debug', 'name', 'description', 'licence' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\s*(.+?)\s*$/ ) ) {
|
||||
$checked->{$param} = $1;
|
||||
}
|
||||
}
|
||||
if ( defined $checked->{studio_id} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
|
||||
#Words
|
||||
for my $attr ('action') {
|
||||
if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /(\S+)/ ) ) {
|
||||
$checked->{$attr} = $params->{$attr};
|
||||
}
|
||||
}
|
||||
return $checked;
|
||||
#string
|
||||
for my $param ( 'debug', 'name', 'description', 'licence' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\s*(.+?)\s*$/ ) ) {
|
||||
$checked->{$param} = $1;
|
||||
}
|
||||
}
|
||||
|
||||
#Words
|
||||
for my $attr ('action') {
|
||||
if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /(\S+)/ ) ) {
|
||||
$checked->{$attr} = $params->{$attr};
|
||||
}
|
||||
}
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,11 +24,11 @@ my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( $user eq '' );
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
}
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $config, $params ),
|
||||
}
|
||||
};
|
||||
$params = $request->{params}->{checked};
|
||||
my $loc = localization::get( $config, { user => $user, file => $params->{usecase} } );
|
||||
@@ -38,25 +38,23 @@ my $json = JSON::to_json( $loc, { pretty => 1 } );
|
||||
my @json_lines = ();
|
||||
|
||||
for my $line ( split /\n/, $json ) {
|
||||
push @json_lines, "'" . $line . "'\n";
|
||||
push @json_lines, "'" . $line . "'\n";
|
||||
}
|
||||
|
||||
$json = $header . $json;
|
||||
|
||||
# .'var loc_text='.join('+',@json_lines).";\n"
|
||||
# .'var loc = JQuery.parseJSON(loc_text)';
|
||||
print $json;
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $checked = { usecase => '' };
|
||||
my $checked = { usecase => '' };
|
||||
|
||||
if ( defined $params->{usecase} ) {
|
||||
if ( $params->{usecase} =~ /^([a-z\-\_\,]+)$/ ) {
|
||||
$checked->{usecase} = $1;
|
||||
}
|
||||
}
|
||||
return $checked;
|
||||
if ( defined $params->{usecase} ) {
|
||||
if ( $params->{usecase} =~ /^([a-z\-\_\,]+)$/ ) {
|
||||
$checked->{usecase} = $1;
|
||||
}
|
||||
}
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
use warnings "all";
|
||||
use strict;
|
||||
use URI::Escape();
|
||||
use Encode();
|
||||
|
||||
#use Encode();
|
||||
use Data::Dumper;
|
||||
use MIME::Lite();
|
||||
|
||||
@@ -31,12 +32,12 @@ my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
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->{studio_id} = $params->{default_studio_id}
|
||||
@@ -45,11 +46,11 @@ $params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
|
||||
#print STDERR Dumper($request)."\n";
|
||||
@@ -61,221 +62,222 @@ $params = $request->{params}->{checked};
|
||||
|
||||
#show header
|
||||
unless ( params::isJson() || ( $params->{template} =~ /\.txt/ ) ) {
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( $config, 'print', template::check($config, 'default.html'), $headerParams );
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( $config, 'print', template::check( $config, 'default.html' ), $headerParams );
|
||||
}
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
$config->{access}->{write} = 0;
|
||||
if ( $params->{action} eq 'send' ) {
|
||||
sendMail( $config, $request );
|
||||
return;
|
||||
sendMail( $config, $request );
|
||||
return;
|
||||
}
|
||||
show_events( $config, $request );
|
||||
|
||||
#show existing event history
|
||||
sub show_events {
|
||||
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', 'duration' ) { # 'series_id','event_id'
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( "missing " . $attr . " to show changes" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
for my $attr ( 'project_id', 'studio_id', 'duration' ) { # 'series_id','event_id'
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( "missing " . $attr . " to show changes" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
unless ( $permissions->{read_event} == 1 ) {
|
||||
uac::print_error("missing permissions to show changes");
|
||||
return;
|
||||
}
|
||||
unless ( $permissions->{read_event} == 1 ) {
|
||||
uac::print_error("missing permissions to show changes");
|
||||
return;
|
||||
}
|
||||
|
||||
# get events
|
||||
my $duration = $params->{duration};
|
||||
my $options = {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
from_date => time::time_to_date(),
|
||||
till_date => time::time_to_date( time() + $duration * 24 * 60 * 60 ),
|
||||
draft => 0,
|
||||
published => 1
|
||||
};
|
||||
# get events
|
||||
my $duration = $params->{duration};
|
||||
my $options = {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
from_date => time::time_to_date(),
|
||||
till_date => time::time_to_date( time() + $duration * 24 * 60 * 60 ),
|
||||
draft => 0,
|
||||
published => 1
|
||||
};
|
||||
|
||||
my $events = series::get_events( $config, $options );
|
||||
my $events = series::get_events( $config, $options );
|
||||
|
||||
# get series_users
|
||||
for my $event (@$events) {
|
||||
my $mail = getMail( $config, $request, $event );
|
||||
$event->{mail} = $mail;
|
||||
}
|
||||
# get series_users
|
||||
for my $event (@$events) {
|
||||
my $mail = getMail( $config, $request, $event );
|
||||
$event->{mail} = $mail;
|
||||
}
|
||||
|
||||
return unless defined $events;
|
||||
my @events = sort { $a->{start} cmp $b->{start} } @$events;
|
||||
$params->{events} = \@events;
|
||||
return unless defined $events;
|
||||
my @events = sort { $a->{start} cmp $b->{start} } @$events;
|
||||
$params->{events} = \@events;
|
||||
|
||||
for my $permission ( keys %{$permissions} ) {
|
||||
$params->{'allow'}->{$permission} = $request->{permissions}->{$permission};
|
||||
}
|
||||
for my $permission ( keys %{$permissions} ) {
|
||||
$params->{'allow'}->{$permission} = $request->{permissions}->{$permission};
|
||||
}
|
||||
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'notify_events' } );
|
||||
template::process($config, 'print', $params->{template}, $params );
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'notify_events' } );
|
||||
template::process( $config, 'print', $params->{template}, $params );
|
||||
|
||||
}
|
||||
|
||||
sub sendMail {
|
||||
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 send notification" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
for my $attr ( 'project_id', 'studio_id', 'series_id', 'event_id' ) {
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( "missing " . $attr . " to send notification" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
unless ( $permissions->{read_event} == 1 ) {
|
||||
uac::print_error("missing permissions to send notification");
|
||||
return;
|
||||
}
|
||||
unless ( $permissions->{read_event} == 1 ) {
|
||||
uac::print_error("missing permissions to send notification");
|
||||
return;
|
||||
}
|
||||
|
||||
my $options = {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
series_id => $params->{series_id},
|
||||
event_id => $params->{event_id},
|
||||
draft => 0,
|
||||
published => 0,
|
||||
};
|
||||
my $events = series::get_events( $config, $options );
|
||||
my $options = {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
series_id => $params->{series_id},
|
||||
event_id => $params->{event_id},
|
||||
draft => 0,
|
||||
published => 0,
|
||||
};
|
||||
my $events = series::get_events( $config, $options );
|
||||
|
||||
unless ( scalar(@$events) == 1 ) {
|
||||
uac::print_error("did not found exactly one event");
|
||||
return;
|
||||
}
|
||||
unless ( scalar(@$events) == 1 ) {
|
||||
uac::print_error("did not found exactly one event");
|
||||
return;
|
||||
}
|
||||
|
||||
my $mail = getMail( $config, $request, $events->[0] );
|
||||
$mail->{To} = $params->{to} if defined $params->{to};
|
||||
$mail->{Cc} = $params->{cc} if defined $params->{cc};
|
||||
$mail->{Subject} = $params->{subject} if defined $params->{subject};
|
||||
$mail->{Data} = $params->{content} if defined $params->{content};
|
||||
my $mail = getMail( $config, $request, $events->[0] );
|
||||
$mail->{To} = $params->{to} if defined $params->{to};
|
||||
$mail->{Cc} = $params->{cc} if defined $params->{cc};
|
||||
$mail->{Subject} = $params->{subject} if defined $params->{subject};
|
||||
$mail->{Data} = $params->{content} if defined $params->{content};
|
||||
|
||||
my $msg = MIME::Lite->new(
|
||||
'From' => $mail->{'From'},
|
||||
'To' => $mail->{'To'},
|
||||
'Cc' => $mail->{'Cc'},
|
||||
'Reply-To' => $mail->{'Reply-To'},
|
||||
'Subject' => $mail->{'Subject'},
|
||||
'Data' => $mail->{'Data'},
|
||||
);
|
||||
my $msg = MIME::Lite->new(
|
||||
'From' => $mail->{'From'},
|
||||
'To' => $mail->{'To'},
|
||||
'Cc' => $mail->{'Cc'},
|
||||
'Reply-To' => $mail->{'Reply-To'},
|
||||
'Subject' => $mail->{'Subject'},
|
||||
'Data' => $mail->{'Data'},
|
||||
);
|
||||
|
||||
print '<pre>';
|
||||
$msg->print( \*STDOUT );
|
||||
print '</pre>';
|
||||
$msg->send;
|
||||
print '<pre>';
|
||||
$msg->print( \*STDOUT );
|
||||
print '</pre>';
|
||||
$msg->send;
|
||||
}
|
||||
|
||||
sub getMail {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $event = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $event = shift;
|
||||
|
||||
my $users = series::get_users(
|
||||
$config,
|
||||
{
|
||||
project_id => $event->{project_id},
|
||||
studio_id => $event->{studio_id},
|
||||
series_id => $event->{series_id}
|
||||
}
|
||||
);
|
||||
my $users = series::get_users(
|
||||
$config,
|
||||
{
|
||||
project_id => $event->{project_id},
|
||||
studio_id => $event->{studio_id},
|
||||
series_id => $event->{series_id}
|
||||
}
|
||||
);
|
||||
|
||||
my $userNames = [];
|
||||
my $userMails = [];
|
||||
for my $user (@$users) {
|
||||
push @$userNames, ( split( /\s+/, $user->{full_name} ) )[0];
|
||||
push @$userMails, $user->{email};
|
||||
}
|
||||
if ( scalar(@$userMails) == 0 ) {
|
||||
$event->{noRecipient} = 1;
|
||||
return;
|
||||
}
|
||||
my $userNames = [];
|
||||
my $userMails = [];
|
||||
for my $user (@$users) {
|
||||
push @$userNames, ( split( /\s+/, $user->{full_name} ) )[0];
|
||||
push @$userMails, $user->{email};
|
||||
}
|
||||
if ( scalar(@$userMails) == 0 ) {
|
||||
$event->{noRecipient} = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
my $mail = {
|
||||
'From' => 'programm@radiopiloten.de',
|
||||
'To' => join( ', ', @$userMails ),
|
||||
'Cc' => 'programm@radiopiloten.de',
|
||||
'Reply-To' => 'programm@radiopiloten.de',
|
||||
'Subject' => "$event->{start} - $event->{full_title}",
|
||||
'Data' => "Hallo " . join( ' und ', @$userNames ) . ",\n\n"
|
||||
};
|
||||
my $mail = {
|
||||
'From' => 'programm@radiopiloten.de',
|
||||
'To' => join( ', ', @$userMails ),
|
||||
'Cc' => 'programm@radiopiloten.de',
|
||||
'Reply-To' => 'programm@radiopiloten.de',
|
||||
'Subject' => "$event->{start} - $event->{full_title}",
|
||||
'Data' => "Hallo " . join( ' und ', @$userNames ) . ",\n\n"
|
||||
};
|
||||
|
||||
$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} .= "Gruss, $request->{user}\n";
|
||||
return $mail;
|
||||
$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} .= "Gruss, $request->{user}\n";
|
||||
return $mail;
|
||||
}
|
||||
|
||||
sub eventToText {
|
||||
my $event = shift;
|
||||
my $event = shift;
|
||||
|
||||
my $s = events::get_keys($event)->{full_title} . "\n";
|
||||
$s .= $event->{excerpt} . "\n";
|
||||
$s .= $event->{user_excerpt} . "\n";
|
||||
$s .= $event->{topic} . "\n";
|
||||
$s .= $event->{content} . "\n";
|
||||
my $s = events::get_keys($event)->{full_title} . "\n";
|
||||
$s .= $event->{excerpt} . "\n";
|
||||
$s .= $event->{user_excerpt} . "\n";
|
||||
$s .= $event->{topic} . "\n";
|
||||
$s .= $event->{content} . "\n";
|
||||
|
||||
#print STDERR "DUMP\n$s";
|
||||
return $s;
|
||||
#print STDERR "DUMP\n$s";
|
||||
return $s;
|
||||
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $checked = {};
|
||||
my $template = '';
|
||||
$checked->{template} = template::check($config, $params->{template}, 'notify_events' );
|
||||
my $checked = {};
|
||||
my $template = '';
|
||||
$checked->{template} = template::check( $config, $params->{template}, 'notify_events' );
|
||||
|
||||
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 ( 'event_id', 'project_id', 'studio_id', 'default_studio_id', 'user_id', 'series_id', 'duration' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
#numeric values
|
||||
for my $param ( 'event_id', 'project_id', 'studio_id', 'default_studio_id', 'user_id', 'series_id', 'duration' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
for my $param ( 'subject', 'to', 'cc', 'content' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /\S/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
for my $param ( 'subject', 'to', 'cc', 'content' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /\S/ ) ) {
|
||||
$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;
|
||||
}
|
||||
|
||||
#actions and roles
|
||||
$checked->{action} = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(send)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
#actions and roles
|
||||
$checked->{action} = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(send)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
|
||||
return $checked;
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@ use strict;
|
||||
use Data::Dumper;
|
||||
|
||||
use URI::Escape();
|
||||
use Encode();
|
||||
|
||||
#use Encode();
|
||||
use localization();
|
||||
|
||||
use params();
|
||||
@@ -39,12 +40,12 @@ print "Content-type:text/html; charset=UTF-8;\n\n";
|
||||
|
||||
#print STDERR $params->{project_id}."\n";
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
user => $user
|
||||
}
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
user => $user
|
||||
}
|
||||
);
|
||||
|
||||
$params->{default_studio_id} = $user_presets->{studio_id};
|
||||
@@ -56,11 +57,11 @@ $params->{project_id} = $user_presets->{project_id}
|
||||
#print STDERR $params->{project_id}."\n";
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
|
||||
@@ -74,88 +75,89 @@ $headerParams->{loc} = localization::get( $config, { user => $user, file => 'men
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
if ( defined $params->{action} ) {
|
||||
deleteFromPlayout( $config, $request ) if ( $params->{action} eq 'delete' );
|
||||
deleteFromPlayout( $config, $request ) if ( $params->{action} eq 'delete' );
|
||||
} else {
|
||||
print "missing action\n";
|
||||
print "missing action\n";
|
||||
}
|
||||
return;
|
||||
|
||||
sub deleteFromPlayout {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{update_event_status_playout} == 1 ) {
|
||||
uac::permissions_denied('update_event_status_playout');
|
||||
return;
|
||||
}
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{update_event_status_playout} == 1 ) {
|
||||
uac::permissions_denied('update_event_status_playout');
|
||||
return;
|
||||
}
|
||||
|
||||
for my $attr ( 'project_id', 'studio_id', 'start_date' ) {
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( "missing " . $attr . " to show event" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
for my $attr ( 'project_id', 'studio_id', 'start_date' ) {
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( "missing " . $attr . " to show event" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$config->{access}->{write} = 1;
|
||||
my $dbh = db::connect($config);
|
||||
$config->{access}->{write} = 1;
|
||||
my $dbh = db::connect($config);
|
||||
|
||||
my $result = playout::delete(
|
||||
$config, $dbh,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
start => $params->{start_date}
|
||||
}
|
||||
);
|
||||
$config->{access}->{write} = 0;
|
||||
my $result = playout::delete(
|
||||
$config, $dbh,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
start => $params->{start_date}
|
||||
}
|
||||
);
|
||||
$config->{access}->{write} = 0;
|
||||
|
||||
print "result:$result\n";
|
||||
print "result:$result\n";
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
my $config = 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;
|
||||
|
||||
#actions and roles
|
||||
$checked->{action} = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(delete)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
#actions and roles
|
||||
$checked->{action} = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(delete)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
|
||||
#numeric values
|
||||
$checked->{exclude} = 0;
|
||||
for my $param ( 'project_id', 'studio_id' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
#numeric values
|
||||
$checked->{exclude} = 0;
|
||||
for my $param ( 'project_id', 'studio_id' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
#dates
|
||||
for my $param ('start_date') {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /(\d\d\d\d\-\d\d\-\d\d \d\d\:\d\d)/ ) ) {
|
||||
$checked->{$param} = $1 . ':00';
|
||||
}
|
||||
}
|
||||
#dates
|
||||
for my $param ('start_date') {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /(\d\d\d\d\-\d\d\-\d\d \d\d\:\d\d)/ ) ) {
|
||||
$checked->{$param} = $1 . ':00';
|
||||
}
|
||||
}
|
||||
|
||||
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},'playout');
|
||||
#$checked->{template}=template::check($config, $params->{template},'playout');
|
||||
|
||||
return $checked;
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,12 +26,12 @@ return if ( $user eq '' );
|
||||
|
||||
my $permissions = roles::get_user_permissions($config);
|
||||
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->{studio_id} = $params->{default_studio_id}
|
||||
@@ -40,11 +40,11 @@ $params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
|
||||
@@ -53,7 +53,7 @@ $params = $request->{params}->{checked};
|
||||
#process header
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process($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{
|
||||
@@ -63,244 +63,245 @@ print q{
|
||||
};
|
||||
|
||||
if ( defined $params->{action} ) {
|
||||
save_project( $config, $request ) if ( $params->{action} eq 'save' );
|
||||
delete_project( $config, $request ) if ( $params->{action} eq 'delete' );
|
||||
assign_studio( $config, $request ) if ( $params->{action} eq 'assign_studio' );
|
||||
unassign_studio( $config, $request ) if ( $params->{action} eq 'unassign_studio' );
|
||||
save_project( $config, $request ) if ( $params->{action} eq 'save' );
|
||||
delete_project( $config, $request ) if ( $params->{action} eq 'delete' );
|
||||
assign_studio( $config, $request ) if ( $params->{action} eq 'assign_studio' );
|
||||
unassign_studio( $config, $request ) if ( $params->{action} eq 'unassign_studio' );
|
||||
}
|
||||
$config->{access}->{write} = 0;
|
||||
show_projects( $config, $request );
|
||||
|
||||
sub delete_project {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{delete_project} == 1 ) {
|
||||
uac::permissions_denied('delete_project');
|
||||
return;
|
||||
}
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{delete_project} == 1 ) {
|
||||
uac::permissions_denied('delete_project');
|
||||
return;
|
||||
}
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $columns = project::get_columns($config);
|
||||
my $params = $request->{params}->{checked};
|
||||
my $columns = project::get_columns($config);
|
||||
|
||||
my $entry = {};
|
||||
for my $param ( keys %$params ) {
|
||||
if ( defined $columns->{$param} ) {
|
||||
$entry->{$param} = $params->{$param} || '';
|
||||
}
|
||||
}
|
||||
my $entry = {};
|
||||
for my $param ( keys %$params ) {
|
||||
if ( defined $columns->{$param} ) {
|
||||
$entry->{$param} = $params->{$param} || '';
|
||||
}
|
||||
}
|
||||
|
||||
my $project_id = $params->{pid} || '';
|
||||
my $project_id = $params->{pid} || '';
|
||||
|
||||
if ( $project_id ne '' ) {
|
||||
$config->{access}->{write} = 1;
|
||||
$entry->{project_id} = $project_id;
|
||||
delete $entry->{studio_id};
|
||||
project::delete( $config, $entry );
|
||||
uac::print_info("Project deleted");
|
||||
}
|
||||
if ( $project_id ne '' ) {
|
||||
$config->{access}->{write} = 1;
|
||||
$entry->{project_id} = $project_id;
|
||||
delete $entry->{studio_id};
|
||||
project::delete( $config, $entry );
|
||||
uac::print_info("Project deleted");
|
||||
}
|
||||
}
|
||||
|
||||
sub save_project {
|
||||
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};
|
||||
|
||||
#filter entry for studio columns
|
||||
my $columns = project::get_columns($config);
|
||||
my $entry = {};
|
||||
for my $param ( keys %$params ) {
|
||||
if ( defined $columns->{$param} ) {
|
||||
$entry->{$param} = $params->{$param} || '';
|
||||
}
|
||||
}
|
||||
#filter entry for studio columns
|
||||
my $columns = project::get_columns($config);
|
||||
my $entry = {};
|
||||
for my $param ( keys %$params ) {
|
||||
if ( defined $columns->{$param} ) {
|
||||
$entry->{$param} = $params->{$param} || '';
|
||||
}
|
||||
}
|
||||
|
||||
my $project_id = $params->{pid} || '';
|
||||
if ( $project_id ne '' ) {
|
||||
unless ( $permissions->{update_project} == 1 ) {
|
||||
uac::permissions_denied('update_project');
|
||||
return;
|
||||
}
|
||||
$entry->{project_id} = $project_id;
|
||||
delete $entry->{studio_id};
|
||||
my $project_id = $params->{pid} || '';
|
||||
if ( $project_id ne '' ) {
|
||||
unless ( $permissions->{update_project} == 1 ) {
|
||||
uac::permissions_denied('update_project');
|
||||
return;
|
||||
}
|
||||
$entry->{project_id} = $project_id;
|
||||
delete $entry->{studio_id};
|
||||
|
||||
$config->{access}->{write} = 1;
|
||||
project::update( $config, $entry );
|
||||
$config->{access}->{write} = 0;
|
||||
uac::print_info("project saved");
|
||||
} else {
|
||||
unless ( $permissions->{create_project} == 1 ) {
|
||||
uac::permissions_denied('create_project');
|
||||
return;
|
||||
}
|
||||
my $projects = project::get( $config, { name => $entry->{name} } );
|
||||
if ( scalar @$projects > 0 ) {
|
||||
uac::print_error("project with name '$entry->{name}' already exists");
|
||||
return;
|
||||
}
|
||||
delete $entry->{project_id};
|
||||
delete $entry->{studio_id};
|
||||
$config->{access}->{write} = 1;
|
||||
project::update( $config, $entry );
|
||||
$config->{access}->{write} = 0;
|
||||
uac::print_info("project saved");
|
||||
} else {
|
||||
unless ( $permissions->{create_project} == 1 ) {
|
||||
uac::permissions_denied('create_project');
|
||||
return;
|
||||
}
|
||||
my $projects = project::get( $config, { name => $entry->{name} } );
|
||||
if ( scalar @$projects > 0 ) {
|
||||
uac::print_error("project with name '$entry->{name}' already exists");
|
||||
return;
|
||||
}
|
||||
delete $entry->{project_id};
|
||||
delete $entry->{studio_id};
|
||||
|
||||
$config->{access}->{write} = 1;
|
||||
project::insert( $config, $entry );
|
||||
$config->{access}->{write} = 0;
|
||||
uac::print_info("project created");
|
||||
}
|
||||
$config->{access}->{write} = 1;
|
||||
project::insert( $config, $entry );
|
||||
$config->{access}->{write} = 0;
|
||||
uac::print_info("project created");
|
||||
}
|
||||
}
|
||||
|
||||
sub assign_studio {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{assign_project_studio} == 1 ) {
|
||||
uac::permissions_denied('assign_project_studio');
|
||||
return;
|
||||
}
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{assign_project_studio} == 1 ) {
|
||||
uac::permissions_denied('assign_project_studio');
|
||||
return;
|
||||
}
|
||||
|
||||
for my $param ( 'pid', 'sid' ) {
|
||||
unless ( defined $params->{$param} ) {
|
||||
uac::print_error( 'missing ' . $param );
|
||||
return;
|
||||
}
|
||||
}
|
||||
$config->{access}->{write} = 1;
|
||||
project::assign_studio(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{pid},
|
||||
studio_id => $params->{sid}
|
||||
}
|
||||
);
|
||||
$config->{access}->{write} = 0;
|
||||
uac::print_info("project assigned");
|
||||
for my $param ( 'pid', 'sid' ) {
|
||||
unless ( defined $params->{$param} ) {
|
||||
uac::print_error( 'missing ' . $param );
|
||||
return;
|
||||
}
|
||||
}
|
||||
$config->{access}->{write} = 1;
|
||||
project::assign_studio(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{pid},
|
||||
studio_id => $params->{sid}
|
||||
}
|
||||
);
|
||||
$config->{access}->{write} = 0;
|
||||
uac::print_info("project assigned");
|
||||
|
||||
}
|
||||
|
||||
# TODO: unassign series from studio
|
||||
sub unassign_studio {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{assign_project_studio} == 1 ) {
|
||||
uac::permissions_denied('assign_project_studio');
|
||||
return;
|
||||
}
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{assign_project_studio} == 1 ) {
|
||||
uac::permissions_denied('assign_project_studio');
|
||||
return;
|
||||
}
|
||||
|
||||
for my $param ( 'pid', 'sid' ) {
|
||||
unless ( defined $params->{$param} ) {
|
||||
uac::print_error( 'missing ' . $param );
|
||||
return;
|
||||
}
|
||||
}
|
||||
$config->{access}->{write} = 1;
|
||||
project::unassign_studio(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{pid},
|
||||
studio_id => $params->{sid}
|
||||
}
|
||||
);
|
||||
$config->{access}->{write} = 0;
|
||||
uac::print_info("project unassigned");
|
||||
for my $param ( 'pid', 'sid' ) {
|
||||
unless ( defined $params->{$param} ) {
|
||||
uac::print_error( 'missing ' . $param );
|
||||
return;
|
||||
}
|
||||
}
|
||||
$config->{access}->{write} = 1;
|
||||
project::unassign_studio(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{pid},
|
||||
studio_id => $params->{sid}
|
||||
}
|
||||
);
|
||||
$config->{access}->{write} = 0;
|
||||
uac::print_info("project unassigned");
|
||||
|
||||
}
|
||||
|
||||
sub show_projects {
|
||||
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->{read_project} == 1 ) {
|
||||
uac::permissions_denied('read_project');
|
||||
return;
|
||||
}
|
||||
unless ( $permissions->{read_project} == 1 ) {
|
||||
uac::permissions_denied('read_project');
|
||||
return;
|
||||
}
|
||||
|
||||
my $projects = project::get($config);
|
||||
my $studios = studios::get($config);
|
||||
my @projects = reverse sort { $a->{end_date} cmp $b->{end_date} } (@$projects);
|
||||
$projects = \@projects;
|
||||
my $projects = project::get($config);
|
||||
my $studios = studios::get($config);
|
||||
my @projects = reverse sort { $a->{end_date} cmp $b->{end_date} } (@$projects);
|
||||
$projects = \@projects;
|
||||
|
||||
for my $project (@$projects) {
|
||||
for my $project (@$projects) {
|
||||
|
||||
# get assigned studios
|
||||
my $project_studio_assignements = project::get_studio_assignments( $config, { project_id => $project->{project_id} } );
|
||||
$project->{pid} = $project->{project_id};
|
||||
# get assigned studios
|
||||
my $project_studio_assignements = project::get_studio_assignments( $config, { project_id => $project->{project_id} } );
|
||||
$project->{pid} = $project->{project_id};
|
||||
|
||||
# get assigned studios by id
|
||||
my $assigned_studio_by_id = {};
|
||||
for my $studio (@$project_studio_assignements) {
|
||||
$assigned_studio_by_id->{ $studio->{studio_id} } = 1;
|
||||
}
|
||||
# get assigned studios by id
|
||||
my $assigned_studio_by_id = {};
|
||||
for my $studio (@$project_studio_assignements) {
|
||||
$assigned_studio_by_id->{ $studio->{studio_id} } = 1;
|
||||
}
|
||||
|
||||
my $assigned_studios = [];
|
||||
my $unassigned_studios = [];
|
||||
for my $studio (@$studios) {
|
||||
my %studio = %$studio;
|
||||
$studio = \%studio;
|
||||
$studio->{pid} = $project->{pid};
|
||||
$studio->{sid} = $studio->{id};
|
||||
if ( defined $assigned_studio_by_id->{ $studio->{id} } ) {
|
||||
push @$assigned_studios, $studio;
|
||||
} else {
|
||||
push @$unassigned_studios, $studio;
|
||||
}
|
||||
}
|
||||
$project->{assigned_studios} = $assigned_studios;
|
||||
$project->{unassigned_studios} = $unassigned_studios;
|
||||
}
|
||||
my $assigned_studios = [];
|
||||
my $unassigned_studios = [];
|
||||
for my $studio (@$studios) {
|
||||
my %studio = %$studio;
|
||||
$studio = \%studio;
|
||||
$studio->{pid} = $project->{pid};
|
||||
$studio->{sid} = $studio->{id};
|
||||
if ( defined $assigned_studio_by_id->{ $studio->{id} } ) {
|
||||
push @$assigned_studios, $studio;
|
||||
} else {
|
||||
push @$unassigned_studios, $studio;
|
||||
}
|
||||
}
|
||||
$project->{assigned_studios} = $assigned_studios;
|
||||
$project->{unassigned_studios} = $unassigned_studios;
|
||||
}
|
||||
|
||||
$params->{projects} = $projects;
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'projects' } );
|
||||
uac::set_template_permissions( $permissions, $params );
|
||||
$params->{projects} = $projects;
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'projects' } );
|
||||
uac::set_template_permissions( $permissions, $params );
|
||||
|
||||
template::process($config, 'print', $params->{template}, $params );
|
||||
template::process( $config, 'print', $params->{template}, $params );
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $checked = {};
|
||||
my $checked = {};
|
||||
|
||||
#template
|
||||
my $template = '';
|
||||
$template = template::check($config, $params->{template}, 'projects' );
|
||||
$checked->{template} = $template;
|
||||
#template
|
||||
my $template = '';
|
||||
$template = template::check( $config, $params->{template}, 'projects' );
|
||||
$checked->{template} = $template;
|
||||
|
||||
#actions
|
||||
my $action = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(save|delete|assign_studio|unassign_studio)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
#actions
|
||||
my $action = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(save|delete|assign_studio|unassign_studio)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
|
||||
for my $param ( 'name', 'title', 'subtitle', 'start_date', 'end_date', 'image', 'email' ) {
|
||||
if ( defined $params->{$param} ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
for my $param ( 'name', 'title', 'subtitle', 'start_date', 'end_date', 'image', 'email' ) {
|
||||
if ( defined $params->{$param} ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
#numeric values
|
||||
for my $param ( 'project_id', 'studio_id', 'default_studio_id', 'pid', 'sid' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
if ( defined $checked->{studio_id} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
#numeric values
|
||||
for my $param ( 'project_id', 'studio_id', 'default_studio_id', 'pid', 'sid' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
if ( defined $checked->{studio_id} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
|
||||
return $checked;
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ my $r = shift;
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
|
||||
$params = check_params($params);
|
||||
$params = check_params( $config, $params );
|
||||
|
||||
print "Content-type:text/html\n\n";
|
||||
print qq{<!DOCTYPE html>
|
||||
@@ -31,100 +31,100 @@ print qq{<!DOCTYPE html>
|
||||
};
|
||||
|
||||
if ( defined $params->{user} ) {
|
||||
sendToken( $config, $params );
|
||||
return;
|
||||
sendToken( $config, $params );
|
||||
return;
|
||||
} else {
|
||||
my $result = checkToken( $config, $params );
|
||||
return;
|
||||
my $result = checkToken( $config, $params );
|
||||
return;
|
||||
}
|
||||
|
||||
sub sendToken {
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
my $entry = password_requests::sendToken( $config, { user => $params->{user} } );
|
||||
if ( defined $entry ) {
|
||||
print "Please check you mails\n";
|
||||
} else {
|
||||
print "Sorry\n";
|
||||
}
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
my $entry = password_requests::sendToken( $config, { user => $params->{user} } );
|
||||
if ( defined $entry ) {
|
||||
print "Please check you mails\n";
|
||||
} else {
|
||||
print "Sorry\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub checkToken {
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $token = $params->{token};
|
||||
my $token = $params->{token};
|
||||
|
||||
my $entry = password_requests::get( $config, { token => $token } );
|
||||
unless ( defined $entry ) {
|
||||
print "invalid token\n";
|
||||
return undef;
|
||||
}
|
||||
my $entry = password_requests::get( $config, { token => $token } );
|
||||
unless ( defined $entry ) {
|
||||
print "invalid token\n";
|
||||
return undef;
|
||||
}
|
||||
|
||||
print STDERR Dumper($entry);
|
||||
my $created_at = $entry->{created_at};
|
||||
unless ( defined $created_at ) {
|
||||
print "invalid token age\n";
|
||||
return undef;
|
||||
}
|
||||
print STDERR Dumper($entry);
|
||||
my $created_at = $entry->{created_at};
|
||||
unless ( defined $created_at ) {
|
||||
print "invalid token age\n";
|
||||
return undef;
|
||||
}
|
||||
|
||||
my $age = time() - time::datetime_to_time($created_at);
|
||||
if ( $age > 600 ) {
|
||||
print "token is too old\n";
|
||||
password_requests::delete( $config, { token => $token } );
|
||||
return undef;
|
||||
}
|
||||
my $age = time() - time::datetime_to_time($created_at);
|
||||
if ( $age > 600 ) {
|
||||
print "token is too old\n";
|
||||
password_requests::delete( $config, { token => $token } );
|
||||
return undef;
|
||||
}
|
||||
|
||||
$config->{access}->{write} = 1;
|
||||
$entry->{max_attempts}++;
|
||||
password_requests::update( $config, $entry );
|
||||
$config->{access}->{write} = 0;
|
||||
$config->{access}->{write} = 1;
|
||||
$entry->{max_attempts}++;
|
||||
password_requests::update( $config, $entry );
|
||||
$config->{access}->{write} = 0;
|
||||
|
||||
if ( $entry->{max_attempts} > 10 ) {
|
||||
print "too many failed attempts, please request a new token by mail\n";
|
||||
password_requests::delete( $config, { token => $token } );
|
||||
return undef;
|
||||
}
|
||||
if ( $entry->{max_attempts} > 10 ) {
|
||||
print "too many failed attempts, please request a new token by mail\n";
|
||||
password_requests::delete( $config, { token => $token } );
|
||||
return undef;
|
||||
}
|
||||
|
||||
unless ( ( defined $params->{user_password} ) && ( defined $params->{user_password2} ) ) {
|
||||
printForm($token);
|
||||
return undef;
|
||||
}
|
||||
unless ( ( defined $params->{user_password} ) && ( defined $params->{user_password2} ) ) {
|
||||
printForm($token);
|
||||
return undef;
|
||||
}
|
||||
|
||||
if ( $params->{action} eq 'change' ) {
|
||||
my $user = $entry->{user};
|
||||
my $request = {
|
||||
config => $config,
|
||||
params => { checked => $params }
|
||||
};
|
||||
my $result = password_requests::changePassword( $config, $request, $user );
|
||||
if ( $params->{action} eq 'change' ) {
|
||||
my $user = $entry->{user};
|
||||
my $request = {
|
||||
config => $config,
|
||||
params => { checked => $params }
|
||||
};
|
||||
my $result = password_requests::changePassword( $config, $request, $user );
|
||||
|
||||
if ( defined $result->{error} ) {
|
||||
if ( defined $result->{error} ) {
|
||||
|
||||
#print "sorry\n";
|
||||
print $result->{error} . "\n";
|
||||
printForm($token);
|
||||
}
|
||||
#print "sorry\n";
|
||||
print $result->{error} . "\n";
|
||||
printForm($token);
|
||||
}
|
||||
|
||||
if ( defined $result->{success} ) {
|
||||
if ( defined $result->{success} ) {
|
||||
|
||||
#print "success\n";
|
||||
print $result->{success} . "\n";
|
||||
password_requests::delete( $config, { user => $user } );
|
||||
my $url = $config->{locations}->{editor_base_url};
|
||||
print qq{
|
||||
#print "success\n";
|
||||
print $result->{success} . "\n";
|
||||
password_requests::delete( $config, { user => $user } );
|
||||
my $url = $config->{locations}->{editor_base_url};
|
||||
print qq{
|
||||
<script type="text/javascript">
|
||||
window.location = "$url";
|
||||
</script>
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub printForm {
|
||||
my $token = shift;
|
||||
print qq{
|
||||
my $token = shift;
|
||||
print qq{
|
||||
<form method="post">
|
||||
<input type="hidden" name="token" value="$token">
|
||||
<input type="password" name="user_password" placeholder="enter new password">
|
||||
@@ -136,32 +136,33 @@ sub printForm {
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $checked = {};
|
||||
my $checked = {};
|
||||
|
||||
#my $template = '';
|
||||
#$checked->{template} = template::check($config, $params->{template}, 'requestPassword' );
|
||||
#my $template = '';
|
||||
#$checked->{template} = template::check($config, $params->{template}, 'requestPassword' );
|
||||
|
||||
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;
|
||||
|
||||
for my $param ( 'user', 'token', 'user_password', 'user_password2' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /\S/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
for my $param ( 'user', 'token', 'user_password', 'user_password2' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /\S/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
$checked->{action} = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(change)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
$checked->{action} = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(change)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
|
||||
return $checked;
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,23 +26,23 @@ my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
our $actions = {
|
||||
read => 1,
|
||||
update => 2,
|
||||
assign => 3,
|
||||
remove => 4,
|
||||
disable => 5,
|
||||
scan => 6,
|
||||
create => 7,
|
||||
delete => 8,
|
||||
read => 1,
|
||||
update => 2,
|
||||
assign => 3,
|
||||
remove => 4,
|
||||
disable => 5,
|
||||
scan => 6,
|
||||
create => 7,
|
||||
delete => 8,
|
||||
};
|
||||
|
||||
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->{studio_id} = $params->{default_studio_id}
|
||||
@@ -50,11 +50,11 @@ $params->{studio_id} = $params->{default_studio_id}
|
||||
$params->{project_id} = $user_presets->{project_id};
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
$params = $request->{params}->{checked};
|
||||
@@ -62,11 +62,11 @@ $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, 'roles.html'), $headerParams );
|
||||
template::process( $config, 'print', template::check( $config, 'roles.html' ), $headerParams );
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
if ( defined $params->{action} ) {
|
||||
save_roles( $config, $request ) if ( $params->{action} eq 'save' );
|
||||
save_roles( $config, $request ) if ( $params->{action} eq 'save' );
|
||||
}
|
||||
|
||||
#show current roles
|
||||
@@ -83,381 +83,382 @@ return;
|
||||
# new roles will have role level 0 by default
|
||||
#
|
||||
sub save_roles {
|
||||
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->{update_role} == 1 ) {
|
||||
uac::permissions_denied('update_role');
|
||||
return;
|
||||
}
|
||||
unless ( $permissions->{update_role} == 1 ) {
|
||||
uac::permissions_denied('update_role');
|
||||
return;
|
||||
}
|
||||
|
||||
my $studio_id = $params->{studio_id};
|
||||
my $project_id = $params->{project_id};
|
||||
my $roles = uac::get_roles( $config, { project_id => $project_id, studio_id => $studio_id } );
|
||||
my $studio_id = $params->{studio_id};
|
||||
my $project_id = $params->{project_id};
|
||||
my $roles = uac::get_roles( $config, { project_id => $project_id, studio_id => $studio_id } );
|
||||
|
||||
my $role_by_id = {};
|
||||
my $role_by_name = {};
|
||||
for my $role (@$roles) {
|
||||
$role_by_id->{ $role->{id} } = $role;
|
||||
$role_by_name->{ $role->{role} } = $role;
|
||||
}
|
||||
my $role_by_id = {};
|
||||
my $role_by_name = {};
|
||||
for my $role (@$roles) {
|
||||
$role_by_id->{ $role->{id} } = $role;
|
||||
$role_by_name->{ $role->{role} } = $role;
|
||||
}
|
||||
|
||||
my $columns = uac::get_role_columns($config);
|
||||
my $columns = uac::get_role_columns($config);
|
||||
|
||||
#print '<pre>'.Dumper($columns).'</pre>';
|
||||
#print '<pre>'.Dumper($columns).'</pre>';
|
||||
|
||||
#initialize all value ids (given by params matching to database columns)
|
||||
my $values = {};
|
||||
for my $param ( keys %$params ) {
|
||||
if ( $param =~ /(.+?)\_(\d+)?$/ ) {
|
||||
my $column = $1;
|
||||
my $id = $2 || '';
|
||||
next unless defined $columns->{$column};
|
||||
$values->{$id} = {} if ( update_allowed( $permissions, $role_by_id, $id ) );
|
||||
}
|
||||
}
|
||||
#initialize all value ids (given by params matching to database columns)
|
||||
my $values = {};
|
||||
for my $param ( keys %$params ) {
|
||||
if ( $param =~ /(.+?)\_(\d+)?$/ ) {
|
||||
my $column = $1;
|
||||
my $id = $2 || '';
|
||||
next unless defined $columns->{$column};
|
||||
$values->{$id} = {} if ( update_allowed( $permissions, $role_by_id, $id ) );
|
||||
}
|
||||
}
|
||||
|
||||
#init checkbox values with 0
|
||||
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' );
|
||||
$values->{$id}->{$column} = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#init checkbox values with 0
|
||||
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' );
|
||||
$values->{$id}->{$column} = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#set all checkbox values to 1
|
||||
for my $param ( keys %$params ) {
|
||||
if ( $param =~ /(.+?)\_(\d+)?$/ ) {
|
||||
my $column = $1;
|
||||
my $id = $2 || '';
|
||||
next unless ( defined $columns->{$column} );
|
||||
if ( update_allowed( $permissions, $role_by_id, $id ) ) {
|
||||
my $value = $params->{$param} || '';
|
||||
if ( $column eq 'level' ) {
|
||||
if ( check_level( $permissions, $value ) == 1 ) {
|
||||
$values->{$id}->{$column} = $value;
|
||||
} else {
|
||||
uac::permissions_denied("change the level of role!");
|
||||
return;
|
||||
}
|
||||
} elsif ( $column eq 'role' ) {
|
||||
$values->{$id}->{$column} = $value;
|
||||
} elsif ( $column eq 'id' || $column eq 'project_id' || $column eq 'studio_id' ) {
|
||||
#set all checkbox values to 1
|
||||
for my $param ( keys %$params ) {
|
||||
if ( $param =~ /(.+?)\_(\d+)?$/ ) {
|
||||
my $column = $1;
|
||||
my $id = $2 || '';
|
||||
next unless ( defined $columns->{$column} );
|
||||
if ( update_allowed( $permissions, $role_by_id, $id ) ) {
|
||||
my $value = $params->{$param} || '';
|
||||
if ( $column eq 'level' ) {
|
||||
if ( check_level( $permissions, $value ) == 1 ) {
|
||||
$values->{$id}->{$column} = $value;
|
||||
} else {
|
||||
uac::permissions_denied("change the level of role!");
|
||||
return;
|
||||
}
|
||||
} elsif ( $column eq 'role' ) {
|
||||
$values->{$id}->{$column} = $value;
|
||||
} elsif ( $column eq 'id' || $column eq 'project_id' || $column eq 'studio_id' ) {
|
||||
|
||||
#id and studio id will be set later
|
||||
} else {
|
||||
$values->{$id}->{$column} = 1 if ( $value =~ /^\d+$/ );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#id and studio id will be set later
|
||||
} else {
|
||||
$values->{$id}->{$column} = 1 if ( $value =~ /^\d+$/ );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#print STDERR Dumper($values);
|
||||
#order roles to update by level
|
||||
for my $id ( sort { $values->{$a}->{level} <=> $values->{$b}->{level} } keys %$values ) {
|
||||
my $role = $values->{$id};
|
||||
$role->{id} = $id || '';
|
||||
$role->{studio_id} = $studio_id;
|
||||
$role->{project_id} = $project_id;
|
||||
#print STDERR Dumper($values);
|
||||
#order roles to update by level
|
||||
for my $id ( sort { $values->{$a}->{level} <=> $values->{$b}->{level} } keys %$values ) {
|
||||
my $role = $values->{$id};
|
||||
$role->{id} = $id || '';
|
||||
$role->{studio_id} = $studio_id;
|
||||
$role->{project_id} = $project_id;
|
||||
|
||||
#if you are not admin
|
||||
next if check_level( $permissions, $role->{level} ) == 0;
|
||||
#if you are not admin
|
||||
next if check_level( $permissions, $role->{level} ) == 0;
|
||||
|
||||
if ( $role->{project_id} eq '' ) {
|
||||
uac::print_error('missing parameter project_id!');
|
||||
next;
|
||||
}
|
||||
if ( $role->{studio_id} eq '' ) {
|
||||
uac::print_error('missing parameter studio_id!');
|
||||
next;
|
||||
}
|
||||
if ( ( $role->{role} eq '' ) && ( $id ne '' ) ) {
|
||||
uac::print_error('missing parameter role!');
|
||||
next;
|
||||
}
|
||||
if ( $role->{project_id} eq '' ) {
|
||||
uac::print_error('missing parameter project_id!');
|
||||
next;
|
||||
}
|
||||
if ( $role->{studio_id} eq '' ) {
|
||||
uac::print_error('missing parameter studio_id!');
|
||||
next;
|
||||
}
|
||||
if ( ( $role->{role} eq '' ) && ( $id ne '' ) ) {
|
||||
uac::print_error('missing parameter role!');
|
||||
next;
|
||||
}
|
||||
|
||||
my $role_from_db = undef;
|
||||
$role_from_db = $role_by_name->{ $role->{role} } if defined $role_by_name->{ $role->{role} };
|
||||
my $role_from_db = undef;
|
||||
$role_from_db = $role_by_name->{ $role->{role} } if defined $role_by_name->{ $role->{role} };
|
||||
|
||||
if ( $id eq '' ) {
|
||||
if ( $id eq '' ) {
|
||||
|
||||
#insert role
|
||||
next if ( $role->{role} eq '' );
|
||||
if ( defined $role_from_db ) {
|
||||
uac::print_error("a role with name '$role->{role}' already exists!");
|
||||
next;
|
||||
}
|
||||
$role->{level} = 0;
|
||||
print "insert $id $role->{role}<br>\n";
|
||||
$config->{access}->{write} = 1;
|
||||
uac::insert_role( $config, $role );
|
||||
$config->{access}->{write} = 0;
|
||||
} else {
|
||||
#insert role
|
||||
next if ( $role->{role} eq '' );
|
||||
if ( defined $role_from_db ) {
|
||||
uac::print_error("a role with name '$role->{role}' already exists!");
|
||||
next;
|
||||
}
|
||||
$role->{level} = 0;
|
||||
print "insert $id $role->{role}<br>\n";
|
||||
$config->{access}->{write} = 1;
|
||||
uac::insert_role( $config, $role );
|
||||
$config->{access}->{write} = 0;
|
||||
} else {
|
||||
|
||||
#update role
|
||||
if ( ( defined $role_from_db ) && ( $id ne $role_from_db->{id} ) ) {
|
||||
uac::print_error( 'you cannot rename role to existing role!'
|
||||
. " '$role->{role}' ($id) != '$role_from_db->{role}' ($role_from_db->{id})" );
|
||||
next;
|
||||
}
|
||||
print "update $role->{role}<br>\n";
|
||||
#update role
|
||||
if ( ( defined $role_from_db ) && ( $id ne $role_from_db->{id} ) ) {
|
||||
uac::print_error( 'you cannot rename role to existing role!'
|
||||
. " '$role->{role}' ($id) != '$role_from_db->{role}' ($role_from_db->{id})" );
|
||||
next;
|
||||
}
|
||||
print "update $role->{role}<br>\n";
|
||||
|
||||
#print '<div style="height:3em;overflow:auto;white-space:pre">'.Dumper($role).'</div>';
|
||||
$config->{access}->{write} = 1;
|
||||
uac::update_role( $config, $role );
|
||||
$config->{access}->{write} = 0;
|
||||
}
|
||||
}
|
||||
print qq{<div class="ok head">changes saved</div>};
|
||||
#print '<div style="height:3em;overflow:auto;white-space:pre">'.Dumper($role).'</div>';
|
||||
$config->{access}->{write} = 1;
|
||||
uac::update_role( $config, $role );
|
||||
$config->{access}->{write} = 0;
|
||||
}
|
||||
}
|
||||
print qq{<div class="ok head">changes saved</div>};
|
||||
|
||||
}
|
||||
|
||||
#check if update is allowed
|
||||
sub update_allowed {
|
||||
my $permissions = shift;
|
||||
my $role_by_id = shift;
|
||||
my $id = shift;
|
||||
my $permissions = shift;
|
||||
my $role_by_id = shift;
|
||||
my $id = shift;
|
||||
|
||||
return 0 unless defined $permissions;
|
||||
return 0 unless defined $role_by_id;
|
||||
return 0 unless defined $id;
|
||||
return 1 if $id eq '';
|
||||
return 0 unless defined $role_by_id->{$id};
|
||||
my $role = $role_by_id->{$id};
|
||||
return check_level( $permissions, $role->{level} );
|
||||
return 0 unless defined $permissions;
|
||||
return 0 unless defined $role_by_id;
|
||||
return 0 unless defined $id;
|
||||
return 1 if $id eq '';
|
||||
return 0 unless defined $role_by_id->{$id};
|
||||
my $role = $role_by_id->{$id};
|
||||
return check_level( $permissions, $role->{level} );
|
||||
}
|
||||
|
||||
#check if update is allowed
|
||||
sub check_level {
|
||||
my $permissions = shift;
|
||||
my $level = shift;
|
||||
return 0 unless defined $permissions;
|
||||
return 0 unless defined $level;
|
||||
return 1 if ( $permissions->{is_admin} );
|
||||
return 1 if ( $permissions->{level} > $level );
|
||||
return 0;
|
||||
my $permissions = shift;
|
||||
my $level = shift;
|
||||
return 0 unless defined $permissions;
|
||||
return 0 unless defined $level;
|
||||
return 1 if ( $permissions->{is_admin} );
|
||||
return 1 if ( $permissions->{level} > $level );
|
||||
return 0;
|
||||
}
|
||||
|
||||
# user has to be assigned to studio
|
||||
# user needs to have permissions read_role
|
||||
sub show_roles {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{read_role} == 1 ) {
|
||||
uac::permissions_denied('read_role');
|
||||
return;
|
||||
}
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{read_role} == 1 ) {
|
||||
uac::permissions_denied('read_role');
|
||||
return;
|
||||
}
|
||||
|
||||
my $studio_id = $params->{studio_id};
|
||||
my $project_id = $params->{project_id};
|
||||
my $columns = uac::get_role_columns($config);
|
||||
my $studio_id = $params->{studio_id};
|
||||
my $project_id = $params->{project_id};
|
||||
my $columns = uac::get_role_columns($config);
|
||||
|
||||
#get user roles
|
||||
my $conditions = {};
|
||||
$conditions->{studio_id} = $params->{studio_id} if ( $params->{studio_id} ne '' );
|
||||
$conditions->{project_id} = $params->{project_id} if ( $params->{project_id} ne '' );
|
||||
my $roles = uac::get_roles( $config, $conditions );
|
||||
@$roles = reverse sort { $a->{level} cmp $b->{level} } (@$roles);
|
||||
#get user roles
|
||||
my $conditions = {};
|
||||
$conditions->{studio_id} = $params->{studio_id} if ( $params->{studio_id} ne '' );
|
||||
$conditions->{project_id} = $params->{project_id} if ( $params->{project_id} ne '' );
|
||||
my $roles = uac::get_roles( $config, $conditions );
|
||||
@$roles = reverse sort { $a->{level} cmp $b->{level} } (@$roles);
|
||||
|
||||
#add new role template
|
||||
unshift @$roles, { role => '', level => '0' };
|
||||
#add new role template
|
||||
unshift @$roles, { role => '', level => '0' };
|
||||
|
||||
#print user role form
|
||||
my $out = qq{
|
||||
#print user role form
|
||||
my $out = qq{
|
||||
<div id="edit_roles">
|
||||
<form method="post">
|
||||
<input type="hidden" name="project_id" value="$project_id">
|
||||
<input type="hidden" name="studio_id" value="$studio_id">
|
||||
};
|
||||
|
||||
if ( defined $permissions->{update_role} ) {
|
||||
if ( defined $permissions->{update_role} ) {
|
||||
|
||||
#add new user role button
|
||||
$out .= q{
|
||||
#add new user role button
|
||||
$out .= q{
|
||||
<button id="add_user_role_button" onclick="add_user_role();return false;">add user role</button>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$out .= '<hr>';
|
||||
$out .= '<table class="table">';
|
||||
my $localization = localization::get( $config, { user => $params->{presets}->{user}, file => 'roles' } );
|
||||
for my $key ( keys %$localization ) {
|
||||
$localization->{$key} =~ s/\(/<span class\=\"comment\">/;
|
||||
$localization->{$key} =~ s/\)/<\/span>/;
|
||||
}
|
||||
$out .= '<hr>';
|
||||
$out .= '<table class="table">';
|
||||
my $localization = localization::get( $config, { user => $params->{presets}->{user}, file => 'roles' } );
|
||||
for my $key ( keys %$localization ) {
|
||||
$localization->{$key} =~ s/\(/<span class\=\"comment\">/;
|
||||
$localization->{$key} =~ s/\)/<\/span>/;
|
||||
}
|
||||
|
||||
#add role row
|
||||
$out .= qq{<tr>};
|
||||
my $description = $localization->{label_role} || 'role';
|
||||
$out .= qq{<td>$description</td>};
|
||||
#add role row
|
||||
$out .= qq{<tr>};
|
||||
my $description = $localization->{label_role} || 'role';
|
||||
$out .= qq{<td>$description</td>};
|
||||
|
||||
for my $role (@$roles) {
|
||||
$role->{active} = '';
|
||||
$role->{active} = ' disabled' if check_level( $permissions, $role->{level} ) == 0;
|
||||
$role->{active} = ' disabled' unless defined $permissions->{update_role};
|
||||
}
|
||||
for my $role (@$roles) {
|
||||
$role->{active} = '';
|
||||
$role->{active} = ' disabled' if check_level( $permissions, $role->{level} ) == 0;
|
||||
$role->{active} = ' disabled' unless defined $permissions->{update_role};
|
||||
}
|
||||
|
||||
for my $role (@$roles) {
|
||||
for my $role (@$roles) {
|
||||
|
||||
#print Dumper($role);
|
||||
my $id = $role->{id} || '';
|
||||
my $value = $role->{role} || '';
|
||||
my $style = '';
|
||||
$style = ' id="new_user_role" class="editor" style="display:none"' if ( $id eq '' );
|
||||
my $active = $role->{active};
|
||||
$out .= qq{<td$style><input name="role_$id" value="$value" class="role$active" title="$value"></td>};
|
||||
}
|
||||
$out .= qq{</tr>};
|
||||
#print Dumper($role);
|
||||
my $id = $role->{id} || '';
|
||||
my $value = $role->{role} || '';
|
||||
my $style = '';
|
||||
$style = ' id="new_user_role" class="editor" style="display:none"' if ( $id eq '' );
|
||||
my $active = $role->{active};
|
||||
$out .= qq{<td$style><input name="role_$id" value="$value" class="role$active" title="$value"></td>};
|
||||
}
|
||||
$out .= qq{</tr>};
|
||||
|
||||
#add level row
|
||||
$out .= qq{<tr>};
|
||||
$description = $localization->{label_level} || 'level';
|
||||
$out .= qq{<td>$description</td>};
|
||||
for my $role (@$roles) {
|
||||
my $id = $role->{id} || '';
|
||||
my $value = $role->{level} || '';
|
||||
my $style = '';
|
||||
$style = ' id="new_user_level" class="editor" style="display:none"' if ( $id eq '' );
|
||||
my $active = $role->{active};
|
||||
$out .= qq{<td$style><input name="level_$id" value="$value" class="role$active" title="$value"></td>};
|
||||
}
|
||||
$out .= qq{</tr>};
|
||||
#add level row
|
||||
$out .= qq{<tr>};
|
||||
$description = $localization->{label_level} || 'level';
|
||||
$out .= qq{<td>$description</td>};
|
||||
for my $role (@$roles) {
|
||||
my $id = $role->{id} || '';
|
||||
my $value = $role->{level} || '';
|
||||
my $style = '';
|
||||
$style = ' id="new_user_level" class="editor" style="display:none"' if ( $id eq '' );
|
||||
my $active = $role->{active};
|
||||
$out .= qq{<td$style><input name="level_$id" value="$value" class="role$active" title="$value"></td>};
|
||||
}
|
||||
$out .= qq{</tr>};
|
||||
|
||||
#add permission rows
|
||||
$columns = sort_columns($columns);
|
||||
#add permission rows
|
||||
$columns = sort_columns($columns);
|
||||
|
||||
for my $key (@$columns) {
|
||||
next
|
||||
if ( $key eq 'level'
|
||||
|| $key eq 'role'
|
||||
|| $key eq 'id'
|
||||
|| $key eq 'project_id'
|
||||
|| $key eq 'studio_id'
|
||||
|| $key eq 'modified_at'
|
||||
|| $key eq 'created_at' );
|
||||
my $title = $key;
|
||||
$title =~ s/\_/ /g;
|
||||
my $description = $localization->{ 'label_' . $key } || $key;
|
||||
$out .= qq{<tr>};
|
||||
$out .= qq{<td title="$title">$description</td>};
|
||||
for my $role (@$roles) {
|
||||
my $value = $role->{$key} || '0';
|
||||
my $id = $role->{id} || '';
|
||||
my $active = $role->{active};
|
||||
my $style = '';
|
||||
$style = ' class="editor' . $active . '" style="display:none"' if ( $id eq '' );
|
||||
my $checked = '';
|
||||
$checked = 'checked="checked"' if ( $value eq '1' );
|
||||
$active =~ s/\s//g;
|
||||
$out .= qq{<td$style>
|
||||
for my $key (@$columns) {
|
||||
next
|
||||
if ( $key eq 'level'
|
||||
|| $key eq 'role'
|
||||
|| $key eq 'id'
|
||||
|| $key eq 'project_id'
|
||||
|| $key eq 'studio_id'
|
||||
|| $key eq 'modified_at'
|
||||
|| $key eq 'created_at' );
|
||||
my $title = $key;
|
||||
$title =~ s/\_/ /g;
|
||||
my $description = $localization->{ 'label_' . $key } || $key;
|
||||
$out .= qq{<tr>};
|
||||
$out .= qq{<td title="$title">$description</td>};
|
||||
for my $role (@$roles) {
|
||||
my $value = $role->{$key} || '0';
|
||||
my $id = $role->{id} || '';
|
||||
my $active = $role->{active};
|
||||
my $style = '';
|
||||
$style = ' class="editor' . $active . '" style="display:none"' if ( $id eq '' );
|
||||
my $checked = '';
|
||||
$checked = 'checked="checked"' if ( $value eq '1' );
|
||||
$active =~ s/\s//g;
|
||||
$out .= qq{<td$style>
|
||||
<input type="checkbox" name="} . $key . '_' . $id . qq{" value="$value" $checked class="$active">
|
||||
</td>
|
||||
};
|
||||
}
|
||||
$out .= qq{</tr>};
|
||||
}
|
||||
$out .= '</table>';
|
||||
$out .= '<input type="submit" name="action" value="save">' if ( defined $permissions->{update_role} );
|
||||
$out .= '</form>';
|
||||
$out .= '</div>';
|
||||
print $out. "\n";
|
||||
}
|
||||
$out .= qq{</tr>};
|
||||
}
|
||||
$out .= '</table>';
|
||||
$out .= '<input type="submit" name="action" value="save">' if ( defined $permissions->{update_role} );
|
||||
$out .= '</form>';
|
||||
$out .= '</div>';
|
||||
print $out. "\n";
|
||||
}
|
||||
|
||||
# sort columns by group and action
|
||||
sub sort_columns {
|
||||
my $columns = shift;
|
||||
my $columns = shift;
|
||||
|
||||
my $column_level = {};
|
||||
my $groups = sort_groups($columns);
|
||||
for my $column ( keys %$columns ) {
|
||||
my @words = split /_/, $column;
|
||||
my $action = shift @words;
|
||||
my $group = join( ' ', @words );
|
||||
my $column_level = {};
|
||||
my $groups = sort_groups($columns);
|
||||
for my $column ( keys %$columns ) {
|
||||
my @words = split /_/, $column;
|
||||
my $action = shift @words;
|
||||
my $group = join( ' ', @words );
|
||||
|
||||
#print "action:'$action' group:'$group' <br>\n";
|
||||
#print "action:'$action' group:'$group' <br>\n";
|
||||
|
||||
my $index = $groups->{$group} || 0;
|
||||
$index += $actions->{$action} if ( defined $actions->{$action} );
|
||||
$column_level->{$column} = $index;
|
||||
my $index = $groups->{$group} || 0;
|
||||
$index += $actions->{$action} if ( defined $actions->{$action} );
|
||||
$column_level->{$column} = $index;
|
||||
|
||||
# print $index."<br>";
|
||||
}
|
||||
# print $index."<br>";
|
||||
}
|
||||
|
||||
my @columns = sort { $column_level->{$a} <=> $column_level->{$b} } ( keys %$column_level );
|
||||
return \@columns;
|
||||
my @columns = sort { $column_level->{$a} <=> $column_level->{$b} } ( keys %$column_level );
|
||||
return \@columns;
|
||||
}
|
||||
|
||||
# sort columns by group
|
||||
sub sort_groups {
|
||||
my $columns = shift;
|
||||
my $groups = {};
|
||||
my $columns = shift;
|
||||
my $groups = {};
|
||||
|
||||
#extract groups
|
||||
for my $column ( keys %$columns ) {
|
||||
my @words = split /_/, $column;
|
||||
my $action = shift @words;
|
||||
my $group = join( ' ', @words );
|
||||
$groups->{$group} = 1;
|
||||
}
|
||||
#extract groups
|
||||
for my $column ( keys %$columns ) {
|
||||
my @words = split /_/, $column;
|
||||
my $action = shift @words;
|
||||
my $group = join( ' ', @words );
|
||||
$groups->{$group} = 1;
|
||||
}
|
||||
|
||||
#weigth groups
|
||||
my $i = 0;
|
||||
for my $group ( sort keys %$groups ) {
|
||||
$groups->{$group} = $i;
|
||||
$i += 100;
|
||||
}
|
||||
#weigth groups
|
||||
my $i = 0;
|
||||
for my $group ( sort keys %$groups ) {
|
||||
$groups->{$group} = $i;
|
||||
$i += 100;
|
||||
}
|
||||
|
||||
#print "<pre>";
|
||||
#for my $group (sort {$groups->{$a} <=> $groups->{$b}} (keys %$groups)){
|
||||
# print "$groups->{$group}\t$group\n";
|
||||
#}
|
||||
#print "</pre>";
|
||||
#print "<pre>";
|
||||
#for my $group (sort {$groups->{$a} <=> $groups->{$b}} (keys %$groups)){
|
||||
# print "$groups->{$group}\t$group\n";
|
||||
#}
|
||||
#print "</pre>";
|
||||
|
||||
return $groups;
|
||||
return $groups;
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $checked = {};
|
||||
my $checked = {};
|
||||
|
||||
#template
|
||||
my $template = '';
|
||||
$template = template::check($config, $params->{template}, 'roles.html' );
|
||||
$checked->{template} = $template;
|
||||
#template
|
||||
my $template = '';
|
||||
$template = template::check( $config, $params->{template}, 'roles.html' );
|
||||
$checked->{template} = $template;
|
||||
|
||||
#actions
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} eq 'save' ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
#actions
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} eq 'save' ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
|
||||
#numeric values
|
||||
for my $param ( 'project_id', 'studio_id', 'default_studio_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;
|
||||
}
|
||||
#numeric values
|
||||
for my $param ( 'project_id', 'studio_id', 'default_studio_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;
|
||||
}
|
||||
|
||||
#permission fields
|
||||
for my $key ( keys %$params ) {
|
||||
$checked->{$key} = $params->{$key} if ( $key =~ /^[a-z_]+_\d*$/ );
|
||||
}
|
||||
#permission fields
|
||||
for my $key ( keys %$params ) {
|
||||
$checked->{$key} = $params->{$key} if ( $key =~ /^[a-z_]+_\d*$/ );
|
||||
}
|
||||
|
||||
return $checked;
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,12 +25,12 @@ my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
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->{studio_id} = $params->{default_studio_id}
|
||||
@@ -39,11 +39,11 @@ $params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
|
||||
@@ -59,120 +59,121 @@ show_events( $config, $request );
|
||||
|
||||
#TODO: filter by published, draft
|
||||
sub show_events {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{read_event} == 1 ) {
|
||||
uac::permissions_denied('read_event');
|
||||
return;
|
||||
}
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{read_event} == 1 ) {
|
||||
uac::permissions_denied('read_event');
|
||||
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_';
|
||||
}
|
||||
|
||||
# get events
|
||||
$options->{series_id} = $params->{series_id} if defined $params->{series_id};
|
||||
$options->{from_date} = $params->{from_date} if defined $params->{from_date};
|
||||
$options->{till_date} = $params->{till_date} if defined $params->{till_date};
|
||||
my $events = series::get_events( $config, $options );
|
||||
# get events
|
||||
$options->{series_id} = $params->{series_id} if defined $params->{series_id};
|
||||
$options->{from_date} = $params->{from_date} if defined $params->{from_date};
|
||||
$options->{till_date} = $params->{till_date} if defined $params->{till_date};
|
||||
my $events = series::get_events( $config, $options );
|
||||
|
||||
# filter by year
|
||||
my $years = [];
|
||||
for my $year ( 2005 .. 2025 ) {
|
||||
my $date = { year => $year };
|
||||
$date->{selected} = 1 if ( defined $params->{from_date} ) && ( $params->{from_date} eq $year . '-01-01' );
|
||||
push @$years, $date;
|
||||
}
|
||||
# filter by year
|
||||
my $years = [];
|
||||
for my $year ( 2005 .. 2025 ) {
|
||||
my $date = { year => $year };
|
||||
$date->{selected} = 1 if ( defined $params->{from_date} ) && ( $params->{from_date} eq $year . '-01-01' );
|
||||
push @$years, $date;
|
||||
}
|
||||
|
||||
#print Dumper($params->{loc});
|
||||
$params->{studios} = $user_studios;
|
||||
$params->{series} = $series;
|
||||
$params->{events} = $events;
|
||||
$params->{years} = $years;
|
||||
#print Dumper($params->{loc});
|
||||
$params->{studios} = $user_studios;
|
||||
$params->{series} = $series;
|
||||
$params->{events} = $events;
|
||||
$params->{years} = $years;
|
||||
|
||||
#print STDERR Dumper($params);
|
||||
template::process($config, 'print', $params->{template}, $params );
|
||||
return;
|
||||
#print STDERR Dumper($params);
|
||||
template::process( $config, 'print', $params->{template}, $params );
|
||||
return;
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
my $config = 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', 'event_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', 'event_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};
|
||||
}
|
||||
}
|
||||
|
||||
for my $param ( 'from_date', 'till_date' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /(\d\d\d\d\-\d\d\-\d\d)/ ) ) {
|
||||
$checked->{$param} = $1;
|
||||
}
|
||||
}
|
||||
for my $param ( 'from_date', 'till_date' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /(\d\d\d\d\-\d\d\-\d\d)/ ) ) {
|
||||
$checked->{$param} = $1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( defined $params->{year} ) && ( $params->{year} =~ /^\d\d\d\d$/ ) ) {
|
||||
$checked->{year} = $params->{year};
|
||||
}
|
||||
if ( ( defined $params->{year} ) && ( $params->{year} =~ /^\d\d\d\d$/ ) ) {
|
||||
$checked->{year} = $params->{year};
|
||||
}
|
||||
|
||||
# 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}, 'selectEvent' );
|
||||
$checked->{template} = template::check( $config, $params->{template}, 'selectEvent' );
|
||||
|
||||
return $checked;
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params($config, $params),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
@@ -109,6 +109,7 @@ sub show_series {
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $checked = {};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -48,7 +48,7 @@ my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
@@ -58,7 +58,7 @@ $params = $request->{params}->{checked};
|
||||
unless ( params::isJson() ) {
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process($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;
|
||||
|
||||
@@ -75,7 +75,7 @@ showPlayout( $config, $request );
|
||||
|
||||
print STDERR "$0 ERROR: " . $params->{error} . "\n" if $params->{error} ne '';
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'event,comment' } );
|
||||
template::process($config, 'print', $params->{template}, $params );
|
||||
template::process( $config, 'print', $params->{template}, $params );
|
||||
|
||||
exit;
|
||||
|
||||
@@ -170,11 +170,12 @@ sub formatLoudness {
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $checked = {};
|
||||
$checked->{error} = '';
|
||||
$checked->{template} = template::check($config, $params->{template}, 'show_playout' );
|
||||
$checked->{template} = template::check( $config, $params->{template}, 'show_playout' );
|
||||
|
||||
#numeric values
|
||||
for my $param ( 'project_id', 'studio_id', 'default_studio_id', 'series_id', 'event_id', 'id' ) {
|
||||
|
||||
@@ -26,12 +26,12 @@ my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
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->{studio_id} = $params->{default_studio_id}
|
||||
@@ -40,11 +40,11 @@ $params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
$params = $request->{params}->{checked};
|
||||
@@ -56,83 +56,84 @@ showImage( $config, $request );
|
||||
|
||||
#TODO: filter by published, draft
|
||||
sub showImage {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{read_event} == 1 ) {
|
||||
uac::permissions_denied('read_image');
|
||||
return;
|
||||
}
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{read_event} == 1 ) {
|
||||
uac::permissions_denied('read_image');
|
||||
return;
|
||||
}
|
||||
|
||||
unless ( defined $params->{filename} ) {
|
||||
uac::permissions_denied('missing filename');
|
||||
return;
|
||||
}
|
||||
unless ( defined $params->{filename} ) {
|
||||
uac::permissions_denied('missing filename');
|
||||
return;
|
||||
}
|
||||
|
||||
my $filename = images::getInternalPath( $config, $params );
|
||||
unless ( defined $filename ) {
|
||||
uac::permissions_denied("could not find path");
|
||||
return;
|
||||
}
|
||||
|
||||
unless ( -e $filename ) {
|
||||
uac::permissions_denied("read $filename");
|
||||
return;
|
||||
}
|
||||
my $filename = images::getInternalPath( $config, $params );
|
||||
unless ( defined $filename ) {
|
||||
uac::permissions_denied("could not find path");
|
||||
return;
|
||||
}
|
||||
|
||||
my $image = images::readFile($filename);
|
||||
if ( defined $image->{error} ) {
|
||||
uac::permissions_denied("read $filename, $image->{error}");
|
||||
return;
|
||||
}
|
||||
unless ( -e $filename ) {
|
||||
uac::permissions_denied("read $filename");
|
||||
return;
|
||||
}
|
||||
|
||||
binmode STDOUT;
|
||||
print "Content-type:image/jpeg; charset=UTF-8;\n\n";
|
||||
print $image->{content};
|
||||
return;
|
||||
my $image = images::readFile($filename);
|
||||
if ( defined $image->{error} ) {
|
||||
uac::permissions_denied("read $filename, $image->{error}");
|
||||
return;
|
||||
}
|
||||
|
||||
binmode STDOUT;
|
||||
print "Content-type:image/jpeg; charset=UTF-8;\n\n";
|
||||
print $image->{content};
|
||||
return;
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
my $config = 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 ('filename') {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^[A-Za-z\_\-\.\d\/]+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
$checked->{$param} =~ s/^.*\///g;
|
||||
}
|
||||
}
|
||||
#numeric values
|
||||
for my $param ('filename') {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^[A-Za-z\_\-\.\d\/]+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
$checked->{$param} =~ s/^.*\///g;
|
||||
}
|
||||
}
|
||||
|
||||
$checked->{type} = 'thumbs';
|
||||
for my $param ('type') {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^(thumbs|images|icons)$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
$checked->{type} = 'thumbs';
|
||||
for my $param ('type') {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^(thumbs|images|icons)$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
#numeric values
|
||||
for my $param ( 'project_id', 'studio_id', 'series_id', 'event_id' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^[\-\d]+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
#numeric values
|
||||
for my $param ( 'project_id', 'studio_id', 'series_id', 'event_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;
|
||||
}
|
||||
|
||||
return $checked;
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@ use strict;
|
||||
|
||||
use Data::Dumper;
|
||||
use URI::Escape();
|
||||
use Encode();
|
||||
|
||||
#use Encode();
|
||||
|
||||
use params();
|
||||
use config();
|
||||
@@ -32,12 +33,12 @@ my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
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->{studio_id} = $params->{default_studio_id}
|
||||
@@ -46,11 +47,11 @@ $params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
$params = $request->{params}->{checked};
|
||||
@@ -62,16 +63,16 @@ $headerParams->{loc} = localization::get( $config, { user => $user, file => 'all
|
||||
my $action = $params->{action} || '';
|
||||
if ( $action eq 'show_dates' ) {
|
||||
|
||||
#print "Content-type:text/html\n\n";
|
||||
#print "Content-type:text/html\n\n";
|
||||
} else {
|
||||
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;
|
||||
|
||||
if ( $action eq 'show_dates' ) {
|
||||
print "Content-Type:text/html\n\n";
|
||||
print "Content-Type:text/html\n\n";
|
||||
} else {
|
||||
print q{
|
||||
print q{
|
||||
<script src="js/jquery-ui-timepicker.js" type="text/javascript"></script>
|
||||
<link href="css/jquery-ui-timepicker.css" type="text/css" rel="stylesheet" />
|
||||
<link href="css/theme.default.css" rel="stylesheet">
|
||||
@@ -82,12 +83,12 @@ if ( $action eq 'show_dates' ) {
|
||||
}
|
||||
|
||||
if ( defined $params->{action} ) {
|
||||
save_schedule( $config, $request ) if ( $params->{action} eq 'save_schedule' );
|
||||
delete_schedule( $config, $request ) if ( $params->{action} eq 'delete_schedule' );
|
||||
if ( $params->{action} eq 'show_dates' ) {
|
||||
showDates( $config, $request );
|
||||
return;
|
||||
}
|
||||
save_schedule( $config, $request ) if ( $params->{action} eq 'save_schedule' );
|
||||
delete_schedule( $config, $request ) if ( $params->{action} eq 'delete_schedule' );
|
||||
if ( $params->{action} eq 'show_dates' ) {
|
||||
showDates( $config, $request );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$config->{access}->{write} = 0;
|
||||
@@ -96,322 +97,323 @@ return;
|
||||
|
||||
#insert or update a schedule and update all schedule dates
|
||||
sub save_schedule {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{update_studio_timeslot_schedule} == 1 ) {
|
||||
uac::permissions_denied('update_studio_timeslot_schedule');
|
||||
return;
|
||||
}
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{update_studio_timeslot_schedule} == 1 ) {
|
||||
uac::permissions_denied('update_studio_timeslot_schedule');
|
||||
return;
|
||||
}
|
||||
|
||||
#print Dumper($params);
|
||||
my $params = $request->{params}->{checked};
|
||||
#print Dumper($params);
|
||||
my $params = $request->{params}->{checked};
|
||||
|
||||
for my $attr ( 'project_id', 'studio_id', 'start', 'end', 'end_date', 'schedule_studio_id' ) {
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( $attr . ' not given!' );
|
||||
return;
|
||||
}
|
||||
}
|
||||
for my $attr ( 'project_id', 'studio_id', 'start', 'end', 'end_date', 'schedule_studio_id' ) {
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( $attr . ' not given!' );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
my $entry = {};
|
||||
for my $attr ( 'project_id', 'start', 'end', 'end_date', 'frequency' ) {
|
||||
$entry->{$attr} = $params->{$attr} if ( defined $params->{$attr} );
|
||||
}
|
||||
my $entry = {};
|
||||
for my $attr ( 'project_id', 'start', 'end', 'end_date', 'frequency' ) {
|
||||
$entry->{$attr} = $params->{$attr} if ( defined $params->{$attr} );
|
||||
}
|
||||
|
||||
#set schedule's studio to value from schedule_studio_id
|
||||
$entry->{studio_id} = $params->{schedule_studio_id} if ( defined $params->{schedule_studio_id} );
|
||||
#set schedule's studio to value from schedule_studio_id
|
||||
$entry->{studio_id} = $params->{schedule_studio_id} if ( defined $params->{schedule_studio_id} );
|
||||
|
||||
if ( ( $entry->{end} ne '' ) && ( $entry->{end} le $entry->{start} ) ) {
|
||||
uac::print_error('start date should be before end date!');
|
||||
return;
|
||||
}
|
||||
if ( ( $entry->{end} ne '' ) && ( $entry->{end} le $entry->{start} ) ) {
|
||||
uac::print_error('start date should be before end date!');
|
||||
return;
|
||||
}
|
||||
|
||||
#print Dumper($entry);
|
||||
$config->{access}->{write} = 1;
|
||||
if ( defined $params->{schedule_id} ) {
|
||||
$entry->{schedule_id} = $params->{schedule_id};
|
||||
#print Dumper($entry);
|
||||
$config->{access}->{write} = 1;
|
||||
if ( defined $params->{schedule_id} ) {
|
||||
$entry->{schedule_id} = $params->{schedule_id};
|
||||
|
||||
#print Dumper($entry);
|
||||
studio_timeslot_schedule::update( $config, $entry );
|
||||
#print Dumper($entry);
|
||||
studio_timeslot_schedule::update( $config, $entry );
|
||||
|
||||
#my $updates=0;
|
||||
#print Dumper($entry);
|
||||
my $updates = studio_timeslot_dates::update( $config, $entry );
|
||||
uac::print_info("timeslot schedule saved. $updates dates scheduled");
|
||||
} else {
|
||||
$entry->{schedule_id} = studio_timeslot_schedule::insert( $config, $entry );
|
||||
#my $updates=0;
|
||||
#print Dumper($entry);
|
||||
my $updates = studio_timeslot_dates::update( $config, $entry );
|
||||
uac::print_info("timeslot schedule saved. $updates dates scheduled");
|
||||
} else {
|
||||
$entry->{schedule_id} = studio_timeslot_schedule::insert( $config, $entry );
|
||||
|
||||
#my $updates=0;
|
||||
my $updates = studio_timeslot_dates::update( $config, $entry );
|
||||
uac::print_info("timeslot schedule added. $updates dates added");
|
||||
}
|
||||
#my $updates=0;
|
||||
my $updates = studio_timeslot_dates::update( $config, $entry );
|
||||
uac::print_info("timeslot schedule added. $updates dates added");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub delete_schedule {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{update_studio_timeslot_schedule} == 1 ) {
|
||||
uac::permissions_denied('update_studio_timeslot_schedule');
|
||||
return;
|
||||
}
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{update_studio_timeslot_schedule} == 1 ) {
|
||||
uac::permissions_denied('update_studio_timeslot_schedule');
|
||||
return;
|
||||
}
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $params = $request->{params}->{checked};
|
||||
|
||||
my $entry = {};
|
||||
for my $attr ( 'project_id', 'studio_id', 'schedule_id' ) {
|
||||
if ( defined $params->{$attr} ) {
|
||||
$entry->{$attr} = $params->{$attr};
|
||||
} else {
|
||||
uac::print_error( $attr . ' not given!' );
|
||||
return;
|
||||
}
|
||||
}
|
||||
my $entry = {};
|
||||
for my $attr ( 'project_id', 'studio_id', 'schedule_id' ) {
|
||||
if ( defined $params->{$attr} ) {
|
||||
$entry->{$attr} = $params->{$attr};
|
||||
} else {
|
||||
uac::print_error( $attr . ' not given!' );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$config->{access}->{write} = 1;
|
||||
$entry->{schedule_id} = $params->{schedule_id};
|
||||
studio_timeslot_schedule::delete( $config, $entry );
|
||||
studio_timeslot_dates::update( $config, $entry );
|
||||
uac::print_info("timeslot schedule deleted");
|
||||
$config->{access}->{write} = 1;
|
||||
$entry->{schedule_id} = $params->{schedule_id};
|
||||
studio_timeslot_schedule::delete( $config, $entry );
|
||||
studio_timeslot_dates::update( $config, $entry );
|
||||
uac::print_info("timeslot schedule deleted");
|
||||
}
|
||||
|
||||
sub showTimeslotSchedule {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
$config->{access}->{write} = 0;
|
||||
$config->{access}->{write} = 0;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{read_studio_timeslot_schedule} == 1 ) {
|
||||
uac::permissions_denied('read_studio_timeslot_schedule');
|
||||
return;
|
||||
}
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{read_studio_timeslot_schedule} == 1 ) {
|
||||
uac::permissions_denied('read_studio_timeslot_schedule');
|
||||
return;
|
||||
}
|
||||
|
||||
for my $param ( 'project_id', 'studio_id' ) {
|
||||
unless ( defined $params->{$param} ) {
|
||||
uac::print_error("missing $param");
|
||||
return;
|
||||
}
|
||||
}
|
||||
for my $param ( 'project_id', 'studio_id' ) {
|
||||
unless ( defined $params->{$param} ) {
|
||||
uac::print_error("missing $param");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#this will be updated later (especially allow_update_events)
|
||||
for my $permission ( keys %{ $request->{permissions} } ) {
|
||||
$params->{'allow'}->{$permission} = $request->{permissions}->{$permission};
|
||||
}
|
||||
#this will be updated later (especially allow_update_events)
|
||||
for my $permission ( keys %{ $request->{permissions} } ) {
|
||||
$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};
|
||||
my $studio_id = $params->{studio_id};
|
||||
my $project_id = $params->{project_id};
|
||||
|
||||
#get project schedule
|
||||
my $schedules = studio_timeslot_schedule::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id
|
||||
#get project schedule
|
||||
my $schedules = studio_timeslot_schedule::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id
|
||||
|
||||
# studio_id=>$studio_id
|
||||
}
|
||||
);
|
||||
# studio_id=>$studio_id
|
||||
}
|
||||
);
|
||||
|
||||
#list of all studios by id
|
||||
my $studios = studios::get( $config, { project_id => $project_id } );
|
||||
#list of all studios by id
|
||||
my $studios = studios::get( $config, { project_id => $project_id } );
|
||||
|
||||
#remove seconds from dates
|
||||
for my $schedule (@$schedules) {
|
||||
$schedule->{start} =~ s/(\d\d\:\d\d)\:\d\d/$1/;
|
||||
$schedule->{end} =~ s/(\d\d\:\d\d)\:\d\d/$1/;
|
||||
#remove seconds from dates
|
||||
for my $schedule (@$schedules) {
|
||||
$schedule->{start} =~ s/(\d\d\:\d\d)\:\d\d/$1/;
|
||||
$schedule->{end} =~ s/(\d\d\:\d\d)\:\d\d/$1/;
|
||||
|
||||
#insert assigned studio
|
||||
for my $studio (@$studios) {
|
||||
my $entry = {
|
||||
id => $studio->{id},
|
||||
name => $studio->{name},
|
||||
};
|
||||
$entry->{selected} = 1 if ( $studio->{id} eq $schedule->{studio_id} );
|
||||
push @{ $schedule->{studios} }, $entry;
|
||||
}
|
||||
}
|
||||
#insert assigned studio
|
||||
for my $studio (@$studios) {
|
||||
my $entry = {
|
||||
id => $studio->{id},
|
||||
name => $studio->{name},
|
||||
};
|
||||
$entry->{selected} = 1 if ( $studio->{id} eq $schedule->{studio_id} );
|
||||
push @{ $schedule->{studios} }, $entry;
|
||||
}
|
||||
}
|
||||
|
||||
my $result = {
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id
|
||||
};
|
||||
$result->{schedule} = $schedules;
|
||||
$result->{studios} = $studios;
|
||||
$result->{start} = $params->{start};
|
||||
$result->{end} = $params->{end};
|
||||
$result->{end_date} = $params->{end_date};
|
||||
$result->{frequency} = $params->{frequency};
|
||||
my $result = {
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id
|
||||
};
|
||||
$result->{schedule} = $schedules;
|
||||
$result->{studios} = $studios;
|
||||
$result->{start} = $params->{start};
|
||||
$result->{end} = $params->{end};
|
||||
$result->{end_date} = $params->{end_date};
|
||||
$result->{frequency} = $params->{frequency};
|
||||
|
||||
#remove seconds from datetimes
|
||||
$result->{start} =~ s/(\d\d\:\d\d)\:\d\d/$1/ if defined $result->{start};
|
||||
$result->{end} =~ s/(\d\d\:\d\d)\:\d\d/$1/ if defined $result->{end};
|
||||
#remove seconds from datetimes
|
||||
$result->{start} =~ s/(\d\d\:\d\d)\:\d\d/$1/ if defined $result->{start};
|
||||
$result->{end} =~ s/(\d\d\:\d\d)\:\d\d/$1/ if defined $result->{end};
|
||||
|
||||
#copy entry values to params
|
||||
for my $key ( keys %$result ) {
|
||||
$params->{$key} = $result->{$key};
|
||||
}
|
||||
#copy entry values to params
|
||||
for my $key ( keys %$result ) {
|
||||
$params->{$key} = $result->{$key};
|
||||
}
|
||||
|
||||
#print '<pre>'.Dumper($params).'</pre>';
|
||||
template::process($config, 'print', $params->{template}, $params );
|
||||
#print '<pre>'.Dumper($params).'</pre>';
|
||||
template::process( $config, 'print', $params->{template}, $params );
|
||||
}
|
||||
|
||||
sub showDates {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
$config->{access}->{write} = 0;
|
||||
$config->{access}->{write} = 0;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{read_studio_timeslot_schedule} == 1 ) {
|
||||
uac::permissions_denied('read_studio_timeslot_schedule');
|
||||
return;
|
||||
}
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{read_studio_timeslot_schedule} == 1 ) {
|
||||
uac::permissions_denied('read_studio_timeslot_schedule');
|
||||
return;
|
||||
}
|
||||
|
||||
for my $param ( 'project_id', 'studio_id' ) {
|
||||
unless ( defined $params->{$param} ) {
|
||||
uac::print_error("missing $param");
|
||||
return;
|
||||
}
|
||||
}
|
||||
for my $param ( 'project_id', 'studio_id' ) {
|
||||
unless ( defined $params->{$param} ) {
|
||||
uac::print_error("missing $param");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#this will be updated later (especially allow_update_events)
|
||||
for my $permission ( keys %{ $request->{permissions} } ) {
|
||||
$params->{'allow'}->{$permission} = $request->{permissions}->{$permission};
|
||||
}
|
||||
#this will be updated later (especially allow_update_events)
|
||||
for my $permission ( keys %{ $request->{permissions} } ) {
|
||||
$params->{'allow'}->{$permission} = $request->{permissions}->{$permission};
|
||||
}
|
||||
|
||||
my $studio_id = $params->{studio_id};
|
||||
my $project_id = $params->{project_id};
|
||||
my $studio_id = $params->{studio_id};
|
||||
my $project_id = $params->{project_id};
|
||||
|
||||
my $fromDate = $params->{show_date} . '-01-01';
|
||||
my $tillDate = $params->{show_date} . '-12-31';
|
||||
my $fromDate = $params->{show_date} . '-01-01';
|
||||
my $tillDate = $params->{show_date} . '-12-31';
|
||||
|
||||
#add timeslot dates
|
||||
my $timeslot_dates = studio_timeslot_dates::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
#add timeslot dates
|
||||
my $timeslot_dates = studio_timeslot_dates::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
|
||||
# studio_id=>$studio_id,
|
||||
from => $fromDate,
|
||||
till => $tillDate
|
||||
}
|
||||
);
|
||||
# studio_id=>$studio_id,
|
||||
from => $fromDate,
|
||||
till => $tillDate
|
||||
}
|
||||
);
|
||||
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'all,studio_timeslots' } );
|
||||
my $language = $params->{loc}->{region};
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'all,studio_timeslots' } );
|
||||
my $language = $params->{loc}->{region};
|
||||
|
||||
# translate weekday names to selected language
|
||||
my $weekday = {
|
||||
'Mo' => $params->{loc}->{weekday_Mo},
|
||||
'Tu' => $params->{loc}->{weekday_Tu},
|
||||
'We' => $params->{loc}->{weekday_We},
|
||||
'Th' => $params->{loc}->{weekday_Th},
|
||||
'Fr' => $params->{loc}->{weekday_Fr},
|
||||
'Sa' => $params->{loc}->{weekday_Sa},
|
||||
'Su' => $params->{loc}->{weekday_Su},
|
||||
};
|
||||
# translate weekday names to selected language
|
||||
my $weekday = {
|
||||
'Mo' => $params->{loc}->{weekday_Mo},
|
||||
'Tu' => $params->{loc}->{weekday_Tu},
|
||||
'We' => $params->{loc}->{weekday_We},
|
||||
'Th' => $params->{loc}->{weekday_Th},
|
||||
'Fr' => $params->{loc}->{weekday_Fr},
|
||||
'Sa' => $params->{loc}->{weekday_Sa},
|
||||
'Su' => $params->{loc}->{weekday_Su},
|
||||
};
|
||||
|
||||
my $studios = studios::get( $config, { project_id => $project_id } );
|
||||
my $studio_by_id = {};
|
||||
for my $studio (@$studios) {
|
||||
$studio_by_id->{ $studio->{id} } = $studio;
|
||||
}
|
||||
my $studios = studios::get( $config, { project_id => $project_id } );
|
||||
my $studio_by_id = {};
|
||||
for my $studio (@$studios) {
|
||||
$studio_by_id->{ $studio->{id} } = $studio;
|
||||
}
|
||||
|
||||
#remove seconds from dates
|
||||
for my $date (@$timeslot_dates) {
|
||||
#remove seconds from dates
|
||||
for my $date (@$timeslot_dates) {
|
||||
|
||||
#remove seconds from datetimes
|
||||
$date->{start} =~ s/(\d\d\:\d\d)\:\d\d/$1/;
|
||||
$date->{end} =~ s/(\d\d\:\d\d)\:\d\d/$1/;
|
||||
#remove seconds from datetimes
|
||||
$date->{start} =~ s/(\d\d\:\d\d)\:\d\d/$1/;
|
||||
$date->{end} =~ s/(\d\d\:\d\d)\:\d\d/$1/;
|
||||
|
||||
# translate weekday
|
||||
if ( $language ne 'en' ) {
|
||||
$date->{start_weekday} = $weekday->{ $date->{start_weekday} };
|
||||
$date->{end_weekday} = $weekday->{ $date->{end_weekday} };
|
||||
}
|
||||
$date->{studio_name} = $studio_by_id->{ $date->{studio_id} }->{name};
|
||||
}
|
||||
my $result = {
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
dates => $timeslot_dates
|
||||
};
|
||||
# translate weekday
|
||||
if ( $language ne 'en' ) {
|
||||
$date->{start_weekday} = $weekday->{ $date->{start_weekday} };
|
||||
$date->{end_weekday} = $weekday->{ $date->{end_weekday} };
|
||||
}
|
||||
$date->{studio_name} = $studio_by_id->{ $date->{studio_id} }->{name};
|
||||
}
|
||||
my $result = {
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
dates => $timeslot_dates
|
||||
};
|
||||
|
||||
#copy entry values to params
|
||||
for my $key ( keys %$result ) {
|
||||
$params->{$key} = $result->{$key};
|
||||
}
|
||||
#copy entry values to params
|
||||
for my $key ( keys %$result ) {
|
||||
$params->{$key} = $result->{$key};
|
||||
}
|
||||
|
||||
my $template = template::check($config, 'studio_timeslot_dates');
|
||||
template::process($config, 'print', $template, $params );
|
||||
my $template = template::check( $config, 'studio_timeslot_dates' );
|
||||
template::process( $config, 'print', $template, $params );
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
my $config = 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;
|
||||
|
||||
#actions and roles
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(show|save_schedule|delete_schedule|show_dates)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
#actions and roles
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(show|save_schedule|delete_schedule|show_dates)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
|
||||
#numeric values
|
||||
$checked->{exclude} = 0;
|
||||
for my $param ( 'id', 'project_id', 'studio_id', 'default_studio_id', 'schedule_id', 'schedule_studio_id' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
#numeric values
|
||||
$checked->{exclude} = 0;
|
||||
for my $param ( 'id', 'project_id', 'studio_id', 'default_studio_id', 'schedule_id', 'schedule_studio_id' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( defined $params->{show_date} ) && ( $params->{show_date} =~ /^(\d\d\d\d)/ ) ) {
|
||||
$checked->{show_date} = $1;
|
||||
} else {
|
||||
my $date = time::date_to_array( time::time_to_date() );
|
||||
$checked->{show_date} = $date->[0];
|
||||
}
|
||||
if ( ( defined $params->{show_date} ) && ( $params->{show_date} =~ /^(\d\d\d\d)/ ) ) {
|
||||
$checked->{show_date} = $1;
|
||||
} else {
|
||||
my $date = time::date_to_array( time::time_to_date() );
|
||||
$checked->{show_date} = $date->[0];
|
||||
}
|
||||
|
||||
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}, 'studio_timeslots' );
|
||||
$checked->{template} = template::check( $config, $params->{template}, 'studio_timeslots' );
|
||||
|
||||
for my $param ('frequency') {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /(\d+)/ ) ) {
|
||||
$checked->{$param} = $1;
|
||||
}
|
||||
}
|
||||
for my $param ('frequency') {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /(\d+)/ ) ) {
|
||||
$checked->{$param} = $1;
|
||||
}
|
||||
}
|
||||
|
||||
for my $attr ( 'start', 'end' ) {
|
||||
if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /(\d\d\d\d\-\d\d\-\d\d[ T]\d\d\:\d\d)/ ) ) {
|
||||
$checked->{$attr} = $1 . ':00';
|
||||
}
|
||||
}
|
||||
for my $attr ('end_date') {
|
||||
if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /(\d\d\d\d\-\d\d\-\d\d)/ ) ) {
|
||||
$checked->{$attr} = $1;
|
||||
}
|
||||
}
|
||||
for my $attr ( 'start', 'end' ) {
|
||||
if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /(\d\d\d\d\-\d\d\-\d\d[ T]\d\d\:\d\d)/ ) ) {
|
||||
$checked->{$attr} = $1 . ':00';
|
||||
}
|
||||
}
|
||||
for my $attr ('end_date') {
|
||||
if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /(\d\d\d\d\-\d\d\-\d\d)/ ) ) {
|
||||
$checked->{$attr} = $1;
|
||||
}
|
||||
}
|
||||
|
||||
return $checked;
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,12 +26,12 @@ return if ( $user eq '' );
|
||||
|
||||
my $permissions = roles::get_user_permissions($config);
|
||||
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->{studio_id} = $params->{default_studio_id}
|
||||
@@ -40,11 +40,11 @@ $params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
$params = $request->{params}->{checked};
|
||||
@@ -52,7 +52,7 @@ $params = $request->{params}->{checked};
|
||||
#process header
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process($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{
|
||||
@@ -61,183 +61,184 @@ print q{
|
||||
};
|
||||
|
||||
if ( defined $params->{action} ) {
|
||||
save_studio( $config, $request ) if ( $params->{action} eq 'save' );
|
||||
delete_studio( $config, $request ) if ( $params->{action} eq 'delete' );
|
||||
save_studio( $config, $request ) if ( $params->{action} eq 'save' );
|
||||
delete_studio( $config, $request ) if ( $params->{action} eq 'delete' );
|
||||
}
|
||||
$config->{access}->{write} = 0;
|
||||
show_studios( $config, $request );
|
||||
|
||||
sub delete_studio {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{update_studio} == 1 ) {
|
||||
uac::permissions_denied('update_studio');
|
||||
return;
|
||||
}
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{update_studio} == 1 ) {
|
||||
uac::permissions_denied('update_studio');
|
||||
return;
|
||||
}
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $columns = studios::get_columns($config);
|
||||
my $params = $request->{params}->{checked};
|
||||
my $columns = studios::get_columns($config);
|
||||
|
||||
my $entry = {};
|
||||
for my $param ( keys %$params ) {
|
||||
if ( defined $columns->{$param} ) {
|
||||
$entry->{$param} = $params->{$param} || '';
|
||||
}
|
||||
}
|
||||
my $entry = {};
|
||||
for my $param ( keys %$params ) {
|
||||
if ( defined $columns->{$param} ) {
|
||||
$entry->{$param} = $params->{$param} || '';
|
||||
}
|
||||
}
|
||||
|
||||
my $studio_id = $entry->{id} || '';
|
||||
if ( $studio_id ne '' ) {
|
||||
$config->{access}->{write} = 1;
|
||||
my $studio_id = $entry->{id} || '';
|
||||
if ( $studio_id ne '' ) {
|
||||
$config->{access}->{write} = 1;
|
||||
|
||||
project::unassign_studio(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $studio_id
|
||||
}
|
||||
);
|
||||
project::unassign_studio(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $studio_id
|
||||
}
|
||||
);
|
||||
|
||||
my $studio_assignments = project::get_studio_assignments(
|
||||
$config,
|
||||
{
|
||||
studio_id => $studio_id
|
||||
}
|
||||
);
|
||||
my $studio_assignments = project::get_studio_assignments(
|
||||
$config,
|
||||
{
|
||||
studio_id => $studio_id
|
||||
}
|
||||
);
|
||||
|
||||
unless ( scalar @$studio_assignments == 0 ) {
|
||||
uac::print_info("Studio unassigned from project");
|
||||
uac::print_warn("Studio is assigned to other projects, so it will not be deleted");
|
||||
return undef;
|
||||
}
|
||||
studios::delete( $config, $entry );
|
||||
uac::print_info("Studio deleted");
|
||||
}
|
||||
unless ( scalar @$studio_assignments == 0 ) {
|
||||
uac::print_info("Studio unassigned from project");
|
||||
uac::print_warn("Studio is assigned to other projects, so it will not be deleted");
|
||||
return undef;
|
||||
}
|
||||
studios::delete( $config, $entry );
|
||||
uac::print_info("Studio deleted");
|
||||
}
|
||||
}
|
||||
|
||||
sub save_studio {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{update_studio} == 1 ) {
|
||||
uac::permissions_denied('update_studio');
|
||||
return;
|
||||
}
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{update_studio} == 1 ) {
|
||||
uac::permissions_denied('update_studio');
|
||||
return;
|
||||
}
|
||||
|
||||
#filter entry for studio columns
|
||||
my $columns = studios::get_columns($config);
|
||||
my $entry = {};
|
||||
for my $param ( keys %$params ) {
|
||||
if ( defined $columns->{$param} ) {
|
||||
$entry->{$param} = $params->{$param} || '';
|
||||
}
|
||||
}
|
||||
#filter entry for studio columns
|
||||
my $columns = studios::get_columns($config);
|
||||
my $entry = {};
|
||||
for my $param ( keys %$params ) {
|
||||
if ( defined $columns->{$param} ) {
|
||||
$entry->{$param} = $params->{$param} || '';
|
||||
}
|
||||
}
|
||||
|
||||
$config->{access}->{write} = 1;
|
||||
if ( ( defined $entry->{id} ) && ( $entry ne '' ) ) {
|
||||
studios::update( $config, $entry );
|
||||
} else {
|
||||
my $studios = studios::get( $config, { name => $entry->{name} } );
|
||||
if ( scalar @$studios > 0 ) {
|
||||
uac::print_error("studio with name '$entry->{name}' already exists");
|
||||
return;
|
||||
}
|
||||
$entry->{id} = studios::insert( $config, $entry );
|
||||
$config->{access}->{write} = 1;
|
||||
if ( ( defined $entry->{id} ) && ( $entry ne '' ) ) {
|
||||
studios::update( $config, $entry );
|
||||
} else {
|
||||
my $studios = studios::get( $config, { name => $entry->{name} } );
|
||||
if ( scalar @$studios > 0 ) {
|
||||
uac::print_error("studio with name '$entry->{name}' already exists");
|
||||
return;
|
||||
}
|
||||
$entry->{id} = studios::insert( $config, $entry );
|
||||
|
||||
project::assign_studio(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $entry->{id}
|
||||
}
|
||||
);
|
||||
}
|
||||
project::assign_studio(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $entry->{id}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#insert series for single events (if not already existing)
|
||||
my $studio_id = $entry->{id};
|
||||
my $single_series = series::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $studio_id,
|
||||
has_single_events => 1
|
||||
}
|
||||
);
|
||||
if ( scalar @$single_series == 0 ) {
|
||||
series::insert(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $studio_id,
|
||||
has_single_events => 1,
|
||||
count_episodes => 0,
|
||||
series_name => '_single_'
|
||||
}
|
||||
);
|
||||
}
|
||||
#insert series for single events (if not already existing)
|
||||
my $studio_id = $entry->{id};
|
||||
my $single_series = series::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $studio_id,
|
||||
has_single_events => 1
|
||||
}
|
||||
);
|
||||
if ( scalar @$single_series == 0 ) {
|
||||
series::insert(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $studio_id,
|
||||
has_single_events => 1,
|
||||
count_episodes => 0,
|
||||
series_name => '_single_'
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
print qq{<div class="ok head">changes saved</div>};
|
||||
print qq{<div class="ok head">changes saved</div>};
|
||||
}
|
||||
|
||||
sub show_studios {
|
||||
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 $studios = studios::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id}
|
||||
}
|
||||
);
|
||||
$params->{studios} = $studios;
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'studios' } );
|
||||
uac::set_template_permissions( $permissions, $params );
|
||||
my $studios = studios::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id}
|
||||
}
|
||||
);
|
||||
$params->{studios} = $studios;
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'studios' } );
|
||||
uac::set_template_permissions( $permissions, $params );
|
||||
|
||||
template::process($config, 'print', $params->{template}, $params );
|
||||
template::process( $config, 'print', $params->{template}, $params );
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $checked = {};
|
||||
my $checked = {};
|
||||
|
||||
#template
|
||||
my $template = '';
|
||||
$template = template::check($config, $params->{template}, 'studios' );
|
||||
$checked->{template} = $template;
|
||||
#template
|
||||
my $template = '';
|
||||
$template = template::check( $config, $params->{template}, 'studios' );
|
||||
$checked->{template} = $template;
|
||||
|
||||
#actions
|
||||
my $action = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(save|delete)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
#actions
|
||||
my $action = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(save|delete)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
|
||||
for my $param ( 'name', 'description', 'location', 'stream', 'google_calendar', 'image' ) {
|
||||
if ( defined $params->{$param} ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
for my $param ( 'name', 'description', 'location', 'stream', 'google_calendar', 'image' ) {
|
||||
if ( defined $params->{$param} ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
#numeric values
|
||||
for my $param ( 'project_id', 'studio_id', 'default_studio_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;
|
||||
}
|
||||
#numeric values
|
||||
for my $param ( 'project_id', 'studio_id', 'default_studio_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;
|
||||
}
|
||||
|
||||
return $checked;
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,12 +24,12 @@ my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
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->{studio_id} = $params->{default_studio_id}
|
||||
@@ -38,11 +38,11 @@ $params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
|
||||
@@ -51,162 +51,163 @@ $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_settings( $config, $request ) if ( $params->{action} eq 'save' );
|
||||
update_settings( $config, $request ) if ( $params->{action} eq 'save' );
|
||||
}
|
||||
$config->{access}->{write} = 0;
|
||||
show_settings( $config, $request );
|
||||
|
||||
sub show_settings {
|
||||
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->{read_user}==1){
|
||||
# uac::permissions_denied('read_user');
|
||||
# return;
|
||||
# }
|
||||
my $user = $params->{presets}->{user};
|
||||
my $colors = user_settings::getColors( $config, { user => $user } );
|
||||
# unless ($permissions->{read_user}==1){
|
||||
# uac::permissions_denied('read_user');
|
||||
# return;
|
||||
# }
|
||||
my $user = $params->{presets}->{user};
|
||||
my $colors = user_settings::getColors( $config, { user => $user } );
|
||||
|
||||
#map colors to params
|
||||
my @colors = ();
|
||||
my $c = 0;
|
||||
for my $color (@$colors) {
|
||||
push @colors,
|
||||
{
|
||||
title => $color->{name},
|
||||
class => $color->{css},
|
||||
name => 'color_' . $c,
|
||||
value => $color->{color}
|
||||
};
|
||||
$c++;
|
||||
}
|
||||
#map colors to params
|
||||
my @colors = ();
|
||||
my $c = 0;
|
||||
for my $color (@$colors) {
|
||||
push @colors,
|
||||
{
|
||||
title => $color->{name},
|
||||
class => $color->{css},
|
||||
name => 'color_' . $c,
|
||||
value => $color->{color}
|
||||
};
|
||||
$c++;
|
||||
}
|
||||
|
||||
$params->{colors} = \@colors;
|
||||
$params->{css} = user_settings::getColorCss( $config, { user => $user } );
|
||||
$params->{permissions} = $permissions;
|
||||
$params->{errors} = $errors;
|
||||
$params->{colors} = \@colors;
|
||||
$params->{css} = user_settings::getColorCss( $config, { user => $user } );
|
||||
$params->{permissions} = $permissions;
|
||||
$params->{errors} = $errors;
|
||||
|
||||
my $user_settings = user_settings::get( $config, { user => $user } );
|
||||
my $language = $user_settings->{language} || 'en';
|
||||
$params->{language} = $language;
|
||||
$params->{ 'language_' . $language } = 1;
|
||||
my $user_settings = user_settings::get( $config, { user => $user } );
|
||||
my $language = $user_settings->{language} || 'en';
|
||||
$params->{language} = $language;
|
||||
$params->{ 'language_' . $language } = 1;
|
||||
|
||||
my $period = $user_settings->{period} || 'month';
|
||||
$params->{ 'period_' . $period } = 1;
|
||||
my $period = $user_settings->{period} || 'month';
|
||||
$params->{ 'period_' . $period } = 1;
|
||||
|
||||
$params->{loc} = localization::get( $config, { language => $language, file => 'user_settings' } );
|
||||
$params->{loc} = localization::get( $config, { language => $language, file => 'user_settings' } );
|
||||
|
||||
#print STDERR Dumper($params->{loc});
|
||||
#print STDERR Dumper($params->{loc});
|
||||
|
||||
for my $color ( @{ $params->{colors} } ) {
|
||||
$color->{title} = $params->{loc}->{ $color->{title} };
|
||||
}
|
||||
uac::set_template_permissions( $permissions, $params );
|
||||
for my $color ( @{ $params->{colors} } ) {
|
||||
$color->{title} = $params->{loc}->{ $color->{title} };
|
||||
}
|
||||
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 );
|
||||
|
||||
#print '<pre>'.Dumper($user_settings);
|
||||
#print '<pre>'.Dumper($user_settings);
|
||||
}
|
||||
|
||||
sub update_settings {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
my $user = $params->{presets}->{user};
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
my $user = $params->{presets}->{user};
|
||||
|
||||
# map params to colors
|
||||
my @colors = ();
|
||||
my $c = 0;
|
||||
for my $color ( @{$user_settings::defaultColors} ) {
|
||||
if ( defined $params->{ 'color_' . $c } ) {
|
||||
push @colors, $color->{css} . '=' . $params->{ 'color_' . $c };
|
||||
} else {
|
||||
push @colors, $color->{css} . '=' . $color->{color};
|
||||
}
|
||||
$c++;
|
||||
}
|
||||
# map params to colors
|
||||
my @colors = ();
|
||||
my $c = 0;
|
||||
for my $color ( @{$user_settings::defaultColors} ) {
|
||||
if ( defined $params->{ 'color_' . $c } ) {
|
||||
push @colors, $color->{css} . '=' . $params->{ 'color_' . $c };
|
||||
} else {
|
||||
push @colors, $color->{css} . '=' . $color->{color};
|
||||
}
|
||||
$c++;
|
||||
}
|
||||
|
||||
my $settings = {
|
||||
user => $user,
|
||||
colors => join( "\n", @colors ),
|
||||
language => $params->{language},
|
||||
period => $params->{period}
|
||||
};
|
||||
my $settings = {
|
||||
user => $user,
|
||||
colors => join( "\n", @colors ),
|
||||
language => $params->{language},
|
||||
period => $params->{period}
|
||||
};
|
||||
|
||||
my $results = user_settings::get( $config, { user => $user } );
|
||||
if ( defined $results ) {
|
||||
uac::print_info("update");
|
||||
$config->{access}->{write} = 1;
|
||||
user_settings::update( $config, $settings );
|
||||
} else {
|
||||
$config->{access}->{write} = 1;
|
||||
uac::print_info("insert");
|
||||
user_settings::insert( $config, $settings );
|
||||
}
|
||||
$config->{access}->{write} = 0;
|
||||
my $results = user_settings::get( $config, { user => $user } );
|
||||
if ( defined $results ) {
|
||||
uac::print_info("update");
|
||||
$config->{access}->{write} = 1;
|
||||
user_settings::update( $config, $settings );
|
||||
} else {
|
||||
$config->{access}->{write} = 1;
|
||||
uac::print_info("insert");
|
||||
user_settings::insert( $config, $settings );
|
||||
}
|
||||
$config->{access}->{write} = 0;
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $checked = {};
|
||||
my $checked = {};
|
||||
|
||||
#template
|
||||
my $template = '';
|
||||
$template = template::check($config, $params->{template}, 'user_settings' );
|
||||
$checked->{template} = $template;
|
||||
#template
|
||||
my $template = '';
|
||||
$template = template::check( $config, $params->{template}, 'user_settings' );
|
||||
$checked->{template} = $template;
|
||||
|
||||
#numeric values
|
||||
for my $param ( 'project_id', 'default_studio_id', 'studio_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;
|
||||
}
|
||||
#numeric values
|
||||
for my $param ( 'project_id', 'default_studio_id', 'studio_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;
|
||||
}
|
||||
|
||||
for my $param ( keys %$params ) {
|
||||
if ( ( defined $params->{$param} ) && ( $param =~ /^(color\_\d+)$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
for my $param ( keys %$params ) {
|
||||
if ( ( defined $params->{$param} ) && ( $param =~ /^(color\_\d+)$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
$checked->{language} = 'en';
|
||||
if ( ( defined $params->{language} ) && ( $params->{language} =~ /^de$/ ) ) {
|
||||
$checked->{language} = 'de';
|
||||
}
|
||||
$checked->{language} = 'en';
|
||||
if ( ( defined $params->{language} ) && ( $params->{language} =~ /^de$/ ) ) {
|
||||
$checked->{language} = 'de';
|
||||
}
|
||||
|
||||
if ( defined $params->{period} ) {
|
||||
if ( $params->{period} =~ /(\S+)/ ) {
|
||||
$checked->{period} = $1;
|
||||
}
|
||||
}
|
||||
if ( defined $params->{period} ) {
|
||||
if ( $params->{period} =~ /(\S+)/ ) {
|
||||
$checked->{period} = $1;
|
||||
}
|
||||
}
|
||||
|
||||
#actions
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(save)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
return $checked;
|
||||
#actions
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(save)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
return $checked;
|
||||
}
|
||||
|
||||
sub error {
|
||||
push @$errors, { error => $_[0] };
|
||||
push @$errors, { error => $_[0] };
|
||||
}
|
||||
|
||||
|
||||
@@ -26,12 +26,12 @@ my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
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->{studio_id} = $params->{default_studio_id}
|
||||
@@ -40,11 +40,11 @@ $params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
$params = $request->{params}->{checked};
|
||||
@@ -52,7 +52,7 @@ $params = $request->{params}->{checked};
|
||||
#process header
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process($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 = [];
|
||||
@@ -60,51 +60,52 @@ our $errors = [];
|
||||
show_stats( $config, $request );
|
||||
|
||||
sub show_stats {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{read_user_stats} ) {
|
||||
uac::permissions_denied('read_user_stats');
|
||||
return;
|
||||
}
|
||||
print STDERR "continue\n";
|
||||
$params->{user_stats} = user_stats::get_stats( $config, $params );
|
||||
$params->{permissions} = $permissions;
|
||||
$params->{errors} = $errors;
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{read_user_stats} ) {
|
||||
uac::permissions_denied('read_user_stats');
|
||||
return;
|
||||
}
|
||||
print STDERR "continue\n";
|
||||
$params->{user_stats} = user_stats::get_stats( $config, $params );
|
||||
$params->{permissions} = $permissions;
|
||||
$params->{errors} = $errors;
|
||||
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'user_stats' } );
|
||||
uac::set_template_permissions( $permissions, $params );
|
||||
template::process($config, 'print', $params->{template}, $params );
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'user_stats' } );
|
||||
uac::set_template_permissions( $permissions, $params );
|
||||
template::process( $config, 'print', $params->{template}, $params );
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $checked = {};
|
||||
my $checked = {};
|
||||
|
||||
#template
|
||||
my $template = '';
|
||||
$template = template::check($config, $params->{template}, 'user_stats' );
|
||||
$checked->{template} = $template;
|
||||
#template
|
||||
my $template = '';
|
||||
$template = template::check( $config, $params->{template}, 'user_stats' );
|
||||
$checked->{template} = $template;
|
||||
|
||||
#numeric values
|
||||
for my $param ( 'project_id', 'default_studio_id', 'studio_id', 'series_id' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
if ( defined $checked->{studio_id} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
#numeric values
|
||||
for my $param ( 'project_id', 'default_studio_id', 'studio_id', 'series_id' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
if ( defined $checked->{studio_id} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
|
||||
return $checked;
|
||||
return $checked;
|
||||
}
|
||||
|
||||
sub error {
|
||||
push @$errors, { error => $_[0] };
|
||||
push @$errors, { error => $_[0] };
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params($config, $params),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
@@ -399,6 +399,7 @@ sub update_user_roles {
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $checked = {};
|
||||
|
||||
@@ -5,7 +5,8 @@ use strict;
|
||||
|
||||
use Data::Dumper;
|
||||
use URI::Escape();
|
||||
use Encode();
|
||||
|
||||
#use Encode();
|
||||
|
||||
use params();
|
||||
use config();
|
||||
@@ -32,12 +33,12 @@ return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
#print STDERR $params->{project_id}."\n";
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
user => $user
|
||||
}
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
user => $user
|
||||
}
|
||||
);
|
||||
$params->{default_studio_id} = $user_presets->{studio_id};
|
||||
$params->{studio_id} = $params->{default_studio_id}
|
||||
@@ -47,11 +48,11 @@ $params->{project_id} = $user_presets->{project_id}
|
||||
|
||||
#print STDERR $params->{project_id}."\n";
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
$params = $request->{params}->{checked};
|
||||
@@ -59,12 +60,12 @@ $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;
|
||||
|
||||
if ( defined $params->{action} ) {
|
||||
save_schedule( $config, $request ) if ( $params->{action} eq 'save_schedule' );
|
||||
delete_schedule( $config, $request ) if ( $params->{action} eq 'delete_schedule' );
|
||||
save_schedule( $config, $request ) if ( $params->{action} eq 'save_schedule' );
|
||||
delete_schedule( $config, $request ) if ( $params->{action} eq 'delete_schedule' );
|
||||
}
|
||||
|
||||
$config->{access}->{write} = 0;
|
||||
@@ -74,267 +75,268 @@ return;
|
||||
|
||||
#insert or update a schedule and update all schedule dates
|
||||
sub save_schedule {
|
||||
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};
|
||||
unless ( $permissions->{update_schedule} == 1 ) {
|
||||
uac::permissions_denied('update_schedule');
|
||||
return;
|
||||
}
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{update_schedule} == 1 ) {
|
||||
uac::permissions_denied('update_schedule');
|
||||
return;
|
||||
}
|
||||
|
||||
#print Dumper($params);
|
||||
for my $attr ( 'project_id', 'studio_id', 'start' ) {
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( $attr . ' not given!' );
|
||||
return;
|
||||
}
|
||||
}
|
||||
#print Dumper($params);
|
||||
for my $attr ( 'project_id', 'studio_id', 'start' ) {
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( $attr . ' not given!' );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
my $entry = {};
|
||||
for my $attr (
|
||||
'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} );
|
||||
}
|
||||
my $entry = {};
|
||||
for my $attr (
|
||||
'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} );
|
||||
}
|
||||
|
||||
my $found = 0;
|
||||
for my $type ( 'single', 'days', 'week_of_month' ) {
|
||||
$found = 1 if ( $entry->{period_type} eq $type );
|
||||
}
|
||||
if ( $found == 0 ) {
|
||||
uac::print_error('no period type selected!');
|
||||
return;
|
||||
}
|
||||
my $found = 0;
|
||||
for my $type ( 'single', 'days', 'week_of_month' ) {
|
||||
$found = 1 if ( $entry->{period_type} eq $type );
|
||||
}
|
||||
if ( $found == 0 ) {
|
||||
uac::print_error('no period type selected!');
|
||||
return;
|
||||
}
|
||||
|
||||
$entry->{exclude} = 0 if ( $entry->{exclude} ne '1' );
|
||||
$entry->{exclude} = 0 if ( $entry->{exclude} ne '1' );
|
||||
|
||||
if ( ( $entry->{end} ne '' ) && ( $entry->{end} le $entry->{start} ) ) {
|
||||
uac::print_error('start date should be before end date!');
|
||||
return;
|
||||
}
|
||||
if ( ( $entry->{end} ne '' ) && ( $entry->{end} le $entry->{start} ) ) {
|
||||
uac::print_error('start date should be before end date!');
|
||||
return;
|
||||
}
|
||||
|
||||
#TODO: check if schedule is in studio_timeslots
|
||||
#TODO: check if schedule is in studio_timeslots
|
||||
|
||||
$config->{access}->{write} = 1;
|
||||
if ( defined $params->{schedule_id} ) {
|
||||
$entry->{schedule_id} = $params->{schedule_id};
|
||||
work_schedule::update( $config, $entry );
|
||||
$config->{access}->{write} = 1;
|
||||
if ( defined $params->{schedule_id} ) {
|
||||
$entry->{schedule_id} = $params->{schedule_id};
|
||||
work_schedule::update( $config, $entry );
|
||||
|
||||
#timeslots are checked inside
|
||||
my $updates = work_dates::update( $config, $entry );
|
||||
uac::print_info("schedule saved. $updates dates scheduled");
|
||||
} else {
|
||||
my $schedule_id = work_schedule::insert( $config, $entry );
|
||||
$entry->{schedule_id} = $schedule_id;
|
||||
#timeslots are checked inside
|
||||
my $updates = work_dates::update( $config, $entry );
|
||||
uac::print_info("schedule saved. $updates dates scheduled");
|
||||
} else {
|
||||
my $schedule_id = work_schedule::insert( $config, $entry );
|
||||
$entry->{schedule_id} = $schedule_id;
|
||||
|
||||
#timeslots are checked inside
|
||||
my $updates = work_dates::update( $config, $entry );
|
||||
uac::print_info("schedule added. $updates dates added");
|
||||
}
|
||||
$config->{access}->{write} = 0;
|
||||
#timeslots are checked inside
|
||||
my $updates = work_dates::update( $config, $entry );
|
||||
uac::print_info("schedule added. $updates dates added");
|
||||
}
|
||||
$config->{access}->{write} = 0;
|
||||
}
|
||||
|
||||
sub delete_schedule {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{delete_schedule} == 1 ) {
|
||||
uac::permissions_denied('delete_schedule');
|
||||
return;
|
||||
}
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{delete_schedule} == 1 ) {
|
||||
uac::permissions_denied('delete_schedule');
|
||||
return;
|
||||
}
|
||||
|
||||
my $entry = {};
|
||||
for my $attr ( 'project_id', 'studio_id', 'schedule_id' ) {
|
||||
if ( defined $params->{$attr} ) {
|
||||
$entry->{$attr} = $params->{$attr};
|
||||
} else {
|
||||
uac::print_error( $attr . ' not given!' );
|
||||
return;
|
||||
}
|
||||
}
|
||||
my $entry = {};
|
||||
for my $attr ( 'project_id', 'studio_id', 'schedule_id' ) {
|
||||
if ( defined $params->{$attr} ) {
|
||||
$entry->{$attr} = $params->{$attr};
|
||||
} else {
|
||||
uac::print_error( $attr . ' not given!' );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$config->{access}->{write} = 1;
|
||||
$entry->{schedule_id} = $params->{schedule_id};
|
||||
work_schedule::delete( $config, $entry );
|
||||
work_dates::update( $config, $entry );
|
||||
uac::print_info("schedule deleted");
|
||||
$config->{access}->{write} = 1;
|
||||
$entry->{schedule_id} = $params->{schedule_id};
|
||||
work_schedule::delete( $config, $entry );
|
||||
work_dates::update( $config, $entry );
|
||||
uac::print_info("schedule deleted");
|
||||
}
|
||||
|
||||
sub show_work_schedule {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
$config->{access}->{write} = 0;
|
||||
$config->{access}->{write} = 0;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
for my $param ( 'project_id', 'studio_id' ) {
|
||||
unless ( defined $params->{$param} ) {
|
||||
uac::print_error("missing $param");
|
||||
return;
|
||||
}
|
||||
}
|
||||
for my $param ( 'project_id', 'studio_id' ) {
|
||||
unless ( defined $params->{$param} ) {
|
||||
uac::print_error("missing $param");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#this will be updated later (especially allow_update_events)
|
||||
for my $permission ( keys %{ $request->{permissions} } ) {
|
||||
$params->{'allow'}->{$permission} = $request->{permissions}->{$permission};
|
||||
}
|
||||
#this will be updated later (especially allow_update_events)
|
||||
for my $permission ( keys %{ $request->{permissions} } ) {
|
||||
$params->{'allow'}->{$permission} = $request->{permissions}->{$permission};
|
||||
}
|
||||
|
||||
my $project_id = $params->{project_id};
|
||||
my $studio_id = $params->{studio_id};
|
||||
my $project_id = $params->{project_id};
|
||||
my $studio_id = $params->{studio_id};
|
||||
|
||||
#add schedules
|
||||
my $schedules = work_schedule::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
}
|
||||
);
|
||||
#add schedules
|
||||
my $schedules = work_schedule::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
}
|
||||
);
|
||||
|
||||
#remove seconds from dates
|
||||
for my $schedule (@$schedules) {
|
||||
$schedule->{start} =~ s/(\d\d\:\d\d)\:\d\d/$1/ if defined $schedule->{start};
|
||||
$schedule->{end} =~ s/(\d\d\:\d\d)\:\d\d/$1/ if defined $schedule->{end};
|
||||
#remove seconds from dates
|
||||
for my $schedule (@$schedules) {
|
||||
$schedule->{start} =~ s/(\d\d\:\d\d)\:\d\d/$1/ if defined $schedule->{start};
|
||||
$schedule->{end} =~ s/(\d\d\:\d\d)\:\d\d/$1/ if defined $schedule->{end};
|
||||
|
||||
#detect schedule type
|
||||
if ( $schedule->{period_type} eq '' ) {
|
||||
$schedule->{period_type} = 'week_of_month';
|
||||
$schedule->{period_type} = 'days' unless ( $schedule->{week_of_month} =~ /\d/ );
|
||||
$schedule->{period_type} = 'single' unless ( $schedule->{end} =~ /\d/ );
|
||||
}
|
||||
$schedule->{ 'period_type_' . $schedule->{period_type} } = 1;
|
||||
if ( $params->{schedule_id} eq $schedule->{schedule_id} ) {
|
||||
$schedule->{selected} = 1;
|
||||
}
|
||||
#detect schedule type
|
||||
if ( $schedule->{period_type} eq '' ) {
|
||||
$schedule->{period_type} = 'week_of_month';
|
||||
$schedule->{period_type} = 'days' unless ( $schedule->{week_of_month} =~ /\d/ );
|
||||
$schedule->{period_type} = 'single' unless ( $schedule->{end} =~ /\d/ );
|
||||
}
|
||||
$schedule->{ 'period_type_' . $schedule->{period_type} } = 1;
|
||||
if ( $params->{schedule_id} eq $schedule->{schedule_id} ) {
|
||||
$schedule->{selected} = 1;
|
||||
}
|
||||
|
||||
#print STDERR $schedule->{period_type}."\n";
|
||||
}
|
||||
my $serie = {};
|
||||
$serie->{schedule} = $schedules;
|
||||
#print STDERR $schedule->{period_type}."\n";
|
||||
}
|
||||
my $serie = {};
|
||||
$serie->{schedule} = $schedules;
|
||||
|
||||
$serie->{start} = $params->{start};
|
||||
$serie->{end} = $params->{end};
|
||||
$serie->{frequency} = $params->{frequency};
|
||||
$serie->{duration} = $serie->{default_duration};
|
||||
my $duration = $params->{duration} || '';
|
||||
$serie->{duration} = $params->{duration} if $duration ne '';
|
||||
$serie->{start} = $params->{start};
|
||||
$serie->{end} = $params->{end};
|
||||
$serie->{frequency} = $params->{frequency};
|
||||
$serie->{duration} = $serie->{default_duration};
|
||||
my $duration = $params->{duration} || '';
|
||||
$serie->{duration} = $params->{duration} if $duration ne '';
|
||||
|
||||
$serie->{start} =~ s/(\d\d\:\d\d)\:\d\d/$1/ if defined $serie->{start};
|
||||
$serie->{end} =~ s/(\d\d\:\d\d)\:\d\d/$1/ if defined $serie->{end};
|
||||
$serie->{start} =~ s/(\d\d\:\d\d)\:\d\d/$1/ if defined $serie->{start};
|
||||
$serie->{end} =~ s/(\d\d\:\d\d)\:\d\d/$1/ if defined $serie->{end};
|
||||
|
||||
#add series dates
|
||||
my $work_dates = work_dates::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
}
|
||||
);
|
||||
#add series dates
|
||||
my $work_dates = work_dates::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
}
|
||||
);
|
||||
|
||||
#remove seconds from dates
|
||||
for my $date (@$work_dates) {
|
||||
$date->{start} =~ s/(\d\d\:\d\d)\:\d\d/$1/;
|
||||
$date->{end} =~ s/(\d\d\:\d\d)\:\d\d/$1/;
|
||||
}
|
||||
$serie->{work_dates} = $work_dates;
|
||||
#remove seconds from dates
|
||||
for my $date (@$work_dates) {
|
||||
$date->{start} =~ s/(\d\d\:\d\d)\:\d\d/$1/;
|
||||
$date->{end} =~ s/(\d\d\:\d\d)\:\d\d/$1/;
|
||||
}
|
||||
$serie->{work_dates} = $work_dates;
|
||||
|
||||
$serie->{show_hint_to_add_schedule} = $params->{show_hint_to_add_schedule};
|
||||
$serie->{show_hint_to_add_schedule} = $params->{show_hint_to_add_schedule};
|
||||
|
||||
#copy series to params
|
||||
#$params->{series}=[$serie];
|
||||
for my $key ( keys %$serie ) {
|
||||
$params->{$key} = $serie->{$key};
|
||||
}
|
||||
#copy series to params
|
||||
#$params->{series}=[$serie];
|
||||
for my $key ( keys %$serie ) {
|
||||
$params->{$key} = $serie->{$key};
|
||||
}
|
||||
|
||||
#print STDERR '<pre>'.Dumper($params).'</pre>';
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'work_time' } );
|
||||
template::process($config, 'print', $params->{template}, $params );
|
||||
#print STDERR '<pre>'.Dumper($params).'</pre>';
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'work_time' } );
|
||||
template::process( $config, 'print', $params->{template}, $params );
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
my $config = 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;
|
||||
|
||||
#actions and roles
|
||||
$checked->{action} = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(show|save_schedule|delete_schedule)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
#actions and roles
|
||||
$checked->{action} = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(show|save_schedule|delete_schedule)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
|
||||
#numeric values
|
||||
$checked->{exclude} = 0;
|
||||
for my $param (
|
||||
'project_id', 'studio_id', 'default_studio_id', 'schedule_id',
|
||||
'exclude', 'show_hint_to_add_schedule', 'weekday week_of_month', 'month'
|
||||
)
|
||||
{
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
if ( defined $checked->{studio_id} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
#numeric values
|
||||
$checked->{exclude} = 0;
|
||||
for my $param (
|
||||
'project_id', 'studio_id', 'default_studio_id', 'schedule_id',
|
||||
'exclude', 'show_hint_to_add_schedule', 'weekday week_of_month', 'month'
|
||||
)
|
||||
{
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
if ( defined $checked->{studio_id} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
|
||||
$checked->{template} = template::check($config, $params->{template}, 'edit_work_time' );
|
||||
$checked->{template} = template::check( $config, $params->{template}, 'edit_work_time' );
|
||||
|
||||
if ( ( defined $checked->{action} ) && ( $checked->{action} eq 'save_schedule' ) ) {
|
||||
if ( ( defined $checked->{action} ) && ( $checked->{action} eq 'save_schedule' ) ) {
|
||||
|
||||
#set defaults
|
||||
$checked->{create_events} = 0;
|
||||
$checked->{publish_events} = 0;
|
||||
}
|
||||
for my $param ( 'frequency', 'duration', 'default_duration' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /(\d+)/ ) ) {
|
||||
$checked->{$param} = $1;
|
||||
}
|
||||
}
|
||||
#set defaults
|
||||
$checked->{create_events} = 0;
|
||||
$checked->{publish_events} = 0;
|
||||
}
|
||||
for my $param ( 'frequency', 'duration', 'default_duration' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /(\d+)/ ) ) {
|
||||
$checked->{$param} = $1;
|
||||
}
|
||||
}
|
||||
|
||||
#scalars
|
||||
for my $param ( 'from', 'till', 'period_type', 'type', 'title' ) {
|
||||
if ( defined $params->{$param} ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
$checked->{$param} =~ s/^\s+//g;
|
||||
$checked->{$param} =~ s/\s+$//g;
|
||||
}
|
||||
}
|
||||
#scalars
|
||||
for my $param ( 'from', 'till', 'period_type', 'type', 'title' ) {
|
||||
if ( defined $params->{$param} ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
$checked->{$param} =~ s/^\s+//g;
|
||||
$checked->{$param} =~ s/\s+$//g;
|
||||
}
|
||||
}
|
||||
|
||||
for my $attr ('start') {
|
||||
if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /(\d\d\d\d\-\d\d\-\d\d[ T]\d\d\:\d\d)/ ) ) {
|
||||
$checked->{$attr} = $1 . ':00';
|
||||
}
|
||||
}
|
||||
for my $attr ('start') {
|
||||
if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /(\d\d\d\d\-\d\d\-\d\d[ T]\d\d\:\d\d)/ ) ) {
|
||||
$checked->{$attr} = $1 . ':00';
|
||||
}
|
||||
}
|
||||
|
||||
for my $attr ('end') {
|
||||
if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /(\d\d\d\d\-\d\d\-\d\d)/ ) ) {
|
||||
$checked->{$attr} = $1;
|
||||
}
|
||||
}
|
||||
for my $attr ('end') {
|
||||
if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /(\d\d\d\d\-\d\d\-\d\d)/ ) ) {
|
||||
$checked->{$attr} = $1;
|
||||
}
|
||||
}
|
||||
|
||||
return $checked;
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/perl -w
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
@@ -18,84 +18,85 @@ my $r = shift;
|
||||
|
||||
my $config = config::get('config/config.cgi');
|
||||
|
||||
$params = check_params($params);
|
||||
$params = check_params( $config, $params );
|
||||
|
||||
list_series( $config, $params );
|
||||
|
||||
sub list_series {
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
|
||||
$config->{access}->{write} = 0;
|
||||
$config->{access}->{write} = 0;
|
||||
|
||||
my $project_id = $params->{project_id};
|
||||
my $studio_id = $params->{studio_id};
|
||||
my $location = $params->{location};
|
||||
my $project_id = $params->{project_id};
|
||||
my $studio_id = $params->{studio_id};
|
||||
my $location = $params->{location};
|
||||
|
||||
if (defined $location){
|
||||
my $studios = studios::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
if ( defined $location ) {
|
||||
my $studios = studios::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
location => $location
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
$studio_id = $studios->[0]->{id};
|
||||
}
|
||||
|
||||
my $conditions = {};
|
||||
my $conditions = {};
|
||||
$conditions->{project_id} = $project_id if defined $project_id;
|
||||
$conditions->{studio_id} = $studio_id if defined $studio_id;
|
||||
$conditions->{studio_id} = $studio_id if defined $studio_id;
|
||||
|
||||
if (scalar (keys %$conditions) == 0){
|
||||
if ( scalar( keys %$conditions ) == 0 ) {
|
||||
$params->{info} .= "missing parameters";
|
||||
return;
|
||||
}
|
||||
$params->{info}.= Dumper($conditions);
|
||||
$params->{info} .= Dumper($conditions);
|
||||
|
||||
my $series = series::get_event_age( $config, $conditions );
|
||||
my $series2 = [];
|
||||
for my $serie ( sort { lc $a->{series_name} cmp lc $b->{series_name} } (@$series) ) {
|
||||
next if $serie->{days_over} > 80 ;
|
||||
next if $serie->{days_over} == 0 ;
|
||||
my $series = series::get_event_age( $config, $conditions );
|
||||
my $series2 = [];
|
||||
for my $serie ( sort { lc $a->{series_name} cmp lc $b->{series_name} } (@$series) ) {
|
||||
next if $serie->{days_over} > 80;
|
||||
next if $serie->{days_over} == 0;
|
||||
next unless defined $serie->{series_name};
|
||||
next if $serie->{series_name} eq '_single_';
|
||||
push @$series2, $serie;
|
||||
}
|
||||
$params->{series} = $series2;
|
||||
push @$series2, $serie;
|
||||
}
|
||||
$params->{series} = $series2;
|
||||
|
||||
$params->{info}.="no results found" if scalar(@$series)==0;
|
||||
$params->{info}='';
|
||||
$params->{info} .= "no results found" if scalar(@$series) == 0;
|
||||
$params->{info} = '';
|
||||
|
||||
template::process($config, 'print', 'templates/series.html', $params );
|
||||
template::process( $config, 'print', 'templates/series.html', $params );
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
my $config = 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;
|
||||
|
||||
for my $param ('project_id', 'studio_id') {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
for my $param ( 'project_id', 'studio_id' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
for my $param ( 'location') {
|
||||
if ( defined $params->{$param} ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
$checked->{$param} =~ s/^\s+//g;
|
||||
$checked->{$param} =~ s/\s+$//g;
|
||||
}
|
||||
}
|
||||
for my $param ('location') {
|
||||
if ( defined $params->{$param} ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
$checked->{$param} =~ s/^\s+//g;
|
||||
$checked->{$param} =~ s/\s+$//g;
|
||||
}
|
||||
}
|
||||
|
||||
return $checked;
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user