diff --git a/lib/calcms/config.pm b/lib/calcms/config.pm
index e51b65b..56bdcfb 100644
--- a/lib/calcms/config.pm
+++ b/lib/calcms/config.pm
@@ -3,6 +3,7 @@ package config;
use warnings;
use strict;
+use FindBin();
use Config::General();
use base 'Exporter';
@@ -19,7 +20,7 @@ sub set {
sub get {
my $filename = shift;
- return $config if defined $config;;
+ return $config if ( defined $config ) && ( $config->{cache}->{cache_config} == 1 );
my $configuration = Config::General->new(
-ConfigFile => $filename,
@@ -29,5 +30,11 @@ sub get {
return $config;
}
+sub getFromScriptLocation() {
+ FindBin::again();
+ my $configFile = $FindBin::Bin . '/config/config.cgi';
+ return config::get($configFile);
+}
+
#do not delete last line
1;
diff --git a/website/agenda/add_comment.cgi b/website/agenda/add_comment.cgi
index 66ca5f3..04dff2e 100755
--- a/website/agenda/add_comment.cgi
+++ b/website/agenda/add_comment.cgi
@@ -23,7 +23,7 @@ binmode STDOUT, ":utf8";
my $r=shift;
(my $cgi, my $params, my $error)=params::get($r);
-my $config = config::get('./config/config.cgi');
+my $config = config::getFromScriptLocation();
my $debug = $config->{system}->{debug};
my $request={
diff --git a/website/agenda/aggregate.cgi b/website/agenda/aggregate.cgi
index 993c1cf..35f5b20 100755
--- a/website/agenda/aggregate.cgi
+++ b/website/agenda/aggregate.cgi
@@ -21,7 +21,8 @@ if ( $0 =~ /aggregate.*?\.cgi$/ ) {
my %params = $cgi->Vars();
my $params = \%params;
- my $config = config::get('config/config.cgi');
+ my $config = config::getFromScriptLocation();
+
my $debug = $config->{system}->{debug};
my $mem_debug = $config->{system}->{debug_memory};
my $base_dir = $config->{locations}->{base_dir};
@@ -32,9 +33,9 @@ if ( $0 =~ /aggregate.*?\.cgi$/ ) {
$output_header .= "Content-type:text/html; charset=UTF-8;\n\n";
}
- $params->{exclude_locations} = 1;
- $params->{exclude_projects} = 1;
- $params->{exclude_event_images} = 1;
+ $params->{exclude_locations} = 1;
+ $params->{exclude_projects} = 1;
+ $params->{exclude_event_images} = 1;
# $output_header.=''."\n";
my $request = {
@@ -71,9 +72,9 @@ if ( $0 =~ /aggregate.*?\.cgi$/ ) {
my $menu = { content => '' };
$list->{day} = '' unless defined $list->{day};
- $list->{day} = $params->{date} if (defined $params->{date}) && ($params->{date} ne '');
- $list->{day} = $params->{from_date} if (defined $params->{from_date}) && ($params->{from_date} ne '');
- $list->{day} = 'today' if $list->{day} eq '';
+ $list->{day} = $params->{date} if ( defined $params->{date} ) && ( $params->{date} ne '' );
+ $list->{day} = $params->{from_date} if ( defined $params->{from_date} ) && ( $params->{from_date} ne '' );
+ $list->{day} = 'today' if $list->{day} eq '';
$menu = aggregator::get_menu( $config, $request, $list->{day}, $list->{results} );
@@ -121,15 +122,15 @@ if ( $0 =~ /aggregate.*?\.cgi$/ ) {
$content =~ s/(<(div|span)\s+id="calcms_title".*?>).*?(<\/(div|span)>)/$list->{project_title}/g;
my $values = [];
- for my $value ($list->{'program'}, $list->{'series_name'}, $list->{'title'}, $list->{'location'}, $list->{'project_title'}){
- next unless defined $value;
- next if $value eq '';
- push @$values, $value;
+ for my $value ( $list->{'program'}, $list->{'series_name'}, $list->{'title'}, $list->{'location'}, $list->{'project_title'} ) {
+ next unless defined $value;
+ next if $value eq '';
+ push @$values, $value;
}
- my $title = join (' - ', @$values);
+ my $title = join( ' - ', @$values );
- $content=~s/(
)(.*?)(<\/title>)/$1$title$3/;
+ $content =~ s/()(.*?)(<\/title>)/$1$title$3/;
$js = '';
if ( ( defined $list->{event_id} ) && ( $list->{event_id} ne '' ) ) {
diff --git a/website/agenda/cal.cgi b/website/agenda/cal.cgi
index e5961cd..558ba67 100755
--- a/website/agenda/cal.cgi
+++ b/website/agenda/cal.cgi
@@ -22,7 +22,7 @@ binmode STDOUT, ":encoding(UTF-8)";
if ( $0 =~ /cal.*?\.cgi$/ ) {
( my $cgi, my $params, my $error ) = params::get($r);
- my $config = config::get('config/config.cgi');
+ my $config = config::getFromScriptLocation();
my $debug = $config->{system}->{debug};
my $request = {
diff --git a/website/agenda/category.cgi b/website/agenda/category.cgi
index 18b64b5..7e6ba91 100755
--- a/website/agenda/category.cgi
+++ b/website/agenda/category.cgi
@@ -21,27 +21,26 @@ binmode STDOUT, ":utf8";
my $r = shift;
( my $cgi, my $params, my $error ) = params::get($r);
-my $config = config::get('config/config.cgi');
-
+my $config = config::getFromScriptLocation();
my $debug = $config->{system}->{debug};
my $request = {
- url => $ENV{QUERY_STRING},
- params => {
- original => $params,
- checked => check_params( $config, $params ),
- },
+ url => $ENV{QUERY_STRING},
+ params => {
+ original => $params,
+ checked => check_params( $config, $params ),
+ },
};
$params = $request->{params}->{checked};
my $cache = {};
if ( $config->{cache}->{use_cache} eq '1' ) {
- cache::configure('categories.html');
- $cache = cache::load( $config, $params );
- if ( defined $cache->{content} ) {
- print $cache->{content};
- return;
- }
+ cache::configure('categories.html');
+ $cache = cache::load( $config, $params );
+ if ( defined $cache->{content} ) {
+ print $cache->{content};
+ return;
+ }
}
my $dbh = db::connect($config);
@@ -56,87 +55,87 @@ $template_parameters->{use_client_cache} = $config->{cache}->{use_client_cache}
my $template = $params->{template};
my $out = '';
-template::process($config, $out, $params->{template}, $template_parameters );
+template::process( $config, $out, $params->{template}, $template_parameters );
print $out;
#write to cache
if ( $config->{cache}->{use_cache} eq '1' ) {
- $cache->{content} = $out;
- cache::save($cache);
+ $cache->{content} = $out;
+ cache::save($cache);
}
sub getProjects {
- my $dbh = shift;
- my $config = shift;
+ my $dbh = shift;
+ my $config = shift;
- my $excludedProjects = {};
- if ( defined $config->{filter}->{projects_to_exclude} ) {
- for my $project ( split( /\,/, $config->{filter}->{projects_to_exclude} ) ) {
- $project =~ s/^\s+//g;
- $project =~ s/\s+$//g;
- $excludedProjects->{$project} = 1;
- }
- }
+ my $excludedProjects = {};
+ if ( defined $config->{filter}->{projects_to_exclude} ) {
+ for my $project ( split( /\,/, $config->{filter}->{projects_to_exclude} ) ) {
+ $project =~ s/^\s+//g;
+ $project =~ s/\s+$//g;
+ $excludedProjects->{$project} = 1;
+ }
+ }
- my $projects = project::get_sorted($config);
- my $results = [];
- for my $project (@$projects) {
- next if defined $excludedProjects->{ $project->{name} };
- my $categories = getCategories( $dbh, $config, $project->{name} );
- $project->{isEmpty} = 1 if scalar(@$categories) == 0;
- $project->{categories} = $categories;
+ my $projects = project::get_sorted($config);
+ my $results = [];
+ for my $project (@$projects) {
+ next if defined $excludedProjects->{ $project->{name} };
+ my $categories = getCategories( $dbh, $config, $project->{name} );
+ $project->{isEmpty} = 1 if scalar(@$categories) == 0;
+ $project->{categories} = $categories;
- $project->{js_name} = $project->{name};
- $project->{js_name} =~ s/[^a-zA-Z\_0-9]/\_/g;
- $project->{js_name} =~ s/\_+/\_/g;
- push @$results, $project;
- }
- return $results;
+ $project->{js_name} = $project->{name};
+ $project->{js_name} =~ s/[^a-zA-Z\_0-9]/\_/g;
+ $project->{js_name} =~ s/\_+/\_/g;
+ push @$results, $project;
+ }
+ return $results;
}
sub getCategories {
- my $dbh = shift;
- my $config = shift;
- my $project = shift;
+ my $dbh = shift;
+ my $config = shift;
+ my $project = shift;
- my $cond = '';
- my $bind_values = [];
- if ( ( $project ne '' ) && ( $project ne 'all' ) ) {
- $cond = 'where project=?';
- $bind_values = [$project];
- }
+ my $cond = '';
+ my $bind_values = [];
+ if ( ( $project ne '' ) && ( $project ne 'all' ) ) {
+ $cond = 'where project=?';
+ $bind_values = [$project];
+ }
- my $query = qq{
+ my $query = qq{
select name, count(name) sum
from calcms_categories
$cond
group by name
order by sum desc, name
};
- my $categories = db::get( $dbh, $query, $bind_values );
+ my $categories = db::get( $dbh, $query, $bind_values );
- my $results = [];
- for my $category (@$categories) {
- push @$results, $category if $category->{sum} > 1;
- }
+ my $results = [];
+ for my $category (@$categories) {
+ push @$results, $category if $category->{sum} > 1;
+ }
- return $results;
+ return $results;
}
sub check_params {
- my $config = $_[0];
- my $params = $_[1];
+ my $config = $_[0];
+ my $params = $_[1];
- my $template = template::check($config, $params->{template}, 'categories.html' );
+ my $template = template::check( $config, $params->{template}, 'categories.html' );
- my $debug = $params->{debug} || '';
- if ( $debug =~ /([a-z\_\,]+)/ ) {
- $debug = $1;
- }
+ my $debug = $params->{debug} || '';
+ if ( $debug =~ /([a-z\_\,]+)/ ) {
+ $debug = $1;
+ }
- return {
- template => $template,
- debug => $debug
- };
+ return {
+ template => $template,
+ debug => $debug
+ };
}
diff --git a/website/agenda/events.cgi b/website/agenda/events.cgi
index ce48a22..c082433 100755
--- a/website/agenda/events.cgi
+++ b/website/agenda/events.cgi
@@ -6,7 +6,6 @@ no warnings 'redefine';
use Data::Dumper;
-#use utf8;
use DBI;
use CGI qw(header param Vars);
$CGI::POST_MAX = 1000;
@@ -18,35 +17,32 @@ use log();
use events();
use time();
-#binmode STDOUT, ":utf8";
binmode STDOUT, ":encoding(UTF-8)";
my $r = shift;
( my $cgi, my $params, my $error ) = params::get($r);
if ( $0 =~ /events.*?\.cgi$/ ) {
- #my $cgi=new CGI();
- #my %params=$cgi->Vars();
- our $config = config::get('config/config.cgi');
+ my $config = config::getFromScriptLocation();
$params->{template} = '' unless defined $params->{template};
- $params->{recordings} = 1 if $params->{template} =~ /events_playout/;
+ $params->{recordings} = 1 if $params->{template} =~ /events_playout/;
- $params->{exclude_locations} = 1;
- $params->{exclude_projects} = 1;
+ $params->{exclude_locations} = 1;
+ $params->{exclude_projects} = 1;
$params->{exclude_event_images} = 1;
-
- my $request = {
- url => $ENV{QUERY_STRING},
- params => {
- original => $params,
- checked => events::check_params( $config, $params ),
- },
- };
- my $output = '';
- events::get_cached_or_render( $output, $config, $request );
- print $output. "\n";
+ my $request = {
+ url => $ENV{QUERY_STRING},
+ params => {
+ original => $params,
+ checked => events::check_params( $config, $params ),
+ },
+ };
+
+ my $output = '';
+ events::get_cached_or_render( $output, $config, $request );
+ print $output. "\n";
}
1;
diff --git a/website/agenda/planung/calendar.cgi b/website/agenda/planung/calendar.cgi
index 541cbad..641aece 100755
--- a/website/agenda/planung/calendar.cgi
+++ b/website/agenda/planung/calendar.cgi
@@ -1417,6 +1417,7 @@ sub print_event {
my $attr = '';
if ( $class =~ /play/ ) {
+ #$event->{rms_image}=~s/\.png/.svg/;
$attr .= ' rms="' . $event->{rms_image} . '"' if defined $event->{rms_image};
$attr .= ' start="' . $event->{start} . '"' if defined $event->{start};
}
diff --git a/website/agenda/planung/create_events.cgi b/website/agenda/planung/create_events.cgi
index 91c7394..85d11bc 100755
--- a/website/agenda/planung/create_events.cgi
+++ b/website/agenda/planung/create_events.cgi
@@ -39,9 +39,9 @@ my $user_presets = uac::get_user_presets(
);
$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' );
#print STDERR $params->{project_id}."\n";
my $request = {
@@ -87,9 +87,14 @@ sub show_events {
my $params = $request->{params}->{checked};
my $permissions = $request->{permissions};
unless ( $permissions->{assign_series_events} == 1 ) {
- uac::permissions_denied('assign_series_events');
+ uac::permissions_denied('read_events');
return;
}
+
+ my $events = getDates( $config, $request );
+ $params->{events} = $events;
+ $params->{total} = scalar(@$events);
+ $params->{action} = 'show';
template::process( $config, 'print', $params->{template}, $params );
}
@@ -106,6 +111,31 @@ sub create_events {
}
print STDERR "create events\n";
+ my $dates = getDates( $config, $request );
+
+ print STDERR "found " . ( scalar @$dates ) . " dates\n";
+ my $events = [];
+ for my $date (@$dates) {
+
+ #print STDERR $date->{start}."\n";
+ push @$events, createEvent( $config, $request, $date );
+ }
+ $params->{events} = $events;
+ $params->{total} = scalar(@$events);
+ $params->{action} = 'created';
+ template::process( $config, 'print', $params->{template}, $params );
+}
+
+sub getDates {
+ 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 $project_id = $params->{project_id};
my $studio_id = $params->{studio_id};
@@ -126,8 +156,7 @@ sub create_events {
}
$params->{from_date} = $from_date;
$params->{till_date} = $till_date;
-
- print STDERR "create events from $from_date to $till_date\n";
+ print STDERR "$0: get events from $from_date to $till_date\n";
my $dates = series_dates::getDatesWithoutEvent(
$config,
@@ -138,16 +167,8 @@ sub create_events {
till => $till_date
}
);
- print STDERR "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 );
+ return $dates;
}
sub createEvent {
@@ -191,7 +212,7 @@ sub check_params {
#actions and roles
$checked->{action} = '';
if ( defined $params->{action} ) {
- if ( $params->{action} =~ /^(create_events)$/ ) {
+ if ( $params->{action} =~ /^(create_events|show_events)$/ ) {
$checked->{action} = $params->{action};
}
}
diff --git a/website/agenda/planung/templates/create_events.html b/website/agenda/planung/templates/create_events.html
index 1602aab..fd4c1a9 100644
--- a/website/agenda/planung/templates/create_events.html
+++ b/website/agenda/planung/templates/create_events.html
@@ -1,33 +1,17 @@
-
-
-
-
create events from schedule
-
-
-created
events from till
- events created
-
-
+
+
+ events from till
+
-
+
-