add playout section
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
-- MySQL dump 10.13 Distrib 5.5.55, for debian-linux-gnu (x86_64)
|
||||
-- MySQL dump 10.13 Distrib 5.7.20, for Linux (x86_64)
|
||||
--
|
||||
-- Host: localhost Database: calcms
|
||||
-- ------------------------------------------------------
|
||||
-- Server version 5.5.55-0ubuntu0.14.04.1
|
||||
-- Server version 5.7.20-0ubuntu0.16.04.1
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
@@ -29,9 +29,15 @@ CREATE TABLE `calcms_audio_recordings` (
|
||||
`event_id` int(11) NOT NULL,
|
||||
`created_by` varchar(100) NOT NULL,
|
||||
`path` varchar(300) NOT NULL,
|
||||
`md5` varchar(100) NOT NULL,
|
||||
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`size` bigint(20) unsigned NOT NULL DEFAULT '0',
|
||||
`audioDuration` float DEFAULT '0',
|
||||
`eventDuration` int(11) DEFAULT '0',
|
||||
`rmsLeft` float DEFAULT NULL,
|
||||
`rmsRight` float DEFAULT NULL,
|
||||
`mastered` tinyint(1) DEFAULT '0',
|
||||
`processed` tinyint(1) DEFAULT '0',
|
||||
`modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `project_index` (`project_id`),
|
||||
KEY `studio_index` (`studio_id`),
|
||||
@@ -384,14 +390,17 @@ CREATE TABLE `calcms_playout` (
|
||||
`rms_left` float DEFAULT NULL,
|
||||
`rms_right` float DEFAULT NULL,
|
||||
`rms_image` varchar(300) DEFAULT NULL,
|
||||
`relpay_gain` float DEFAULT NULL,
|
||||
`replay_gain` float DEFAULT NULL,
|
||||
`updated_at` datetime DEFAULT CURRENT_TIMESTAMP,
|
||||
`modified_at` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`project_id`,`studio_id`,`start`),
|
||||
KEY `project_id` (`project_id`),
|
||||
KEY `studio_id` (`studio_id`),
|
||||
KEY `start` (`start`),
|
||||
KEY `end` (`end`),
|
||||
KEY `start_date` (`start_date`),
|
||||
KEY `end_date` (`end_date`)
|
||||
KEY `end_date` (`end_date`),
|
||||
KEY `modified_at` (`modified_at`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
@@ -576,6 +585,7 @@ CREATE TABLE `calcms_roles` (
|
||||
`update_comment_status_read` tinyint(1) unsigned NOT NULL,
|
||||
`upload_audio_recordings` tinyint(1) unsigned NOT NULL,
|
||||
`delete_audio_recordings` tinyint(1) unsigned NOT NULL,
|
||||
`read_playout` tinyint(1) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `role_2` (`role`),
|
||||
KEY `studio_id` (`studio_id`),
|
||||
@@ -590,8 +600,7 @@ CREATE TABLE `calcms_roles` (
|
||||
|
||||
LOCK TABLES `calcms_roles` WRITE;
|
||||
/*!40000 ALTER TABLE `calcms_roles` DISABLE KEYS */;
|
||||
INSERT INTO `calcms_roles` VALUES (7,'Admin',1,1,1,1,1,1,1,1,1,1,1,1,1,1,7,1,1,1,'0000-00-00 00:00:00','2016-05-16 13:53:46',1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
|
||||
/*!40000 ALTER TABLE `calcms_roles` ENABLE KEYS */;
|
||||
INSERT INTO `calcms_roles` VALUES (7,'Admin',1,1,1,1,1,1,1,1,1,1,1,1,1,1,7,1,1,1,'0000-00-00 00:00:00','2017-07-30 14:32:32',1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);/*!40000 ALTER TABLE `calcms_roles` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
@@ -696,7 +705,8 @@ CREATE TABLE `calcms_series_events` (
|
||||
KEY `event_id` (`event_id`),
|
||||
KEY `studio_id` (`studio_id`),
|
||||
KEY `project_id` (`project_id`),
|
||||
KEY `manual` (`manual`)
|
||||
KEY `manual` (`manual`),
|
||||
KEY `pse` (`project_id`,`studio_id`,`event_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
@@ -730,8 +740,8 @@ CREATE TABLE `calcms_series_schedule` (
|
||||
`period_type` varchar(16) DEFAULT NULL,
|
||||
`month` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`project_id` int(10) unsigned NOT NULL DEFAULT '1',
|
||||
`start_offset` int(11) NOT NULL DEFAULT '0',
|
||||
`nextDay` int(11) NOT NULL DEFAULT '0',
|
||||
`start_offset` int(11) DEFAULT '0',
|
||||
`nextDay` int(11) DEFAULT '0',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `series_id` (`series_id`),
|
||||
KEY `studio_id` (`studio_id`),
|
||||
@@ -1165,4 +1175,4 @@ UNLOCK TABLES;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2017-04-29 13:34:58
|
||||
-- Dump completed on 2018-01-14 17:23:51
|
||||
|
||||
@@ -16,8 +16,9 @@ our %EXPORT_TAGS = ( 'all' => [ @EXPORT_OK ] );
|
||||
|
||||
# columns:
|
||||
# id, project_id, studio_id, event_id
|
||||
# created_by, created_at
|
||||
# path, md5
|
||||
# path, size, created_by, created_at
|
||||
# mastered, processed
|
||||
# audioDuration, eventDuration, rmsLeft, rmsRight
|
||||
|
||||
sub debug;
|
||||
|
||||
@@ -88,16 +89,22 @@ sub get{
|
||||
,studio_id
|
||||
,event_id
|
||||
,path
|
||||
,md5
|
||||
,size
|
||||
,created_by
|
||||
,created_at
|
||||
,modified_at
|
||||
,mastered
|
||||
,processed
|
||||
,audioDuration
|
||||
,eventDuration
|
||||
,rmsLeft
|
||||
,rmsRight
|
||||
from calcms_audio_recordings
|
||||
$whereClause
|
||||
order by created_at desc
|
||||
};
|
||||
|
||||
print STDERR Dumper($query).Dumper($bind_values);
|
||||
#print STDERR Dumper($query).Dumper($bind_values);
|
||||
my $entries=db::get($dbh, $query, $bind_values);
|
||||
return $entries;
|
||||
}
|
||||
@@ -109,21 +116,31 @@ sub update{
|
||||
my $dbh = shift;
|
||||
my $entry = shift;
|
||||
|
||||
print STDERR "update:".Dumper($entry);
|
||||
#print STDERR "update:".Dumper($entry);
|
||||
|
||||
my $day_start=$config->{date}->{day_starting_hour};
|
||||
|
||||
my $bind_values=[
|
||||
$entry->{path}, $entry->{md5}, $entry->{size}, $entry->{created_by}, $entry->{created_at},
|
||||
$entry->{path}, $entry->{size},
|
||||
$entry->{created_by}, $entry->{created_at},
|
||||
$entry->{modified_at} || time::time_to_datetime(time()),
|
||||
$entry->{processed}, $entry->{mastered},
|
||||
$entry->{eventDuration}, $entry->{audioDuration},
|
||||
$entry->{rmsLeft}, $entry->{rmsRight},
|
||||
$entry->{project_id}, $entry->{studio_id}, $entry->{event_id}
|
||||
];
|
||||
|
||||
my $query=qq{
|
||||
update calcms_audio_recordings
|
||||
set path=?, md5=?, size=?, created_by=?, created_at=?
|
||||
set path=?, size=?,
|
||||
created_by=?, created_at=?,
|
||||
modified_at=?,
|
||||
processed=?, mastered=?,
|
||||
eventDuration=?, audioDuration=?,
|
||||
rmsLeft=?, rmsRight=?
|
||||
where project_id=? and studio_id=? and event_id=?
|
||||
};
|
||||
print STDERR Dumper($query).Dumper($bind_values);
|
||||
#print STDERR Dumper($query).Dumper($bind_values);
|
||||
return db::put($dbh, $query, $bind_values);
|
||||
}
|
||||
|
||||
@@ -138,15 +155,20 @@ sub insert{
|
||||
return undef unless defined $entry->{event_id};
|
||||
return undef unless defined $entry->{path};
|
||||
|
||||
print STDERR "insert into audio_recordings:".Dumper($entry);
|
||||
#print STDERR "insert into audio_recordings:".Dumper($entry);
|
||||
return db::insert($dbh, 'calcms_audio_recordings', {
|
||||
project_id => $entry->{project_id},
|
||||
studio_id => $entry->{studio_id},
|
||||
event_id => $entry->{event_id},
|
||||
path => $entry->{path},
|
||||
size => $entry->{size},
|
||||
md5 => $entry->{md5},
|
||||
created_by => $entry->{created_by},
|
||||
project_id => $entry->{project_id},
|
||||
studio_id => $entry->{studio_id},
|
||||
event_id => $entry->{event_id},
|
||||
path => $entry->{path},
|
||||
size => $entry->{size},
|
||||
created_by => $entry->{created_by},
|
||||
eventDuration => $entry->{eventDuration},
|
||||
audioDuration => $entry->{audioDuration},
|
||||
rmsLeft => $entry->{rmsLeft},
|
||||
rmsRight => $entry->{rmsRight},
|
||||
processed => $entry->{processed},
|
||||
mastered => $entry->{mastered} || '0',
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,22 @@ use studios;
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK =
|
||||
qw(init get_cached_or_render get modify_results get_query render get_running_event_id delete check_params configure_cache get_duration calc_dates get_keys add_recordings);
|
||||
our @EXPORT_OK = qw(
|
||||
init
|
||||
get_cached_or_render
|
||||
get
|
||||
modify_results
|
||||
get_query
|
||||
render
|
||||
get_running_event_id
|
||||
delete
|
||||
check_params
|
||||
configure_cache
|
||||
get_duration
|
||||
calc_dates
|
||||
get_keys
|
||||
add_recordings
|
||||
);
|
||||
our %EXPORT_TAGS = ( 'all' => [@EXPORT_OK] );
|
||||
|
||||
sub init {
|
||||
@@ -1050,7 +1064,7 @@ sub get_query {
|
||||
$query .= ', ar.path';
|
||||
$query .= ', ar.size';
|
||||
$query .= ', ar.created_by uploaded_by';
|
||||
$query .= ', ar.created_at uploaded_at';
|
||||
$query .= ', ar.modified_at uploaded_at';
|
||||
#push @$where_cond, 'e.id=ar.event_id';
|
||||
}
|
||||
|
||||
@@ -1456,10 +1470,13 @@ sub get_duration {
|
||||
my $event = shift;
|
||||
my $timezone = $config->{date}->{time_zone};
|
||||
my $start = time::get_datetime( $event->{start}, $timezone );
|
||||
my $end = time::get_datetime( $event->{end}, $timezone );
|
||||
my $end = time::get_datetime( $event->{end}, $timezone );
|
||||
#my $seconds = $end->subtract($start)->in_units("minutes");
|
||||
#return $seconds;
|
||||
return undef unless defined $start;
|
||||
return undef unless defined $end;
|
||||
my $duration = $end->epoch() - $start->epoch();
|
||||
#print STDERR "duration=$duration, end=".$end->datetime()." start=".$start->datetime()."\n";
|
||||
return $duration / 60;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,6 +85,9 @@ sub get{
|
||||
|
||||
my $conditions='';
|
||||
$conditions=" where ".join(" and ",@conditions) if (@conditions>0);
|
||||
|
||||
my $order='start';
|
||||
$order=$condition->{order} if (defined $condition->{order} ) && ($condition->{order} ne'');
|
||||
|
||||
my $query=qq{
|
||||
select date(start) start_date
|
||||
@@ -111,9 +114,12 @@ sub get{
|
||||
,rms_left
|
||||
,rms_right
|
||||
,rms_image
|
||||
,modified_at
|
||||
,updated_at
|
||||
from calcms_playout
|
||||
$conditions
|
||||
order by start
|
||||
order by $order
|
||||
$limit
|
||||
};
|
||||
|
||||
#print STDERR Dumper($query).Dumper(\@bind_values);
|
||||
@@ -128,7 +134,7 @@ sub sync{
|
||||
my $options=shift;
|
||||
|
||||
#print STDERR Dumper($config);
|
||||
#print STDERR Dumper($options);
|
||||
print STDERR "upload ".Dumper($options);
|
||||
return undef unless defined $options->{project_id} ;
|
||||
return undef unless defined $options->{studio_id} ;
|
||||
return undef unless defined $options->{from} ;
|
||||
@@ -227,7 +233,7 @@ sub has_changed{
|
||||
my $newEntry=shift;
|
||||
|
||||
my $update=0;
|
||||
for my $key ('duration', 'errors', 'file', 'channels', 'format', 'format_version', 'format_profile', 'format_settings', 'stream_size', 'bitrate', 'bitrate_mode', 'sampling_rate', 'writing_library'){
|
||||
for my $key ('duration', 'errors', 'file', 'channels', 'format', 'format_version', 'format_profile', 'format_settings', 'stream_size', 'bitrate', 'bitrate_mode', 'sampling_rate', 'writing_library', 'modified_at'){
|
||||
return 1 if ($oldEntry->{$key}||'') ne ($newEntry->{$key}||'');
|
||||
}
|
||||
return 0;
|
||||
@@ -242,7 +248,7 @@ sub update{
|
||||
|
||||
return if has_changed($oldEntry, $newEntry)==0;
|
||||
|
||||
for my $key ('duration', 'errors', 'file', 'channels', 'format', 'format_version', 'format_profile', 'format_settings', 'stream_size', 'bitrate', 'bitrate_mode', 'sampling_rate', 'writing_library', 'rms_left', 'rms_right', 'rms_image', 'replay_gain'){
|
||||
for my $key ('duration', 'errors', 'file', 'channels', 'format', 'format_version', 'format_profile', 'format_settings', 'stream_size', 'bitrate', 'bitrate_mode', 'sampling_rate', 'writing_library', 'rms_left', 'rms_right', 'rms_image', 'replay_gain', 'modified_at'){
|
||||
if (($oldEntry->{$key}||'') ne ($newEntry->{$key}||'')){
|
||||
$oldEntry->{$key}=$newEntry->{$key};
|
||||
}
|
||||
@@ -257,13 +263,13 @@ sub update{
|
||||
$entry->{end_date} = time::add_hours_to_datetime($entry->{end}, -$day_start);
|
||||
|
||||
my $bind_values=[
|
||||
$entry->{end}, $entry->{duration}, $entry->{file}, $entry->{errors},
|
||||
$entry->{start_date}, $entry->{end_date},
|
||||
$entry->{channels}, $entry->{'format'}, $entry->{format_version}, $entry->{format_profile}, $entry->{format_settings}, $entry->{stream_size},
|
||||
$entry->{bitrate}, $entry->{bitrate_mode}, $entry->{sampling_rate}, $entry->{writing_library},
|
||||
$entry->{rms_left}, $entry->{rms_right}, $entry->{rms_image},
|
||||
$entry->{replay_gain},
|
||||
$entry->{project_id}, $entry->{studio_id}, $entry->{start}
|
||||
$entry->{end}, $entry->{duration}, $entry->{file}, $entry->{errors},
|
||||
$entry->{start_date}, $entry->{end_date},
|
||||
$entry->{channels}, $entry->{'format'}, $entry->{format_version}, $entry->{format_profile}, $entry->{format_settings}, $entry->{stream_size},
|
||||
$entry->{bitrate}, $entry->{bitrate_mode}, $entry->{sampling_rate}, $entry->{writing_library},
|
||||
$entry->{rms_left}, $entry->{rms_right}, $entry->{rms_image},
|
||||
$entry->{replay_gain}, $entry->{modified_at},
|
||||
$entry->{project_id}, $entry->{studio_id}, $entry->{start}
|
||||
];
|
||||
my $query=qq{
|
||||
update calcms_playout
|
||||
@@ -272,7 +278,7 @@ sub update{
|
||||
channels=?, format=?, format_version=?, format_profile=?, format_settings=?, stream_size=?,
|
||||
bitrate=?, bitrate_mode=?, sampling_rate=?, writing_library=?,
|
||||
rms_left=?, rms_right=?, rms_image=?,
|
||||
replay_gain=?
|
||||
replay_gain=?, modified_at=?
|
||||
where project_id=? and studio_id=? and start=?
|
||||
};
|
||||
return db::put($dbh, $query, $bind_values);
|
||||
@@ -318,7 +324,8 @@ sub insert{
|
||||
bitrate => $entry->{bitrate},
|
||||
bitrate_mode => $entry->{bitrate_mode},
|
||||
sampling_rate => $entry->{sampling_rate},
|
||||
writing_library => $entry->{writing_library}
|
||||
writing_library => $entry->{writing_library},
|
||||
modified_at => $entry->{modified_at}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ $comment->{content}=~s/(^|\s)((www\.)(.*?))(\s|$|\<)/$1\<a href\=\"http\:\/\/$2\
|
||||
|
||||
if (comments::check($dbh, $config, $comment)){
|
||||
my $nslookup=nslookup();
|
||||
|
||||
#if (is_blocked($nslookup)==1){
|
||||
# send_mail($comment, $nslookup, 'blocked');
|
||||
# return;
|
||||
@@ -68,21 +69,18 @@ if (comments::check($dbh, $config, $comment)){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub is_blocked{
|
||||
my $nslookup=shift;
|
||||
|
||||
my $user_agent=$ENV{HTTP_USER_AGENT};
|
||||
|
||||
my $block=0;
|
||||
$block=1 if (
|
||||
($user_agent eq 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:35.0) Gecko/20100101 Firefox/35.0')
|
||||
&& ($nslookup=~/alicedsl/)
|
||||
);
|
||||
$block = 1
|
||||
if ( ( $user_agent eq 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:35.0) Gecko/20100101 Firefox/35.0' )
|
||||
&& ( $nslookup =~ /alicedsl/ ) );
|
||||
return $block;
|
||||
}
|
||||
|
||||
|
||||
sub send_mail{
|
||||
my $comment = shift;
|
||||
my $nslookup = shift;
|
||||
@@ -227,13 +225,15 @@ sub check_params{
|
||||
my $today=time::datetime_to_array(time::time_to_datetime());
|
||||
my $date =time::datetime_to_array($comment->{event_start});
|
||||
my $delta_days=time::days_between($today,$date);
|
||||
log::error($config, 'add_comment.cgi: no comments allowed, yet') if ($delta_days > $config->{permissions}->{no_new_comments_before} );
|
||||
log::error($config, 'add_comment.cgi: no comments allowed anymore') if ($delta_days < -1*$config->{permissions}->{no_new_comments_after} );
|
||||
log::error( $config, 'add_comment.cgi: no comments allowed, yet' )
|
||||
if ( $delta_days > $config->{permissions}->{no_new_comments_before} );
|
||||
log::error( $config, 'add_comment.cgi: no comments allowed anymore' )
|
||||
if ( $delta_days < -1 * $config->{permissions}->{no_new_comments_after} );
|
||||
|
||||
return {
|
||||
template =>$template,
|
||||
comment =>$comment
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
sub escape_text{
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
|
||||
#use Data::Dumper;
|
||||
|
||||
#use DBI;
|
||||
use CGI qw(header param Vars);
|
||||
|
||||
#use Time::Local qw(timelocal);
|
||||
#use Benchmark;
|
||||
#use Devel::Profiler;
|
||||
@@ -21,150 +23,155 @@ use config;
|
||||
#use params;
|
||||
#my $r=shift;
|
||||
|
||||
if ($0=~/aggregate.*?\.cgi$/){
|
||||
binmode STDOUT, ":encoding(UTF-8)";
|
||||
if ( $0 =~ /aggregate.*?\.cgi$/ ) {
|
||||
binmode STDOUT, ":encoding(UTF-8)";
|
||||
|
||||
#(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $cgi=new CGI();
|
||||
my %params=$cgi->Vars();
|
||||
my $params=\%params;
|
||||
#print STDERR Dumper($params);
|
||||
#(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $cgi = new CGI();
|
||||
my %params = $cgi->Vars();
|
||||
my $params = \%params;
|
||||
|
||||
my $config = config::get('config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my $mem_debug = $config->{system}->{debug_memory};
|
||||
my $base_dir = $config->{locations}->{base_dir};
|
||||
#print STDERR Dumper($params);
|
||||
|
||||
#my $cgi=new CGI();
|
||||
my $output_header='';
|
||||
if(exists $ENV{REQUEST_URI} && $ENV{REQUEST_URI}ne''){
|
||||
$output_header.="Content-type:text/html; charset=UTF-8;\n\n";
|
||||
};
|
||||
# $output_header.='<!DOCTYPE html>'."\n";
|
||||
my $config = config::get('config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my $mem_debug = $config->{system}->{debug_memory};
|
||||
my $base_dir = $config->{locations}->{base_dir};
|
||||
|
||||
my $request={
|
||||
url => $ENV{QUERY_STRING},
|
||||
params => {
|
||||
original => $params,
|
||||
checked => aggregator::check_params($config, $params),
|
||||
},
|
||||
};
|
||||
$params=$request->{params}->{checked};
|
||||
#my $cgi=new CGI();
|
||||
my $output_header = '';
|
||||
if ( exists $ENV{REQUEST_URI} && $ENV{REQUEST_URI} ne '' ) {
|
||||
$output_header .= "Content-type:text/html; charset=UTF-8;\n\n";
|
||||
}
|
||||
|
||||
my $mem=0;
|
||||
log::init($request);
|
||||
|
||||
#get result from cache
|
||||
my $cache=aggregator::get_cache($config, $request);
|
||||
# $output_header.='<!DOCTYPE html>'."\n";
|
||||
|
||||
if ((defined $cache->{content}) && ($cache->{content}ne'')){
|
||||
my $content=$cache->{content};
|
||||
print $output_header;
|
||||
print $content;
|
||||
return;
|
||||
}
|
||||
|
||||
my $content=load_file($base_dir.'./index.html');
|
||||
$content=$$content||'';
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING},
|
||||
params => {
|
||||
original => $params,
|
||||
checked => aggregator::check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
#replace HTML escaped calcms_title span by unescaped one
|
||||
$content=~s/\<\;span id\="\;calcms_title"\;\>\;[^\&]*\<\;\/span\>\;/\<span id=\"calcms_title\" \>\<\/span\>/g;
|
||||
# print $content;
|
||||
my $mem = 0;
|
||||
log::init($request);
|
||||
|
||||
my $list=aggregator::get_list($config, $request);
|
||||
#get result from cache
|
||||
my $cache = aggregator::get_cache( $config, $request );
|
||||
|
||||
my $menu={content=>''};
|
||||
$list->{day}=$params->{date} if ((!defined $list->{day}) || ($list->{day} eq''));
|
||||
$list->{day}='today' if ($list->{day} eq'' && $params->{date} eq'');
|
||||
if ( ( defined $cache->{content} ) && ( $cache->{content} ne '' ) ) {
|
||||
my $content = $cache->{content};
|
||||
print $output_header;
|
||||
print $content;
|
||||
return;
|
||||
}
|
||||
|
||||
$menu=aggregator::get_menu($config, $request, $list->{day}, $list->{results});
|
||||
my $content = load_file( $base_dir . './index.html' );
|
||||
$content = $$content || '';
|
||||
|
||||
my $calendar=aggregator::get_calendar($config, $request, $list->{day});
|
||||
my $newest_comments=aggregator::get_newest_comments($config, $request);
|
||||
|
||||
#my $newest_comments={};
|
||||
#db::disconnect($request) if (defined $request && defined $request->{connection});
|
||||
#print STDERR "$list->{project_title}\n";
|
||||
#replace HTML escaped calcms_title span by unescaped one
|
||||
$content =~ s/\<\;span id\="\;calcms_title"\;\>\;[^\&]*\<\;\/span\>\;/\<span id=\"calcms_title\" \>\<\/span\>/g;
|
||||
|
||||
#build results list
|
||||
my $output={};
|
||||
$output->{calcms_menu} = \$menu->{content};
|
||||
$output->{calcms_list} = \$list->{content};
|
||||
$output->{calcms_calendar} = \$calendar->{content};
|
||||
$output->{calcms_newest_comments} = \$newest_comments->{content};
|
||||
# print $content;
|
||||
|
||||
# $output->{calcms_categories} = load_file($base_dir.'/cache/categories.html');
|
||||
# $output->{calcms_series_names} = load_file($base_dir.'/cache/series_names.html');
|
||||
# $output->{calcms_programs} = load_file($base_dir.'/cache/programs.html');
|
||||
my $list = aggregator::get_list( $config, $request );
|
||||
|
||||
my $url=$list->{url};
|
||||
my $js=qq{
|
||||
my $menu = { content => '' };
|
||||
$list->{day} = $params->{date} if ( ( !defined $list->{day} ) || ( $list->{day} eq '' ) );
|
||||
$list->{day} = 'today' if ( $list->{day} eq '' && $params->{date} eq '' );
|
||||
|
||||
$menu = aggregator::get_menu( $config, $request, $list->{day}, $list->{results} );
|
||||
|
||||
my $calendar = aggregator::get_calendar( $config, $request, $list->{day} );
|
||||
my $newest_comments = aggregator::get_newest_comments( $config, $request );
|
||||
|
||||
#my $newest_comments={};
|
||||
#db::disconnect($request) if (defined $request && defined $request->{connection});
|
||||
#print STDERR "$list->{project_title}\n";
|
||||
|
||||
#build results list
|
||||
my $output = {};
|
||||
$output->{calcms_menu} = \$menu->{content};
|
||||
$output->{calcms_list} = \$list->{content};
|
||||
$output->{calcms_calendar} = \$calendar->{content};
|
||||
$output->{calcms_newest_comments} = \$newest_comments->{content};
|
||||
|
||||
# $output->{calcms_categories} = load_file($base_dir.'/cache/categories.html');
|
||||
# $output->{calcms_series_names} = load_file($base_dir.'/cache/series_names.html');
|
||||
# $output->{calcms_programs} = load_file($base_dir.'/cache/programs.html');
|
||||
|
||||
my $url = $list->{url};
|
||||
my $js = qq{
|
||||
set('preloaded','1');
|
||||
set('last_list_url','$url');
|
||||
};
|
||||
$content=~s/\/\/\s*(calcms_)?preload/$js/;
|
||||
$content =~ s/\/\/\s*(calcms_)?preload/$js/;
|
||||
|
||||
#insert results into page
|
||||
for my $key (keys %$output){
|
||||
my $val=${$output->{$key}};
|
||||
my $start=index($val,"<body>");
|
||||
if ($start!=-1){
|
||||
$val=substr($val,$start+length('<body>'));
|
||||
}
|
||||
my $end=index($val,"</body>");
|
||||
if ($end!=-1){
|
||||
$val=substr($val,0,$end);
|
||||
}
|
||||
$content=~s/(<(div|span)\s+id="$key".*?>).*?(<\/(div|span)>)/$1$val$3/g;
|
||||
}
|
||||
#insert results into page
|
||||
for my $key ( keys %$output ) {
|
||||
my $val = ${ $output->{$key} };
|
||||
my $start = index( $val, "<body>" );
|
||||
if ( $start != -1 ) {
|
||||
$val = substr( $val, $start + length('<body>') );
|
||||
}
|
||||
my $end = index( $val, "</body>" );
|
||||
if ( $end != -1 ) {
|
||||
$val = substr( $val, 0, $end );
|
||||
}
|
||||
$content =~ s/(<(div|span)\s+id="$key".*?>).*?(<\/(div|span)>)/$1$val$3/g;
|
||||
}
|
||||
|
||||
#replace whole element span with id="calcms_title" by value
|
||||
$list->{project_title}='' unless (defined $list->{project_title});
|
||||
$content=~s/(<(div|span)\s+id="calcms_title".*?>).*?(<\/(div|span)>)/$list->{project_title}/g;
|
||||
#replace whole element span with id="calcms_title" by value
|
||||
$list->{project_title} = '' unless ( defined $list->{project_title} );
|
||||
$content =~ s/(<(div|span)\s+id="calcms_title".*?>).*?(<\/(div|span)>)/$list->{project_title}/g;
|
||||
|
||||
my $title=$list->{program}||'';
|
||||
$title.=' - '.$list->{series_name} if ((defined $list->{series_name}) && ($list->{series_name} ne''));
|
||||
$title.=' - '.$list->{title} if ((defined $list->{title}) && ($list->{title} ne''));
|
||||
$title=' | '.$title if($title ne'');
|
||||
$title.='Programmplan';
|
||||
$title.=' | '.$list->{project_title} if $list->{project_title}ne'';
|
||||
#$content=~s/(<title>)(.*?)(<\/title>)/$1$title$3/;
|
||||
my $title = $list->{program} || '';
|
||||
$title .= ' - ' . $list->{series_name} if ( ( defined $list->{series_name} ) && ( $list->{series_name} ne '' ) );
|
||||
$title .= ' - ' . $list->{title} if ( ( defined $list->{title} ) && ( $list->{title} ne '' ) );
|
||||
$title = ' | ' . $title if ( $title ne '' );
|
||||
$title .= 'Programmplan';
|
||||
$title .= ' | ' . $list->{project_title} if $list->{project_title} ne '';
|
||||
|
||||
$js='';
|
||||
if ((defined $list->{event_id}) && ($list->{event_id}ne'')){
|
||||
$js.=qq{showCommentsByEventIdOrEventStart('$list->{event_id}','$list->{start_datetime}')};
|
||||
}
|
||||
#$content=~s/(<title>)(.*?)(<\/title>)/$1$title$3/;
|
||||
|
||||
$content=~s/startCalcms\(\)\;/$js/gi;
|
||||
$js = '';
|
||||
if ( ( defined $list->{event_id} ) && ( $list->{event_id} ne '' ) ) {
|
||||
$js .= qq{showCommentsByEventIdOrEventStart('$list->{event_id}','$list->{start_datetime}')};
|
||||
}
|
||||
|
||||
#replace link to uncompressed or compressed drupal (first link in <head>)
|
||||
my @parts=split(/<\/head>/,$content);
|
||||
$parts[0]=~s|/misc/jquery.js|/agenda_files/js/jquery.js|;
|
||||
$parts[0]=~s|/sites/default/files/js/[a-z0-9\_]+\.js|/agenda_files/js/jquery.js|;
|
||||
$content=join('</head>',@parts);
|
||||
$content =~ s/startCalcms\(\)\;/$js/gi;
|
||||
|
||||
print $output_header;
|
||||
print $content;
|
||||
# $r->print("done");
|
||||
#replace link to uncompressed or compressed drupal (first link in <head>)
|
||||
my @parts = split( /<\/head>/, $content );
|
||||
$parts[0] =~ s|/misc/jquery.js|/agenda_files/js/jquery.js|;
|
||||
$parts[0] =~ s|/sites/default/files/js/[a-z0-9\_]+\.js|/agenda_files/js/jquery.js|;
|
||||
$content = join( '</head>', @parts );
|
||||
|
||||
if ($config->{cache}->{use_cache} eq '1'){
|
||||
$cache->{content}=$content;
|
||||
log::write($config, 'cache_file',$cache->{filename}) if ($debug);
|
||||
cache::save($cache);
|
||||
}
|
||||
# $config=undef;
|
||||
$content=undef;
|
||||
$cache=undef;
|
||||
log::mem($config, 'aggregate done',$mem) if ($mem_debug>0);
|
||||
print $output_header;
|
||||
print $content;
|
||||
|
||||
# $r->print("done");
|
||||
|
||||
if ( $config->{cache}->{use_cache} eq '1' ) {
|
||||
$cache->{content} = $content;
|
||||
log::write( $config, 'cache_file', $cache->{filename} ) if ($debug);
|
||||
cache::save($cache);
|
||||
}
|
||||
|
||||
# $config=undef;
|
||||
$content = undef;
|
||||
$cache = undef;
|
||||
log::mem( $config, 'aggregate done', $mem ) if ( $mem_debug > 0 );
|
||||
}
|
||||
|
||||
sub load_file{
|
||||
my $filename=shift;
|
||||
my $content="cannot load '$filename'";
|
||||
open my $FILE,'<:utf8',$filename or return \$content;
|
||||
$content=join ("",(<$FILE>));
|
||||
close $FILE;
|
||||
return \$content;
|
||||
sub load_file {
|
||||
my $filename = shift;
|
||||
my $content = "cannot load '$filename'";
|
||||
open my $FILE, '<:utf8', $filename or return \$content;
|
||||
$content = join( "", (<$FILE>) );
|
||||
close $FILE;
|
||||
return \$content;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ use warnings;
|
||||
|
||||
use Data::Dumper;
|
||||
use CGI qw(header param Vars);
|
||||
$CGI::POST_MAX = 1000;
|
||||
$CGI::POST_MAX = 1000;
|
||||
$CGI::DISABLE_UPLOADS = 1;
|
||||
|
||||
use params;
|
||||
@@ -19,127 +19,128 @@ use project;
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config=config::get('config/config.cgi');
|
||||
my $config = config::get('config/config.cgi');
|
||||
|
||||
my $debug=$config->{system}->{debug};
|
||||
my $debug = $config->{system}->{debug};
|
||||
|
||||
my $request={
|
||||
url => $ENV{QUERY_STRING},
|
||||
params => {
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING},
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($config, $params),
|
||||
checked => check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
|
||||
log::init($request);
|
||||
|
||||
$params=$request->{params}->{checked};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
my $cache={};
|
||||
if ($config->{cache}->{use_cache} eq '1'){
|
||||
my $cache = {};
|
||||
if ( $config->{cache}->{use_cache} eq '1' ) {
|
||||
cache::configure('categories.html');
|
||||
$cache=cache::load($config, $params);
|
||||
if (defined $cache->{content}){
|
||||
$cache = cache::load( $config, $params );
|
||||
if ( defined $cache->{content} ) {
|
||||
print $cache->{content};
|
||||
return;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
my $dbh=db::connect($config);
|
||||
my $dbh = db::connect($config);
|
||||
|
||||
my $template_parameters = {};
|
||||
$template_parameters->{projects} = getProjects( $dbh, $config );
|
||||
|
||||
my $template_parameters={};
|
||||
$template_parameters->{projects} = getProjects($dbh, $config);
|
||||
#$template_parameters->{categories} = get_categories($dbh,$params->{project});
|
||||
$template_parameters->{debug} = $config->{system}->{debug};
|
||||
$template_parameters->{server_cache} = $config->{cache}->{server_cache} if ($config->{cache}->{server_cache});
|
||||
$template_parameters->{use_client_cache}= $config->{cache}->{use_client_cache} if ($config->{cache}->{use_client_cache});
|
||||
$template_parameters->{debug} = $config->{system}->{debug};
|
||||
$template_parameters->{server_cache} = $config->{cache}->{server_cache} if ( $config->{cache}->{server_cache} );
|
||||
$template_parameters->{use_client_cache} = $config->{cache}->{use_client_cache} if ( $config->{cache}->{use_client_cache} );
|
||||
|
||||
my $template=$params->{template};
|
||||
my $out='';
|
||||
template::process($out, $params->{template}, $template_parameters);
|
||||
my $template = $params->{template};
|
||||
my $out = '';
|
||||
template::process( $out, $params->{template}, $template_parameters );
|
||||
print $out;
|
||||
|
||||
#write to cache
|
||||
if ($config->{cache}->{use_cache} eq '1'){
|
||||
$cache->{content}=$out;
|
||||
if ( $config->{cache}->{use_cache} eq '1' ) {
|
||||
$cache->{content} = $out;
|
||||
cache::save($cache);
|
||||
}
|
||||
|
||||
sub getProjects{
|
||||
my $dbh=shift;
|
||||
my $config=shift;
|
||||
|
||||
my $excludedProjects={};
|
||||
if (defined $config->{filter}->{exclude_projects}){
|
||||
for my $project ( split(/\,/, $config->{filter}->{exclude_projects}) ){
|
||||
$project=~s/^\s+//g;
|
||||
$project=~s/\s+$//g;
|
||||
$excludedProjects->{$project}=1;
|
||||
}
|
||||
}
|
||||
sub getProjects {
|
||||
my $dbh = shift;
|
||||
my $config = shift;
|
||||
|
||||
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 $excludedProjects = {};
|
||||
if ( defined $config->{filter}->{exclude_projects} ) {
|
||||
for my $project ( split( /\,/, $config->{filter}->{exclude_projects} ) ) {
|
||||
$project =~ s/^\s+//g;
|
||||
$project =~ s/\s+$//g;
|
||||
$excludedProjects->{$project} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$project->{js_name}=$project->{name};
|
||||
$project->{js_name}=~s/[^a-zA-Z\_0-9]/\_/g;
|
||||
$project->{js_name}=~s/\_+/\_/g;
|
||||
push @$results, $project;
|
||||
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;
|
||||
}
|
||||
|
||||
sub getCategories{
|
||||
my $dbh=shift;
|
||||
my $config=shift;
|
||||
my $project=shift;
|
||||
sub getCategories {
|
||||
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 $results=[];
|
||||
for my $category (@$categories){
|
||||
push @$results, $category if $category->{sum}>1;
|
||||
my $categories = db::get( $dbh, $query, $bind_values );
|
||||
|
||||
my $results = [];
|
||||
for my $category (@$categories) {
|
||||
push @$results, $category if $category->{sum} > 1;
|
||||
}
|
||||
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
sub check_params{
|
||||
my $config=$_[0];
|
||||
my $params=$_[1];
|
||||
sub check_params {
|
||||
my $config = $_[0];
|
||||
my $params = $_[1];
|
||||
|
||||
my $template=template::check($params->{template},'categories.html');
|
||||
my $template = template::check( $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
|
||||
}
|
||||
template => $template,
|
||||
debug => $debug
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
/*
|
||||
|
||||
wordpress calendar : jero edition
|
||||
|
||||
<link rel="stylesheet" type="text/css" media="screen" href="http://www.funkwelle.org/wp-content/uploads/kalender_css/cal.css" />
|
||||
*/
|
||||
|
||||
|
||||
@@ -4,11 +4,15 @@ include in your web page:
|
||||
*/
|
||||
|
||||
/* fix drupal */
|
||||
|
||||
input{
|
||||
max-width:20em;
|
||||
}
|
||||
|
||||
a{
|
||||
text-decoration:none;
|
||||
box-shadow:none !important;
|
||||
}
|
||||
|
||||
/* hide microformats */
|
||||
.vevent .dtstart,
|
||||
.vevent .dtend,
|
||||
@@ -25,7 +29,6 @@ input{
|
||||
|
||||
|
||||
/* menu */
|
||||
|
||||
#calcms_menu{
|
||||
clear:both;
|
||||
text-align:left;
|
||||
@@ -92,6 +95,8 @@ input{
|
||||
}
|
||||
|
||||
#calcms_playlist img{
|
||||
width:25px;
|
||||
height:25px;
|
||||
border:1px solid #ccc;
|
||||
}
|
||||
|
||||
@@ -139,8 +144,10 @@ input{
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
#calcms_list .event.running{
|
||||
color:#000;
|
||||
#calcms_list .event.running,
|
||||
#calcms_list .event.running a{
|
||||
color:#fff;
|
||||
background:#aaa;
|
||||
}
|
||||
|
||||
#calcms_list .comments.submitted{
|
||||
@@ -153,6 +160,7 @@ input{
|
||||
|
||||
#calcms_list .title{
|
||||
margin-bottom:1em;
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
#calcms_list .content img{
|
||||
@@ -165,14 +173,16 @@ input{
|
||||
}
|
||||
|
||||
#calcms_list .event{
|
||||
padding:1em;
|
||||
padding-top:0.5em;
|
||||
padding-bottom:0.5em;
|
||||
margin:1em;
|
||||
margin-left:0;
|
||||
background:#eee;
|
||||
padding:1rem;
|
||||
padding-right:0.5rem;
|
||||
border-bottom:1rem solid #fff;
|
||||
hyphens: none;
|
||||
cursor:pointer;
|
||||
background:#eee;
|
||||
color:#666;
|
||||
max-height:8rem;
|
||||
overflow:hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
|
||||
@@ -192,6 +202,19 @@ input{
|
||||
|
||||
#icon_bar a {
|
||||
padding:1em;
|
||||
float:left;
|
||||
}
|
||||
|
||||
/* slider */
|
||||
#coming_shows{
|
||||
white-space:nowrap;
|
||||
height:120px;
|
||||
}
|
||||
|
||||
#calcms_list #playlist_container{
|
||||
overflow:hidden;
|
||||
height:120px;
|
||||
padding:10px;
|
||||
}
|
||||
|
||||
#calcms_list #playlist_container .event{
|
||||
@@ -209,6 +232,67 @@ input{
|
||||
box-sizing:border-box;
|
||||
}
|
||||
|
||||
#playlist_container .event div.bottom{
|
||||
max-height:70px;
|
||||
font-size:12px;
|
||||
padding:6px;
|
||||
white-space:wrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
#coming_shows .eventContainer {
|
||||
display:inline-block;
|
||||
vertical-align:top;
|
||||
text-align:center;
|
||||
cursor:pointer;
|
||||
width:100px;
|
||||
height:100px;
|
||||
}
|
||||
#coming_shows .eventContainer:hover {
|
||||
background:#eeeeee;
|
||||
}
|
||||
#coming_shows a:hover {
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
#coming_shows div.event{
|
||||
position:relative;
|
||||
width:100px;
|
||||
height:100px;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center center;
|
||||
background-size: cover;
|
||||
}
|
||||
#coming_shows div.event .top,
|
||||
#coming_shows div.event .bottom{
|
||||
position:absolute;
|
||||
background:#222;
|
||||
color:#fff;
|
||||
opacity:0.8;
|
||||
width:100%;
|
||||
}
|
||||
#coming_shows div.event .top:hover,
|
||||
#coming_shows div.event .bottom:hover{
|
||||
opacity:1;
|
||||
}
|
||||
|
||||
#coming_shows div.event .top{
|
||||
top:0;
|
||||
}
|
||||
|
||||
#coming_shows div.event .bottom{
|
||||
bottom:0;
|
||||
}
|
||||
|
||||
#coming_shows div.event{
|
||||
transition: all .2s ease-in-out;
|
||||
}
|
||||
|
||||
#coming_shows div.event:hover{
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
|
||||
/* calcms comments */
|
||||
#calcms_comments{
|
||||
clear:both;
|
||||
@@ -461,6 +545,7 @@ a#calcms_search_show_details #plus{
|
||||
text-align:center;
|
||||
font-weight:normal;
|
||||
border-bottom:1px solid #ddd;
|
||||
transition: all .1s ease-in-out;
|
||||
}
|
||||
|
||||
#calcms_calendar table thead td:hover,
|
||||
@@ -474,11 +559,6 @@ a#calcms_search_show_details #plus{
|
||||
font-size:large;
|
||||
}
|
||||
|
||||
#calcms_calendar table th,
|
||||
#calcms_calendar table td{
|
||||
transition: all .1s ease-in-out;
|
||||
}
|
||||
|
||||
/* month selector */
|
||||
#calcms_calendar table thead tr:first-child a{
|
||||
padding:6px;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#! /usr/bin/perl -w
|
||||
|
||||
use warnings "all";
|
||||
|
||||
#no warnings 'redefine';
|
||||
#use diagnostics;
|
||||
use strict;
|
||||
@@ -9,7 +10,7 @@ use Data::Dumper;
|
||||
#use utf8;
|
||||
use DBI;
|
||||
use CGI qw(header param Vars);
|
||||
$CGI::POST_MAX = 1000;
|
||||
$CGI::POST_MAX = 1000;
|
||||
$CGI::DISABLE_UPLOADS = 1;
|
||||
|
||||
use params;
|
||||
@@ -21,28 +22,30 @@ use time;
|
||||
#binmode STDOUT, ":utf8";
|
||||
binmode STDOUT, ":encoding(UTF-8)";
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
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');
|
||||
if ( $0 =~ /events.*?\.cgi$/ ) {
|
||||
|
||||
$params->{recordings}=1 if $params->{template}=~/events_playout/;
|
||||
my $request={
|
||||
url => $ENV{QUERY_STRING},
|
||||
params => {
|
||||
original => $params,
|
||||
checked => events::check_params($config, $params),
|
||||
},
|
||||
};
|
||||
#events::init($request);
|
||||
log::init($request);
|
||||
#my $cgi=new CGI();
|
||||
#my %params=$cgi->Vars();
|
||||
our $config = config::get('config/config.cgi');
|
||||
|
||||
my $output='';
|
||||
events::get_cached_or_render($output, $config, $request);
|
||||
print $output."\n";
|
||||
$params->{recordings} = 1 if $params->{template} =~ /events_playout/;
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING},
|
||||
params => {
|
||||
original => $params,
|
||||
checked => events::check_params( $config, $params ),
|
||||
},
|
||||
};
|
||||
|
||||
#events::init($request);
|
||||
log::init($request);
|
||||
|
||||
my $output = '';
|
||||
events::get_cached_or_render( $output, $config, $request );
|
||||
print $output. "\n";
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
266
website/agenda/planung/assign_series.cgi
Normal file → Executable file
266
website/agenda/planung/assign_series.cgi
Normal file → Executable file
@@ -25,41 +25,47 @@ use localization;
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my ($user,$expires) = auth::get_user($cgi, $config);
|
||||
return if ((!defined $user) || ($user eq ''));
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
#print 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
|
||||
});
|
||||
$params->{default_studio_id}=$user_presets->{studio_id};
|
||||
$params->{studio_id} = $params->{default_studio_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
$params->{project_id} = $user_presets->{project_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
user => $user
|
||||
}
|
||||
);
|
||||
$params->{default_studio_id} = $user_presets->{studio_id};
|
||||
$params->{studio_id} = $params->{default_studio_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
$params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
#print STDERR $params->{project_id}."\n";
|
||||
my $request={
|
||||
url => $ENV{QUERY_STRING}||'',
|
||||
params => {
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
$params=$request->{params}->{checked};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
#process header
|
||||
my $headerParams=uac::set_template_permissions($request->{permissions}, $params);
|
||||
$headerParams->{loc} = localization::get($config, {user=>$user, file=>'menu'});
|
||||
template::process('print', template::check('default.html'), $headerParams);
|
||||
return unless uac::check($config, $params, $user_presets)==1;
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( 'print', template::check('default.html'), $headerParams );
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
print q{
|
||||
<script src="js/datetime.js" type="text/javascript"></script>
|
||||
@@ -68,164 +74,170 @@ print q{
|
||||
<link rel="stylesheet" href="css/series.css" type="text/css" />
|
||||
};
|
||||
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{scan_series_events}==1){
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{scan_series_events} == 1 ) {
|
||||
uac::permissions_denied('scan_series_events');
|
||||
return;
|
||||
}
|
||||
|
||||
if (defined $params->{action}){
|
||||
assign_series ($config, $request) if ($params->{action} eq 'assign_series');
|
||||
if ( defined $params->{action} ) {
|
||||
assign_series( $config, $request ) if ( $params->{action} eq 'assign_series' );
|
||||
}
|
||||
show_events($config, $request);
|
||||
show_events( $config, $request );
|
||||
|
||||
sub show_events{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub show_events {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{assign_series_events}==1){
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{assign_series_events} == 1 ) {
|
||||
uac::permissions_denied('assign_series_events');
|
||||
return;
|
||||
}
|
||||
|
||||
my $projects=project::get($config, {project_id=>$params->{project_id}});
|
||||
my $project=$projects->[0];
|
||||
return unless (@$projects==1);
|
||||
my $projects = project::get( $config, { project_id => $params->{project_id} } );
|
||||
my $project = $projects->[0];
|
||||
return unless ( @$projects == 1 );
|
||||
|
||||
my $studios=studios::get($config, {project_id=>$params->{project_id}, studio_id=>$params->{studio_id}});
|
||||
my $studio=$studios->[0];
|
||||
return unless (@$studios==1);
|
||||
my $studios = studios::get( $config, { project_id => $params->{project_id}, studio_id => $params->{studio_id} } );
|
||||
my $studio = $studios->[0];
|
||||
return unless ( @$studios == 1 );
|
||||
|
||||
my $project_name=$project->{name};
|
||||
my $studio_name=$studio->{location};
|
||||
my $project_name = $project->{name};
|
||||
my $studio_name = $studio->{location};
|
||||
|
||||
#get series_names
|
||||
my $dbh=db::connect($config);
|
||||
my $query=q{
|
||||
#get series_names
|
||||
my $dbh = db::connect($config);
|
||||
my $query = q{
|
||||
select project_id, studio_id, series_id, series_name, title
|
||||
from calcms_series s, calcms_project_series ps
|
||||
where s.id=ps.series_id
|
||||
order by series_name, title
|
||||
};
|
||||
my $results=db::get($dbh, $query);
|
||||
my $results = db::get( $dbh, $query );
|
||||
|
||||
# get projects by id
|
||||
my $projects_by_id={};
|
||||
$projects=project::get($config);
|
||||
for my $project (@$projects){
|
||||
$projects_by_id->{$project->{project_id}}=$project;
|
||||
}
|
||||
# get projects by id
|
||||
my $projects_by_id = {};
|
||||
$projects = project::get($config);
|
||||
for my $project (@$projects) {
|
||||
$projects_by_id->{ $project->{project_id} } = $project;
|
||||
}
|
||||
|
||||
# get studios by id
|
||||
my $studios_by_id={};
|
||||
$studios=studios::get($config);
|
||||
for my $studio (@$studios){
|
||||
$studios_by_id->{$studio->{id}}=$studio;
|
||||
}
|
||||
# get studios by id
|
||||
my $studios_by_id = {};
|
||||
$studios = studios::get($config);
|
||||
for my $studio (@$studios) {
|
||||
$studios_by_id->{ $studio->{id} } = $studio;
|
||||
}
|
||||
|
||||
#add project and studio name to series
|
||||
for my $result (@$results){
|
||||
$result->{project_name} = $projects_by_id->{ $result->{project_id} }->{name};
|
||||
$result->{studio_name} = $studios_by_id->{ $result->{studio_id} }->{location};
|
||||
$result->{series_name} = 'Einzelsendung' if $result->{series_name} eq '_single_';
|
||||
}
|
||||
$params->{series}=$results;
|
||||
#add project and studio name to series
|
||||
for my $result (@$results) {
|
||||
$result->{project_name} = $projects_by_id->{ $result->{project_id} }->{name};
|
||||
$result->{studio_name} = $studios_by_id->{ $result->{studio_id} }->{location};
|
||||
$result->{series_name} = 'Einzelsendung' if $result->{series_name} eq '_single_';
|
||||
}
|
||||
$params->{series} = $results;
|
||||
|
||||
#fill template
|
||||
$params->{project_name} = $project_name;
|
||||
$params->{studio_name} = $studio_name;
|
||||
#fill template
|
||||
$params->{project_name} = $project_name;
|
||||
$params->{studio_name} = $studio_name;
|
||||
|
||||
template::process('print', $params->{template}, $params);
|
||||
template::process( 'print', $params->{template}, $params );
|
||||
}
|
||||
|
||||
sub assign_series {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
sub assign_series{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{assign_series_events}==1){
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{assign_series_events} == 1 ) {
|
||||
uac::permissions_denied('assign_series_events');
|
||||
return;
|
||||
}
|
||||
|
||||
my $entry={};
|
||||
for my $attr ('project_id','studio_id', 'series_id'){
|
||||
if (defined $params->{$attr}){
|
||||
$entry->{$attr}=$params->{$attr};
|
||||
}else{
|
||||
uac::print_error($attr.' not given!');
|
||||
my $entry = {};
|
||||
for my $attr ( 'project_id', 'studio_id', 'series_id' ) {
|
||||
if ( defined $params->{$attr} ) {
|
||||
$entry->{$attr} = $params->{$attr};
|
||||
} else {
|
||||
uac::print_error( $attr . ' not given!' );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$config->{access}->{write}=1;
|
||||
$config->{access}->{write} = 1;
|
||||
|
||||
#check if series is assigned to project/studio
|
||||
my $series=series::get(
|
||||
$config,{
|
||||
project_id => $entry->{project_id},
|
||||
studio_id => $entry->{studio_id},
|
||||
series_id => $entry->{series_id},
|
||||
}
|
||||
);
|
||||
#print Dumper($series);
|
||||
if(@$series==0){
|
||||
# assign series to project/studio
|
||||
project::assign_series(
|
||||
$config,{
|
||||
project_id => $entry->{project_id},
|
||||
studio_id => $entry->{studio_id},
|
||||
series_id => $entry->{series_id},
|
||||
}
|
||||
);
|
||||
#print "assign\n";
|
||||
}else{
|
||||
print STDERR "event $entry->{event_id} already assigned to project $entry->{project_id}, studio $entry->{studio_id}, series $entry->{series_id}\n";
|
||||
#print "is schon\n";
|
||||
}
|
||||
#check if series is assigned to project/studio
|
||||
my $series = series::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $entry->{project_id},
|
||||
studio_id => $entry->{studio_id},
|
||||
series_id => $entry->{series_id},
|
||||
}
|
||||
);
|
||||
|
||||
$config->{access}->{write}=0;
|
||||
#print Dumper($series);
|
||||
if ( @$series == 0 ) {
|
||||
|
||||
# assign series to project/studio
|
||||
project::assign_series(
|
||||
$config,
|
||||
{
|
||||
project_id => $entry->{project_id},
|
||||
studio_id => $entry->{studio_id},
|
||||
series_id => $entry->{series_id},
|
||||
}
|
||||
);
|
||||
|
||||
#print "assign\n";
|
||||
} else {
|
||||
print STDERR
|
||||
"event $entry->{event_id} already assigned to project $entry->{project_id}, studio $entry->{studio_id}, series $entry->{series_id}\n";
|
||||
|
||||
#print "is schon\n";
|
||||
}
|
||||
|
||||
$config->{access}->{write} = 0;
|
||||
uac::print_info("event successfully assigned to series");
|
||||
}
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
my $checked={};
|
||||
my $checked = {};
|
||||
|
||||
my $debug=$params->{debug} || '';
|
||||
if ($debug=~/([a-z\_\,]+)/){
|
||||
$debug=$1;
|
||||
my $debug = $params->{debug} || '';
|
||||
if ( $debug =~ /([a-z\_\,]+)/ ) {
|
||||
$debug = $1;
|
||||
}
|
||||
$checked->{debug}=$debug;
|
||||
$checked->{debug} = $debug;
|
||||
|
||||
#actions and roles
|
||||
$checked->{action}='';
|
||||
if (defined $params->{action}){
|
||||
if ($params->{action}=~/^(assign_series)$/){
|
||||
$checked->{action}=$params->{action};
|
||||
$checked->{action} = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(assign_series)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
|
||||
#numeric values
|
||||
$checked->{exclude}=0;
|
||||
for my $param ('id', 'project_id', 'studio_id', 'series_id'){
|
||||
if ((defined $params->{$param})&&($params->{$param}=~/^\d+$/)){
|
||||
$checked->{$param}=$params->{$param};
|
||||
$checked->{exclude} = 0;
|
||||
for my $param ( 'id', 'project_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;
|
||||
}
|
||||
if ( defined $checked->{studio_id} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
|
||||
$checked->{template}=template::check($params->{template},'assign_series');
|
||||
$checked->{template} = template::check( $params->{template}, 'assign_series' );
|
||||
|
||||
return $checked;
|
||||
}
|
||||
|
||||
554
website/agenda/planung/assignments.cgi
Normal file → Executable file
554
website/agenda/planung/assignments.cgi
Normal file → Executable file
@@ -25,41 +25,47 @@ use localization;
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my ($user,$expires) = auth::get_user($cgi, $config);
|
||||
return if ((!defined $user) || ($user eq ''));
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
#print 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
|
||||
});
|
||||
$params->{default_studio_id}=$user_presets->{studio_id};
|
||||
$params->{studio_id} = $params->{default_studio_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
$params->{project_id} = $user_presets->{project_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
user => $user
|
||||
}
|
||||
);
|
||||
$params->{default_studio_id} = $user_presets->{studio_id};
|
||||
$params->{studio_id} = $params->{default_studio_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
$params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
#print STDERR $params->{project_id}."\n";
|
||||
my $request={
|
||||
url => $ENV{QUERY_STRING}||'',
|
||||
params => {
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
$params=$request->{params}->{checked};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
#process header
|
||||
my $headerParams=uac::set_template_permissions($request->{permissions}, $params);
|
||||
$headerParams->{loc} = localization::get($config, {user=>$user, file=>'menu'});
|
||||
template::process('print', template::check('default.html'), $headerParams);
|
||||
return unless uac::check($config, $params, $user_presets)==1;
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( 'print', template::check('default.html'), $headerParams );
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
print q{
|
||||
<script src="js/datetime.js" type="text/javascript"></script>
|
||||
@@ -68,86 +74,88 @@ print q{
|
||||
<link rel="stylesheet" href="css/series.css" type="text/css" />
|
||||
};
|
||||
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{scan_series_events}==1){
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{scan_series_events} == 1 ) {
|
||||
uac::permissions_denied('scan_series_events');
|
||||
return;
|
||||
}
|
||||
|
||||
if (defined $params->{action}){
|
||||
assign_events ($config, $request) if ($params->{action} eq 'assign_events');
|
||||
if ( defined $params->{action} ) {
|
||||
assign_events( $config, $request ) if ( $params->{action} eq 'assign_events' );
|
||||
}
|
||||
show_events($config, $request);
|
||||
show_events( $config, $request );
|
||||
|
||||
sub show_events{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub show_events {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{assign_series_events}==1){
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{assign_series_events} == 1 ) {
|
||||
uac::permissions_denied('assign_series_events');
|
||||
return;
|
||||
}
|
||||
|
||||
my $projects=project::get($config, {project_id=>$params->{project_id}});
|
||||
my $project=$projects->[0];
|
||||
#print STDERR Dumper($project);
|
||||
return unless (@$projects==1);
|
||||
my $projects = project::get( $config, { project_id => $params->{project_id} } );
|
||||
my $project = $projects->[0];
|
||||
|
||||
my $studios=studios::get($config, {project_id=>$params->{project_id}, studio_id=>$params->{studio_id}});
|
||||
my $studio=$studios->[0];
|
||||
#print STDERR Dumper($studio);
|
||||
return unless (@$studios==1);
|
||||
#print STDERR Dumper($project);
|
||||
return unless ( @$projects == 1 );
|
||||
|
||||
my $project_name=$project->{name};
|
||||
my $studio_name=$studio->{location};
|
||||
my $studios = studios::get( $config, { project_id => $params->{project_id}, studio_id => $params->{studio_id} } );
|
||||
my $studio = $studios->[0];
|
||||
|
||||
#get series_names
|
||||
my $dbh=db::connect($config);
|
||||
my $query=q{
|
||||
#print STDERR Dumper($studio);
|
||||
return unless ( @$studios == 1 );
|
||||
|
||||
my $project_name = $project->{name};
|
||||
my $studio_name = $studio->{location};
|
||||
|
||||
#get series_names
|
||||
my $dbh = db::connect($config);
|
||||
my $query = q{
|
||||
select project_id, studio_id, series_id, series_name, title
|
||||
from calcms_series s, calcms_project_series ps
|
||||
where s.id=ps.series_id
|
||||
order by series_name, title
|
||||
};
|
||||
my $results=db::get($dbh, $query);
|
||||
my $results = db::get( $dbh, $query );
|
||||
|
||||
# get projects by id
|
||||
my $projects_by_id={};
|
||||
$projects=project::get($config);
|
||||
for my $project (@$projects){
|
||||
$projects_by_id->{$project->{project_id}}=$project;
|
||||
}
|
||||
# get projects by id
|
||||
my $projects_by_id = {};
|
||||
$projects = project::get($config);
|
||||
for my $project (@$projects) {
|
||||
$projects_by_id->{ $project->{project_id} } = $project;
|
||||
}
|
||||
|
||||
# get studios by id
|
||||
my $studios_by_id={};
|
||||
$studios=studios::get($config);
|
||||
for my $studio (@$studios){
|
||||
$studios_by_id->{$studio->{id}}=$studio;
|
||||
}
|
||||
# get studios by id
|
||||
my $studios_by_id = {};
|
||||
$studios = studios::get($config);
|
||||
for my $studio (@$studios) {
|
||||
$studios_by_id->{ $studio->{id} } = $studio;
|
||||
}
|
||||
|
||||
#add project and studio name to series
|
||||
for my $result (@$results){
|
||||
$result->{project_name} = $projects_by_id->{ $result->{project_id} }->{name};
|
||||
$result->{studio_name} = $studios_by_id->{ $result->{studio_id} }->{location};
|
||||
$result->{series_name} = 'Einzelsendung' if $result->{series_name} eq '_single_';
|
||||
}
|
||||
$params->{series}=$results;
|
||||
#add project and studio name to series
|
||||
for my $result (@$results) {
|
||||
$result->{project_name} = $projects_by_id->{ $result->{project_id} }->{name};
|
||||
$result->{studio_name} = $studios_by_id->{ $result->{studio_id} }->{location};
|
||||
$result->{series_name} = 'Einzelsendung' if $result->{series_name} eq '_single_';
|
||||
}
|
||||
$params->{series} = $results;
|
||||
|
||||
# get events not assigned to series
|
||||
my $conditions=[];
|
||||
my $bind_values=[];
|
||||
if($project_name ne''){
|
||||
push @$conditions, 'e.project=?';
|
||||
push @$bind_values, $project_name;
|
||||
}
|
||||
if($studio_name ne''){
|
||||
push @$conditions, 'e.location=?';
|
||||
push @$bind_values, $studio_name;
|
||||
}
|
||||
$conditions=' and '.join(' and ',@$conditions) if(@$conditions>0);
|
||||
$query=qq{
|
||||
# get events not assigned to series
|
||||
my $conditions = [];
|
||||
my $bind_values = [];
|
||||
if ( $project_name ne '' ) {
|
||||
push @$conditions, 'e.project=?';
|
||||
push @$bind_values, $project_name;
|
||||
}
|
||||
if ( $studio_name ne '' ) {
|
||||
push @$conditions, 'e.location=?';
|
||||
push @$bind_values, $studio_name;
|
||||
}
|
||||
$conditions = ' and ' . join( ' and ', @$conditions ) if ( @$conditions > 0 );
|
||||
$query = qq{
|
||||
select e.id, program, project, location, start, series_name, title, episode, rerun
|
||||
from calcms_events e left join calcms_series_events se on se.event_id =e.id
|
||||
where se.event_id is null
|
||||
@@ -155,233 +163,249 @@ sub show_events{
|
||||
order by series_name,title,start
|
||||
limit 1000
|
||||
};
|
||||
print '<pre>'.Dumper($query).Dumper($bind_values).'</pre>';
|
||||
$results=db::get($dbh, $query, $bind_values);
|
||||
# detect title and episode
|
||||
for my $result(@$results){
|
||||
$result->{rerun}.='';
|
||||
if($result->{title}=~/\#(\d+)([a-z])?\s*$/){
|
||||
$result->{episode}=$1 unless defined $result->{episode};
|
||||
$result->{rerun}=$2||'' unless ($result->{rerun}=~/\d/);
|
||||
$result->{title}=~s/\#\d+[a-z]?\s*$//;
|
||||
$result->{title}=~s/\s+$//;
|
||||
}
|
||||
my $a=time::datetime_to_array($result->{start});
|
||||
#print STDERR "($a->[0],$a->[1],$a->[2])\n";
|
||||
$result->{weekday}=time::weekday($a->[0],$a->[1],$a->[2]);
|
||||
$result->{weekday}=$time::names->{de}->{weekdays_abbr}->[$result->{weekday}-1];
|
||||
}
|
||||
#fill template
|
||||
$params->{unassigned_events}= $results;
|
||||
$params->{sum_events} = @$results;
|
||||
$params->{project_name} = $project_name;
|
||||
$params->{studio_name} = $studio_name;
|
||||
print '<pre>' . Dumper($query) . Dumper($bind_values) . '</pre>';
|
||||
$results = db::get( $dbh, $query, $bind_values );
|
||||
|
||||
template::process('print', $params->{template}, $params);
|
||||
# detect title and episode
|
||||
for my $result (@$results) {
|
||||
$result->{rerun} .= '';
|
||||
if ( $result->{title} =~ /\#(\d+)([a-z])?\s*$/ ) {
|
||||
$result->{episode} = $1 unless defined $result->{episode};
|
||||
$result->{rerun} = $2 || '' unless ( $result->{rerun} =~ /\d/ );
|
||||
$result->{title} =~ s/\#\d+[a-z]?\s*$//;
|
||||
$result->{title} =~ s/\s+$//;
|
||||
}
|
||||
my $a = time::datetime_to_array( $result->{start} );
|
||||
|
||||
#print STDERR "($a->[0],$a->[1],$a->[2])\n";
|
||||
$result->{weekday} = time::weekday( $a->[0], $a->[1], $a->[2] );
|
||||
$result->{weekday} = $time::names->{de}->{weekdays_abbr}->[ $result->{weekday} - 1 ];
|
||||
}
|
||||
|
||||
#fill template
|
||||
$params->{unassigned_events} = $results;
|
||||
$params->{sum_events} = @$results;
|
||||
$params->{project_name} = $project_name;
|
||||
$params->{studio_name} = $studio_name;
|
||||
|
||||
template::process( 'print', $params->{template}, $params );
|
||||
}
|
||||
|
||||
sub assign_events {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
sub assign_events{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{assign_series_events}==1){
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{assign_series_events} == 1 ) {
|
||||
uac::permissions_denied('assign_series_events');
|
||||
return;
|
||||
}
|
||||
|
||||
my $entry={};
|
||||
for my $attr ('project_id','studio_id', 'series_id','event_ids'){
|
||||
if (defined $params->{$attr}){
|
||||
$entry->{$attr}=$params->{$attr};
|
||||
}else{
|
||||
uac::print_error($attr.' not given!');
|
||||
my $entry = {};
|
||||
for my $attr ( 'project_id', 'studio_id', 'series_id', 'event_ids' ) {
|
||||
if ( defined $params->{$attr} ) {
|
||||
$entry->{$attr} = $params->{$attr};
|
||||
} else {
|
||||
uac::print_error( $attr . ' not given!' );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$config->{access}->{write}=1;
|
||||
for my $event_id (split(/[\,\s]+/,$params->{event_ids})){
|
||||
next unless $event_id=~/^\d+/;
|
||||
$entry->{event_id}=$event_id;
|
||||
$config->{access}->{write} = 1;
|
||||
for my $event_id ( split( /[\,\s]+/, $params->{event_ids} ) ) {
|
||||
next unless $event_id =~ /^\d+/;
|
||||
$entry->{event_id} = $event_id;
|
||||
|
||||
#get and parse event
|
||||
my $request2={
|
||||
params=>{
|
||||
checked=>events::check_params($config,
|
||||
{
|
||||
event_id => $entry->{event_id},
|
||||
template => 'no',
|
||||
limit => 1,
|
||||
archive => 'all',
|
||||
no_exclude => '1'
|
||||
}
|
||||
)
|
||||
},
|
||||
config => $request->{config},
|
||||
permissions => $request->{permissions}
|
||||
};
|
||||
$request2->{params}->{checked}->{published}='all';
|
||||
my $events=events::get($config, $request2);
|
||||
my $event=$events->[0];
|
||||
unless (defined $event){
|
||||
print STDERR "event not found for project $entry->{project_id}, studio $entry->{studio_id}, series $entry->{series_id}, event $entry->{event_id}\n";
|
||||
next;
|
||||
}
|
||||
print STDERR "'".$event->{event_id}."' '".$event->{series_name}."' '".$event->{title}."' '".$event->{episode}."'\n";
|
||||
#next;
|
||||
#get and parse event
|
||||
my $request2 = {
|
||||
params => {
|
||||
checked => events::check_params(
|
||||
$config,
|
||||
{
|
||||
event_id => $entry->{event_id},
|
||||
template => 'no',
|
||||
limit => 1,
|
||||
archive => 'all',
|
||||
no_exclude => '1'
|
||||
}
|
||||
)
|
||||
},
|
||||
config => $request->{config},
|
||||
permissions => $request->{permissions}
|
||||
};
|
||||
$request2->{params}->{checked}->{published} = 'all';
|
||||
my $events = events::get( $config, $request2 );
|
||||
my $event = $events->[0];
|
||||
unless ( defined $event ) {
|
||||
print STDERR
|
||||
"event not found for project $entry->{project_id}, studio $entry->{studio_id}, series $entry->{series_id}, event $entry->{event_id}\n";
|
||||
next;
|
||||
}
|
||||
print STDERR "'" . $event->{event_id} . "' '" . $event->{series_name} . "' '" . $event->{title} . "' '" . $event->{episode} . "'\n";
|
||||
|
||||
#check if series is assigned to project/studio
|
||||
my $series=series::get(
|
||||
$config,{
|
||||
project_id => $entry->{project_id},
|
||||
studio_id => $entry->{studio_id},
|
||||
series_id => $entry->{series_id},
|
||||
}
|
||||
);
|
||||
if(@$series==0){
|
||||
# assign series to project/studio
|
||||
project::assign_series(
|
||||
$config,{
|
||||
project_id => $entry->{project_id},
|
||||
studio_id => $entry->{studio_id},
|
||||
series_id => $entry->{series_id},
|
||||
}
|
||||
);
|
||||
}else{
|
||||
print STDERR "event $entry->{event_id} already asigned to project $entry->{project_id}, studio $entry->{studio_id}, series $entry->{series_id}\n";
|
||||
}
|
||||
#get series
|
||||
$series=series::get(
|
||||
$config,{
|
||||
project_id => $entry->{project_id},
|
||||
studio_id => $entry->{studio_id},
|
||||
series_id => $entry->{series_id},
|
||||
}
|
||||
);
|
||||
if (@$series==1){
|
||||
my $serie=$series->[0];
|
||||
|
||||
#set event's series name to value from series
|
||||
my $series_name=$serie->{series_name}||'';
|
||||
if ($series_name ne ''){
|
||||
# prepend series_name from event to title on adding to single_events series
|
||||
my $title=$event->{title};
|
||||
if($serie->{has_single_events}eq'1'){
|
||||
$title= $event->{series_name}.' - '.$title if $event->{series_name} ne '';
|
||||
}
|
||||
#next;
|
||||
|
||||
# save event content
|
||||
series_events::save_content(
|
||||
$config, {
|
||||
studio_id => $entry->{studio_id},
|
||||
id => $entry->{event_id}, #TODO: id=> event_id
|
||||
series_name => $series_name,
|
||||
title => $title,
|
||||
episode => $event->{episode},
|
||||
rerun => $event->{rerun},
|
||||
modified_by => $params->{presets}->{user},
|
||||
}
|
||||
);
|
||||
#check if series is assigned to project/studio
|
||||
my $series = series::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $entry->{project_id},
|
||||
studio_id => $entry->{studio_id},
|
||||
series_id => $entry->{series_id},
|
||||
}
|
||||
);
|
||||
if ( @$series == 0 ) {
|
||||
|
||||
# add to history
|
||||
$event->{project_id} = $entry->{project_id};
|
||||
$event->{studio_id} = $entry->{studio_id};
|
||||
$event->{series_id} = $entry->{series_id};
|
||||
$event->{event_id} = $entry->{event_id};
|
||||
$event->{series_name} = $series_name;
|
||||
$event->{title} = $title;
|
||||
$event->{user} = $params->{presets}->{user};
|
||||
event_history::insert($config, $event);
|
||||
|
||||
# print STDERR "ok\n";
|
||||
}
|
||||
}else{
|
||||
print STDERR "no series title found for studio $entry->{studio_id} series $entry->{series_id}, event $entry->{event_id}\n";
|
||||
next;
|
||||
}
|
||||
# assign series to project/studio
|
||||
project::assign_series(
|
||||
$config,
|
||||
{
|
||||
project_id => $entry->{project_id},
|
||||
studio_id => $entry->{studio_id},
|
||||
series_id => $entry->{series_id},
|
||||
}
|
||||
);
|
||||
} else {
|
||||
print STDERR
|
||||
"event $entry->{event_id} already asigned to project $entry->{project_id}, studio $entry->{studio_id}, series $entry->{series_id}\n";
|
||||
}
|
||||
|
||||
#assign event
|
||||
my $result=series::assign_event(
|
||||
$config, {
|
||||
project_id => $entry->{project_id},
|
||||
studio_id => $entry->{studio_id},
|
||||
series_id => $entry->{series_id},
|
||||
event_id => $entry->{event_id},
|
||||
manual => 1
|
||||
}
|
||||
);
|
||||
unless(defined $result){
|
||||
uac::print_error("error on assigning event to series");
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
#get series
|
||||
$series = series::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $entry->{project_id},
|
||||
studio_id => $entry->{studio_id},
|
||||
series_id => $entry->{series_id},
|
||||
}
|
||||
);
|
||||
if ( @$series == 1 ) {
|
||||
my $serie = $series->[0];
|
||||
|
||||
$config->{access}->{write}=0;
|
||||
#set event's series name to value from series
|
||||
my $series_name = $serie->{series_name} || '';
|
||||
if ( $series_name ne '' ) {
|
||||
|
||||
# prepend series_name from event to title on adding to single_events series
|
||||
my $title = $event->{title};
|
||||
if ( $serie->{has_single_events} eq '1' ) {
|
||||
$title = $event->{series_name} . ' - ' . $title if $event->{series_name} ne '';
|
||||
}
|
||||
|
||||
# save event content
|
||||
series_events::save_content(
|
||||
$config,
|
||||
{
|
||||
studio_id => $entry->{studio_id},
|
||||
id => $entry->{event_id}, #TODO: id=> event_id
|
||||
series_name => $series_name,
|
||||
title => $title,
|
||||
episode => $event->{episode},
|
||||
rerun => $event->{rerun},
|
||||
modified_by => $params->{presets}->{user},
|
||||
}
|
||||
);
|
||||
|
||||
# add to history
|
||||
$event->{project_id} = $entry->{project_id};
|
||||
$event->{studio_id} = $entry->{studio_id};
|
||||
$event->{series_id} = $entry->{series_id};
|
||||
$event->{event_id} = $entry->{event_id};
|
||||
$event->{series_name} = $series_name;
|
||||
$event->{title} = $title;
|
||||
$event->{user} = $params->{presets}->{user};
|
||||
event_history::insert( $config, $event );
|
||||
|
||||
# print STDERR "ok\n";
|
||||
}
|
||||
} else {
|
||||
print STDERR "no series title found for studio $entry->{studio_id} series $entry->{series_id}, event $entry->{event_id}\n";
|
||||
next;
|
||||
}
|
||||
|
||||
#assign event
|
||||
my $result = series::assign_event(
|
||||
$config,
|
||||
{
|
||||
project_id => $entry->{project_id},
|
||||
studio_id => $entry->{studio_id},
|
||||
series_id => $entry->{series_id},
|
||||
event_id => $entry->{event_id},
|
||||
manual => 1
|
||||
}
|
||||
);
|
||||
unless ( defined $result ) {
|
||||
uac::print_error("error on assigning event to series");
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
|
||||
$config->{access}->{write} = 0;
|
||||
uac::print_info("event successfully assigned to series");
|
||||
#$params->{getBack}=1;
|
||||
|
||||
#$params->{getBack}=1;
|
||||
}
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
my $checked={};
|
||||
my $checked = {};
|
||||
|
||||
my $debug=$params->{debug} || '';
|
||||
if ($debug=~/([a-z\_\,]+)/){
|
||||
$debug=$1;
|
||||
my $debug = $params->{debug} || '';
|
||||
if ( $debug =~ /([a-z\_\,]+)/ ) {
|
||||
$debug = $1;
|
||||
}
|
||||
$checked->{debug}=$debug;
|
||||
$checked->{debug} = $debug;
|
||||
|
||||
#actions and roles
|
||||
$checked->{action}='';
|
||||
if (defined $params->{action}){
|
||||
if ($params->{action}=~/^(assign_events)$/){
|
||||
$checked->{action}=$params->{action};
|
||||
$checked->{action} = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(assign_events)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
|
||||
#numeric values
|
||||
$checked->{exclude}=0;
|
||||
for my $param ('id', 'project_id', 'studio_id', 'series_id', 'event_id'){
|
||||
if ((defined $params->{$param})&&($params->{$param}=~/^\d+$/)){
|
||||
$checked->{$param}=$params->{$param};
|
||||
$checked->{exclude} = 0;
|
||||
for my $param ( 'id', 'project_id', 'studio_id', 'series_id', 'event_id' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
for my $param ('event_ids'){
|
||||
if ((defined $params->{$param})&&($params->{$param}=~/^[\d,]+$/)){
|
||||
$checked->{$param}=$params->{$param};
|
||||
for my $param ('event_ids') {
|
||||
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($params->{template},'assignments');
|
||||
$checked->{template} = template::check( $params->{template}, 'assignments' );
|
||||
|
||||
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', 'create_events', 'publish_events', 'live', 'count_episodes'){
|
||||
if ((defined $params->{$param})&&($params->{$param}=~/(\d+)/)){
|
||||
$checked->{$param}=$1;
|
||||
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', 'create_events', 'publish_events', 'live', 'count_episodes' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /(\d+)/ ) ) {
|
||||
$checked->{$param} = $1;
|
||||
}
|
||||
}
|
||||
|
||||
#scalars
|
||||
for my $param ('search', 'from', 'till'){
|
||||
if (defined $params->{$param}){
|
||||
$checked->{$param}=$params->{$param};
|
||||
$checked->{$param}=~s/^\s+//g;
|
||||
$checked->{$param}=~s/\s+$//g;
|
||||
for my $param ( 'search', 'from', 'till' ) {
|
||||
if ( defined $params->{$param} ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
$checked->{$param} =~ s/^\s+//g;
|
||||
$checked->{$param} =~ s/\s+$//g;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
886
website/agenda/planung/audio_recordings.cgi
Normal file → Executable file
886
website/agenda/planung/audio_recordings.cgi
Normal file → Executable file
@@ -7,28 +7,12 @@ use strict;
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
#use CGI;
|
||||
use CGI::Simple ();
|
||||
|
||||
use ModPerl::Util ();
|
||||
#use Apache2::Request;
|
||||
#use Apache2::Upload;
|
||||
#use Apache2::Reload;
|
||||
#use Apache2::RequestRec ();
|
||||
#use Apache2::RequestIO ();
|
||||
#use Apache2::RequestUtil ();
|
||||
#use Apache2::ServerRec ();
|
||||
#use Apache2::ServerUtil ();
|
||||
#use Apache2::Connection ();
|
||||
#use Apache2::Log ();
|
||||
#use APR::Table ();
|
||||
#use ModPerl::Registry ();
|
||||
|
||||
use Date::Calc;
|
||||
use Time::Local;
|
||||
use File::Temp;
|
||||
#use File::Copy;
|
||||
#use Digest::MD5::File;
|
||||
|
||||
use config;
|
||||
use log;
|
||||
@@ -39,511 +23,555 @@ use studios;
|
||||
use series;
|
||||
use template;
|
||||
use audio_recordings;
|
||||
use events;
|
||||
use time;
|
||||
|
||||
#$|=1;
|
||||
binmode STDOUT, ":utf8";
|
||||
#print "HTTP/1.1 200 OK\n";
|
||||
|
||||
my $useCgi=0;
|
||||
my $useCgi = 0;
|
||||
|
||||
our $config = config::get('../config/config.cgi');
|
||||
our $debug = $config->{system}->{debug};
|
||||
my $base_dir = $config->{locations}->{base_dir};
|
||||
our $config = config::get('../config/config.cgi');
|
||||
our $debug = $config->{system}->{debug};
|
||||
my $base_dir = $config->{locations}->{base_dir};
|
||||
|
||||
my $tempDir = '/var/tmp';
|
||||
my $uploadLimit = 200_000_000;
|
||||
|
||||
my %params = ();
|
||||
my $error = '';
|
||||
my $cgi = undef;
|
||||
my $fh = undef;
|
||||
|
||||
#### MOD_PERL2
|
||||
# my $req = Apache2::Request->new(
|
||||
# Apache2::RequestUtil->request,
|
||||
# POST_MAX => $uploadLimit,
|
||||
# DISABLE_UPLOADS => 0
|
||||
# );
|
||||
# my $upload = $req->upload('upload');
|
||||
# my $filename = $upload->filename;
|
||||
# my $fh = $upload->fh;
|
||||
# my $file_size = $upload->size;
|
||||
|
||||
#### CGI
|
||||
# $CGI::POST_MAX = $uploadLimit;
|
||||
# $CGI::TMPDIRECTORY = $tempDir;
|
||||
# $cgi = new CGI();
|
||||
# my $handle = $cgi->upload('upload');
|
||||
# $fh = $handle->handle if (defined $handle);
|
||||
# $error = $cgi->cgi_error() || '';
|
||||
# %params = $cgi->Vars();
|
||||
my %params = ();
|
||||
my $error = '';
|
||||
my $cgi = undef;
|
||||
my $fh = undef;
|
||||
|
||||
#### simple CGI
|
||||
$CGI::Simple::POST_MAX = $uploadLimit;
|
||||
$CGI::Simple::DISABLE_UPLOADS = 0;
|
||||
|
||||
$cgi = $cgi = CGI::Simple->new;
|
||||
$cgi = $cgi = CGI::Simple->new;
|
||||
my $filename = $cgi->param('upload');
|
||||
$fh = $cgi->upload($filename);
|
||||
$error = $cgi->cgi_error() || '';
|
||||
%params = $cgi->Vars();
|
||||
$fh = $cgi->upload($filename);
|
||||
$error = $cgi->cgi_error() || '';
|
||||
%params = $cgi->Vars();
|
||||
|
||||
my $params=\%params;
|
||||
my $params = \%params;
|
||||
binmode $fh if defined $fh;
|
||||
|
||||
#print "Content-type:text/html; charset=UTF-8;\n\n";
|
||||
my ($user, $expires) = auth::get_user($cgi, $config);
|
||||
exit if (!defined $user) || ($user eq '');
|
||||
|
||||
my $user_presets = uac::get_user_presets( $config, {
|
||||
user => $user,
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id}
|
||||
});
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
exit if ( !defined $user ) || ( $user eq '' );
|
||||
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$config,
|
||||
{
|
||||
user => $user,
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id}
|
||||
}
|
||||
);
|
||||
|
||||
$params->{default_studio_id} = $user_presets->{studio_id};
|
||||
$params->{studio_id} = $params->{default_studio_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
$params->{project_id} = $user_presets->{project_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
$params->{studio_id} = $params->{default_studio_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
$params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
my $request={
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
|
||||
#delete $params->{presets};
|
||||
#print Dumper($request->{params}->{checked});
|
||||
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
$params = $request->{params}->{checked};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
my $headerParams=uac::set_template_permissions($request->{permissions}, $params);
|
||||
$headerParams->{loc} = localization::get($config, {user=>$user, file=>'menu'});
|
||||
template::process('print', template::check('default.html'), $headerParams);
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( 'print', template::check('default.html'), $headerParams );
|
||||
|
||||
exit unless defined uac::check($config, $params, $user_presets);
|
||||
exit unless defined uac::check( $config, $params, $user_presets );
|
||||
|
||||
print q{
|
||||
<script src="js/audio_recordings.js" type="text/javascript"></script>
|
||||
<link rel="stylesheet" href="css/audio_recordings.css" type="text/css" />
|
||||
}unless(params::isJson);
|
||||
} unless (params::isJson);
|
||||
|
||||
my $permissions = $request->{permissions};
|
||||
my $permissions = $request->{permissions};
|
||||
$params->{action} = '' unless defined $params->{action};
|
||||
$params->{error} = $error || '';
|
||||
$params->{error} = $error || '';
|
||||
|
||||
#print STDERR Dumper($params);
|
||||
|
||||
if ($params->{action} eq 'upload'){
|
||||
uploadRecording($config, $request);
|
||||
}elsif($params->{action} eq 'delete'){
|
||||
deleteRecording($config, $request);
|
||||
if ( $params->{action} eq 'upload' ) {
|
||||
uploadRecording( $config, $request );
|
||||
} elsif ( $params->{action} eq 'delete' ) {
|
||||
deleteRecording( $config, $request );
|
||||
}
|
||||
|
||||
showAudioRecordings($config, $request);
|
||||
showAudioRecordings( $config, $request );
|
||||
|
||||
print STDERR "$0 ERROR: ".$params->{error}."\n" if $params->{error} ne '';
|
||||
$params->{loc} = localization::get($config, {user=>$params->{presets}->{user}, file=>'event,comment'});
|
||||
template::process('print', $params->{template}, $params);
|
||||
#print Dumper($params->{project_id});
|
||||
#delete $params->{presets};
|
||||
#print STDERR Dumper($params);
|
||||
print STDERR "$0 ERROR: " . $params->{error} . "\n" if $params->{error} ne '';
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'event,comment' } );
|
||||
template::process( 'print', $params->{template}, $params );
|
||||
|
||||
exit;
|
||||
|
||||
sub uploadRecording{
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
sub uploadRecording {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
unless ($permissions->{upload_audio_recordings}==1){
|
||||
uac::permissions_denied('upload_audio_recordings');
|
||||
return;
|
||||
}
|
||||
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 upload productions");
|
||||
return;
|
||||
}
|
||||
}
|
||||
unless ( $permissions->{upload_audio_recordings} == 1 ) {
|
||||
uac::permissions_denied('upload_audio_recordings');
|
||||
return;
|
||||
}
|
||||
|
||||
if (defined $fh){
|
||||
print STDERR "upload\n";
|
||||
#print STDERR Dumper($fh)."<br>";
|
||||
my $fileInfo = uploadFile($config, $fh, $params->{event_id}, $user, $params->{upload});
|
||||
$params->{error} .= $fileInfo->{error} if defined $fileInfo->{error};
|
||||
$params->{path} = $fileInfo->{path};
|
||||
$params->{size} = $fileInfo->{size};
|
||||
$params->{duration} = $fileInfo->{duration};
|
||||
$params = updateDatabase($config, $params, $user) if $params->{error} eq '';
|
||||
}else{
|
||||
$params->{error}.='Could not get file handle';
|
||||
}
|
||||
|
||||
if ($params->{error} ne ''){
|
||||
if ($params->{error}=~/limit/){
|
||||
$params->{error} .= "audio file size is limited to ".int( $uploadLimit/1000000 )." MB!"
|
||||
. "Please make it smaller and try again!";
|
||||
}else{
|
||||
$params->{error} .= "Error:'$error'";
|
||||
}
|
||||
}
|
||||
for my $attr ( 'project_id', 'studio_id', 'series_id', 'event_id' ) {
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( "missing " . $attr . " to upload productions" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( defined $fh ) {
|
||||
print STDERR "upload\n";
|
||||
|
||||
#print STDERR Dumper($fh)."<br>";
|
||||
my $fileInfo = uploadFile( $config, $fh, $params->{event_id}, $user, $params->{upload} );
|
||||
$params->{error} .= $fileInfo->{error} if defined $fileInfo->{error};
|
||||
$params->{path} = $fileInfo->{path};
|
||||
$params->{size} = $fileInfo->{size};
|
||||
#$params->{duration} = $fileInfo->{duration};
|
||||
$params = updateDatabase( $config, $params, $user ) if $params->{error} eq '';
|
||||
} else {
|
||||
$params->{error} .= 'Could not get file handle';
|
||||
}
|
||||
|
||||
if ( $params->{error} ne '' ) {
|
||||
if ( $params->{error} =~ /limit/ ) {
|
||||
$params->{error} .=
|
||||
"audio file size is limited to " . int( $uploadLimit / 1000000 ) . " MB!" . "Please make it smaller and try again!";
|
||||
} else {
|
||||
$params->{error} .= "Error:'$error'";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# return 1 if file has been deleted
|
||||
sub deleteFile{
|
||||
my $file=shift;
|
||||
return 0 unless defined $file;
|
||||
|
||||
if (-e $file){
|
||||
if ( -w $file ){
|
||||
unlink $file;
|
||||
# check if file has been deleted
|
||||
if ( -e $file ){
|
||||
uac::print_error("could not delete audio file '$file', $!\n");
|
||||
return 0;
|
||||
}
|
||||
}else{
|
||||
uac::print_error("cannot delete audio file '$file', missing permissions\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
sub deleteFile {
|
||||
my $file = shift;
|
||||
return 0 unless defined $file;
|
||||
|
||||
if ( -e $file ) {
|
||||
if ( -w $file ) {
|
||||
unlink $file;
|
||||
|
||||
# check if file has been deleted
|
||||
if ( -e $file ) {
|
||||
uac::print_error("could not delete audio file '$file', $!\n");
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
uac::print_error("cannot delete audio file '$file', missing permissions\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub deleteRecording{
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
sub deleteRecording {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
unless ($permissions->{delete_audio_recordings}==1){
|
||||
uac::permissions_denied('delete_audio_recordings');
|
||||
return;
|
||||
}
|
||||
|
||||
for my $attr ('project_id', 'studio_id',
|
||||
#'series_id',
|
||||
'event_id', 'path'){
|
||||
unless (defined $params->{$attr}){
|
||||
uac::print_error("missing ".$attr." to delete production");
|
||||
return;
|
||||
}
|
||||
}
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
|
||||
unless ( $permissions->{delete_audio_recordings} == 1 ) {
|
||||
uac::permissions_denied('delete_audio_recordings');
|
||||
return;
|
||||
}
|
||||
|
||||
for my $attr (
|
||||
'project_id', 'studio_id',
|
||||
|
||||
#'series_id',
|
||||
'event_id', 'path'
|
||||
)
|
||||
{
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( "missing " . $attr . " to delete production" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
my $dbh = db::connect($config);
|
||||
$config->{access}->{write} = 0;
|
||||
|
||||
my $audioRecordings = audio_recordings::get($config, {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
event_id => $params->{event_id},
|
||||
path => $params->{path}
|
||||
});
|
||||
|
||||
unless ( (defined $audioRecordings) && (scalar @$audioRecordings >0)){
|
||||
uac::print_error("could not find audio file $params->{path} in database");
|
||||
return;
|
||||
}
|
||||
|
||||
my $targetDir = $config->{locations}->{local_audio_recordings_dir};
|
||||
unless ( defined $targetDir ){
|
||||
uac::print_error("'local_audio_recordings_dir' is not configured.");
|
||||
return;
|
||||
}
|
||||
unless ( -d $targetDir ){
|
||||
uac::print_error("audio dir '$targetDir' does not exist");
|
||||
return;
|
||||
}
|
||||
|
||||
my $file = $targetDir.'/'.$params->{path};
|
||||
print STDERR "ERROR: cannot delete audio file '$file', file does not exist\n" unless -e $file;
|
||||
my $audioRecordings = audio_recordings::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
event_id => $params->{event_id},
|
||||
path => $params->{path}
|
||||
}
|
||||
);
|
||||
|
||||
my $isDeleted = deleteFile($file);
|
||||
return unless $isDeleted;
|
||||
unless ( ( defined $audioRecordings ) && ( scalar @$audioRecordings > 0 ) ) {
|
||||
uac::print_error("could not find audio file $params->{path} in database");
|
||||
return;
|
||||
}
|
||||
|
||||
$config->{access}->{write}=1;
|
||||
$audioRecordings = audio_recordings::delete($config, $dbh, {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
event_id => $params->{event_id},
|
||||
path => $params->{path},
|
||||
});
|
||||
$config->{access}->{write}=0;
|
||||
|
||||
}
|
||||
my $targetDir = $config->{locations}->{local_audio_recordings_dir};
|
||||
unless ( defined $targetDir ) {
|
||||
uac::print_error("'local_audio_recordings_dir' is not configured.");
|
||||
return;
|
||||
}
|
||||
unless ( -d $targetDir ) {
|
||||
uac::print_error("audio dir '$targetDir' does not exist");
|
||||
return;
|
||||
}
|
||||
|
||||
sub showAudioRecordings{
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
my $file = $targetDir . '/' . $params->{path};
|
||||
print STDERR "ERROR: cannot delete audio file '$file', file does not exist\n" unless -e $file;
|
||||
|
||||
for my $attr ('project_id', 'studio_id', 'series_id', 'event_id'){
|
||||
unless (defined $params->{$attr}){
|
||||
uac::print_error("missing ".$attr." to show productions");
|
||||
return;
|
||||
}
|
||||
}
|
||||
my $isDeleted = deleteFile($file);
|
||||
return unless $isDeleted;
|
||||
|
||||
my $event=series::get_event($config, {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
series_id => $params->{series_id},
|
||||
event_id => $params->{event_id}
|
||||
});
|
||||
unless (defined $event){
|
||||
uac::print_error("event not found");
|
||||
}
|
||||
#print '<pre>'.Dumper($event).'</pre>';
|
||||
|
||||
my $audioRecordings = audio_recordings::get($config, {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
event_id => $params->{event_id},
|
||||
});
|
||||
for my $recording (@$audioRecordings){
|
||||
$recording->{size}=~s/(\d)(\d\d\d)$/$1\.$2/g;
|
||||
$recording->{size}=~s/(\d)(\d\d\d\.\d\d\d)$/$1\.$2/g;
|
||||
}
|
||||
|
||||
my $now = time();
|
||||
my $timeZone=$config->{date}->{time_zone};
|
||||
my $start = time::datetime_to_utc($event->{start}, $timeZone);
|
||||
my $end = time::datetime_to_utc($event->{end}, $timeZone);
|
||||
if ($now > $end){
|
||||
uac::print_error("upload is expired due to the show is over");
|
||||
$params->{isOver}=1;
|
||||
}
|
||||
my $days = 24 * 60 * 60;
|
||||
uac::print_warn("show is more than a week ahead") if ( $now + 7 * $days ) < $start;
|
||||
|
||||
$params->{event} = $event;
|
||||
$params->{audio_recordings} = $audioRecordings;
|
||||
|
||||
}
|
||||
|
||||
sub uploadFile{
|
||||
my $config = $_[0];
|
||||
my $fh = $_[1];
|
||||
my $eventId = $_[2];
|
||||
my $user = $_[3] || '';
|
||||
my $filename = $_[4] || '';
|
||||
|
||||
# check target directory
|
||||
my $targetDir = $config->{locations}->{local_audio_recordings_dir};
|
||||
return { error => "could not find local_audio_recordings_dir" } unless defined $targetDir;
|
||||
return { error => "local_audio_recordings_dir does not exist" } unless -e $targetDir;
|
||||
|
||||
# save file to disk
|
||||
my $userName = $user;
|
||||
$userName =~ s/[^a-zA-Z0-9\.\-\_]//g;
|
||||
|
||||
my $time = time::time_to_datetime();
|
||||
$time =~ s/\:/\-/g;
|
||||
$time =~ s/\s/\_/g;
|
||||
$time =~ s/[^a-zA-Z0-9\.\-\_]//g;
|
||||
|
||||
$filename =~ s/[^a-zA-Z0-9\.\-\_]//g;
|
||||
$filename =~ s/\.(mp3)$//g;
|
||||
$filename = join('-', ($time, 'id'.$eventId, $userName, $filename)).'.mp3';
|
||||
|
||||
my $tempFile = $targetDir.'/'.$filename;
|
||||
print STDERR "tempFile=$tempFile\n";
|
||||
|
||||
my $start = time();
|
||||
open DAT, '>', $tempFile or return { error => 'could not save upload. '.$!." ".$tempFile };
|
||||
binmode DAT;
|
||||
my $size=0;
|
||||
my $data='';
|
||||
while( my $bytesRead = $fh->read( $data, 65000) ){
|
||||
print DAT $data;
|
||||
$size += $bytesRead;
|
||||
$data='';
|
||||
}
|
||||
close DAT;
|
||||
|
||||
# get filename from content
|
||||
#my $md5Filename = Digest::MD5::File::file_md5_hex($tempFile);
|
||||
#$md5Filename = ~s/[\/\+]+/_/g;
|
||||
#print STDERR "md5Filename=$md5Filename\n";
|
||||
|
||||
## rename file to name from content
|
||||
#my $targetFilename = $eventId.'-'.$md5Filename.'-'.$userName.'-'.$time.'.mp3';
|
||||
#my $targetFile = $targetDir.'/'.$targetFilename;
|
||||
#print STDERR "targetFile=$targetFile\n";
|
||||
#File::Copy::move( $tempFile, $targetFile);
|
||||
#return { error => 'could not create $targetFile' } unless -e $targetFile;
|
||||
|
||||
return {
|
||||
dir => $targetDir,
|
||||
path => $filename,
|
||||
size => $size,
|
||||
};
|
||||
$config->{access}->{write} = 1;
|
||||
$audioRecordings = audio_recordings::delete(
|
||||
$config, $dbh,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
event_id => $params->{event_id},
|
||||
path => $params->{path},
|
||||
}
|
||||
);
|
||||
$config->{access}->{write} = 0;
|
||||
|
||||
}
|
||||
|
||||
sub updateDatabase{
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
my $user = shift;
|
||||
|
||||
my $entry={
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
event_id => $params->{event_id},
|
||||
path => $params->{path},
|
||||
md5 => $params->{md5}||'',
|
||||
size => $params->{size},
|
||||
created_by => $user
|
||||
};
|
||||
print STDERR "updateDatabase:".Dumper($entry);
|
||||
sub showAudioRecordings {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
#connect
|
||||
$config->{access}->{write}=1;
|
||||
my $dbh=db::connect($config);
|
||||
|
||||
my $entries = audio_recordings::get(
|
||||
$config, {
|
||||
project_id => $entry->{project_id},
|
||||
studio_id => $entry->{studio_id},
|
||||
event_id => $entry->{event_id},
|
||||
path => $entry->{path}
|
||||
}
|
||||
);
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
|
||||
if ( (defined $entries) && (scalar @$entries > 0) ){
|
||||
print STDERR "update\n";
|
||||
audio_recordings::update($config, $dbh, $entry);
|
||||
my $entry = $entries->[0];
|
||||
$params->{id} = $entry->{id};
|
||||
}else{
|
||||
print STDERR "insert\n";
|
||||
$entry->{created_by} = $user;
|
||||
$params->{id} = audio_recordings::insert($config, $dbh, $entry);
|
||||
}
|
||||
$config->{access}->{write} = 0;
|
||||
$params->{action_result} = 'done!';
|
||||
for my $attr ( 'project_id', 'studio_id', 'series_id', 'event_id' ) {
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( "missing " . $attr . " to show productions" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return $params;
|
||||
my $event = series::get_event(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
series_id => $params->{series_id},
|
||||
event_id => $params->{event_id}
|
||||
}
|
||||
);
|
||||
unless ( defined $event ) {
|
||||
uac::print_error("event not found");
|
||||
return;
|
||||
}
|
||||
|
||||
#print '<pre>'.Dumper($event).'</pre>';
|
||||
|
||||
my $audioRecordings = audio_recordings::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
event_id => $params->{event_id},
|
||||
}
|
||||
);
|
||||
for my $recording (@$audioRecordings) {
|
||||
$recording->{size} =~ s/(\d)(\d\d\d)$/$1\.$2/g;
|
||||
$recording->{size} =~ s/(\d)(\d\d\d\.\d\d\d)$/$1\.$2/g;
|
||||
|
||||
$recording->{processed} = $recording->{processed} ? 'yes' : 'no';
|
||||
$recording->{mastered} = $recording->{mastered} ? 'yes' : 'no';
|
||||
|
||||
$recording->{eventDuration} = getDuration( $recording->{eventDuration} );
|
||||
$recording->{audioDuration} = getDuration( $recording->{audioDuration} );
|
||||
|
||||
$recording->{rmsLeft} ||= '-';
|
||||
$recording->{rmsRight} ||= '-';
|
||||
}
|
||||
|
||||
my $now = time();
|
||||
my $timeZone = $config->{date}->{time_zone};
|
||||
my $start = time::datetime_to_utc( $event->{start}, $timeZone );
|
||||
my $end = time::datetime_to_utc( $event->{end}, $timeZone );
|
||||
if ( $now > $end ) {
|
||||
uac::print_error("upload is expired due to the show is over");
|
||||
$params->{isOver} = 1;
|
||||
}
|
||||
my $days = 24 * 60 * 60;
|
||||
uac::print_warn("show is more than a week ahead") if ( $now + 7 * $days ) < $start;
|
||||
|
||||
$params->{event} = $event;
|
||||
$params->{audio_recordings} = $audioRecordings;
|
||||
|
||||
}
|
||||
|
||||
sub getDuration{
|
||||
my $duration=shift;
|
||||
my $hour = int($duration / 3600);
|
||||
$duration -= $hour * 3600;
|
||||
|
||||
my $minutes = int($duration / 60);
|
||||
$duration -= $minutes * 60;
|
||||
|
||||
my $seconds = int($duration);
|
||||
$duration -= $seconds;
|
||||
|
||||
my $milli= int(100 * $duration);
|
||||
return sprintf("%02d:%02d:%02d.%02d",$hour, $minutes, $seconds, $milli);
|
||||
}
|
||||
|
||||
sub uploadFile {
|
||||
my $config = $_[0];
|
||||
my $fh = $_[1];
|
||||
my $eventId = $_[2];
|
||||
my $user = $_[3] || '';
|
||||
my $filename = $_[4] || '';
|
||||
|
||||
# check target directory
|
||||
my $targetDir = $config->{locations}->{local_audio_recordings_dir};
|
||||
return { error => "could not find local_audio_recordings_dir" } unless defined $targetDir;
|
||||
return { error => "local_audio_recordings_dir does not exist" } unless -e $targetDir;
|
||||
|
||||
# save file to disk
|
||||
my $userName = $user;
|
||||
$userName =~ s/[^a-zA-Z0-9\.\-\_]//g;
|
||||
|
||||
my $time = time::time_to_datetime();
|
||||
$time =~ s/\:/\-/g;
|
||||
$time =~ s/\s/\_/g;
|
||||
$time =~ s/[^a-zA-Z0-9\.\-\_]//g;
|
||||
|
||||
$filename =~ s/\.(mp3)$//g;
|
||||
$filename = join( '-', ( $time, 'id' . $eventId, $userName, $filename ) ) . '.mp3';
|
||||
$filename =~ s/[^a-zA-Z0-9\.\-\_]//g;
|
||||
|
||||
my $tempFile = $targetDir . '/' . $filename;
|
||||
print STDERR "tempFile=$tempFile\n";
|
||||
|
||||
my $start = time();
|
||||
open DAT, '>', $tempFile or return { error => 'could not save upload. ' . $! . " " . $tempFile };
|
||||
binmode DAT;
|
||||
my $size = 0;
|
||||
my $data = '';
|
||||
while ( my $bytesRead = $fh->read( $data, 65000 ) ) {
|
||||
print DAT $data;
|
||||
$size += $bytesRead;
|
||||
$data = '';
|
||||
}
|
||||
close DAT;
|
||||
|
||||
return {
|
||||
dir => $targetDir,
|
||||
path => $filename,
|
||||
size => $size,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
sub updateDatabase {
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
my $user = shift;
|
||||
|
||||
my $eventDuration = getEventDuration($config, $params->{event_id});
|
||||
|
||||
my $entry = {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
event_id => $params->{event_id},
|
||||
path => $params->{path},
|
||||
md5 => $params->{md5} || '',
|
||||
size => $params->{size},
|
||||
created_by => $user,
|
||||
eventDuration => $eventDuration,
|
||||
};
|
||||
#print STDERR "updateDatabase:" . Dumper($entry);
|
||||
|
||||
#connect
|
||||
$config->{access}->{write} = 1;
|
||||
my $dbh = db::connect($config);
|
||||
|
||||
my $entries = audio_recordings::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $entry->{project_id},
|
||||
studio_id => $entry->{studio_id},
|
||||
event_id => $entry->{event_id},
|
||||
path => $entry->{path}
|
||||
}
|
||||
);
|
||||
|
||||
if ( ( defined $entries ) && ( scalar @$entries > 0 ) ) {
|
||||
print STDERR "update\n";
|
||||
audio_recordings::update( $config, $dbh, $entry );
|
||||
my $entry = $entries->[0];
|
||||
$params->{id} = $entry->{id};
|
||||
} else {
|
||||
print STDERR "insert\n";
|
||||
$entry->{created_by} = $user;
|
||||
$params->{id} = audio_recordings::insert( $config, $dbh, $entry );
|
||||
}
|
||||
$config->{access}->{write} = 0;
|
||||
$params->{action_result} = 'done!';
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
# return filename, filehandle and optionally error from upload
|
||||
sub getFilename{
|
||||
my $cgi = shift;
|
||||
my $upload = shift;
|
||||
sub getFilename {
|
||||
my $cgi = shift;
|
||||
my $upload = shift;
|
||||
|
||||
if (defined $upload){
|
||||
# try apache2 module
|
||||
my $filename = $upload->filename();
|
||||
return {
|
||||
filename => $filename,
|
||||
fh => $upload->fh(),
|
||||
error => ''
|
||||
};
|
||||
if ( defined $upload ) {
|
||||
|
||||
}
|
||||
# try apache2 module
|
||||
my $filename = $upload->filename();
|
||||
return {
|
||||
filename => $filename,
|
||||
fh => $upload->fh(),
|
||||
error => ''
|
||||
};
|
||||
|
||||
#print STDERR "cgi:".Dumper($cgi);
|
||||
|
||||
# fallback to CGI module
|
||||
my $file = $cgi->param("upload");
|
||||
return { error => "is no file" } if (defined $file) && ($file=~/\|/);
|
||||
}
|
||||
|
||||
#print STDERR "file:".Dumper($file);
|
||||
my $fileInfo = $cgi->uploadInfo($file);
|
||||
#print STDERR "fileInfo:".Dumper($fileInfo);
|
||||
#print STDERR "cgi:".Dumper($cgi);
|
||||
|
||||
if (defined $fileInfo){
|
||||
my $filename=$fileInfo->{'Content-Disposition'}||'';
|
||||
if ($filename=~/filename=\"(.*?)\"/){
|
||||
$filename=$1;
|
||||
return {
|
||||
filename => $filename,
|
||||
fh => $file,
|
||||
error => ''
|
||||
};
|
||||
# fallback to CGI module
|
||||
my $file = $cgi->param("upload");
|
||||
return { error => "is no file" } if ( defined $file ) && ( $file =~ /\|/ );
|
||||
|
||||
}
|
||||
}
|
||||
#print STDERR "file:".Dumper($file);
|
||||
my $fileInfo = $cgi->uploadInfo($file);
|
||||
|
||||
#error
|
||||
return {
|
||||
error => 'Could not detect file name!'
|
||||
};
|
||||
#print STDERR "fileInfo:".Dumper($fileInfo);
|
||||
|
||||
if ( defined $fileInfo ) {
|
||||
my $filename = $fileInfo->{'Content-Disposition'} || '';
|
||||
if ( $filename =~ /filename=\"(.*?)\"/ ) {
|
||||
$filename = $1;
|
||||
return {
|
||||
filename => $filename,
|
||||
fh => $file,
|
||||
error => ''
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#error
|
||||
return { error => 'Could not detect file name!' };
|
||||
}
|
||||
|
||||
# get extension and optionally error
|
||||
sub checkFilename{
|
||||
my $filename = shift;
|
||||
sub checkFilename {
|
||||
my $filename = shift;
|
||||
|
||||
my @validExtensions=('mp3');
|
||||
if($filename =~ /\.([a-zA-Z]{3,5})$/){
|
||||
my $extension = lc $1;
|
||||
unless(grep(/$extension/, @validExtensions)) {
|
||||
return {
|
||||
error => 'Following file formats are supported: '.join(",", @validExtensions).'!'
|
||||
};
|
||||
}
|
||||
return{
|
||||
extension => $extension,
|
||||
error => ''
|
||||
};
|
||||
my @validExtensions = ('mp3');
|
||||
if ( $filename =~ /\.([a-zA-Z]{3,5})$/ ) {
|
||||
my $extension = lc $1;
|
||||
unless ( grep( /$extension/, @validExtensions ) ) {
|
||||
return { error => 'Following file formats are supported: ' . join( ",", @validExtensions ) . '!' };
|
||||
}
|
||||
return {
|
||||
extension => $extension,
|
||||
error => ''
|
||||
};
|
||||
}
|
||||
return { error => 'Not matching file extension found! Supported are: ' . join( ",", @validExtensions ) . '!' };
|
||||
}
|
||||
|
||||
# return event duration in seconds
|
||||
sub getEventDuration{
|
||||
my $config = shift;
|
||||
my $eventId = shift;
|
||||
|
||||
if ($eventId<1){
|
||||
print STDERR "invalid eventId $eventId\n";
|
||||
return 0;
|
||||
}
|
||||
return {
|
||||
error => 'Not matching file extension found! Supported are: '.join(",", @validExtensions).'!'
|
||||
};
|
||||
|
||||
my $request = {
|
||||
params => {
|
||||
checked => events::check_params(
|
||||
$config,
|
||||
{
|
||||
event_id => $eventId,
|
||||
template => 'no',
|
||||
limit => 1,
|
||||
}
|
||||
)
|
||||
},
|
||||
config => $config
|
||||
};
|
||||
my $events = events::get( $config, $request );
|
||||
if (scalar @$events == 0){
|
||||
print STDERR "getEventDuration: no event found with event_id=$eventId\n";
|
||||
};
|
||||
my $event = $events->[0];
|
||||
my $duration = time::get_duration_seconds( $event->{start}, $event->{end}, $config->{date}->{time_zone} );
|
||||
return $duration;
|
||||
}
|
||||
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
my $checked={};
|
||||
$checked->{error}='';
|
||||
$checked->{template} = template::check($params->{template}, 'upload_audio_recordings');
|
||||
my $checked = {};
|
||||
$checked->{error} = '';
|
||||
$checked->{template} = template::check( $params->{template}, 'upload_audio_recordings' );
|
||||
|
||||
#print Dumper($params);
|
||||
#numeric values
|
||||
for my $param ('project_id', 'studio_id', 'default_studio_id', 'series_id', 'event_id','id'){
|
||||
if ((defined $params->{$param})&&($params->{$param}=~/^\d+$/)){
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
if (defined $checked->{studio_id}){
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
}else{
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
#print Dumper($params);
|
||||
#numeric values
|
||||
for my $param ( 'project_id', 'studio_id', 'default_studio_id', 'series_id', 'event_id', 'id' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
if ( defined $checked->{studio_id} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
|
||||
#word
|
||||
for my $param ('debug', 'name', 'description'){
|
||||
if ((defined $params->{$param}) && ($params->{$param}=~/^\s*(.+?)\s*$/)){
|
||||
$checked->{$param} = $1;
|
||||
}
|
||||
}
|
||||
|
||||
# words
|
||||
for my $attr('action','path'){
|
||||
if ((defined $params->{$attr}) && ($params->{$attr}=~/(\S+)/)){
|
||||
$checked->{$attr} = $params->{$attr};
|
||||
}
|
||||
}
|
||||
|
||||
$checked->{upload} = $params->{upload};
|
||||
return $checked;
|
||||
#word
|
||||
for my $param ( 'debug', 'name', 'description' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\s*(.+?)\s*$/ ) ) {
|
||||
$checked->{$param} = $1;
|
||||
}
|
||||
}
|
||||
|
||||
# words
|
||||
for my $attr ( 'action', 'path' ) {
|
||||
if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /(\S+)/ ) ) {
|
||||
$checked->{$attr} = $params->{$attr};
|
||||
}
|
||||
}
|
||||
|
||||
$checked->{upload} = $params->{upload};
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
|
||||
2763
website/agenda/planung/calendar.cgi
Normal file → Executable file
2763
website/agenda/planung/calendar.cgi
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
469
website/agenda/planung/comment.cgi
Normal file → Executable file
469
website/agenda/planung/comment.cgi
Normal file → Executable file
@@ -15,12 +15,14 @@ use template;
|
||||
use db;
|
||||
use auth;
|
||||
use uac;
|
||||
|
||||
#use roles;
|
||||
use time;
|
||||
use markup;
|
||||
use project;
|
||||
use studios;
|
||||
use comments;
|
||||
|
||||
#use events;
|
||||
#use series;
|
||||
#use series_dates;
|
||||
@@ -30,295 +32,300 @@ use localization;
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my ($user,$expires) = auth::get_user($cgi, $config);
|
||||
return if ((!defined $user) || ($user eq ''));
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
my $user_presets=uac::get_user_presets($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'));
|
||||
$params->{project_id}=$user_presets->{project_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$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' ) );
|
||||
$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),
|
||||
},
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
|
||||
#set user at params->presets->user
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
$params=$request->{params}->{checked};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
#print Dumper($params);
|
||||
#show header
|
||||
if ((params::isJson()) || (defined $params->{action})){
|
||||
print "Content-Type:text/html; charset=utf-8;\n\n";
|
||||
}else{
|
||||
my $headerParams=uac::set_template_permissions($request->{permissions}, $params);
|
||||
$headerParams->{loc} = localization::get($config, {user=>$user, file=>'menu'});
|
||||
template::process('print', template::check('default.html'), $headerParams);
|
||||
print q{
|
||||
if ( ( params::isJson() ) || ( defined $params->{action} ) ) {
|
||||
print "Content-Type:text/html; charset=utf-8;\n\n";
|
||||
} else {
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( 'print', template::check('default.html'), $headerParams );
|
||||
print q{
|
||||
<script src="js/datetime.js" type="text/javascript"></script>
|
||||
}unless(params::isJson);
|
||||
} unless (params::isJson);
|
||||
}
|
||||
return unless defined uac::check($config, $params, $user_presets);
|
||||
return unless defined uac::check( $config, $params, $user_presets );
|
||||
|
||||
if (defined $params->{action}){
|
||||
if ($params->{action} eq 'get_json') {
|
||||
getJson($config, $request);
|
||||
return;
|
||||
}
|
||||
if ($params->{action} eq 'setLock'){
|
||||
setLock($config, $request);
|
||||
return;
|
||||
}
|
||||
if ($params->{action} eq 'setRead'){
|
||||
setRead($config, $request);
|
||||
return;
|
||||
}
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} eq 'get_json' ) {
|
||||
getJson( $config, $request );
|
||||
return;
|
||||
}
|
||||
if ( $params->{action} eq 'setLock' ) {
|
||||
setLock( $config, $request );
|
||||
return;
|
||||
}
|
||||
if ( $params->{action} eq 'setRead' ) {
|
||||
setRead( $config, $request );
|
||||
return;
|
||||
}
|
||||
}
|
||||
$config->{access}->{write}=0;
|
||||
showComments($config, $request);
|
||||
$config->{access}->{write} = 0;
|
||||
showComments( $config, $request );
|
||||
|
||||
sub showComments {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
sub showComments{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{read_comment} == 1 ) {
|
||||
uac::permissions_denied('read_comment');
|
||||
return;
|
||||
}
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{read_comment}==1){
|
||||
uac::permissions_denied('read_comment');
|
||||
return;
|
||||
}
|
||||
for my $attr ( 'project_id', 'studio_id' ) {
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( "missing " . $attr . " to show comment" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for my $attr ('project_id','studio_id'){
|
||||
unless (defined $params->{$attr}){
|
||||
uac::print_error("missing ".$attr." to show comment");
|
||||
return;
|
||||
}
|
||||
}
|
||||
$config->{access}->{write} = 0;
|
||||
my $dbh = db::connect($config);
|
||||
|
||||
$config->{access}->{write}=0;
|
||||
my $dbh=db::connect($config);
|
||||
my $comment = $params->{comment};
|
||||
my $template_parameters = {};
|
||||
|
||||
my $comment =$params->{comment};
|
||||
my $template_parameters={};
|
||||
#my $nodes={};
|
||||
#my $sorted_nodes=[];
|
||||
|
||||
#my $nodes={};
|
||||
#my $sorted_nodes=[];
|
||||
my $results = [];
|
||||
if ( $params->{search} ne '' ) {
|
||||
$params->{comment}->{search} = $params->{search};
|
||||
$results = comments::get_by_event( $dbh, $config, $request );
|
||||
} elsif ( $comment->{event_id} ne '' ) {
|
||||
$results = comments::get_by_event( $dbh, $config, $request );
|
||||
} else {
|
||||
$results = comments::get_by_time( $dbh, $config, $comment );
|
||||
}
|
||||
|
||||
my $results=[];
|
||||
if ($params->{search} ne ''){
|
||||
$params->{comment}->{search}=$params->{search};
|
||||
$results=comments::get_by_event($dbh, $config, $request);
|
||||
}elsif ($comment->{event_id} ne ''){
|
||||
$results=comments::get_by_event($dbh, $config, $request);
|
||||
}else{
|
||||
$results=comments::get_by_time($dbh, $config, $comment);
|
||||
}
|
||||
|
||||
my $events=[];
|
||||
my $comment_count=0;
|
||||
if (@$results>0){
|
||||
my $comments=modify_comments($request, $results);
|
||||
my $events = [];
|
||||
my $comment_count = 0;
|
||||
if ( @$results > 0 ) {
|
||||
my $comments = modify_comments( $request, $results );
|
||||
|
||||
$comments=comments::sort($config, $comments);
|
||||
$comments = comments::sort( $config, $comments );
|
||||
|
||||
$events=comments::get_events($dbh, $config, $request, $comments);
|
||||
my $language= $config::config->{date}->{language} || 'en';
|
||||
for my $event(@$events){
|
||||
$event->{start}=time::date_time_format($event->{start}, $language);
|
||||
$comment_count+=$event->{comment_count} if (defined $event->{comment_count});
|
||||
$event->{cache_base_url} =$config::config->{cache}->{base_url};
|
||||
}
|
||||
}
|
||||
for my $param (%$comment){
|
||||
$template_parameters->{$param} = $comment->{$param};
|
||||
}
|
||||
$events = comments::get_events( $dbh, $config, $request, $comments );
|
||||
my $language = $config::config->{date}->{language} || 'en';
|
||||
for my $event (@$events) {
|
||||
$event->{start} = time::date_time_format( $event->{start}, $language );
|
||||
$comment_count += $event->{comment_count} if ( defined $event->{comment_count} );
|
||||
$event->{cache_base_url} = $config::config->{cache}->{base_url};
|
||||
}
|
||||
}
|
||||
for my $param (%$comment) {
|
||||
$template_parameters->{$param} = $comment->{$param};
|
||||
}
|
||||
|
||||
$template_parameters->{search} = markup::fix_utf8($request->{params}->{original}->{search});
|
||||
$template_parameters->{events} = $events;
|
||||
$template_parameters->{debug} = $config->{system}->{debug};
|
||||
$template_parameters->{event_count} = @$events+0;
|
||||
$template_parameters->{comment_count} = $comment_count;
|
||||
$template_parameters->{is_empty} = 1 if (@$events==0);
|
||||
$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'});
|
||||
#fill and output template
|
||||
template::process('print', $params->{template}, $template_parameters);
|
||||
$template_parameters->{search} = markup::fix_utf8( $request->{params}->{original}->{search} );
|
||||
$template_parameters->{events} = $events;
|
||||
$template_parameters->{debug} = $config->{system}->{debug};
|
||||
$template_parameters->{event_count} = @$events + 0;
|
||||
$template_parameters->{comment_count} = $comment_count;
|
||||
$template_parameters->{is_empty} = 1 if ( @$events == 0 );
|
||||
$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' } );
|
||||
|
||||
#fill and output template
|
||||
template::process( 'print', $params->{template}, $template_parameters );
|
||||
}
|
||||
|
||||
sub modify_comments{
|
||||
my $request=shift;
|
||||
my $results=shift;
|
||||
sub modify_comments {
|
||||
my $request = shift;
|
||||
my $results = shift;
|
||||
|
||||
my $language = $config::config->{date}->{language} || 'en';
|
||||
for my $result (@$results){
|
||||
$result->{start_date_name} = time::date_format($result->{created_at}, $language);
|
||||
$result->{start_time_name} = time::time_format($result->{created_at});
|
||||
$result->{$result->{lock_status}} = 1;
|
||||
$result->{$result->{news_status}} = 1;
|
||||
}
|
||||
return $results;
|
||||
my $language = $config::config->{date}->{language} || 'en';
|
||||
for my $result (@$results) {
|
||||
$result->{start_date_name} = time::date_format( $result->{created_at}, $language );
|
||||
$result->{start_time_name} = time::time_format( $result->{created_at} );
|
||||
$result->{ $result->{lock_status} } = 1;
|
||||
$result->{ $result->{news_status} } = 1;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
sub setLock{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub setLock {
|
||||
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_comment_status_lock}==1){
|
||||
uac::permissions_denied('update_comment_status_lock');
|
||||
return;
|
||||
}
|
||||
unless ( $permissions->{update_comment_status_lock} == 1 ) {
|
||||
uac::permissions_denied('update_comment_status_lock');
|
||||
return;
|
||||
}
|
||||
|
||||
my $comment =$params->{comment};
|
||||
$comment->{id} = $comment->{comment_id};
|
||||
if ($comment->{id} eq ''){
|
||||
return
|
||||
}
|
||||
|
||||
#todo change set_news_status to lock_status in comment module
|
||||
$comment->{set_lock_status}=$comment->{lockStatus};
|
||||
$comment->{set_lock_status}='blocked' unless $comment->{set_lock_status} eq 'show';
|
||||
my $comment = $params->{comment};
|
||||
$comment->{id} = $comment->{comment_id};
|
||||
if ( $comment->{id} eq '' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$config->{access}->{write}=1;
|
||||
my $dbh=db::connect($config);
|
||||
print STDERR "setLock ".Dumper($comment);
|
||||
comments::set_lock_status($dbh, $config, $comment);
|
||||
print "done\n";
|
||||
#todo change set_news_status to lock_status in comment module
|
||||
$comment->{set_lock_status} = $comment->{lockStatus};
|
||||
$comment->{set_lock_status} = 'blocked' unless $comment->{set_lock_status} eq 'show';
|
||||
|
||||
$config->{access}->{write} = 1;
|
||||
my $dbh = db::connect($config);
|
||||
print STDERR "setLock " . Dumper($comment);
|
||||
comments::set_lock_status( $dbh, $config, $comment );
|
||||
print "done\n";
|
||||
}
|
||||
|
||||
sub setRead{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub setRead {
|
||||
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_comment_status_read}==1){
|
||||
uac::permissions_denied('update_comment_status_read');
|
||||
return;
|
||||
}
|
||||
unless ( $permissions->{update_comment_status_read} == 1 ) {
|
||||
uac::permissions_denied('update_comment_status_read');
|
||||
return;
|
||||
}
|
||||
|
||||
$config->{access}->{write}=1;
|
||||
my $dbh=db::connect($config);
|
||||
$config->{access}->{write} = 1;
|
||||
my $dbh = db::connect($config);
|
||||
|
||||
my $comment =$params->{comment};
|
||||
$comment->{id} = $comment->{comment_id};
|
||||
if ($comment->{id} eq ''){
|
||||
return;
|
||||
}
|
||||
my $comment = $params->{comment};
|
||||
$comment->{id} = $comment->{comment_id};
|
||||
if ( $comment->{id} eq '' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
#todo change set_news_status to read_status in comment module
|
||||
$comment->{set_news_status}=$comment->{readStatus};
|
||||
$comment->{set_news_status}='received' unless $comment->{set_news_status} eq 'unread';
|
||||
|
||||
print STDERR "setRead ".Dumper($comment);
|
||||
comments::set_news_status($dbh, $config, $comment);
|
||||
print "done\n";
|
||||
#todo change set_news_status to read_status in comment module
|
||||
$comment->{set_news_status} = $comment->{readStatus};
|
||||
$comment->{set_news_status} = 'received' unless $comment->{set_news_status} eq 'unread';
|
||||
|
||||
print STDERR "setRead " . Dumper($comment);
|
||||
comments::set_news_status( $dbh, $config, $comment );
|
||||
print "done\n";
|
||||
}
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
my $checked={};
|
||||
my $checked = {};
|
||||
|
||||
#actions
|
||||
#actions
|
||||
|
||||
if (defined $params->{action}){
|
||||
if ($params->{action}=~/^(setLock|setRead|showComment)$/){
|
||||
$checked->{action}=$params->{action};
|
||||
}
|
||||
}
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(setLock|setRead|showComment)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
|
||||
#template
|
||||
my $template='';
|
||||
if (defined $checked->{action}) {
|
||||
$template=template::check($params->{template},'edit_comment') if $checked->{action}eq'showComment';
|
||||
}else{
|
||||
$template=template::check($params->{template},'comments');
|
||||
}
|
||||
$checked->{template}=$template;
|
||||
#template
|
||||
my $template = '';
|
||||
if ( defined $checked->{action} ) {
|
||||
$template = template::check( $params->{template}, 'edit_comment' ) if $checked->{action} eq 'showComment';
|
||||
} else {
|
||||
$template = template::check( $params->{template}, 'comments' );
|
||||
}
|
||||
$checked->{template} = $template;
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
my $comment={};
|
||||
my $comment = {};
|
||||
|
||||
for my $key ('readStatus'){
|
||||
my $value=$params->{$key};
|
||||
$comment->{$key} = $value if (defined $value) && ($value=~/^(received|unread)$/);
|
||||
}
|
||||
for my $key ('readStatus') {
|
||||
my $value = $params->{$key};
|
||||
$comment->{$key} = $value if ( defined $value ) && ( $value =~ /^(received|unread)$/ );
|
||||
}
|
||||
|
||||
for my $key ('lockStatus'){
|
||||
my $value=$params->{$key};
|
||||
$comment->{$key} = $value if (defined $value) && ($value=~/^(blocked|show)$/);
|
||||
}
|
||||
for my $key ('lockStatus') {
|
||||
my $value = $params->{$key};
|
||||
$comment->{$key} = $value if ( defined $value ) && ( $value =~ /^(blocked|show)$/ );
|
||||
}
|
||||
|
||||
$comment->{event_start}=time::check_date($params->{event_start})||'';
|
||||
$comment->{from}=time::check_date($params->{from})||'';
|
||||
$comment->{till}=time::check_date($params->{till})||'';
|
||||
$comment->{event_start} = time::check_date( $params->{event_start} ) || '';
|
||||
$comment->{from} = time::check_date( $params->{from} ) || '';
|
||||
$comment->{till} = time::check_date( $params->{till} ) || '';
|
||||
|
||||
my $event_id=$params->{event_id}||'';
|
||||
if ($event_id=~/^(\d+)$/){
|
||||
$comment->{event_id}=$1;
|
||||
}else{
|
||||
# error('invalid event_id');
|
||||
}
|
||||
$comment->{event_id}='' unless defined $comment->{event_id};
|
||||
my $event_id = $params->{event_id} || '';
|
||||
if ( $event_id =~ /^(\d+)$/ ) {
|
||||
$comment->{event_id} = $1;
|
||||
} else {
|
||||
|
||||
my $id=$params->{comment_id}||'';
|
||||
if ($id=~/^(\d+)$/){
|
||||
$comment->{comment_id}=$1;
|
||||
}
|
||||
$comment->{comment_id}='' unless defined $comment->{comment_id};
|
||||
# error('invalid event_id');
|
||||
}
|
||||
$comment->{event_id} = '' unless defined $comment->{event_id};
|
||||
|
||||
my $age=$params->{age}||'';
|
||||
if ($age=~/^(\d+)$/){
|
||||
$comment->{age}=$1;
|
||||
}
|
||||
$comment->{age}='365' unless defined $comment->{age};
|
||||
my $id = $params->{comment_id} || '';
|
||||
if ( $id =~ /^(\d+)$/ ) {
|
||||
$comment->{comment_id} = $1;
|
||||
}
|
||||
$comment->{comment_id} = '' unless defined $comment->{comment_id};
|
||||
|
||||
my $search=$params->{search} || '';
|
||||
if ((defined $search) && ($search ne '')){
|
||||
$search=substr($search,0,100);
|
||||
$search=~s/^\s+//gi;
|
||||
$search=~s/\s+$//gi;
|
||||
$search=~s/\-\-//gi;
|
||||
$search=~s/\;//gi;
|
||||
$checked->{search}=$search if $search ne '';
|
||||
};
|
||||
$checked->{search}='' unless defined $checked->{search};
|
||||
$checked->{comment}=$comment;
|
||||
my $age = $params->{age} || '';
|
||||
if ( $age =~ /^(\d+)$/ ) {
|
||||
$comment->{age} = $1;
|
||||
}
|
||||
$comment->{age} = '365' unless defined $comment->{age};
|
||||
|
||||
return $checked;
|
||||
my $search = $params->{search} || '';
|
||||
if ( ( defined $search ) && ( $search ne '' ) ) {
|
||||
$search = substr( $search, 0, 100 );
|
||||
$search =~ s/^\s+//gi;
|
||||
$search =~ s/\s+$//gi;
|
||||
$search =~ s/\-\-//gi;
|
||||
$search =~ s/\;//gi;
|
||||
$checked->{search} = $search if $search ne '';
|
||||
}
|
||||
$checked->{search} = '' unless defined $checked->{search};
|
||||
$checked->{comment} = $comment;
|
||||
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
414
website/agenda/planung/create_events.cgi
Normal file → Executable file
414
website/agenda/planung/create_events.cgi
Normal file → Executable file
@@ -1,4 +1,4 @@
|
||||
#! /usr/bin/perl -w
|
||||
#! /usr/bin/perl -w
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
@@ -6,15 +6,18 @@ use Data::Dumper;
|
||||
|
||||
use params;
|
||||
use config;
|
||||
|
||||
#use log;
|
||||
#use template;
|
||||
use auth;
|
||||
use uac;
|
||||
|
||||
#use roles;
|
||||
#use project;
|
||||
#use studios;
|
||||
#use events;
|
||||
use series;
|
||||
|
||||
#use series_schedule;
|
||||
#use series_events;
|
||||
#use series_dates;
|
||||
@@ -25,41 +28,47 @@ use localization;
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my ($user,$expires) = auth::get_user($cgi, $config);
|
||||
return if ((!defined $user) || ($user eq ''));
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
#print 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
|
||||
});
|
||||
$params->{default_studio_id}=$user_presets->{studio_id};
|
||||
$params->{studio_id} = $params->{default_studio_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
$params->{project_id} = $user_presets->{project_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
user => $user
|
||||
}
|
||||
);
|
||||
$params->{default_studio_id} = $user_presets->{studio_id};
|
||||
$params->{studio_id} = $params->{default_studio_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
$params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
#print STDERR $params->{project_id}."\n";
|
||||
my $request={
|
||||
url => $ENV{QUERY_STRING}||'',
|
||||
params => {
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
$params=$request->{params}->{checked};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
#process header
|
||||
my $headerParams=uac::set_template_permissions($request->{permissions}, $params);
|
||||
$headerParams->{loc} = localization::get($config, {user=>$user, file=>'menu'});
|
||||
template::process('print', template::check('default.html'), $headerParams);
|
||||
return unless uac::check($config, $params, $user_presets)==1;
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( 'print', template::check('default.html'), $headerParams );
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
print q{
|
||||
<script src="js/datetime.js" type="text/javascript"></script>
|
||||
@@ -68,231 +77,236 @@ print q{
|
||||
<link rel="stylesheet" href="css/series.css" type="text/css" />
|
||||
};
|
||||
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{create_event_from_schedule}==1){
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{create_event_from_schedule} == 1 ) {
|
||||
uac::permissions_denied('create_event_from_schedule');
|
||||
return;
|
||||
}
|
||||
|
||||
if (defined $params->{action}){
|
||||
# assign_series ($config, $request) if ($params->{action} eq 'assign_series');
|
||||
}
|
||||
#print Dumper($params);
|
||||
show_events($config, $request);
|
||||
if ( defined $params->{action} ) {
|
||||
|
||||
sub show_events{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{assign_series_events}==1){
|
||||
# assign_series ($config, $request) if ($params->{action} eq 'assign_series');
|
||||
}
|
||||
|
||||
#print Dumper($params);
|
||||
show_events( $config, $request );
|
||||
|
||||
sub show_events {
|
||||
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;
|
||||
}
|
||||
|
||||
#print STDERR Dumper($params);
|
||||
#print '<pre>'.Dumper($eventsByStart);
|
||||
#return;
|
||||
|
||||
my $scheduleDates=getScheduleDates($config, $request);
|
||||
my $schedulesByStart=getEventsByDate($scheduleDates);
|
||||
#print STDERR Dumper($params);
|
||||
#print '<pre>'.Dumper($eventsByStart);
|
||||
#return;
|
||||
|
||||
my $events=getEvents($config, $request);
|
||||
my $eventsByStart=getEventsByDate($events);
|
||||
my $scheduleDates = getScheduleDates( $config, $request );
|
||||
my $schedulesByStart = getEventsByDate($scheduleDates);
|
||||
|
||||
print "<pre>\n";
|
||||
for my $date (sort keys %$schedulesByStart){
|
||||
my $schedules=$schedulesByStart->{$date};
|
||||
my $scheduleCount=scalar(@$schedules);
|
||||
if ($scheduleCount==0){
|
||||
print "skip datetime $date, no schedule found\n";
|
||||
next;
|
||||
}
|
||||
if ($scheduleCount>1){
|
||||
print "skip datetime $date, $scheduleCount schedules found\n";
|
||||
next;
|
||||
}
|
||||
my $schedule=$schedules->[0];
|
||||
|
||||
if (defined $eventsByStart->{$date}){
|
||||
my $events=$eventsByStart->{$date};
|
||||
my $eventCount=scalar(@$events);
|
||||
if ($eventCount>0){
|
||||
print "skip datetime $date, $eventCount events already exist\n";
|
||||
next;
|
||||
}
|
||||
}
|
||||
print "found schedule without event for $date"
|
||||
." - "
|
||||
. $schedule->{series_name}." - ".$schedule->{title}
|
||||
. "\n";
|
||||
#createEvent($config, $request, $schedule);
|
||||
}
|
||||
my $events = getEvents( $config, $request );
|
||||
my $eventsByStart = getEventsByDate($events);
|
||||
|
||||
print "<pre>\n";
|
||||
for my $date ( sort keys %$schedulesByStart ) {
|
||||
my $schedules = $schedulesByStart->{$date};
|
||||
my $scheduleCount = scalar(@$schedules);
|
||||
if ( $scheduleCount == 0 ) {
|
||||
print "skip datetime $date, no schedule found\n";
|
||||
next;
|
||||
}
|
||||
if ( $scheduleCount > 1 ) {
|
||||
print "skip datetime $date, $scheduleCount schedules found\n";
|
||||
next;
|
||||
}
|
||||
my $schedule = $schedules->[0];
|
||||
|
||||
if ( defined $eventsByStart->{$date} ) {
|
||||
my $events = $eventsByStart->{$date};
|
||||
my $eventCount = scalar(@$events);
|
||||
if ( $eventCount > 0 ) {
|
||||
print "skip datetime $date, $eventCount events already exist\n";
|
||||
next;
|
||||
}
|
||||
}
|
||||
print "found schedule without event for $date" . " - " . $schedule->{series_name} . " - " . $schedule->{title} . "\n";
|
||||
|
||||
#createEvent($config, $request, $schedule);
|
||||
}
|
||||
}
|
||||
|
||||
# get a list of events with given start datetime
|
||||
sub getEventsByDate{
|
||||
my $events=shift;
|
||||
|
||||
my $eventsByDate={};
|
||||
for my $event (@$events){
|
||||
my $startDate=$event->{start};
|
||||
push @{$eventsByDate->{$startDate}}, $event;
|
||||
}
|
||||
return $eventsByDate;
|
||||
sub getEventsByDate {
|
||||
my $events = shift;
|
||||
|
||||
my $eventsByDate = {};
|
||||
for my $event (@$events) {
|
||||
my $startDate = $event->{start};
|
||||
push @{ $eventsByDate->{$startDate} }, $event;
|
||||
}
|
||||
return $eventsByDate;
|
||||
}
|
||||
|
||||
sub getScheduleDates{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
|
||||
my $options = {};
|
||||
|
||||
my $from=$params->{from_date};
|
||||
my $till=$params->{till_date};
|
||||
my $project_id = $params->{project_id};
|
||||
my $studio_id = $params->{studio_id};
|
||||
|
||||
#build series filter
|
||||
$options={
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
from => $from,
|
||||
till => $till,
|
||||
date_range_include => 1,
|
||||
exclude => 0
|
||||
};
|
||||
|
||||
#get all series dates
|
||||
my $series_dates=series_dates::get_series($config, $options);
|
||||
return $series_dates;
|
||||
}
|
||||
|
||||
sub getEvents{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
|
||||
my $options = {};
|
||||
|
||||
my $from=$params->{from_date};
|
||||
my $till=$params->{till_date};
|
||||
my $project_id = $params->{project_id};
|
||||
my $studio_id = $params->{studio_id};
|
||||
|
||||
#build event filter
|
||||
$options={
|
||||
project_id => $project_id,
|
||||
template => 'no',
|
||||
limit => 600,
|
||||
get => 'no_content',
|
||||
from_date => $from,
|
||||
till_date => $till,
|
||||
date_range_include => 1,
|
||||
archive => 'all',
|
||||
no_exclude => '1',
|
||||
};
|
||||
|
||||
my $events=getSeriesEvents($config, $request, $options, $params);
|
||||
return $events;
|
||||
}
|
||||
|
||||
sub getSeriesEvents{
|
||||
my $config = shift;
|
||||
sub getScheduleDates {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $options = shift;
|
||||
my $params = shift;
|
||||
|
||||
#get events by series id
|
||||
my $series_id=$request->{params}->{checked}->{series_id};
|
||||
if (defined $series_id){
|
||||
my $events=series::get_events($request->{config}, $options);
|
||||
return $events;
|
||||
}
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
|
||||
#get events (directly from database to get the ones, not assigned, yet)
|
||||
delete $options->{studio_id};
|
||||
delete $options->{project_id};
|
||||
my $options = {};
|
||||
|
||||
my $request2={
|
||||
params=>{
|
||||
checked => events::check_params($config, $options)
|
||||
my $from = $params->{from_date};
|
||||
my $till = $params->{till_date};
|
||||
my $project_id = $params->{project_id};
|
||||
my $studio_id = $params->{studio_id};
|
||||
|
||||
#build series filter
|
||||
$options = {
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
from => $from,
|
||||
till => $till,
|
||||
date_range_include => 1,
|
||||
exclude => 0
|
||||
};
|
||||
|
||||
#get all series dates
|
||||
my $series_dates = series_dates::get_series( $config, $options );
|
||||
return $series_dates;
|
||||
}
|
||||
|
||||
sub getEvents {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
|
||||
my $options = {};
|
||||
|
||||
my $from = $params->{from_date};
|
||||
my $till = $params->{till_date};
|
||||
my $project_id = $params->{project_id};
|
||||
my $studio_id = $params->{studio_id};
|
||||
|
||||
#build event filter
|
||||
$options = {
|
||||
project_id => $project_id,
|
||||
template => 'no',
|
||||
limit => 600,
|
||||
get => 'no_content',
|
||||
from_date => $from,
|
||||
till_date => $till,
|
||||
date_range_include => 1,
|
||||
archive => 'all',
|
||||
no_exclude => '1',
|
||||
};
|
||||
|
||||
my $events = getSeriesEvents( $config, $request, $options, $params );
|
||||
return $events;
|
||||
}
|
||||
|
||||
sub getSeriesEvents {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $options = shift;
|
||||
my $params = shift;
|
||||
|
||||
#get events by series id
|
||||
my $series_id = $request->{params}->{checked}->{series_id};
|
||||
if ( defined $series_id ) {
|
||||
my $events = series::get_events( $request->{config}, $options );
|
||||
return $events;
|
||||
}
|
||||
|
||||
#get events (directly from database to get the ones, not assigned, yet)
|
||||
delete $options->{studio_id};
|
||||
delete $options->{project_id};
|
||||
|
||||
my $request2 = {
|
||||
params => {
|
||||
checked => events::check_params( $config, $options )
|
||||
},
|
||||
config => $request->{config},
|
||||
permissions => $request->{permissions}
|
||||
};
|
||||
$request2->{params}->{checked}->{published}='all';
|
||||
delete $request2->{params}->{checked}->{exclude_locations} if (($params->{studio_id}==-1)&&(defined $request2->{params}->{checked}->{exclude_locations}));
|
||||
$request2->{params}->{checked}->{published} = 'all';
|
||||
delete $request2->{params}->{checked}->{exclude_locations}
|
||||
if ( ( $params->{studio_id} == -1 ) && ( defined $request2->{params}->{checked}->{exclude_locations} ) );
|
||||
|
||||
my $events=events::get($config, $request2);
|
||||
#print STDERR Dumper($request2->{params}->{checked});
|
||||
#print STDERR Dumper($events);
|
||||
series::add_series_ids_to_events($request->{config}, $events);
|
||||
my $events = events::get( $config, $request2 );
|
||||
|
||||
my $studios=studios::get($request->{config},{
|
||||
project_id => $options->{project_id}
|
||||
});
|
||||
my $studio_id_by_location={};
|
||||
for my $studio (@$studios){
|
||||
$studio_id_by_location->{$studio->{location}}=$studio->{id};
|
||||
#print STDERR Dumper($request2->{params}->{checked});
|
||||
#print STDERR Dumper($events);
|
||||
series::add_series_ids_to_events( $request->{config}, $events );
|
||||
|
||||
my $studios = studios::get(
|
||||
$request->{config},
|
||||
{
|
||||
project_id => $options->{project_id}
|
||||
}
|
||||
);
|
||||
my $studio_id_by_location = {};
|
||||
for my $studio (@$studios) {
|
||||
$studio_id_by_location->{ $studio->{location} } = $studio->{id};
|
||||
}
|
||||
|
||||
for my $event (@$events) {
|
||||
$event->{project_id} = $options->{project_id} unless defined $event->{project_id};
|
||||
$event->{studio_id} = $studio_id_by_location->{ $event->{location} } unless defined $event->{studio_id};
|
||||
}
|
||||
|
||||
for my $event (@$events){
|
||||
$event->{project_id}= $options->{project_id} unless defined $event->{project_id};
|
||||
$event->{studio_id} = $studio_id_by_location->{$event->{location}} unless defined $event->{studio_id};
|
||||
}
|
||||
|
||||
return $events;
|
||||
}
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
|
||||
my $checked={};
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
my $debug=$params->{debug} || '';
|
||||
if ($debug=~/([a-z\_\,]+)/){
|
||||
$debug=$1;
|
||||
my $checked = {};
|
||||
|
||||
my $debug = $params->{debug} || '';
|
||||
if ( $debug =~ /([a-z\_\,]+)/ ) {
|
||||
$debug = $1;
|
||||
}
|
||||
$checked->{debug}=$debug;
|
||||
$checked->{debug} = $debug;
|
||||
|
||||
#actions and roles
|
||||
$checked->{action}='';
|
||||
if (defined $params->{action}){
|
||||
if ($params->{action}=~/^(create_events)$/){
|
||||
$checked->{action}=$params->{action};
|
||||
$checked->{action} = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(create_events)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
|
||||
#numeric values
|
||||
$checked->{exclude}=0;
|
||||
for my $param ('id', 'project_id', 'studio_id', 'series_id'){
|
||||
if ((defined $params->{$param})&&($params->{$param}=~/^\d+$/)){
|
||||
$checked->{$param}=$params->{$param};
|
||||
$checked->{exclude} = 0;
|
||||
for my $param ( 'id', 'project_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;
|
||||
}
|
||||
|
||||
for my $param ('date','from_date','till_date'){
|
||||
$checked->{$param}=time::check_date($params->{$param});
|
||||
if ( defined $checked->{studio_id} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
|
||||
$checked->{template}=template::check($params->{template},'create_events');
|
||||
for my $param ( 'date', 'from_date', 'till_date' ) {
|
||||
$checked->{$param} = time::check_date( $params->{$param} );
|
||||
}
|
||||
|
||||
$checked->{template} = template::check( $params->{template}, 'create_events' );
|
||||
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
__DATA__
|
||||
|
||||
https://piradio.de/agenda/planung/create_events.cgi?project_id=1&studio_id=1&from_date=2016-09-01&till_date=2016-10-01
|
||||
|
||||
@@ -14,7 +14,6 @@ body #content{
|
||||
max-width:980px;
|
||||
color:#000;
|
||||
background:#fff;
|
||||
line-height:100%;
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
@@ -31,10 +30,9 @@ body,
|
||||
font-family:sans-serif;
|
||||
}
|
||||
|
||||
#content input,
|
||||
#content textarea{
|
||||
border:1px solid #ccc;
|
||||
padding:6px;
|
||||
border:1px solid #ccc;
|
||||
}
|
||||
|
||||
@media handheld{
|
||||
@@ -98,6 +96,10 @@ body,
|
||||
background:#888;
|
||||
}
|
||||
|
||||
#calcms_admin_menu div {
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
#calcms_admin_menu select,
|
||||
#calcms_admin_menu option{
|
||||
font-size:0.8rem;
|
||||
@@ -321,6 +323,8 @@ tr.tablesorter-filter-row input{
|
||||
}
|
||||
|
||||
/*colors*/
|
||||
#content input[type="submit"],
|
||||
#content input[type="file"],
|
||||
#content button,
|
||||
#content .ui-state-active,
|
||||
#content a.ui-button:active,
|
||||
@@ -328,13 +332,16 @@ tr.tablesorter-filter-row input{
|
||||
background-color:#2196f3;
|
||||
}
|
||||
|
||||
#content input[type="submit"]:hover,
|
||||
#content input[type="file"]:hover,
|
||||
#content button:hover,
|
||||
#content .ui-button.ui-state-active:hover{
|
||||
background-color:#39a1f4;
|
||||
}
|
||||
|
||||
/*colors end */
|
||||
|
||||
#content input[type="submit"],
|
||||
#content input[type="file"],
|
||||
#content button{
|
||||
border:none;
|
||||
color:#fff;
|
||||
@@ -347,6 +354,8 @@ tr.tablesorter-filter-row input{
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
#content input[type="submit"],
|
||||
#content input[type="file"],
|
||||
#content button{
|
||||
box-shadow:0 2px 5px 0 rgba(0,0,0,.16),0 2px 10px 0 rgba(0,0,0,.12);
|
||||
position:relative;
|
||||
@@ -356,11 +365,15 @@ tr.tablesorter-filter-row input{
|
||||
border:0
|
||||
}
|
||||
|
||||
#content input[type="submit"]:hover,
|
||||
#content input[type="file"]:hover,
|
||||
#content button:focus{
|
||||
outline:0;
|
||||
transition:all 0.5s cubic-bezier(.64,.09,.08,1)
|
||||
}
|
||||
|
||||
#content input[type="submit"]:hover,
|
||||
#content input[type="file"]:hover,
|
||||
#content button:hover{
|
||||
box-shadow:0 5px 11px 0 rgba(0,0,0,.18),0 4px 15px 0 rgba(0,0,0,.15);
|
||||
}
|
||||
@@ -377,7 +390,7 @@ tr.tablesorter-filter-row input{
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#content input:focus{
|
||||
#content input[type="text"]:focus{
|
||||
border-bottom:2px solid #03a9f4;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
img{
|
||||
margin-right :1em;
|
||||
margin-bottom :1em;
|
||||
vertical-align:middle
|
||||
}
|
||||
|
||||
@@ -11,3 +12,10 @@ h2 {
|
||||
line-height:1.5em;
|
||||
}
|
||||
|
||||
.thin{
|
||||
font-weight:100;
|
||||
}
|
||||
|
||||
th{
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
@@ -19,10 +19,8 @@ button:hover{
|
||||
#content{
|
||||
top:0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#content #calendar_weekdays,
|
||||
#content #calendar_weekdays table,
|
||||
#content #calendar{
|
||||
@@ -66,7 +64,6 @@ button:hover{
|
||||
#calendar table td{
|
||||
word-wrap:break-word;
|
||||
hyphens:auto;
|
||||
/*word-break:break-all;*/
|
||||
}
|
||||
|
||||
#calendar div.text{
|
||||
@@ -98,9 +95,6 @@ button:hover{
|
||||
padding-left:0;
|
||||
padding-top:0;
|
||||
padding-bottom:0;
|
||||
/*
|
||||
// padding-right:16px;
|
||||
*/
|
||||
}
|
||||
|
||||
#calendar div.event div.icons{
|
||||
@@ -108,21 +102,8 @@ button:hover{
|
||||
top:-5px;
|
||||
right:-7px;
|
||||
width:16px;
|
||||
image-rendering: optimizeSpeed; /* FUCK SMOOTHING, GIVE ME SPEED */
|
||||
image-rendering: -moz-crisp-edges; /* Firefox */
|
||||
image-rendering: -o-crisp-edges; /* Opera */
|
||||
image-rendering: -webkit-optimize-contrast; /* Chrome (and eventually Safari) */
|
||||
image-rendering: optimize-contrast; /* CSS3 Proposed */
|
||||
-ms-interpolation-mode: nearest-neighbor; /* IE8+ */
|
||||
}
|
||||
|
||||
/*
|
||||
#calendar div.event,
|
||||
#calendar div.schedule{
|
||||
border-bottom:1px solid black;
|
||||
}
|
||||
*/
|
||||
|
||||
#calendar div.time.now {
|
||||
padding:0;
|
||||
margin:0;
|
||||
@@ -185,7 +166,6 @@ button:hover{
|
||||
border:0;
|
||||
border-bottom:1px solid #666;
|
||||
border-top:1px solid #666;
|
||||
/*border:1px solid black;*/
|
||||
}
|
||||
|
||||
#calendar div.time,
|
||||
@@ -230,14 +210,8 @@ button:hover{
|
||||
z-index:1;
|
||||
margin-left:0px;
|
||||
background:white;
|
||||
/*
|
||||
// margin-right:15px;
|
||||
*/
|
||||
}
|
||||
|
||||
#event_list tr{
|
||||
/*border-bottom:1px solid #999;*/
|
||||
}
|
||||
#event_list tr th:hover{
|
||||
cursor:pointer;
|
||||
}
|
||||
@@ -342,12 +316,6 @@ input.tablesorter-filter{
|
||||
|
||||
/* calendar colors */
|
||||
|
||||
/*
|
||||
#content .grid{
|
||||
border:1px dashed #ccc;
|
||||
}
|
||||
*/
|
||||
|
||||
#content div.event.no_series{
|
||||
color:#000;
|
||||
}
|
||||
@@ -421,6 +389,11 @@ div#toolbar input.search{
|
||||
padding-bottom:6px;
|
||||
}
|
||||
|
||||
#content #toolbar div#selectDate:hover{
|
||||
padding-top:0;
|
||||
padding-bottom:0;
|
||||
}
|
||||
|
||||
#content #toolbar div#current_date{
|
||||
cursor:pointer;
|
||||
font-size:1.5em;
|
||||
@@ -444,11 +417,9 @@ div#toolbar input.search{
|
||||
padding:6px;
|
||||
}
|
||||
|
||||
|
||||
#calendar td div.play {
|
||||
transition: min-height 0.1s;
|
||||
transition: min-width 0.1s;
|
||||
transition-delay: 0.7s;
|
||||
#calendar div {
|
||||
transition: all 0.1s;
|
||||
transition-delay: 0s;
|
||||
}
|
||||
|
||||
#calendar td div.play:hover {
|
||||
@@ -516,16 +487,19 @@ div.rms_detail div.text{
|
||||
|
||||
div.event .ok,
|
||||
div.play .ok{
|
||||
display:inline;
|
||||
background:#4caf50;
|
||||
}
|
||||
|
||||
div.event .warn,
|
||||
div.play .warn{
|
||||
display:inline;
|
||||
background:#ffeb3b;
|
||||
}
|
||||
|
||||
div.event .error,
|
||||
div.play .error{
|
||||
display:inline;
|
||||
background:#f44336;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ use warnings "all";
|
||||
use strict;
|
||||
use Data::Dumper;
|
||||
use HTML::Template;
|
||||
|
||||
#use URI::Escape;
|
||||
#use Encode;
|
||||
|
||||
@@ -15,69 +16,70 @@ use config;
|
||||
use auth;
|
||||
use localization;
|
||||
use studios;
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my ($user, $expires) = auth::get_user($cgi, $config);
|
||||
return if (!defined $user) || ($user eq '');
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( !defined $user ) || ( $user eq '' );
|
||||
|
||||
my $user_presets=uac::get_user_presets($config, {user=>$user, studio_id=>$params->{studio_id}});
|
||||
my $request={
|
||||
url => $ENV{QUERY_STRING}||'',
|
||||
params => {
|
||||
my $user_presets = uac::get_user_presets( $config, { user => $user, studio_id => $params->{studio_id} } );
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => $params
|
||||
# checked => check_params($params),
|
||||
checked => $params
|
||||
|
||||
# checked => check_params($params),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
#process header
|
||||
my $headerParams = uac::set_template_permissions($request->{permissions}, $params);
|
||||
$headerParams->{loc} = localization::get($config, {user=>$user, file=>'menu'});
|
||||
template::process('print', template::check('default.html'), $headerParams);
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( 'print', template::check('default.html'), $headerParams );
|
||||
|
||||
#filter
|
||||
my $lines = $cgi->param('lines');
|
||||
$lines=100 if $lines eq '';
|
||||
$lines = 100 if $lines eq '';
|
||||
|
||||
my $filter='' ;
|
||||
$filter=' |grep -v "Use of uninitialized value in | grep -v redefined " ' if ($cgi->param('warn') eq '1');
|
||||
my $filter = '';
|
||||
$filter = ' |grep -v "Use of uninitialized value in | grep -v redefined " ' if ( $cgi->param('warn') eq '1' );
|
||||
|
||||
#get file
|
||||
my $file=$config->{system}->{log_file};
|
||||
if ($cgi->param('log')eq'app'){
|
||||
$file=$config->{system}->{log_debug_file};
|
||||
my $file = $config->{system}->{log_file};
|
||||
if ( $cgi->param('log') eq 'app' ) {
|
||||
$file = $config->{system}->{log_debug_file};
|
||||
}
|
||||
if ($cgi->param('log')eq'mem'){
|
||||
$file=$config->{system}->{log_debug_memory_file};
|
||||
if ( $cgi->param('log') eq 'mem' ) {
|
||||
$file = $config->{system}->{log_debug_memory_file};
|
||||
}
|
||||
if ($cgi->param('log')eq'job'){
|
||||
$file=$config->{system}->{job_log};
|
||||
if ( $cgi->param('log') eq 'job' ) {
|
||||
$file = $config->{system}->{job_log};
|
||||
}
|
||||
|
||||
#output header
|
||||
my $out='';
|
||||
template::process('print','templates/error_log.html', $params);
|
||||
my $out = '';
|
||||
template::process( 'print', 'templates/error_log.html', $params );
|
||||
|
||||
#get log
|
||||
my $cmd="tail -$lines ".$file.$filter;
|
||||
print '<pre>'.$cmd.'</pre>';
|
||||
my $cmd = "tail -$lines " . $file . $filter;
|
||||
print '<pre>' . $cmd . '</pre>';
|
||||
|
||||
my $log= `$cmd`;
|
||||
$log=join("\n",reverse(split("\n",$log)));
|
||||
my $log = `$cmd`;
|
||||
$log = join( "\n", reverse( split( "\n", $log ) ) );
|
||||
|
||||
#replace
|
||||
if ($cgi->param('log')eq'app'){
|
||||
$log=~s/\\n/<br>/gi;
|
||||
}else{
|
||||
$log=~s/</\</gi;
|
||||
$log=~s/\\n/<\/pre><pre> /gi;
|
||||
#replace
|
||||
if ( $cgi->param('log') eq 'app' ) {
|
||||
$log =~ s/\\n/<br>/gi;
|
||||
} else {
|
||||
$log =~ s/</\</gi;
|
||||
$log =~
|
||||
s/\\n/<\/pre><pre> /gi;
|
||||
}
|
||||
|
||||
#output content
|
||||
|
||||
1584
website/agenda/planung/event.cgi
Normal file → Executable file
1584
website/agenda/planung/event.cgi
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
309
website/agenda/planung/event_history.cgi
Normal file → Executable file
309
website/agenda/planung/event_history.cgi
Normal file → Executable file
@@ -6,6 +6,7 @@ use URI::Escape;
|
||||
use Encode;
|
||||
use Data::Dumper;
|
||||
use MIME::Base64;
|
||||
|
||||
#use Text::Diff ();
|
||||
use Text::Diff::FormattedHTML;
|
||||
|
||||
@@ -16,50 +17,54 @@ use template;
|
||||
use db;
|
||||
use auth;
|
||||
use uac;
|
||||
|
||||
#use roles;
|
||||
use time;
|
||||
use markup;
|
||||
use studios;
|
||||
use event_history;
|
||||
use events;
|
||||
|
||||
#use series;
|
||||
#use series_dates;
|
||||
use series_events;
|
||||
use localization;
|
||||
binmode STDOUT, ":utf8";
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my ($user,$expires) = auth::get_user($cgi, $config);
|
||||
return if ((!defined $user) || ($user eq ''));
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
my $user_presets=uac::get_user_presets($config, {user=>$user, 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'));
|
||||
my $user_presets = uac::get_user_presets( $config, { user => $user, 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' ) );
|
||||
|
||||
my $request={
|
||||
url => $ENV{QUERY_STRING}||'',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
|
||||
#print STDERR Dumper($request)."\n";
|
||||
|
||||
#set user at params->presets->user
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
$params=$request->{params}->{checked};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
#show header
|
||||
my $headerParams=uac::set_template_permissions($request->{permissions}, $params);
|
||||
$headerParams->{loc} = localization::get($config, {user=>$user, file=>'menu'});
|
||||
template::process('print', template::check('default.html'), $headerParams);
|
||||
return unless uac::check($config, $params, $user_presets)==1;
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( 'print', template::check('default.html'), $headerParams );
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
print q{
|
||||
<script src="js/datetime.js" type="text/javascript"></script>
|
||||
@@ -67,166 +72,170 @@ print q{
|
||||
<link rel="stylesheet" href="css/event.css" type="text/css" />
|
||||
};
|
||||
|
||||
$config->{access}->{write}=0;
|
||||
if($params->{action} eq'diff'){
|
||||
compare($config, $request);
|
||||
return;
|
||||
$config->{access}->{write} = 0;
|
||||
if ( $params->{action} eq 'diff' ) {
|
||||
compare( $config, $request );
|
||||
return;
|
||||
}
|
||||
show_history($config, $request);
|
||||
show_history( $config, $request );
|
||||
|
||||
#show existing event history
|
||||
sub show_history{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub show_history {
|
||||
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);
|
||||
#print STDERR Dumper($events);
|
||||
return unless defined $events;
|
||||
$params->{events}=$events;
|
||||
my $events = event_history::get( $config, $options );
|
||||
|
||||
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($events);
|
||||
return unless defined $events;
|
||||
$params->{events} = $events;
|
||||
|
||||
template::process('print', template::check('event_history'), $params);
|
||||
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' } );
|
||||
|
||||
template::process( 'print', template::check('event_history'), $params );
|
||||
}
|
||||
|
||||
#show existing event history
|
||||
sub compare{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub compare {
|
||||
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];
|
||||
|
||||
$options->{change_id}=$params->{v2};
|
||||
$events=event_history::get($config, $options);
|
||||
return unless @$events==1;
|
||||
my $v2=$events->[0];
|
||||
my $events = event_history::get( $config, $options );
|
||||
return unless @$events == 1;
|
||||
my $v1 = $events->[0];
|
||||
|
||||
my $t1=eventToText($v1);
|
||||
my $t2=eventToText($v2);
|
||||
$options->{change_id} = $params->{v2};
|
||||
$events = event_history::get( $config, $options );
|
||||
return unless @$events == 1;
|
||||
my $v2 = $events->[0];
|
||||
|
||||
if($t1 eq $t2){
|
||||
print "no changes\n";
|
||||
return;
|
||||
}
|
||||
my $t1 = eventToText($v1);
|
||||
my $t2 = eventToText($v2);
|
||||
|
||||
#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 '</pre>';
|
||||
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 Text::Diff::diff(\$t1, \$t2, { STYLE => "Table" });
|
||||
#print Text::Diff::diff($v1, $v2, { STYLE => "Table" });
|
||||
print $diff;
|
||||
|
||||
#print '</pre>';
|
||||
}
|
||||
|
||||
sub eventToText{
|
||||
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";
|
||||
#print STDERR "DUMP\n$s";
|
||||
return $s;
|
||||
sub eventToText {
|
||||
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";
|
||||
|
||||
#print STDERR "DUMP\n$s";
|
||||
return $s;
|
||||
|
||||
}
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
my $checked={};
|
||||
my $template='';
|
||||
$checked->{template}=template::check($params->{template},'event_history');
|
||||
my $checked = {};
|
||||
my $template = '';
|
||||
$checked->{template} = template::check( $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};
|
||||
}
|
||||
}
|
||||
|
||||
if (defined $checked->{studio_id}){
|
||||
$checked->{default_studio_id}=$checked->{studio_id};
|
||||
}else{
|
||||
$checked->{studio_id}=-1;
|
||||
}
|
||||
#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};
|
||||
}
|
||||
}
|
||||
|
||||
#actions and roles
|
||||
$checked->{action}='';
|
||||
if (defined $params->{action}){
|
||||
if ($params->{action}=~/^(show|diff)$/){
|
||||
$checked->{action}=$params->{action};
|
||||
}
|
||||
}
|
||||
#print STDERR Dumper($checked);
|
||||
return $checked;
|
||||
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};
|
||||
}
|
||||
}
|
||||
|
||||
#print STDERR Dumper($checked);
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
|
||||
106
website/agenda/planung/help.cgi
Normal file → Executable file
106
website/agenda/planung/help.cgi
Normal file → Executable file
@@ -1,4 +1,4 @@
|
||||
# !/usr/bin/perl -w
|
||||
# !/usr/bin/perl -w
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
@@ -19,42 +19,47 @@ use localization;
|
||||
|
||||
#binmode STDOUT, ":utf8";
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my ($user,$expires) = auth::get_user($cgi, $config);
|
||||
return if ((!defined $user) || ($user eq ''));
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
my $user_presets=uac::get_user_presets($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'));
|
||||
$params->{project_id}=$user_presets->{project_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$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' ) );
|
||||
$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 => {
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
$params=$request->{params}->{checked};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
#process header
|
||||
my $headerParams=uac::set_template_permissions($request->{permissions}, $params);
|
||||
$headerParams->{loc} = localization::get($config, {user=>$user, file=>'menu'});
|
||||
template::process('print', template::check('default.html'), $headerParams);
|
||||
return unless uac::check($config, $params, $user_presets)==1;
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( 'print', template::check('default.html'), $headerParams );
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
my $toc=$headerParams->{loc}->{toc};
|
||||
my $toc = $headerParams->{loc}->{toc};
|
||||
|
||||
print q!
|
||||
<style>
|
||||
@@ -121,16 +126,16 @@ $( document ).ready(function() {
|
||||
</script>
|
||||
!;
|
||||
|
||||
print markup::creole_to_html(getHelp($headerParams->{loc}->{region}));
|
||||
print markup::creole_to_html( getHelp( $headerParams->{loc}->{region} ) );
|
||||
|
||||
sub getHelp{
|
||||
my $region=shift;
|
||||
return getGermanHelp() if $region eq 'de';
|
||||
return getEnglishHelp();
|
||||
sub getHelp {
|
||||
my $region = shift;
|
||||
return getGermanHelp() if $region eq 'de';
|
||||
return getEnglishHelp();
|
||||
}
|
||||
|
||||
sub getGermanHelp{
|
||||
return q{
|
||||
sub getGermanHelp {
|
||||
return q{
|
||||
|
||||
<div id="toc"><h1 class="hide">Inhaltsverzeichnis</h1></div>
|
||||
|
||||
@@ -373,8 +378,8 @@ Folgende Status-Felder gibt es:
|
||||
};
|
||||
}
|
||||
|
||||
sub getEnglishHelp{
|
||||
return q{
|
||||
sub getEnglishHelp {
|
||||
return q{
|
||||
<div id="toc"><h1 class="hide">Table of Contents</h1></div>
|
||||
|
||||
= Menu
|
||||
@@ -608,33 +613,32 @@ There are following status fields:
|
||||
* The user needs permissiosn to "edit series he/she is assigned to"
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
my $checked={};
|
||||
my $checked = {};
|
||||
|
||||
my $debug=$params->{debug} || '';
|
||||
if ($debug=~/([a-z\_\,]+)/){
|
||||
$debug=$1;
|
||||
my $debug = $params->{debug} || '';
|
||||
if ( $debug =~ /([a-z\_\,]+)/ ) {
|
||||
$debug = $1;
|
||||
}
|
||||
$checked->{debug}=$debug;
|
||||
$checked->{debug} = $debug;
|
||||
|
||||
#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};
|
||||
$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;
|
||||
}
|
||||
if ( defined $checked->{studio_id} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
|
||||
return $checked;
|
||||
}
|
||||
|
||||
619
website/agenda/planung/image.cgi
Normal file → Executable file
619
website/agenda/planung/image.cgi
Normal file → Executable file
@@ -1,4 +1,4 @@
|
||||
#! /usr/bin/perl -w
|
||||
#! /usr/bin/perl -w
|
||||
|
||||
use warnings "all";
|
||||
use strict;
|
||||
@@ -27,401 +27,418 @@ use localization;
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
$CGI::POST_MAX = 1024*10;
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
$CGI::POST_MAX = 1024 * 10;
|
||||
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my ($user,$expires) = auth::get_user($cgi, $config);
|
||||
return if ((!defined $user) || ($user eq ''));
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
my $user_presets=uac::get_user_presets($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'));
|
||||
$params->{project_id}=$user_presets->{project_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$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' ) );
|
||||
$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),
|
||||
}
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
}
|
||||
};
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
$params=$request->{params}->{checked};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
#show header
|
||||
my $headerParams=uac::set_template_permissions($request->{permissions}, $params);
|
||||
$headerParams->{loc} = localization::get($config, {user=>$user, file=>'menu'});
|
||||
template::process('print', template::check('ajax_header.html'), $headerParams);
|
||||
return unless defined uac::check($config, $params, $user_presets);
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( 'print', template::check('ajax_header.html'), $headerParams );
|
||||
return unless defined uac::check( $config, $params, $user_presets );
|
||||
|
||||
#my $base_dir = $config->{locations}->{base_dir};
|
||||
my $local_media_dir = $config->{locations}->{local_media_dir};
|
||||
my $local_media_url = $config->{locations}->{local_media_url};
|
||||
my $local_media_dir = $config->{locations}->{local_media_dir};
|
||||
my $local_media_url = $config->{locations}->{local_media_url};
|
||||
|
||||
#my $local_base_url = $config->{locations}->{local_base_url};
|
||||
|
||||
log::error($config, 'cannot locate media dir'.$local_media_dir) unless(-e $local_media_dir);
|
||||
log::error( $config, 'cannot locate media dir' . $local_media_dir ) unless ( -e $local_media_dir );
|
||||
|
||||
#continue on error
|
||||
uac::permissions_denied('reading from local media dir') unless(-r $local_media_dir);
|
||||
uac::permissions_denied('writing to local media dir') unless(-w $local_media_dir);
|
||||
uac::permissions_denied('reading from local media dir') unless ( -r $local_media_dir );
|
||||
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);
|
||||
if ( $params->{delete_image} ne '' ) {
|
||||
delete_image( $config, $request, $user, $local_media_dir );
|
||||
return;
|
||||
} elsif ( $params->{save_image} ne '' ) {
|
||||
save_image( $config, $request, $user );
|
||||
return;
|
||||
}elsif ($params->{save_image}ne''){
|
||||
save_image($config, $request, $user);
|
||||
return;
|
||||
}
|
||||
show_image($config, $request, $user, $local_media_url);
|
||||
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;
|
||||
sub show_image {
|
||||
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 $selectedFilename=$params->{filename}||'';
|
||||
my $filenames={};
|
||||
my $results=[];
|
||||
my $selectedFilename = $params->{filename} || '';
|
||||
my $filenames = {};
|
||||
my $results = [];
|
||||
|
||||
# add images from series
|
||||
if(defined $params->{series_id}){
|
||||
my $seriesImages=series::get_images($config, $params);
|
||||
# add images from series
|
||||
if ( defined $params->{series_id} ) {
|
||||
my $seriesImages = series::get_images( $config, $params );
|
||||
|
||||
for my $image (@$seriesImages){
|
||||
my $filename=$image->{filename};
|
||||
unless (defined $filenames->{$filename}){
|
||||
#print STDERR "add1 $filename\n";
|
||||
push @$results, $image;
|
||||
$filenames->{$filename}=$image;
|
||||
}
|
||||
}
|
||||
}
|
||||
for my $image (@$seriesImages) {
|
||||
my $filename = $image->{filename};
|
||||
unless ( defined $filenames->{$filename} ) {
|
||||
|
||||
#load images matching by search
|
||||
if(defined $params->{search}){
|
||||
#print STDERR "add1 $filename\n";
|
||||
push @$results, $image;
|
||||
$filenames->{$filename} = $image;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#remove filename from search
|
||||
delete $params->{filename};
|
||||
delete $params->{series_id};
|
||||
my $searchImages=images::get($config, $params);
|
||||
#load images matching by search
|
||||
if ( defined $params->{search} ) {
|
||||
|
||||
for my $image (@$searchImages){
|
||||
my $filename=$image->{filename};
|
||||
unless (defined $filenames->{$filename}){
|
||||
#print STDERR "add2 $filename\n";
|
||||
push @$results, $image;
|
||||
$filenames->{$filename}=$image;
|
||||
}
|
||||
}
|
||||
}
|
||||
#remove filename from search
|
||||
delete $params->{filename};
|
||||
delete $params->{series_id};
|
||||
my $searchImages = images::get( $config, $params );
|
||||
|
||||
#load selected image, if not already loaded
|
||||
if($selectedFilename ne''){
|
||||
my $search =$params->{search}||'';
|
||||
for my $image (@$searchImages) {
|
||||
my $filename = $image->{filename};
|
||||
unless ( defined $filenames->{$filename} ) {
|
||||
|
||||
# use selected image if already loaded
|
||||
my $selectedImage=undef;
|
||||
if (defined $filenames->{$selectedFilename}){
|
||||
$selectedImage=$filenames->{$selectedFilename};
|
||||
}else{
|
||||
#now add filename and remove search
|
||||
$params->{filename}=$selectedFilename;
|
||||
delete $params->{search};
|
||||
#print STDERR "add2 $filename\n";
|
||||
push @$results, $image;
|
||||
$filenames->{$filename} = $image;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#put selected image to the top
|
||||
my $imagesByNames=images::get($config, $params);
|
||||
$selectedImage=$imagesByNames->[0] if(scalar(@$imagesByNames)>0);
|
||||
}
|
||||
#load selected image, if not already loaded
|
||||
if ( $selectedFilename ne '' ) {
|
||||
my $search = $params->{search} || '';
|
||||
|
||||
my $finalResults=[];
|
||||
# use selected image if already loaded
|
||||
my $selectedImage = undef;
|
||||
if ( defined $filenames->{$selectedFilename} ) {
|
||||
$selectedImage = $filenames->{$selectedFilename};
|
||||
} else {
|
||||
|
||||
# put selected image first
|
||||
$selectedFilename='not-found';
|
||||
if (defined $selectedImage){
|
||||
push @$finalResults, $selectedImage ;
|
||||
$selectedFilename=$selectedImage->{filename};
|
||||
}
|
||||
#now add filename and remove search
|
||||
$params->{filename} = $selectedFilename;
|
||||
delete $params->{search};
|
||||
|
||||
# then other images
|
||||
for my $image (@$results){
|
||||
push @$finalResults, $image if $image->{filename} ne $selectedFilename;
|
||||
}
|
||||
$results=$finalResults;
|
||||
#put selected image to the top
|
||||
my $imagesByNames = images::get( $config, $params );
|
||||
$selectedImage = $imagesByNames->[0] if ( scalar(@$imagesByNames) > 0 );
|
||||
}
|
||||
|
||||
#add search again
|
||||
$params->{search}=$search;
|
||||
}
|
||||
|
||||
if($params->{template}=~/edit/){
|
||||
$results=[$results->[0]]||undef;
|
||||
}
|
||||
if (defined $results){
|
||||
$results=modify_results($results, $permissions, $user, $local_media_url);
|
||||
}
|
||||
my $finalResults = [];
|
||||
|
||||
my $search=$params->{search}||'';
|
||||
$search=~s/\%+/ /g;
|
||||
my $template_params={
|
||||
'search' => $search,
|
||||
'images' => $results,
|
||||
'count' => @$results.'',
|
||||
'projects' => project::get_with_dates($config),
|
||||
'project_id' => $params->{project_id},
|
||||
'studio_id' => $params->{studio_id},
|
||||
'filename' => $params->{filename}
|
||||
};
|
||||
# put selected image first
|
||||
$selectedFilename = 'not-found';
|
||||
if ( defined $selectedImage ) {
|
||||
push @$finalResults, $selectedImage;
|
||||
$selectedFilename = $selectedImage->{filename};
|
||||
}
|
||||
|
||||
# print STDERR
|
||||
$template_params->{loc} = localization::get($config, {user=>$params->{presets}->{user}, file=>'image'});
|
||||
$template_params=uac::set_template_permissions($permissions, $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('print', $params->{template}, $template_params);
|
||||
# then other images
|
||||
for my $image (@$results) {
|
||||
push @$finalResults, $image if $image->{filename} ne $selectedFilename;
|
||||
}
|
||||
$results = $finalResults;
|
||||
|
||||
#add search again
|
||||
$params->{search} = $search;
|
||||
}
|
||||
|
||||
if ( $params->{template} =~ /edit/ ) {
|
||||
$results = [ $results->[0] ] || undef;
|
||||
}
|
||||
if ( defined $results ) {
|
||||
$results = modify_results( $results, $permissions, $user, $local_media_url );
|
||||
}
|
||||
|
||||
my $search = $params->{search} || '';
|
||||
$search =~ s/\%+/ /g;
|
||||
my $template_params = {
|
||||
'search' => $search,
|
||||
'images' => $results,
|
||||
'count' => @$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 );
|
||||
|
||||
#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( 'print', $params->{template}, $template_params );
|
||||
}
|
||||
|
||||
sub print_js_error{
|
||||
my $message=shift;
|
||||
print qq{<!--
|
||||
sub print_js_error {
|
||||
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;
|
||||
sub save_image {
|
||||
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");
|
||||
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!");
|
||||
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'');
|
||||
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->{modified_by} = $user;
|
||||
|
||||
$image->{name}='new' if ($image->{name}eq'');
|
||||
$image->{name} = 'new' if ( $image->{name} eq '' );
|
||||
|
||||
$config->{access}->{write} = 1;
|
||||
my $dbh = db::connect($config);
|
||||
|
||||
$config->{access}->{write}=1;
|
||||
my $dbh=db::connect($config);
|
||||
|
||||
#print STDERR "going to save\n";
|
||||
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}
|
||||
}
|
||||
);
|
||||
|
||||
#print STDERR Dumper($entries);
|
||||
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);
|
||||
}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 );
|
||||
} 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 $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
|
||||
unless (check_permission($config, $user, $permissions, 'delete_image', $params->{delete_image}) eq '1'){
|
||||
sub delete_image {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $user = shift;
|
||||
my $local_media_dir = shift;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
#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},
|
||||
$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);
|
||||
my $result = images::delete( $dbh, $image );
|
||||
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);
|
||||
#use Data::Dumper;print STDERR "delete\n".Dumper($params);
|
||||
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";
|
||||
}
|
||||
|
||||
sub check_permission{
|
||||
my $config=shift;
|
||||
my $user=shift;
|
||||
my $permissions=shift;
|
||||
my $permission=shift;
|
||||
my $filename=shift;
|
||||
sub check_permission {
|
||||
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";
|
||||
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);
|
||||
} 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;
|
||||
}
|
||||
|
||||
sub modify_results{
|
||||
my $results=shift;
|
||||
my $permissions=shift;
|
||||
my $user=shift;
|
||||
my $local_media_url=shift;
|
||||
sub modify_results {
|
||||
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});
|
||||
#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;
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
my $checked = { template => template::check( $params->{template}, 'image.html' ) };
|
||||
|
||||
my $checked={
|
||||
template => template::check($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;
|
||||
}
|
||||
|
||||
$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;
|
||||
#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;
|
||||
}
|
||||
|
||||
for my $attr('update_name','update_description'){
|
||||
$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};
|
||||
}
|
||||
}
|
||||
|
||||
#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->{limit} = 100 unless defined $checked->{limit};
|
||||
$checked->{limit} = 100 if ( $checked->{limit} > 100 );
|
||||
|
||||
$checked->{from}=time::check_date($params->{from});
|
||||
$checked->{till}=time::check_date($params->{till});
|
||||
#string
|
||||
$checked->{search} = '';
|
||||
if ( ( defined $params->{search} ) && ( $params->{search} =~ /^\s*(.+?)\s*$/ ) ) {
|
||||
$checked->{search} = $1;
|
||||
}
|
||||
|
||||
for my $attr ( 'update_name', 'update_description' ) {
|
||||
$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};
|
||||
}
|
||||
}
|
||||
|
||||
#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} );
|
||||
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,123 +23,134 @@ use images;
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
|
||||
my $r = shift;
|
||||
my $cgi = undef;
|
||||
my $r = shift;
|
||||
my $cgi = undef;
|
||||
|
||||
my $config = config::get('../config/config.cgi');
|
||||
our $debug = $config->{system}->{debug};
|
||||
my $config = config::get('../config/config.cgi');
|
||||
our $debug = $config->{system}->{debug};
|
||||
my $base_dir = $config->{locations}->{base_dir};
|
||||
my $tmp_dir = '/var/tmp';
|
||||
my $upload_limit = 2048*1000;
|
||||
my $upload_limit = 2048 * 1000;
|
||||
|
||||
#binmode STDOUT, ":utf8";
|
||||
#binmode STDOUT, ":encoding(UTF-8)";
|
||||
|
||||
my $params = {};
|
||||
my $upload = undef;
|
||||
my $error = '';
|
||||
my $params = {};
|
||||
my $upload = undef;
|
||||
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);
|
||||
if ( defined $r ) {
|
||||
|
||||
#copy params to hash
|
||||
my $body=$apr->body();
|
||||
if (defined $body){
|
||||
for my $key (keys %$body){
|
||||
# print "$key=".$apr->param($key)."<br>\n";
|
||||
$params->{scalar($key)}=scalar($apr->param($key));# unless ($key eq'image');
|
||||
}
|
||||
}
|
||||
# print Dumper($params);
|
||||
#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 );
|
||||
|
||||
# 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});
|
||||
}
|
||||
#copy params to hash
|
||||
my $body = $apr->body();
|
||||
if ( defined $body ) {
|
||||
for my $key ( keys %$body ) {
|
||||
|
||||
#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;
|
||||
}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;
|
||||
# print "$key=".$apr->param($key)."<br>\n";
|
||||
$params->{ scalar($key) } = scalar( $apr->param($key) ); # unless ($key eq'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;
|
||||
} 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;
|
||||
}
|
||||
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, $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}
|
||||
});
|
||||
$params->{default_studio_id}=$user_presets->{studio_id};
|
||||
$params->{studio_id}=$params->{default_studio_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
$params->{project_id}=$user_presets->{project_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$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' ) );
|
||||
$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),
|
||||
},
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
$params = $request->{params}->{checked};
|
||||
return unless defined uac::check($config, $params, $user_presets);
|
||||
return unless defined uac::check( $config, $params, $user_presets );
|
||||
|
||||
my $permissions=$request->{permissions};
|
||||
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;
|
||||
if ( $permissions->{create_image} ne '1' ) {
|
||||
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'";
|
||||
}
|
||||
}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'');
|
||||
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'";
|
||||
}
|
||||
} 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 '' );
|
||||
}
|
||||
print STDERR $params->{error}."\n" if defined $params->{error};
|
||||
my $out='';
|
||||
template::process('print', $params->{template}, $params);
|
||||
print STDERR $params->{error} . "\n" if defined $params->{error};
|
||||
my $out = '';
|
||||
template::process( 'print', $params->{template}, $params );
|
||||
|
||||
print $cgi->cgi_error() if defined $cgi;
|
||||
|
||||
#return;
|
||||
|
||||
return if($params->{action} eq '');
|
||||
return if ( $params->{action} eq '' );
|
||||
|
||||
if ($params->{error} eq''){
|
||||
print qq{
|
||||
if ( $params->{error} eq '' ) {
|
||||
print qq{
|
||||
<div id="output">success</div>
|
||||
<div id="message">
|
||||
$params->{action_result}
|
||||
@@ -152,264 +163,258 @@ if ($params->{error} eq''){
|
||||
<div id="upload_image_link">{{thumbs//$params->{filename}}}</div>
|
||||
|
||||
};
|
||||
}else{
|
||||
print qq{
|
||||
} else {
|
||||
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;
|
||||
sub upload_file {
|
||||
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 $file = $result->{fh};
|
||||
my $filename = $result->{filename};
|
||||
my $result = get_filename( $cgi, $upload );
|
||||
return $result if ( $result->{error} ne '' );
|
||||
|
||||
$result=check_filename($filename);
|
||||
print STDERR $result."\n";
|
||||
return $result if ($result->{error} ne '');
|
||||
my $file = $result->{fh};
|
||||
my $filename = $result->{filename};
|
||||
|
||||
my $extension=$result->{extension}||'';
|
||||
$result = check_filename($filename);
|
||||
print STDERR $result . "\n";
|
||||
return $result if ( $result->{error} ne '' );
|
||||
|
||||
#read file from handle
|
||||
my $data;
|
||||
my $content='';
|
||||
print STDERR $file."\n";
|
||||
#unless (-e $file){}
|
||||
binmode $file;
|
||||
while(read $file,$data,1024) {
|
||||
$content.=$data;
|
||||
}
|
||||
my $extension = $result->{extension} || '';
|
||||
|
||||
#set filename to MD5 from content
|
||||
my $md5_filename=Digest::MD5::md5_base64($content);
|
||||
$md5_filename=~s/[\/\+]/_/gi;
|
||||
#read file from handle
|
||||
my $data;
|
||||
my $content = '';
|
||||
print STDERR $file . "\n";
|
||||
|
||||
return process_image($config, $filename, $extension, $md5_filename, $content);
|
||||
#unless (-e $file){}
|
||||
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;
|
||||
|
||||
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;
|
||||
sub update_database {
|
||||
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};
|
||||
|
||||
my $name=$params->{name}||'';
|
||||
$name='neu' unless $params=~/\S/;
|
||||
$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 $image={
|
||||
filename => $params->{filename},
|
||||
name => $params->{name}||'new',
|
||||
description => $params->{description},
|
||||
modified_by => $user,
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id}
|
||||
};
|
||||
my $name = $params->{name} || '';
|
||||
$name = 'neu' unless $params =~ /\S/;
|
||||
|
||||
#connect
|
||||
$config->{access}->{write}=1;
|
||||
my $dbh=db::connect($config);
|
||||
|
||||
my $entries=images::get($config, { filename => $image->{filename} } );
|
||||
if ((defined $entries)&&(@$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 $image = {
|
||||
filename => $params->{filename},
|
||||
name => $params->{name} || 'new',
|
||||
description => $params->{description},
|
||||
modified_by => $user,
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id}
|
||||
};
|
||||
|
||||
return $params;
|
||||
#connect
|
||||
$config->{access}->{write} = 1;
|
||||
my $dbh = db::connect($config);
|
||||
|
||||
my $entries = images::get( $config, { filename => $image->{filename} } );
|
||||
if ( ( defined $entries ) && ( @$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;
|
||||
}
|
||||
|
||||
#get filename and filehandle from upload
|
||||
sub get_filename{
|
||||
my $cgi=shift;
|
||||
my $upload=shift;
|
||||
sub get_filename {
|
||||
my $cgi = shift;
|
||||
my $upload = shift;
|
||||
|
||||
if (defined $upload){
|
||||
# try apache2 module
|
||||
my $filename=$upload->filename();
|
||||
return {
|
||||
filename => $filename,
|
||||
fh => $upload->fh(),
|
||||
error => ''
|
||||
};
|
||||
if ( defined $upload ) {
|
||||
|
||||
}
|
||||
|
||||
# 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 => ''
|
||||
};
|
||||
# try apache2 module
|
||||
my $filename = $upload->filename();
|
||||
return {
|
||||
filename => $filename,
|
||||
fh => $upload->fh(),
|
||||
error => ''
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#error
|
||||
return {
|
||||
error=>'Could not detect file name!'
|
||||
};
|
||||
# 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!' };
|
||||
}
|
||||
|
||||
sub check_filename{
|
||||
my $filename=shift;
|
||||
sub check_filename {
|
||||
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;
|
||||
sub process_image {
|
||||
my $config = shift;
|
||||
my $filename = shift;
|
||||
my $extension = shift;
|
||||
my $md5_filename = shift;
|
||||
my $content = shift;
|
||||
|
||||
my $upload_path = $config->{locations}->{local_media_dir}.'upload/'.$md5_filename.'.'.$extension;
|
||||
my $thumb_path = $config->{locations}->{local_media_dir}.'thumbs/'.$md5_filename.'.jpg';
|
||||
my $icon_path = $config->{locations}->{local_media_dir}.'icons/'.$md5_filename.'.jpg';
|
||||
my $image_path = $config->{locations}->{local_media_dir}.'images/'.$md5_filename.'.jpg';
|
||||
my $upload_path = $config->{locations}->{local_media_dir} . 'upload/' . $md5_filename . '.' . $extension;
|
||||
my $thumb_path = $config->{locations}->{local_media_dir} . 'thumbs/' . $md5_filename . '.jpg';
|
||||
my $icon_path = $config->{locations}->{local_media_dir} . 'icons/' . $md5_filename . '.jpg';
|
||||
my $image_path = $config->{locations}->{local_media_dir} . 'images/' . $md5_filename . '.jpg';
|
||||
|
||||
#copy file to upload space
|
||||
open DAT,'>'.$upload_path or return {error=> 'could not save image. '.$!." $upload_path"};
|
||||
binmode DAT;
|
||||
print DAT $content;
|
||||
close DAT;
|
||||
#copy file to upload space
|
||||
open DAT, '>' . $upload_path or return { error => 'could not save image. ' . $! . " $upload_path" };
|
||||
binmode DAT;
|
||||
print DAT $content;
|
||||
close DAT;
|
||||
|
||||
#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');
|
||||
}
|
||||
}
|
||||
|
||||
#$image->Normalize();
|
||||
$image->Write('jpg:'.$image_path);
|
||||
#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' );
|
||||
}
|
||||
}
|
||||
|
||||
#write thumb
|
||||
my $thumb=$image;
|
||||
$thumb->Trim2Square;
|
||||
$thumb->Resize(width=>150,height=>150);
|
||||
$thumb->Write('jpg:'.$thumb_path);
|
||||
#$image->Normalize();
|
||||
$image->Write( 'jpg:' . $image_path );
|
||||
|
||||
my $icon=$image;
|
||||
$icon->Trim2Square;
|
||||
$icon->Resize(width=>25,height=>25);
|
||||
$icon->Write('jpg:'.$icon_path);
|
||||
#write thumb
|
||||
my $thumb = $image;
|
||||
$thumb->Trim2Square;
|
||||
$thumb->Resize( width => 150, height => 150 );
|
||||
$thumb->Write( 'jpg:' . $thumb_path );
|
||||
|
||||
unless(-e $thumb_path){
|
||||
return {error=>'could not create thumb nail file!'};
|
||||
}
|
||||
unless(-e $icon_path){
|
||||
return {error=>'could not create icon file!'};
|
||||
}
|
||||
unless(-e $image_path){
|
||||
return {error=>'could not create image file!'};
|
||||
}
|
||||
my $icon = $image;
|
||||
$icon->Trim2Square;
|
||||
$icon->Resize( width => 25, height => 25 );
|
||||
$icon->Write( 'jpg:' . $icon_path );
|
||||
|
||||
return {
|
||||
upload_filename =>$filename,
|
||||
unless ( -e $thumb_path ) {
|
||||
return { error => 'could not create thumb nail file!' };
|
||||
}
|
||||
unless ( -e $icon_path ) {
|
||||
return { error => 'could not create icon file!' };
|
||||
}
|
||||
unless ( -e $image_path ) {
|
||||
return { error => 'could not create image file!' };
|
||||
}
|
||||
|
||||
filename =>$md5_filename.'.jpg',
|
||||
thumb_path =>$thumb_path,
|
||||
icon_path =>$icon_path,
|
||||
image_path =>$image_path,
|
||||
return {
|
||||
upload_filename => $filename,
|
||||
|
||||
error =>''
|
||||
};
|
||||
filename => $md5_filename . '.jpg',
|
||||
thumb_path => $thumb_path,
|
||||
icon_path => $icon_path,
|
||||
image_path => $image_path,
|
||||
|
||||
error => ''
|
||||
};
|
||||
}
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
my $checked={};
|
||||
$checked->{template} = template::check($params->{template},'imageUpload');
|
||||
my $checked = {};
|
||||
$checked->{template} = template::check( $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' ) {
|
||||
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;
|
||||
}
|
||||
|
||||
#string
|
||||
for my $param ( 'debug', 'name', 'description' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\s*(.+?)\s*$/ ) ) {
|
||||
$checked->{$param} = $1;
|
||||
}
|
||||
}
|
||||
|
||||
#string
|
||||
for my $param ('debug','name','description'){
|
||||
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;
|
||||
#Words
|
||||
for my $attr ('action') {
|
||||
if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /(\S+)/ ) ) {
|
||||
$checked->{$attr} = $params->{$attr};
|
||||
}
|
||||
}
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,13 +4,123 @@ function showProgress(){
|
||||
return false;
|
||||
}
|
||||
|
||||
function hideProgress(){
|
||||
$('#progress').slideUp();
|
||||
return false;
|
||||
}
|
||||
|
||||
function playAudio(path){
|
||||
var url='../../agenda_files/recordings/'+path;
|
||||
var win = window.open(url, '_blank');
|
||||
}
|
||||
|
||||
function changeFile(fileInput){
|
||||
var file = fileInput.files[0];
|
||||
var size = file.size / (1000*1000);
|
||||
$('#uploadSize').html(size + " MB");
|
||||
if (size > 200){
|
||||
$('#uploadButton').hide();
|
||||
showError("file is too large. maximum size is 200 MB! Please use MP3, 192 kHz, CBR, 44100 Hz, 16bit");
|
||||
}else{
|
||||
$('#uploadButton').show();
|
||||
}
|
||||
}
|
||||
|
||||
function showError(error){
|
||||
$('#error').html(error);
|
||||
$('#error').show();
|
||||
}
|
||||
|
||||
function hideError(){
|
||||
$('#error').hide();
|
||||
}
|
||||
|
||||
function showFinished(){
|
||||
$('#info').html("upload finished");
|
||||
$('#info').show();
|
||||
}
|
||||
|
||||
function hideFinished(){
|
||||
$('#info').hide();
|
||||
}
|
||||
|
||||
function roundSize(size){
|
||||
var MB=1000*1000;
|
||||
return Math.round(size*10/MB)/10;
|
||||
}
|
||||
|
||||
function uploadFile(uploadButton){
|
||||
hideFinished();
|
||||
hideError();
|
||||
showProgress();
|
||||
$.ajax({
|
||||
url: 'audio_recordings.cgi',
|
||||
type: 'POST',
|
||||
data: new FormData($('#audio_recordings_upload')[0]),
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
xhr: function() {
|
||||
var start = new Date();
|
||||
var myXhr = $.ajaxSettings.xhr();
|
||||
if (myXhr.upload) {
|
||||
myXhr.upload.addEventListener(
|
||||
'progress',
|
||||
function(data) {
|
||||
if (data.lengthComputable) {
|
||||
var loaded=roundSize(data.loaded);
|
||||
var total=roundSize(data.total);
|
||||
$('#progressBar').attr("value", loaded);
|
||||
$('#progressBar').attr("max", total);
|
||||
var duration=(new Date().getTime() - start.getTime()) / 1000 ;
|
||||
var bitrate = loaded / duration;
|
||||
var remaining = Math.round(100 * bitrate * ( total - loaded) );
|
||||
var content = loaded + " of " + total + " MB<br>";
|
||||
content += '<div class="thin">';
|
||||
content += "finished in " + remaining + " seconds<br>";
|
||||
content += "took " + Math.round(duration) + " seconds<br>";
|
||||
content += '</div>'
|
||||
$('#progressLabel').html(content);
|
||||
}
|
||||
} ,
|
||||
false
|
||||
);
|
||||
}
|
||||
return myXhr;
|
||||
},
|
||||
}).error(
|
||||
function(jqXHR, textStatus, errorThrown ){
|
||||
showError("error: "+errorThrown);
|
||||
hideProgress();
|
||||
hideFinished();
|
||||
}
|
||||
).done(
|
||||
function(data){
|
||||
showFinished();
|
||||
hideProgress();
|
||||
hideError();
|
||||
//setTimeout(function() { location.reload() }, 1000);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$( document ).ready(
|
||||
function() {
|
||||
$('#file').on( 'change',
|
||||
function(){
|
||||
changeFile( this );
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
$('#uploadButton').on( 'click',
|
||||
function(){
|
||||
uploadFile( this );
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
var number = 1+Math.floor(11 * Math.random());
|
||||
$('#progress img').attr("src", "/agenda/image/upload/bird"+number+".gif");
|
||||
}
|
||||
|
||||
@@ -589,7 +589,7 @@ function deleteFromPlayout(id, projectId, studioId, start){
|
||||
url+='&project_id='+escape(projectId);
|
||||
url+='&studio_id='+escape(studioId);
|
||||
url+='&start_date='+escape(start);
|
||||
|
||||
//console.log(url);
|
||||
$('#'+id).dialog({
|
||||
width:940,
|
||||
height:440,
|
||||
|
||||
@@ -61,10 +61,10 @@ function isNewToHistory(url){
|
||||
var ignore=0;
|
||||
//provide back to series from series details
|
||||
if(contains(url,'series')){
|
||||
console.log(url);
|
||||
console.log(history[0]);
|
||||
//console.log(url);
|
||||
//console.log(history[0]);
|
||||
if( (contains(url,'series_id')==true) && (contains(history[0],'series_id')==false)) ignore=1;
|
||||
console.log(ignore);
|
||||
//console.log(ignore);
|
||||
}
|
||||
if (ignore==0) history.shift();
|
||||
}
|
||||
|
||||
60
website/agenda/planung/localization.cgi
Normal file → Executable file
60
website/agenda/planung/localization.cgi
Normal file → Executable file
@@ -13,52 +13,48 @@ use localization;
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( $user eq '' );
|
||||
|
||||
my $config =config::get('../config/config.cgi');
|
||||
my $debug =$config->{system}->{debug};
|
||||
|
||||
my ($user,$expires) = auth::get_user($cgi, $config);
|
||||
return if ($user eq '');
|
||||
|
||||
my $request={
|
||||
url => $ENV{QUERY_STRING}||'',
|
||||
params => {
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params($params),
|
||||
}
|
||||
};
|
||||
$params=$request->{params}->{checked};
|
||||
my $loc = localization::get($config, {user=>$user, file=>$params->{usecase}});
|
||||
my $header="Content-type:application/json; charset=UTF-8;\n\n";
|
||||
$loc->{usecase}=$params->{usecase};
|
||||
my $json=to_json($loc, {pretty => 1});
|
||||
my @json_lines=();
|
||||
for my $line (split/\n/,$json){
|
||||
push @json_lines, "'".$line."'\n";
|
||||
$params = $request->{params}->{checked};
|
||||
my $loc = localization::get( $config, { user => $user, file => $params->{usecase} } );
|
||||
my $header = "Content-type:application/json; charset=UTF-8;\n\n";
|
||||
$loc->{usecase} = $params->{usecase};
|
||||
my $json = to_json( $loc, { pretty => 1 } );
|
||||
my @json_lines = ();
|
||||
|
||||
for my $line ( split /\n/, $json ) {
|
||||
push @json_lines, "'" . $line . "'\n";
|
||||
}
|
||||
|
||||
$json=$header.$json;
|
||||
$json = $header . $json;
|
||||
|
||||
# .'var loc_text='.join('+',@json_lines).";\n"
|
||||
# .'var loc = JQuery.parseJSON(loc_text)';
|
||||
;
|
||||
print $json;
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
my $checked = { usecase => '' };
|
||||
|
||||
my $checked={
|
||||
usecase => ''
|
||||
};
|
||||
|
||||
if (defined $params->{usecase}){
|
||||
if ($params->{usecase}=~/^([a-z\-\_\,]+)$/){
|
||||
$checked->{usecase}=$1;
|
||||
if ( defined $params->{usecase} ) {
|
||||
if ( $params->{usecase} =~ /^([a-z\-\_\,]+)$/ ) {
|
||||
$checked->{usecase} = $1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
399
website/agenda/planung/notify_events.cgi
Normal file → Executable file
399
website/agenda/planung/notify_events.cgi
Normal file → Executable file
@@ -5,6 +5,7 @@ use strict;
|
||||
use URI::Escape;
|
||||
use Encode;
|
||||
use Data::Dumper;
|
||||
|
||||
#use Text::Diff::FormattedHTML;
|
||||
use MIME::Lite;
|
||||
|
||||
@@ -15,260 +16,272 @@ use template;
|
||||
use db;
|
||||
use auth;
|
||||
use uac;
|
||||
|
||||
#use roles;
|
||||
use time;
|
||||
use markup;
|
||||
use studios;
|
||||
|
||||
#use event_history;
|
||||
#use events;
|
||||
use series;
|
||||
|
||||
#use series_dates;
|
||||
#use series_events;
|
||||
use localization;
|
||||
binmode STDOUT, ":utf8";
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my ($user,$expires) = auth::get_user($cgi, $config);
|
||||
return if ((!defined $user) || ($user eq ''));
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
my $user_presets=uac::get_user_presets($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'));
|
||||
$params->{project_id}=$user_presets->{project_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$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' ) );
|
||||
$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),
|
||||
},
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
|
||||
#print STDERR Dumper($request)."\n";
|
||||
|
||||
#set user at params->presets->user
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
$params=$request->{params}->{checked};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
#show header
|
||||
unless(params::isJson()){
|
||||
my $headerParams=uac::set_template_permissions($request->{permissions}, $params);
|
||||
$headerParams->{loc} = localization::get($config, {user=>$user, file=>'menu'});
|
||||
template::process('print', template::check('default.html'), $headerParams);
|
||||
unless ( params::isJson() || ( $params->{template}=~/\.txt/ ) ) {
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( 'print', template::check('default.html'), $headerParams );
|
||||
}
|
||||
return unless uac::check($config, $params, $user_presets)==1;
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
$config->{access}->{write}=0;
|
||||
if($params->{action} eq'send'){
|
||||
sendMail($config, $request);
|
||||
return;
|
||||
$config->{access}->{write} = 0;
|
||||
if ( $params->{action} eq 'send' ) {
|
||||
sendMail( $config, $request );
|
||||
return;
|
||||
}
|
||||
show_events($config, $request);
|
||||
show_events( $config, $request );
|
||||
|
||||
#show existing event history
|
||||
sub show_events{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub show_events {
|
||||
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),
|
||||
};
|
||||
# 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 ),
|
||||
};
|
||||
|
||||
my $events=series::get_events($config, $options);
|
||||
# get series_users
|
||||
for my $event (@$events){
|
||||
my $mail=getMail($config, $request, $event);
|
||||
$event->{mail}=$mail;
|
||||
}
|
||||
my $events = series::get_events( $config, $options );
|
||||
|
||||
return unless defined $events;
|
||||
my @events = sort {$a->{start} cmp $b->{start}} @$events;
|
||||
$params->{events}=\@events;
|
||||
# get series_users
|
||||
for my $event (@$events) {
|
||||
my $mail = getMail( $config, $request, $event );
|
||||
$event->{mail} = $mail;
|
||||
}
|
||||
|
||||
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('print', template::check('notify_events'), $params);
|
||||
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};
|
||||
}
|
||||
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'notify_events' } );
|
||||
template::process( 'print', $params->{template}, $params );
|
||||
|
||||
}
|
||||
|
||||
sub sendMail{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub sendMail {
|
||||
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},
|
||||
};
|
||||
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},
|
||||
};
|
||||
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 $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 $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};
|
||||
|
||||
print '<pre>';
|
||||
$msg->print(\*STDOUT);
|
||||
print '</pre>';
|
||||
$msg->send;
|
||||
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;
|
||||
}
|
||||
|
||||
sub getMail{
|
||||
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}
|
||||
}
|
||||
);
|
||||
sub getMail {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $event = shift;
|
||||
|
||||
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 $users = series::get_users(
|
||||
$config,
|
||||
{
|
||||
project_id => $event->{project_id},
|
||||
studio_id => $event->{studio_id},
|
||||
series_id => $event->{series_id}
|
||||
}
|
||||
);
|
||||
|
||||
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 $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;
|
||||
}
|
||||
|
||||
$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;
|
||||
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;
|
||||
}
|
||||
|
||||
sub eventToText{
|
||||
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";
|
||||
#print STDERR "DUMP\n$s";
|
||||
return $s;
|
||||
sub eventToText {
|
||||
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";
|
||||
|
||||
#print STDERR "DUMP\n$s";
|
||||
return $s;
|
||||
|
||||
}
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
my $checked={};
|
||||
my $template='';
|
||||
$checked->{template}=template::check($params->{template},'notify_events');
|
||||
my $checked = {};
|
||||
my $template = '';
|
||||
$checked->{template} = template::check( $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};
|
||||
}
|
||||
}
|
||||
|
||||
if (defined $checked->{studio_id}){
|
||||
$checked->{default_studio_id}=$checked->{studio_id};
|
||||
}else{
|
||||
$checked->{studio_id}=-1;
|
||||
}
|
||||
for my $param ( 'subject', 'to', 'cc', 'content' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /\S/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
#actions and roles
|
||||
$checked->{action}='';
|
||||
if (defined $params->{action}){
|
||||
if ($params->{action}=~/^(send)$/){
|
||||
$checked->{action}=$params->{action};
|
||||
}
|
||||
}
|
||||
if ( defined $checked->{studio_id} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
|
||||
return $checked;
|
||||
#actions and roles
|
||||
$checked->{action} = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(send)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,10 @@ use warnings "all";
|
||||
use strict;
|
||||
use Data::Dumper;
|
||||
|
||||
use URI::Escape;
|
||||
use Encode;
|
||||
use localization;
|
||||
|
||||
use params;
|
||||
use config;
|
||||
use log;
|
||||
@@ -19,134 +23,139 @@ use series_schedule;
|
||||
use series_events;
|
||||
use series_dates;
|
||||
use markup;
|
||||
use URI::Escape;
|
||||
use Encode;
|
||||
use localization;
|
||||
use playout;
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my ($user,$expires) = auth::get_user($cgi, $config);
|
||||
return if ((!defined $user) || ($user eq ''));
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
print "Content-type:text/html; charset=UTF-8;\n\n";
|
||||
|
||||
#print STDERR $params->{project_id}."\n";
|
||||
my $user_presets=uac::get_user_presets($config, {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
user => $user
|
||||
});
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
user => $user
|
||||
}
|
||||
);
|
||||
|
||||
$params->{default_studio_id} = $user_presets->{studio_id};
|
||||
$params->{studio_id} = $params->{default_studio_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
$params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
$params->{default_studio_id}=$user_presets->{studio_id};
|
||||
$params->{studio_id} = $params->{default_studio_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
$params->{project_id} = $user_presets->{project_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
#print STDERR $params->{project_id}."\n";
|
||||
|
||||
my $request={
|
||||
url => $ENV{QUERY_STRING}||'',
|
||||
params => {
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
$params=$request->{params}->{checked};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
#process header
|
||||
my $headerParams=uac::set_template_permissions($request->{permissions}, $params);
|
||||
$headerParams->{loc} = localization::get($config, {user=>$user, file=>'menu'});
|
||||
#template::process('print', template::check('default.html'), $headerParams);
|
||||
return unless uac::check($config, $params, $user_presets)==1;
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
|
||||
if (defined $params->{action}){
|
||||
deleteFromPlayout ($config, $request) if ($params->{action} eq 'delete');
|
||||
}else{
|
||||
print "missing action\n";
|
||||
#template::process('print', template::check('default.html'), $headerParams);
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
if ( defined $params->{action} ) {
|
||||
deleteFromPlayout( $config, $request ) if ( $params->{action} eq 'delete' );
|
||||
} else {
|
||||
print "missing action\n";
|
||||
}
|
||||
return;
|
||||
|
||||
sub deleteFromPlayout{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub deleteFromPlayout {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{update_event_status_playout}==1){
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{update_event_status_playout} == 1 ) {
|
||||
uac::permissions_denied('update_event_status_playout');
|
||||
return;
|
||||
}
|
||||
|
||||
for my $attr ('project_id', 'studio_id', 'start_date'){
|
||||
unless (defined $params->{$attr}){
|
||||
uac::print_error("missing ".$attr." to show event");
|
||||
return;
|
||||
}
|
||||
}
|
||||
for my $attr ( 'project_id', 'studio_id', 'start_date' ) {
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( "missing " . $attr . " to show event" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$config->{access}->{write}=1;
|
||||
my $dbh=db::connect($config);
|
||||
$config->{access}->{write} = 1;
|
||||
my $dbh = db::connect($config);
|
||||
|
||||
my $result=playout::delete(
|
||||
$config, $dbh, {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
start => $params->{start_date}
|
||||
});
|
||||
$config->{access}->{write}=0;
|
||||
|
||||
print "result:$result\n";
|
||||
my $result = playout::delete(
|
||||
$config, $dbh,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
start => $params->{start_date}
|
||||
}
|
||||
);
|
||||
$config->{access}->{write} = 0;
|
||||
|
||||
print "result:$result\n";
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
my $checked = {};
|
||||
|
||||
my $checked={};
|
||||
|
||||
my $debug=$params->{debug} || '';
|
||||
if ($debug=~/([a-z\_\,]+)/){
|
||||
$debug=$1;
|
||||
my $debug = $params->{debug} || '';
|
||||
if ( $debug =~ /([a-z\_\,]+)/ ) {
|
||||
$debug = $1;
|
||||
}
|
||||
$checked->{debug}=$debug;
|
||||
$checked->{debug} = $debug;
|
||||
|
||||
#actions and roles
|
||||
$checked->{action}='';
|
||||
if (defined $params->{action}){
|
||||
if ($params->{action}=~/^(delete)$/){
|
||||
$checked->{action}=$params->{action};
|
||||
$checked->{action} = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(delete)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
|
||||
#numeric values
|
||||
$checked->{exclude}=0;
|
||||
for my $param ('project_id', 'studio_id'){
|
||||
if ((defined $params->{$param})&&($params->{$param}=~/^\d+$/)){
|
||||
$checked->{$param}=$params->{$param};
|
||||
$checked->{exclude} = 0;
|
||||
for my $param ( 'project_id', 'studio_id' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#dates
|
||||
for my $param ('start_date'){
|
||||
if((defined $params->{$param})&&($params->{$param}=~/(\d\d\d\d\-\d\d\-\d\d \d\d\:\d\d)/)){
|
||||
$checked->{$param}=$1.':00';
|
||||
}
|
||||
}
|
||||
for my $param ('start_date') {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /(\d\d\d\d\-\d\d\-\d\d \d\d\:\d\d)/ ) ) {
|
||||
$checked->{$param} = $1 . ':00';
|
||||
}
|
||||
}
|
||||
|
||||
if ( defined $checked->{studio_id} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
|
||||
if (defined $checked->{studio_id}){
|
||||
$checked->{default_studio_id}=$checked->{studio_id};
|
||||
}else{
|
||||
$checked->{studio_id}=-1;
|
||||
}
|
||||
|
||||
#$checked->{template}=template::check($params->{template},'playout');
|
||||
#$checked->{template}=template::check($params->{template},'playout');
|
||||
|
||||
return $checked;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,9 @@ msgstr "Studio"
|
||||
msgid "project"
|
||||
msgstr "Projekt"
|
||||
|
||||
msgid "playout"
|
||||
msgstr "Playout"
|
||||
|
||||
msgid "import"
|
||||
msgstr "Import"
|
||||
|
||||
|
||||
@@ -244,3 +244,6 @@ msgstr "Vorproduktion hochladen"
|
||||
msgid "label_delete_audio_recordings"
|
||||
msgstr "Vorproduktion löschen"
|
||||
|
||||
msgid "label_read_playout"
|
||||
msgstr "Playout anzeigen"
|
||||
|
||||
|
||||
@@ -40,6 +40,9 @@ msgstr "Studio"
|
||||
msgid "project"
|
||||
msgstr "Project"
|
||||
|
||||
msgid "playout"
|
||||
msgstr "Playout"
|
||||
|
||||
msgid "import"
|
||||
msgstr "Import"
|
||||
|
||||
|
||||
@@ -247,3 +247,6 @@ msgstr "upload audio recordings"
|
||||
msgid "label_delete_audio_recordings"
|
||||
msgstr "delete audio recordings"
|
||||
|
||||
msgid "label_read_playout"
|
||||
msgstr "show playout"
|
||||
|
||||
|
||||
392
website/agenda/planung/projects.cgi
Normal file → Executable file
392
website/agenda/planung/projects.cgi
Normal file → Executable file
@@ -15,42 +15,47 @@ use studios;
|
||||
use series;
|
||||
use localization;
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config =config::get('../config/config.cgi');
|
||||
my $debug =$config->{system}->{debug};
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
|
||||
my ($user,$expires) = auth::get_user($cgi, $config);
|
||||
return if ($user eq '');
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( $user eq '' );
|
||||
|
||||
my $permissions=roles::get_user_permissions();
|
||||
my $user_presets=uac::get_user_presets($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'));
|
||||
$params->{project_id}=$user_presets->{project_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
my $permissions = roles::get_user_permissions();
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$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' ) );
|
||||
$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 => {
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
$params=$request->{params}->{checked};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
#process header
|
||||
my $headerParams=uac::set_template_permissions($request->{permissions}, $params);
|
||||
$headerParams->{loc} = localization::get($config, {user=>$user, file=>'menu'});
|
||||
template::process('print', template::check('default.html'), $headerParams);
|
||||
return unless uac::check($config, $params, $user_presets)==1;
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( 'print', template::check('default.html'), $headerParams );
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
print q{
|
||||
<link rel="stylesheet" href="css/projects.css" type="text/css" />
|
||||
@@ -58,237 +63,244 @@ print q{
|
||||
<script src="js/projects.js" type="text/javascript"></script>
|
||||
};
|
||||
|
||||
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');
|
||||
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' );
|
||||
}
|
||||
$config->{access}->{write}=0;
|
||||
show_projects ($config, $request);
|
||||
$config->{access}->{write} = 0;
|
||||
show_projects( $config, $request );
|
||||
|
||||
sub delete_project{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub delete_project {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{delete_project}==1){
|
||||
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}||'';
|
||||
|
||||
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");
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
sub save_project{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub save_project {
|
||||
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};
|
||||
|
||||
$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(@$projects>0){
|
||||
uac::print_error("project with name '$entry->{name}' already exists");
|
||||
return;
|
||||
}
|
||||
delete $entry->{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::insert($config, $entry);
|
||||
$config->{access}->{write}=0;
|
||||
uac::print_info("project created");
|
||||
$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 ( @$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");
|
||||
}
|
||||
}
|
||||
|
||||
sub assign_studio{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub assign_studio {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{assign_project_studio}==1){
|
||||
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;
|
||||
# TODO: unassign series from studio
|
||||
sub unassign_studio {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{assign_project_studio}==1){
|
||||
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;
|
||||
sub show_projects {
|
||||
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){
|
||||
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){
|
||||
# get assigned studios
|
||||
my $project_studio_assignements=project::get_studio_assignments($config, {project_id=>$project->{project_id}});
|
||||
$project->{pid}=$project->{project_id};
|
||||
for my $project (@$projects) {
|
||||
|
||||
# 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
|
||||
my $project_studio_assignements = project::get_studio_assignments( $config, { project_id => $project->{project_id} } );
|
||||
$project->{pid} = $project->{project_id};
|
||||
|
||||
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;
|
||||
}
|
||||
# get assigned studios by id
|
||||
my $assigned_studio_by_id = {};
|
||||
for my $studio (@$project_studio_assignements) {
|
||||
$assigned_studio_by_id->{ $studio->{studio_id} } = 1;
|
||||
}
|
||||
|
||||
$params->{projects}= $projects;
|
||||
$params->{loc} = localization::get($config, {user=>$params->{presets}->{user}, file=>'projects'});
|
||||
uac::set_template_permissions($permissions, $params);
|
||||
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;
|
||||
}
|
||||
|
||||
template::process('print', $params->{template}, $params);
|
||||
$params->{projects} = $projects;
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'projects' } );
|
||||
uac::set_template_permissions( $permissions, $params );
|
||||
|
||||
template::process( 'print', $params->{template}, $params );
|
||||
}
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
my $checked={};
|
||||
my $checked = {};
|
||||
|
||||
#template
|
||||
my $template='';
|
||||
$template=template::check($params->{template},'projects');
|
||||
$checked->{template}=$template;
|
||||
my $template = '';
|
||||
$template = template::check( $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};
|
||||
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};
|
||||
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;
|
||||
}
|
||||
if ( defined $checked->{studio_id} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
|
||||
return $checked;
|
||||
}
|
||||
|
||||
@@ -15,58 +15,65 @@ use studios;
|
||||
use localization;
|
||||
binmode STDOUT, ":utf8";
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config =config::get('../config/config.cgi');
|
||||
my $debug =$config->{system}->{debug};
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
|
||||
my ($user,$expires) = auth::get_user($cgi, $config);
|
||||
return if ((!defined $user) || ($user eq ''));
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
our $actions={
|
||||
read => 1,
|
||||
update => 2,
|
||||
assign => 3,
|
||||
remove => 4,
|
||||
our $actions = {
|
||||
read => 1,
|
||||
update => 2,
|
||||
assign => 3,
|
||||
remove => 4,
|
||||
disable => 5,
|
||||
scan => 6,
|
||||
create => 7,
|
||||
create => 7,
|
||||
delete => 8,
|
||||
};
|
||||
|
||||
my $user_presets=uac::get_user_presets($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'));
|
||||
$params->{project_id} = $user_presets->{project_id};
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$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' ) );
|
||||
$params->{project_id} = $user_presets->{project_id};
|
||||
|
||||
my $request={
|
||||
url => $ENV{QUERY_STRING}||'',
|
||||
params => {
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
$params=$request->{params}->{checked};
|
||||
#process header
|
||||
my $headerParams=uac::set_template_permissions($request->{permissions}, $params);
|
||||
$headerParams->{loc} = localization::get($config, {user=>$user, file=>'menu'});
|
||||
template::process('print', template::check('roles.html'), $headerParams);
|
||||
return unless uac::check($config, $params, $user_presets)==1;
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
if (defined $params->{action}){
|
||||
save_roles($config, $request) if ($params->{action}eq 'save');
|
||||
#process header
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( 'print', template::check('roles.html'), $headerParams );
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
if ( defined $params->{action} ) {
|
||||
save_roles( $config, $request ) if ( $params->{action} eq 'save' );
|
||||
}
|
||||
|
||||
#show current roles
|
||||
$config->{access}->{write}=0;
|
||||
show_roles($config,$request);
|
||||
$config->{access}->{write} = 0;
|
||||
show_roles( $config, $request );
|
||||
|
||||
#print '<pre>'.Dumper($request);
|
||||
return;
|
||||
|
||||
@@ -75,129 +82,136 @@ return;
|
||||
# role can be changed only if permission "update_role" is assigned to the user at the current studio
|
||||
# role can be changed only if role level is smaller than user's maximum role level
|
||||
# new roles will have role level 0 by default
|
||||
#
|
||||
sub save_roles{
|
||||
#
|
||||
sub save_roles {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
|
||||
unless ($permissions->{update_role}==1){
|
||||
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>';
|
||||
|
||||
|
||||
#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||'';
|
||||
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))
|
||||
$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;
|
||||
}
|
||||
}
|
||||
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'){
|
||||
#id and studio id will be set later
|
||||
}else{
|
||||
$values->{$id}->{$column}=1 if ($value=~/^\d+$/);
|
||||
}
|
||||
}
|
||||
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+$/ );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#print STDERR Dumper($values);
|
||||
#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||'';
|
||||
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''){
|
||||
if ( $role->{project_id} eq '' ) {
|
||||
uac::print_error('missing parameter project_id!');
|
||||
next;
|
||||
}
|
||||
if($role->{studio_id}eq''){
|
||||
if ( $role->{studio_id} eq '' ) {
|
||||
uac::print_error('missing parameter studio_id!');
|
||||
next;
|
||||
}
|
||||
if(($role->{role}eq'')&&($id ne '')){
|
||||
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''){
|
||||
#insert role
|
||||
next if ($role->{role} eq'');
|
||||
if(defined $role_from_db){
|
||||
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;
|
||||
$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})" );
|
||||
$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";
|
||||
|
||||
#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;
|
||||
$config->{access}->{write} = 1;
|
||||
uac::update_role( $config, $role );
|
||||
$config->{access}->{write} = 0;
|
||||
}
|
||||
}
|
||||
print qq{<div class="ok head">changes saved</div>};
|
||||
@@ -205,241 +219,252 @@ sub save_roles{
|
||||
}
|
||||
|
||||
#check if update is allowed
|
||||
sub update_allowed{
|
||||
my $permissions=shift;
|
||||
my $role_by_id=shift;
|
||||
my $id=shift;
|
||||
sub update_allowed {
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
# user has to be assigned to studio
|
||||
# user needs to have permissions read_role
|
||||
sub show_roles{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub show_roles {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{read_role}==1){
|
||||
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 $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'};
|
||||
unshift @$roles, { role => '', level => '0' };
|
||||
|
||||
#print user role form
|
||||
my $out=qq{
|
||||
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}){
|
||||
#add new user role button
|
||||
$out.=q{
|
||||
if ( defined $permissions->{update_role} ) {
|
||||
|
||||
#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>/;
|
||||
}
|
||||
|
||||
#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){
|
||||
#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 .= '<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.=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>} ;
|
||||
#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};
|
||||
}
|
||||
$out.=qq{</tr>};
|
||||
|
||||
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>};
|
||||
|
||||
#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);
|
||||
# print '<pre>';
|
||||
# for my $key (@$columns){
|
||||
# printf (" %-40s => '',\n", "'".$key."'");
|
||||
# }
|
||||
# print '</pre>';
|
||||
$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>
|
||||
<input type="checkbox" name="}.$key.'_'.$id.qq{" value="$value" $checked class="$active">
|
||||
# print '<pre>';
|
||||
# for my $key (@$columns){
|
||||
# printf (" %-40s => '',\n", "'".$key."'");
|
||||
# }
|
||||
# print '</pre>';
|
||||
|
||||
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 .= 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 .= '</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;
|
||||
sub sort_columns {
|
||||
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";
|
||||
|
||||
my $index = $groups->{$group}||0;
|
||||
$index+=$actions->{$action} if (defined $actions->{$action});
|
||||
$column_level->{$column}=$index;
|
||||
# print $index."<br>";
|
||||
my $index = $groups->{$group} || 0;
|
||||
$index += $actions->{$action} if ( defined $actions->{$action} );
|
||||
$column_level->{$column} = $index;
|
||||
|
||||
# print $index."<br>";
|
||||
}
|
||||
|
||||
my @columns=sort {$column_level->{$a} <=> $column_level->{$b}} (keys %$column_level);
|
||||
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={};
|
||||
sub sort_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;
|
||||
}
|
||||
#weigth groups
|
||||
my $i=0;
|
||||
for my $group (sort keys %$groups){
|
||||
$groups->{$group}=$i;
|
||||
$i+=100;
|
||||
for my $column ( keys %$columns ) {
|
||||
my @words = split /_/, $column;
|
||||
my $action = shift @words;
|
||||
my $group = join( ' ', @words );
|
||||
$groups->{$group} = 1;
|
||||
}
|
||||
|
||||
#print "<pre>";
|
||||
#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>";
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
my $checked={};
|
||||
my $checked = {};
|
||||
|
||||
#template
|
||||
my $template='';
|
||||
$template=template::check($params->{template},'roles.html');
|
||||
$checked->{template}=$template;
|
||||
my $template = '';
|
||||
$template = template::check( $params->{template}, 'roles.html' );
|
||||
$checked->{template} = $template;
|
||||
|
||||
#actions
|
||||
if (defined $params->{action}){
|
||||
if ($params->{action} eq'save'){
|
||||
$checked->{action}=$params->{action};
|
||||
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};
|
||||
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;
|
||||
}
|
||||
|
||||
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*$/);
|
||||
for my $key ( keys %$params ) {
|
||||
$checked->{$key} = $params->{$key} if ( $key =~ /^[a-z_]+_\d*$/ );
|
||||
}
|
||||
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
|
||||
221
website/agenda/planung/selectEvent.cgi
Normal file → Executable file
221
website/agenda/planung/selectEvent.cgi
Normal file → Executable file
@@ -10,11 +10,13 @@ use log;
|
||||
use template;
|
||||
use auth;
|
||||
use uac;
|
||||
|
||||
#use roles;
|
||||
#use project;
|
||||
#use studios;
|
||||
#use events;
|
||||
use series;
|
||||
|
||||
#use series_schedule;
|
||||
#use series_events;
|
||||
#use series_dates;
|
||||
@@ -25,160 +27,163 @@ use localization;
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my ($user,$expires) = auth::get_user($cgi, $config);
|
||||
return if ((!defined $user) || ($user eq ''));
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
my $user_presets=uac::get_user_presets($config, {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
user => $user
|
||||
});
|
||||
$params->{default_studio_id}=$user_presets->{studio_id};
|
||||
$params->{studio_id} = $params->{default_studio_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
$params->{project_id} = $user_presets->{project_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
user => $user
|
||||
}
|
||||
);
|
||||
$params->{default_studio_id} = $user_presets->{studio_id};
|
||||
$params->{studio_id} = $params->{default_studio_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
$params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
my $request={
|
||||
url => $ENV{QUERY_STRING}||'',
|
||||
params => {
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
$params=$request->{params}->{checked};
|
||||
$params=uac::set_template_permissions($request->{permissions}, $params);
|
||||
$params->{loc} = localization::get($config, {user=>$user, file=>'selectEvent'});
|
||||
$params = $request->{params}->{checked};
|
||||
$params = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$params->{loc} = localization::get( $config, { user => $user, file => 'selectEvent' } );
|
||||
|
||||
#process header
|
||||
print "Content-type:text/html; charset=UTF-8;\n\n";
|
||||
|
||||
return unless uac::check($config, $params, $user_presets)==1;
|
||||
show_events($config, $request);
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
show_events( $config, $request );
|
||||
|
||||
sub show_events{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub show_events {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{read_event}==1){
|
||||
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 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 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 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_';
|
||||
}
|
||||
# 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 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 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 );
|
||||
|
||||
# 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 STDERR Dumper($params);
|
||||
template::process('print', $params->{template}, $params);
|
||||
return;
|
||||
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 );
|
||||
|
||||
# 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 STDERR Dumper($params);
|
||||
template::process( 'print', $params->{template}, $params );
|
||||
return;
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
my $checked = {};
|
||||
|
||||
my $checked={};
|
||||
|
||||
my $debug=$params->{debug} || '';
|
||||
if ($debug=~/([a-z\_\,]+)/){
|
||||
$debug=$1;
|
||||
my $debug = $params->{debug} || '';
|
||||
if ( $debug =~ /([a-z\_\,]+)/ ) {
|
||||
$debug = $1;
|
||||
}
|
||||
$checked->{debug}=$debug;
|
||||
$checked->{debug} = $debug;
|
||||
|
||||
#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 ( '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;
|
||||
}
|
||||
}
|
||||
|
||||
if ((defined $params->{year})&&($params->{year}=~/^\d\d\d\d$/)){
|
||||
$checked->{year}=$params->{year};
|
||||
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};
|
||||
}
|
||||
|
||||
# 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($params->{template},'selectEvent');
|
||||
$checked->{template} = template::check( $params->{template}, 'selectEvent' );
|
||||
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
|
||||
171
website/agenda/planung/selectSeries.cgi
Normal file → Executable file
171
website/agenda/planung/selectSeries.cgi
Normal file → Executable file
@@ -15,123 +15,127 @@ use localization;
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my ($user,$expires) = auth::get_user($cgi, $config);
|
||||
return if ((!defined $user) || ($user eq ''));
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
my $user_presets=uac::get_user_presets($config, {
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
user => $user
|
||||
});
|
||||
$params->{default_studio_id}=$user_presets->{studio_id};
|
||||
$params->{studio_id} = $params->{default_studio_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
$params->{project_id} = $user_presets->{project_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
user => $user
|
||||
}
|
||||
);
|
||||
$params->{default_studio_id} = $user_presets->{studio_id};
|
||||
$params->{studio_id} = $params->{default_studio_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
$params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
my $request={
|
||||
url => $ENV{QUERY_STRING}||'',
|
||||
params => {
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
$params=$request->{params}->{checked};
|
||||
$params=uac::set_template_permissions($request->{permissions}, $params);
|
||||
$params->{loc} = localization::get($config, {user=>$user, file=>'selectSeries'});
|
||||
$params = $request->{params}->{checked};
|
||||
$params = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$params->{loc} = localization::get( $config, { user => $user, file => 'selectSeries' } );
|
||||
|
||||
#process header
|
||||
print "Content-type:text/html; charset=UTF-8;\n\n";
|
||||
|
||||
return unless uac::check($config, $params, $user_presets)==1;
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{read_series}==1){
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{read_series} == 1 ) {
|
||||
uac::permissions_denied('read_series');
|
||||
return;
|
||||
}
|
||||
|
||||
show_series($config, $request);
|
||||
show_series( $config, $request );
|
||||
|
||||
sub show_series{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub show_series {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{read_series}==1){
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{read_series} == 1 ) {
|
||||
uac::permissions_denied('read_series');
|
||||
return;
|
||||
}
|
||||
|
||||
# get user projects
|
||||
my $user_projects=uac::get_projects_by_user($config, { user => $request->{user} });
|
||||
my $projects={};
|
||||
for my $project (@$user_projects){
|
||||
$projects->{$project->{project_id}}=$project;
|
||||
}
|
||||
|
||||
# get user 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 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 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_';
|
||||
}
|
||||
# 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} );
|
||||
}
|
||||
|
||||
$params->{studios}= $user_studios;
|
||||
$params->{series} = $series;
|
||||
|
||||
template::process('print', $params->{template}, $params);
|
||||
return;
|
||||
# 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_';
|
||||
}
|
||||
|
||||
$params->{studios} = $user_studios;
|
||||
$params->{series} = $series;
|
||||
|
||||
template::process( 'print', $params->{template}, $params );
|
||||
return;
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
my $checked = {};
|
||||
|
||||
my $checked={};
|
||||
|
||||
my $debug=$params->{debug} || '';
|
||||
if ($debug=~/([a-z\_\,]+)/){
|
||||
$debug=$1;
|
||||
my $debug = $params->{debug} || '';
|
||||
if ( $debug =~ /([a-z\_\,]+)/ ) {
|
||||
$debug = $1;
|
||||
}
|
||||
$checked->{debug}=$debug;
|
||||
$checked->{debug} = $debug;
|
||||
|
||||
#numeric values
|
||||
for my $param ('id', 'project_id', 'studio_id', 'series_id', 'p_id', 's_id'){
|
||||
if ((defined $params->{$param})&&($params->{$param}=~/^[\-\d]+$/)){
|
||||
$checked->{$param}=$params->{$param};
|
||||
for my $param ( 'id', 'project_id', 'studio_id', 'series_id', 'p_id', 's_id' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^[\-\d]+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
for my $param ('selectProjectStudio', 'selectSeries', 'selectRange'){
|
||||
if ((defined $params->{$param})&&($params->{$param} eq '1')){
|
||||
$checked->{$param}=$params->{$param};
|
||||
for my $param ( 'selectProjectStudio', 'selectSeries', 'selectRange' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} eq '1' ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
for my $param ('resultElemId'){
|
||||
if ((defined $params->{$param})&&($params->{$param}=~/^[a-zA-ZöäüÖÄÜß_\d]+$/)){
|
||||
$checked->{$param}=$params->{$param};
|
||||
for my $param ('resultElemId') {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^[a-zA-ZöäüÖÄÜß_\d]+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,15 +143,14 @@ sub check_params{
|
||||
$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($params->{template},'selectSeries');
|
||||
$checked->{template} = template::check( $params->{template}, 'selectSeries' );
|
||||
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
204
website/agenda/planung/show-playout.cgi
Executable file
204
website/agenda/planung/show-playout.cgi
Executable file
@@ -0,0 +1,204 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
local $| = 0;
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use Data::Dumper;
|
||||
use CGI::Simple ();
|
||||
use ModPerl::Util ();
|
||||
|
||||
use config;
|
||||
use log;
|
||||
use localization;
|
||||
use auth;
|
||||
use uac;
|
||||
use studios;
|
||||
use series;
|
||||
use template;
|
||||
use playout;
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
#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
|
||||
}
|
||||
);
|
||||
$params->{default_studio_id} = $user_presets->{studio_id};
|
||||
$params->{studio_id} = $params->{default_studio_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
$params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
#print STDERR $params->{project_id}."\n";
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
#process header
|
||||
unless ( params::isJson() ) {
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( 'print', template::check('default.html'), $headerParams );
|
||||
}
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
print q{
|
||||
<script src="js/show-playout.js" type="text/javascript"></script>
|
||||
<link rel="stylesheet" href="css/show-playout.css" type="text/css" />
|
||||
} unless (params::isJson);
|
||||
|
||||
my $permissions = $request->{permissions};
|
||||
$params->{action} = '' unless defined $params->{action};
|
||||
$params->{error} = $error || '';
|
||||
|
||||
showPlayout( $config, $request );
|
||||
|
||||
print STDERR "$0 ERROR: " . $params->{error} . "\n" if $params->{error} ne '';
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'event,comment' } );
|
||||
template::process( 'print', $params->{template}, $params );
|
||||
|
||||
exit;
|
||||
|
||||
sub showPlayout {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
|
||||
for my $attr ( 'project_id', 'studio_id' ) {
|
||||
unless ( defined $params->{$attr} ) {
|
||||
uac::print_error( "missing " . $attr . " to show playout" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
my $events = playout::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
order => 'modified_at desc, start desc',
|
||||
limit => 500
|
||||
}
|
||||
);
|
||||
|
||||
# print '<pre>'.Dumper($events).'</pre>';
|
||||
unless ( defined $events ) {
|
||||
uac::print_error("not found");
|
||||
return;
|
||||
}
|
||||
|
||||
for my $event (@$events) {
|
||||
$event->{stream_size} =~ s/(\d)(\d\d\d)$/$1\.$2/g;
|
||||
$event->{stream_size} =~ s/(\d)(\d\d\d\.\d\d\d)$/$1\.$2/g;
|
||||
$event->{duration} =~ s/(\d\.\d)(\d+)$/$1/g;
|
||||
$event->{duration} =~ s/(\d)\.0/$1/g;
|
||||
$event->{rms_left} = formatLoudness( $event->{rms_left} );
|
||||
$event->{rms_right} = formatLoudness( $event->{rms_right} );
|
||||
$event->{bitrate} = formatBitrate($event);
|
||||
$event->{duration} = formatDuration($event);
|
||||
}
|
||||
|
||||
$params->{events} = $events;
|
||||
|
||||
#print Dumper($events);
|
||||
}
|
||||
|
||||
sub formatDuration {
|
||||
my $event = $_[0];
|
||||
my $duration = $event->{duration};
|
||||
return '' unless defined $duration;
|
||||
return '' if $duration eq '';
|
||||
my $result = int( ( $duration + 3600 ) * 10 ) % 600;
|
||||
my $class = "ok";
|
||||
$class = "warn" if $result > 1;
|
||||
$class = "error" if $result > 10;
|
||||
return sprintf( qq{<div class="%s">%.01f</div>}, $class, $duration );
|
||||
}
|
||||
|
||||
sub formatBitrate {
|
||||
my $event = $_[0];
|
||||
my $bitrate = $event->{bitrate};
|
||||
my $mode = $event->{bitrate_mode};
|
||||
if ( $bitrate ne '' ) {
|
||||
if ( $bitrate >= 200 ) {
|
||||
$bitrate = '<div class="warn">' . $bitrate . ' ' . $mode . '</div>';
|
||||
} elsif ( $bitrate < 190 ) {
|
||||
$bitrate = '<div class="error">' . $bitrate . ' ' . $mode . '</div>';
|
||||
} else {
|
||||
$bitrate .= ' ' . $mode;
|
||||
}
|
||||
}
|
||||
return $bitrate;
|
||||
}
|
||||
|
||||
sub formatLoudness {
|
||||
my $value = shift;
|
||||
return '' unless defined $value;
|
||||
return '' if $value == 0;
|
||||
return '' if $value eq '';
|
||||
|
||||
$value = sprintf( "%.1f", $value );
|
||||
my $class = 'ok';
|
||||
$class = 'warn' if $value > -18.5;
|
||||
$class = 'error' if $value > -16.0;
|
||||
$class = 'warn' if $value < -24.0;
|
||||
$class = 'error' if $value < -27.0;
|
||||
|
||||
return qq{<div class="$class">$value dB</div>};
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
my $checked = {};
|
||||
$checked->{error} = '';
|
||||
$checked->{template} = template::check( $params->{template}, 'show_playout' );
|
||||
|
||||
#numeric values
|
||||
for my $param ( 'project_id', 'studio_id', 'default_studio_id', 'series_id', 'event_id', 'id' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
if ( defined $checked->{studio_id} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
|
||||
#word
|
||||
for my $param ('debug') {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\s*(.+?)\s*$/ ) ) {
|
||||
$checked->{$param} = $1;
|
||||
}
|
||||
}
|
||||
|
||||
return $checked;
|
||||
}
|
||||
|
||||
543
website/agenda/planung/studio_timeslots.cgi
Normal file → Executable file
543
website/agenda/planung/studio_timeslots.cgi
Normal file → Executable file
@@ -22,51 +22,57 @@ use localization;
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my ($user,$expires) = auth::get_user($cgi, $config);
|
||||
return if ((!defined $user) || ($user eq ''));
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
my $user_presets=uac::get_user_presets($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'));
|
||||
$params->{project_id}=$user_presets->{project_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$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' ) );
|
||||
$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 => {
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
$params=$request->{params}->{checked};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
#process header
|
||||
my $headerParams=uac::set_template_permissions($request->{permissions}, $params);
|
||||
$headerParams->{loc} = localization::get($config, {user=>$user, file=>'all,menu'});
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'all,menu' } );
|
||||
|
||||
my $action=$params->{action}||'';
|
||||
if ($action eq 'show_dates'){
|
||||
#print "Content-type:text/html\n\n";
|
||||
}else{
|
||||
template::process('print', template::check('default.html'), $headerParams);
|
||||
my $action = $params->{action} || '';
|
||||
if ( $action eq 'show_dates' ) {
|
||||
|
||||
#print "Content-type:text/html\n\n";
|
||||
} else {
|
||||
template::process( 'print', template::check('default.html'), $headerParams );
|
||||
}
|
||||
return unless uac::check($config, $params, $user_presets)==1;
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
if ($action eq 'show_dates'){
|
||||
print "Content-Type:text/html\n\n";
|
||||
}else{
|
||||
print q{
|
||||
if ( $action eq 'show_dates' ) {
|
||||
print "Content-Type:text/html\n\n";
|
||||
} else {
|
||||
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">
|
||||
@@ -76,334 +82,337 @@ 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;
|
||||
};
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
$config->{access}->{write}=0;
|
||||
showTimeslotSchedule($config, $request);
|
||||
$config->{access}->{write} = 0;
|
||||
showTimeslotSchedule( $config, $request );
|
||||
return;
|
||||
|
||||
#insert or update a schedule and update all schedule dates
|
||||
sub save_schedule{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub save_schedule {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{update_studio_timeslot_schedule}==1){
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
my $entry={};
|
||||
for my $attr (
|
||||
'project_id', 'start', 'end', 'end_date', 'frequency'
|
||||
){
|
||||
$entry->{$attr}=$params->{$attr} if (defined $params->{$attr});
|
||||
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;
|
||||
}
|
||||
}
|
||||
#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})){
|
||||
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} );
|
||||
|
||||
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);
|
||||
studio_timeslot_schedule::update($config, $entry);
|
||||
#my $updates=0;
|
||||
#print Dumper($entry);
|
||||
my $updates=studio_timeslot_dates::update($config, $entry);
|
||||
#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 );
|
||||
|
||||
#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);
|
||||
} 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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub delete_schedule {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
sub delete_schedule{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{update_studio_timeslot_schedule}==1){
|
||||
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!');
|
||||
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);
|
||||
$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;
|
||||
sub showTimeslotSchedule {
|
||||
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){
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
#this will be updated later (especially allow_update_events)
|
||||
for my $permission (keys %{$request->{permissions}}){
|
||||
$params->{'allow'}->{$permission}=$request->{permissions}->{$permission};
|
||||
for my $param ( 'project_id', 'studio_id' ) {
|
||||
unless ( defined $params->{$param} ) {
|
||||
uac::print_error("missing $param");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$params->{loc} = localization::get($config, {user=>$params->{presets}->{user}, file=>'all,studio_timeslots'});
|
||||
|
||||
#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' } );
|
||||
|
||||
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
|
||||
# studio_id=>$studio_id
|
||||
}
|
||||
);
|
||||
#get project schedule
|
||||
my $schedules = studio_timeslot_schedule::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id
|
||||
|
||||
#list of all studios by id
|
||||
my $studios=studios::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/;
|
||||
$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;
|
||||
}
|
||||
}
|
||||
#list of all studios by id
|
||||
my $studios = studios::get( $config, { project_id => $project_id } );
|
||||
|
||||
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 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 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};
|
||||
#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};
|
||||
|
||||
#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};
|
||||
}
|
||||
|
||||
#print '<pre>'.Dumper($params).'</pre>';
|
||||
template::process('print', $params->{template}, $params);
|
||||
template::process( 'print', $params->{template}, $params );
|
||||
}
|
||||
|
||||
sub showDates {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
sub showDates{
|
||||
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){
|
||||
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 $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,
|
||||
# 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};
|
||||
my $fromDate = $params->{show_date} . '-01-01';
|
||||
my $tillDate = $params->{show_date} . '-12-31';
|
||||
|
||||
# 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},
|
||||
};
|
||||
#add timeslot dates
|
||||
my $timeslot_dates = studio_timeslot_dates::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
|
||||
my $studios=studios::get($config, {project_id=>$project_id});
|
||||
my $studio_by_id={};
|
||||
for my $studio (@$studios){
|
||||
$studio_by_id->{$studio->{id}}=$studio;
|
||||
}
|
||||
# studio_id=>$studio_id,
|
||||
from => $fromDate,
|
||||
till => $tillDate
|
||||
}
|
||||
);
|
||||
|
||||
#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/;
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'all,studio_timeslots' } );
|
||||
my $language = $params->{loc}->{region};
|
||||
|
||||
# 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};
|
||||
# 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 $template=template::check('studio_timeslot_dates');
|
||||
template::process('print', $template, $params);
|
||||
|
||||
#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/;
|
||||
|
||||
# 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};
|
||||
}
|
||||
|
||||
my $template = template::check('studio_timeslot_dates');
|
||||
template::process( 'print', $template, $params );
|
||||
}
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
my $checked={};
|
||||
my $checked = {};
|
||||
|
||||
my $debug=$params->{debug} || '';
|
||||
if ($debug=~/([a-z\_\,]+)/){
|
||||
$debug=$1;
|
||||
my $debug = $params->{debug} || '';
|
||||
if ( $debug =~ /([a-z\_\,]+)/ ) {
|
||||
$debug = $1;
|
||||
}
|
||||
$checked->{debug}=$debug;
|
||||
$checked->{debug} = $debug;
|
||||
|
||||
#actions and roles
|
||||
if (defined $params->{action}){
|
||||
if ($params->{action}=~/^(show|save_schedule|delete_schedule|show_dates)$/){
|
||||
$checked->{action}=$params->{action};
|
||||
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};
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
$checked->{template}=template::check($params->{template},'studio_timeslots');
|
||||
|
||||
for my $param ('frequency'){
|
||||
if ((defined $params->{$param})&&($params->{$param}=~/(\d+)/)){
|
||||
$checked->{$param}=$1;
|
||||
$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};
|
||||
}
|
||||
}
|
||||
|
||||
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';
|
||||
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;
|
||||
}
|
||||
|
||||
$checked->{template} = template::check( $params->{template}, 'studio_timeslots' );
|
||||
|
||||
for my $param ('frequency') {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /(\d+)/ ) ) {
|
||||
$checked->{$param} = $1;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,208 +15,230 @@ use studios;
|
||||
use series;
|
||||
use localization;
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config =config::get('../config/config.cgi');
|
||||
my $debug =$config->{system}->{debug};
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
|
||||
my ($user,$expires) = auth::get_user($cgi, $config);
|
||||
return if ($user eq '');
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( $user eq '' );
|
||||
|
||||
my $permissions=roles::get_user_permissions();
|
||||
my $user_presets=uac::get_user_presets($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'));
|
||||
$params->{project_id}=$user_presets->{project_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
my $permissions = roles::get_user_permissions();
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$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' ) );
|
||||
$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 => {
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
$params=$request->{params}->{checked};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
#process header
|
||||
my $headerParams=uac::set_template_permissions($request->{permissions}, $params);
|
||||
$headerParams->{loc} = localization::get($config, {user=>$user, file=>'menu'});
|
||||
template::process('print', template::check('default.html'), $headerParams);
|
||||
return unless uac::check($config, $params, $user_presets)==1;
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( 'print', template::check('default.html'), $headerParams );
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
print q{
|
||||
<link rel="stylesheet" href="css/studios.css" type="text/css" />
|
||||
<script src="js/studios.js" type="text/javascript"></script>
|
||||
};
|
||||
|
||||
if (defined $params->{action}){
|
||||
save_studio ($config, $request) if ($params->{action} eq 'save');
|
||||
delete_studio($config, $request) if ($params->{action} eq 'delete');
|
||||
if ( defined $params->{action} ) {
|
||||
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);
|
||||
$config->{access}->{write} = 0;
|
||||
show_studios( $config, $request );
|
||||
|
||||
sub delete_studio{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub delete_studio {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{update_studio}==1){
|
||||
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(@$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 ( @$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;
|
||||
sub save_studio {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{update_studio}==1){
|
||||
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(@$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}
|
||||
});
|
||||
$config->{access}->{write} = 1;
|
||||
if ( ( defined $entry->{id} ) && ( $entry ne '' ) ) {
|
||||
studios::update( $config, $entry );
|
||||
} else {
|
||||
my $studios = studios::get( $config, { name => $entry->{name} } );
|
||||
if ( @$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}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#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 ( @$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(@$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>};
|
||||
}
|
||||
|
||||
sub show_studios{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub show_studios {
|
||||
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('print', $params->{template}, $params);
|
||||
template::process( 'print', $params->{template}, $params );
|
||||
}
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
my $checked={};
|
||||
my $checked = {};
|
||||
|
||||
#template
|
||||
my $template='';
|
||||
$template=template::check($params->{template},'studios');
|
||||
$checked->{template}=$template;
|
||||
my $template = '';
|
||||
$template = template::check( $params->{template}, 'studios' );
|
||||
$checked->{template} = $template;
|
||||
|
||||
#actions
|
||||
my $action='';
|
||||
if (defined $params->{action}){
|
||||
if ($params->{action}=~/^(save|delete)$/){
|
||||
$checked->{action}=$params->{action};
|
||||
my $action = '';
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(save|delete)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
|
||||
for my $param ('name', 'description', 'location', 'stream', 'google_calendar'){
|
||||
if (defined $params->{$param}){
|
||||
$checked->{$param}=$params->{$param};
|
||||
for my $param ( 'name', 'description', 'location', 'stream', 'google_calendar' ) {
|
||||
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};
|
||||
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;
|
||||
}
|
||||
|
||||
if ( defined $checked->{studio_id} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
|
||||
return $checked;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,10 @@
|
||||
<div> <a href="series.cgi?project_id=<TMPL_VAR project_id>&studio_id=<TMPL_VAR default_studio_id>"><TMPL_VAR .loc.series></a> </div>
|
||||
</TMPL_IF>
|
||||
|
||||
<TMPL_IF .allow.read_playout>
|
||||
<div> <a href="show-playout.cgi?project_id=<TMPL_VAR project_id>&studio_id=<TMPL_VAR default_studio_id>"><TMPL_VAR .loc.playout></a> </div>
|
||||
</TMPL_IF>
|
||||
|
||||
<TMPL_IF .allow.read_user>
|
||||
<div> <a href="users.cgi?project_id=<TMPL_VAR project_id>&studio_id=<TMPL_VAR default_studio_id>"><TMPL_VAR .loc.users></a> </div>
|
||||
</TMPL_IF>
|
||||
|
||||
@@ -436,6 +436,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<TMPL_IF .allow.read_image>
|
||||
<tr>
|
||||
<td class="label">
|
||||
<TMPL_VAR .loc.label_image>
|
||||
@@ -448,11 +449,10 @@
|
||||
<img id="imagePreview" src="<TMPL_VAR image>">
|
||||
</button>
|
||||
<input id="image_<TMPL_VAR event_id>" name="image" value="<TMPL_VAR image>" class="image" style="float:right" placeholder="<TMPL_VAR .loc.label_image>">
|
||||
<TMPL_ELSE>
|
||||
<img src="<TMPL_VAR image>">
|
||||
</TMPL_IF>
|
||||
</td>
|
||||
</tr>
|
||||
</TMPL_IF>
|
||||
|
||||
<tr>
|
||||
<td class="label">
|
||||
|
||||
@@ -139,8 +139,6 @@
|
||||
<img id="imagePreview" src="<TMPL_VAR image>">
|
||||
</button>
|
||||
<input id="image_<TMPL_VAR .series_id>" name="image" value="<TMPL_VAR image>" class="image" placeholder="<TMPL_VAR .loc.template_image>">
|
||||
<TMPL_ELSE>
|
||||
<img src="<TMPL_VAR image>">
|
||||
</TMPL_IF>
|
||||
</td></tr>
|
||||
<tr> <td class="label"><TMPL_VAR .loc.template_duration></td>
|
||||
@@ -445,7 +443,9 @@
|
||||
<table class="table">
|
||||
<TMPL_LOOP events>
|
||||
<tr id="event_<TMPL_VAR event_id>">
|
||||
<TMPL_IF .allow.read_image>
|
||||
<td class="logo"><img src="<TMPL_VAR image>" width="33" height="33"></td>
|
||||
</TMPL_IF>
|
||||
<td class="weekday"><TMPL_VAR weekday_short_name></td>
|
||||
<td class="date"><TMPL_VAR start_date></td>
|
||||
<td class="time"><TMPL_VAR start_time_name></td>
|
||||
|
||||
16
website/agenda/planung/templates/notify_daily.html
Normal file
16
website/agenda/planung/templates/notify_daily.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<table id="events">
|
||||
<TMPL_LOOP events>
|
||||
<tr id="header_<TMPL_VAR event_id>" class="mailHeader">
|
||||
<td><TMPL_VAR start></td>
|
||||
<td><TMPL_IF live>live</TMPL_IF> <TMPL_IF preproduction>preproduction</TMPL_IF> <TMPL_IF playout>playout</TMPL_IF></td>
|
||||
<td><TMPL_VAR full_title></td>
|
||||
<td><TMPL_VAR mail.To></td>
|
||||
</tr>
|
||||
</TMPL_LOOP>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
9
website/agenda/planung/templates/notify_daily.txt
Normal file
9
website/agenda/planung/templates/notify_daily.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
Content-type:text/plain
|
||||
|
||||
<TMPL_LOOP events>
|
||||
date: <TMPL_VAR start>
|
||||
<TMPL_IF live>live</TMPL_IF> <TMPL_IF preproduction>preproduction</TMPL_IF> <TMPL_IF playout>playout</TMPL_IF>
|
||||
<TMPL_VAR full_title>
|
||||
<TMPL_VAR mail.To>
|
||||
</TMPL_LOOP>
|
||||
|
||||
19
website/agenda/planung/templates/notify_overview.html
Normal file
19
website/agenda/planung/templates/notify_overview.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<html>
|
||||
|
||||
<body>
|
||||
|
||||
<table id="events">
|
||||
<TMPL_LOOP events>
|
||||
|
||||
<tr id="header_<TMPL_VAR event_id>" class="mailHeader">
|
||||
<td><TMPL_VAR start></td>
|
||||
<td><TMPL_IF live>live</TMPL_IF> <TMPL_IF preproduction>preproduction</TMPL_IF> <TMPL_IF playout>playout</TMPL_IF></td>
|
||||
<td><TMPL_VAR full_title></td>
|
||||
<td><TMPL_VAR mail.To></td>
|
||||
</tr>
|
||||
|
||||
</TMPL_LOOP>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
9
website/agenda/planung/templates/notify_overview.txt
Normal file
9
website/agenda/planung/templates/notify_overview.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
Content-type:text/plain; charset=utf-8;
|
||||
|
||||
<TMPL_LOOP events>
|
||||
date: <TMPL_VAR start>
|
||||
title: <TMPL_VAR full_title>
|
||||
status: <TMPL_IF live>live<TMPL_ELSE><TMPL_IF preproduction>preproduction</TMPL_IF></TMPL_IF><TMPL_IF playout>playout</TMPL_IF>
|
||||
contact: <TMPL_VAR mail.To>
|
||||
</TMPL_LOOP>
|
||||
|
||||
43
website/agenda/planung/templates/show_playout.html
Normal file
43
website/agenda/planung/templates/show_playout.html
Normal file
@@ -0,0 +1,43 @@
|
||||
<link href="css/jquery-ui-timepicker.css" type="text/css" rel="stylesheet" />
|
||||
<script src="js/jquery-ui-timepicker.js" type="text/javascript"></script>
|
||||
|
||||
<script src="js/jquery.autosize.min.js" type="text/javascript"></script>
|
||||
<link href="css/theme.default.css" rel="stylesheet">
|
||||
|
||||
<script src="js/jquery.tablesorter.min.js"></script>
|
||||
<script src="js/jquery.tablesorter.widgets.min.js"></script>
|
||||
<script src="js/jquery.tablesorter.scroller.js"></script>
|
||||
|
||||
<script src="js/image.js" type="text/javascript"></script>
|
||||
|
||||
|
||||
<table id="playout-table" class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>start</th>
|
||||
<th>playout path</th>
|
||||
<th>seconds</th>
|
||||
<th>loudness</th>
|
||||
<th>format</th>
|
||||
<th>image</th>
|
||||
<th>bytes</th>
|
||||
<th>modified at</th>
|
||||
</thead>
|
||||
</tr>
|
||||
<tbody>
|
||||
<TMPL_LOOP events>
|
||||
<tr>
|
||||
<td><TMPL_VAR start></td>
|
||||
<td><TMPL_VAR file></td>
|
||||
<td><TMPL_VAR duration escape="text"></td>
|
||||
<td><TMPL_VAR rms_left escape="text"> <TMPL_VAR rms_right escape="text"></td>
|
||||
<td><TMPL_VAR bitrate escape="text"> <TMPL_VAR sampling_rate> <TMPL_VAR channels> ch.</td>
|
||||
<td><TMPL_IF rms_image><a href="/agenda_files/playout/<TMPL_VAR rms_image>"><img src="/agenda_files/playout/<TMPL_VAR rms_image>"></a></TMPL_IF></td>
|
||||
<td><TMPL_VAR stream_size></td>
|
||||
<td><TMPL_VAR modified_at></td>
|
||||
</tr>
|
||||
</TMPL_LOOP>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
|
||||
<TMPL_IF .allow.upload_audio_recordings>
|
||||
<div id="error" class="error" style="display:none"></div>
|
||||
<div id="info" class="ok" style="display:none"></div>
|
||||
|
||||
<h2>
|
||||
<TMPL_VAR event.weekday_short_name>, <TMPL_VAR event.start_date_name> <TMPL_VAR event.start_time_name><br>
|
||||
@@ -13,27 +15,31 @@
|
||||
<hr/>
|
||||
|
||||
<TMPL_UNLESS isOver>
|
||||
|
||||
<div id="progress" style="display:none;vertical-align:middle;background:#aaa;text-align:center;margin:1em;padding:1em;font-size:1em;font-weight:bold;color:#fff" >
|
||||
<div>Ich lade jetzt die Datei hoch... Pieps.</div>
|
||||
<div><img src="/agenda/image/upload/bird9.gif" /></div>
|
||||
<div>Ist das aufregend!</div>
|
||||
<progress id="progressBar"></progress>
|
||||
<div id="progressLabel"></div>
|
||||
</div>
|
||||
|
||||
<form name="audio_recordings_upload" id="audio_recordings_upload" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="project_id" value="<TMPL_VAR project_id>" />
|
||||
<input type="hidden" name="studio_id" value="<TMPL_VAR studio_id>" />
|
||||
<input type="hidden" name="studio_id" value="<TMPL_VAR studio_id>" />
|
||||
<input type="hidden" name="series_id" value="<TMPL_VAR series_id>" />
|
||||
<input type="hidden" name="event_id" value="<TMPL_VAR event_id>" />
|
||||
<table class="table">
|
||||
<input type="hidden" name="action" value="upload" />
|
||||
<table>
|
||||
<tr>
|
||||
<td>Datei</td>
|
||||
|
||||
<td><input type="file" name="upload" size="20"
|
||||
accept="audio/mp3" maxlength="2000000000"
|
||||
/></td>
|
||||
<td><input type="file" id="file" name="upload" size="20" accept="audio/mp3" maxlength="2000000000" /></td>
|
||||
|
||||
<td colspan="2" style="text-align:right;padding-right:0.5em;" onclick="showProgress()">
|
||||
<input type="submit" name="action" value="upload" />
|
||||
<td colspan="2" style="text-align:right;padding-right:0.5em;" id="uploadSize"></td>
|
||||
|
||||
<td colspan="2" style="text-align:right;padding-right:0.5em;" >
|
||||
<button id="uploadButton" name="action" value="upload" >upload</button>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
@@ -51,18 +57,28 @@
|
||||
<table>
|
||||
<tr>
|
||||
<th>action</th>
|
||||
<!--<th>id</th>-->
|
||||
<th>name</th>
|
||||
<th>size in bytes</th>
|
||||
<th>event duration in seconds</th>
|
||||
<th>audio duration in seconds</th>
|
||||
<th>RMS L</th>
|
||||
<th>RMS R</th>
|
||||
<th>processed</th>
|
||||
<th>mastered</th>
|
||||
<th>uploaded by</th>
|
||||
<th>uploaded at</th>
|
||||
</tr>
|
||||
<TMPL_LOOP audio_recordings>
|
||||
<tr>
|
||||
<td><button onclick="playAudio('<TMPL_VAR path>');return false">play</button></td>
|
||||
<!--<td><TMPL_VAR id></td>-->
|
||||
<td><TMPL_VAR path></td>
|
||||
<td><TMPL_VAR size></td>
|
||||
<td><TMPL_VAR eventDuration></td>
|
||||
<td><TMPL_VAR audioDuration></td>
|
||||
<td><TMPL_VAR rmsLeft></td>
|
||||
<td><TMPL_VAR rmsRight></td>
|
||||
<td><TMPL_VAR processed></td>
|
||||
<td><TMPL_VAR mastered></td>
|
||||
<td><TMPL_VAR created_by></td>
|
||||
<td><TMPL_VAR created_at></td>
|
||||
<TMPL_IF .allow.delete_audio_recordings>
|
||||
@@ -70,7 +86,7 @@
|
||||
<form method="post">
|
||||
<input type="hidden" name="project_id" value="<TMPL_VAR project_id>" />
|
||||
<input type="hidden" name="studio_id" value="<TMPL_VAR studio_id>" />
|
||||
<input type="hidden" name="series_id" value="<TMPL_VAR series_id>" />
|
||||
<input type="hidden" name="series_id" value="<TMPL_VAR .series_id>" />
|
||||
<input type="hidden" name="event_id" value="<TMPL_VAR event_id>" />
|
||||
<input type="hidden" name="path" value="<TMPL_VAR path>" />
|
||||
<button type="submit" name="action" value="delete"><TMPL_VAR .loc.button_delete></button>
|
||||
|
||||
294
website/agenda/planung/user_settings.cgi
Normal file → Executable file
294
website/agenda/planung/user_settings.cgi
Normal file → Executable file
@@ -16,192 +16,198 @@ use params;
|
||||
use user_settings;
|
||||
use localization;
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
my $config =config::get('../config/config.cgi');
|
||||
my $debug =$config->{system}->{debug};
|
||||
my ($user,$expires) = auth::get_user($cgi, $config);
|
||||
return if ((!defined $user) || ($user eq ''));
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$config,
|
||||
{
|
||||
user => $user,
|
||||
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' ) );
|
||||
$params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
my $user_presets=uac::get_user_presets($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'));
|
||||
$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 => {
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
$params=$request->{params}->{checked};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
#process header
|
||||
my $headerParams = uac::set_template_permissions($request->{permissions}, $params);
|
||||
$headerParams->{loc} = localization::get($config, {user=>$user, file=>'menu'});
|
||||
template::process('print', template::check('default.html'), $headerParams);
|
||||
return unless uac::check($config, $params, $user_presets)==1;
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( 'print', template::check('default.html'), $headerParams );
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
our $errors=[];
|
||||
our $errors = [];
|
||||
|
||||
if (defined $params->{action}){
|
||||
update_settings($config,$request) if ($params->{action}eq 'save');
|
||||
if ( defined $params->{action} ) {
|
||||
update_settings( $config, $request ) if ( $params->{action} eq 'save' );
|
||||
}
|
||||
$config->{access}->{write}=0;
|
||||
show_settings($config,$request);
|
||||
$config->{access}->{write} = 0;
|
||||
show_settings( $config, $request );
|
||||
|
||||
|
||||
sub show_settings{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
|
||||
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});
|
||||
|
||||
#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;
|
||||
|
||||
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;
|
||||
|
||||
$params->{loc} = localization::get($config, {language=>$language, file=>'user_settings'});
|
||||
#print STDERR Dumper($params->{loc});
|
||||
|
||||
for my $color (@{$params->{colors}}){
|
||||
$color->{title}=$params->{loc}->{$color->{title}};
|
||||
}
|
||||
uac::set_template_permissions($permissions, $params);
|
||||
#print Dumper($permissions);
|
||||
template::process('print', $params->{template}, $params);
|
||||
|
||||
#print '<pre>'.Dumper($user_settings);
|
||||
}
|
||||
|
||||
sub update_settings{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub show_settings {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
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++;
|
||||
}
|
||||
# unless ($permissions->{read_user}==1){
|
||||
# uac::permissions_denied('read_user');
|
||||
# return;
|
||||
# }
|
||||
my $user = $params->{presets}->{user};
|
||||
my $colors = user_settings::getColors( $config, { user => $user } );
|
||||
|
||||
my $settings={
|
||||
user => $user,
|
||||
colors => join("\n",@colors),
|
||||
language => $params->{language},
|
||||
period => $params->{period}
|
||||
};
|
||||
#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++;
|
||||
}
|
||||
|
||||
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;
|
||||
$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 $period = $user_settings->{period} || 'month';
|
||||
$params->{ 'period_' . $period } = 1;
|
||||
|
||||
$params->{loc} = localization::get( $config, { language => $language, file => 'user_settings' } );
|
||||
|
||||
#print STDERR Dumper($params->{loc});
|
||||
|
||||
for my $color ( @{ $params->{colors} } ) {
|
||||
$color->{title} = $params->{loc}->{ $color->{title} };
|
||||
}
|
||||
uac::set_template_permissions( $permissions, $params );
|
||||
|
||||
#print Dumper($permissions);
|
||||
template::process( 'print', $params->{template}, $params );
|
||||
|
||||
#print '<pre>'.Dumper($user_settings);
|
||||
}
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
sub update_settings {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $checked={};
|
||||
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++;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
my $checked = {};
|
||||
|
||||
#template
|
||||
my $template='';
|
||||
$template=template::check($params->{template},'user_settings');
|
||||
$checked->{template}=$template;
|
||||
my $template = '';
|
||||
$template = template::check( $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};
|
||||
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;
|
||||
}
|
||||
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};
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(save)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
}
|
||||
return $checked;
|
||||
}
|
||||
|
||||
sub error{
|
||||
push @$errors,{error=>$_[0]};
|
||||
sub error {
|
||||
push @$errors, { error => $_[0] };
|
||||
}
|
||||
|
||||
|
||||
115
website/agenda/planung/user_stats.cgi
Normal file → Executable file
115
website/agenda/planung/user_stats.cgi
Normal file → Executable file
@@ -17,93 +17,96 @@ use user_settings;
|
||||
use user_stats;
|
||||
use localization;
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config =config::get('../config/config.cgi');
|
||||
my $debug =$config->{system}->{debug};
|
||||
my ($user,$expires) = auth::get_user($cgi, $config);
|
||||
return if ((!defined $user) || ($user eq ''));
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
my $user_presets=uac::get_user_presets($config, {
|
||||
user => $user,
|
||||
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'));
|
||||
$params->{project_id}=$user_presets->{project_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$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' ) );
|
||||
$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 => {
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
$params=$request->{params}->{checked};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
#process header
|
||||
my $headerParams = uac::set_template_permissions($request->{permissions}, $params);
|
||||
$headerParams->{loc} = localization::get($config, {user=>$user, file=>'menu'});
|
||||
template::process('print', template::check('default.html'), $headerParams);
|
||||
return unless uac::check($config, $params, $user_presets)==1;
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( 'print', template::check('default.html'), $headerParams );
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
our $errors=[];
|
||||
our $errors = [];
|
||||
|
||||
show_stats($config,$request);
|
||||
show_stats( $config, $request );
|
||||
|
||||
sub show_stats {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
sub show_stats{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{read_user_stats}){
|
||||
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->{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('print', $params->{template}, $params);
|
||||
$params->{errors} = $errors;
|
||||
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'user_stats' } );
|
||||
uac::set_template_permissions( $permissions, $params );
|
||||
template::process( 'print', $params->{template}, $params );
|
||||
}
|
||||
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
|
||||
my $checked={};
|
||||
my $checked = {};
|
||||
|
||||
#template
|
||||
my $template='';
|
||||
$template=template::check($params->{template},'user_stats');
|
||||
$checked->{template}=$template;
|
||||
my $template = '';
|
||||
$template = template::check( $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};
|
||||
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;
|
||||
}
|
||||
if ( defined $checked->{studio_id} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
|
||||
return $checked;
|
||||
}
|
||||
|
||||
sub error{
|
||||
push @$errors,{error=>$_[0]};
|
||||
sub error {
|
||||
push @$errors, { error => $_[0] };
|
||||
}
|
||||
|
||||
|
||||
@@ -14,473 +14,491 @@ use studios;
|
||||
use params;
|
||||
use localization;
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config =config::get('../config/config.cgi');
|
||||
my $debug =$config->{system}->{debug};
|
||||
my ($user,$expires) = auth::get_user($cgi, $config);
|
||||
return if ((!defined $user) || ($user eq ''));
|
||||
|
||||
my $user_presets=uac::get_user_presets($config, {
|
||||
user => $user,
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id}
|
||||
});
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$config,
|
||||
{
|
||||
user => $user,
|
||||
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'));
|
||||
$params->{project_id} = $user_presets->{project_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
$params->{studio_id} = $params->{default_studio_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
$params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
my $request={
|
||||
url => $ENV{QUERY_STRING}||'',
|
||||
params => {
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
$params=$request->{params}->{checked};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
#process header
|
||||
my $headerParams=uac::set_template_permissions($request->{permissions}, $params);
|
||||
$headerParams->{loc} = localization::get($config, {user=>$user, file=>'menu'});
|
||||
template::process('print', template::check('default.html'), $headerParams);
|
||||
return unless uac::check($config, $params, $user_presets)==1;
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( 'print', template::check('default.html'), $headerParams );
|
||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||
|
||||
our $errors=[];
|
||||
our $errors = [];
|
||||
|
||||
if (defined $params->{action}){
|
||||
update_user_roles($config, $request) if ($params->{action}eq 'assign');
|
||||
update_user($config,$request) if ($params->{action}eq 'save');
|
||||
delete_user($config,$request) if ($params->{action}eq 'delete');
|
||||
if ($params->{action}eq 'change_password'){
|
||||
change_password($config, $request, $user);
|
||||
$config->{access}->{write}=0;
|
||||
return;
|
||||
if ( defined $params->{action} ) {
|
||||
update_user_roles( $config, $request ) if ( $params->{action} eq 'assign' );
|
||||
update_user( $config, $request ) if ( $params->{action} eq 'save' );
|
||||
delete_user( $config, $request ) if ( $params->{action} eq 'delete' );
|
||||
if ( $params->{action} eq 'change_password' ) {
|
||||
change_password( $config, $request, $user );
|
||||
$config->{access}->{write} = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
$config->{access}->{write}=0;
|
||||
show_users($config,$request);
|
||||
$config->{access}->{write} = 0;
|
||||
show_users( $config, $request );
|
||||
|
||||
sub show_users{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub show_users {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $params = $request->{params}->{checked};
|
||||
|
||||
my $permissions=$request->{permissions};
|
||||
my $permissions = $request->{permissions};
|
||||
|
||||
unless ((defined $permissions->{read_user}) && ($permissions->{read_user}==1)){
|
||||
unless ( ( defined $permissions->{read_user} ) && ( $permissions->{read_user} == 1 ) ) {
|
||||
uac::permissions_denied('read_user');
|
||||
return;
|
||||
}
|
||||
|
||||
my $max_level = $permissions->{level};
|
||||
my $project_id = $params->{project_id};
|
||||
my $studio_id = $params->{studio_id};
|
||||
#TODO: get from presets
|
||||
my $studios = studios::get($config, {project_id=>$project_id});
|
||||
my $users = uac::get_users($config);
|
||||
my $roles = uac::get_roles(
|
||||
$config, {
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id
|
||||
}
|
||||
);
|
||||
my $max_level = $permissions->{level};
|
||||
my $project_id = $params->{project_id};
|
||||
my $studio_id = $params->{studio_id};
|
||||
|
||||
# print "max level:$max_level<br>";
|
||||
#TODO: get from presets
|
||||
my $studios = studios::get( $config, { project_id => $project_id } );
|
||||
my $users = uac::get_users($config);
|
||||
my $roles = uac::get_roles(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id
|
||||
}
|
||||
);
|
||||
|
||||
# print "max level:$max_level<br>";
|
||||
|
||||
#user roles
|
||||
for my $user (@$users){
|
||||
$user->{disabled_checked}='selected="selected"' if ($user->{disabled}eq'1');
|
||||
for my $user (@$users) {
|
||||
$user->{disabled_checked} = 'selected="selected"' if ( $user->{disabled} eq '1' );
|
||||
|
||||
#print Dumper($user);
|
||||
my $user_roles=uac::get_user_roles(
|
||||
$config, {
|
||||
user => $user->{name},
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id
|
||||
}
|
||||
my $user_roles = uac::get_user_roles(
|
||||
$config,
|
||||
{
|
||||
user => $user->{name},
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id
|
||||
}
|
||||
);
|
||||
my @user_roles=(map { {role => $_->{role}} } @$user_roles);
|
||||
my @user_roles = ( map { { role => $_->{role} } } @$user_roles );
|
||||
|
||||
#print Dumper(\@user_roles);
|
||||
#@user_roles[-1]->{__last__}=1 unless(@user_roles==0);
|
||||
$user->{user_roles}=\@user_roles;
|
||||
$user->{user_roles} = \@user_roles;
|
||||
|
||||
#mark all roles assigned to user
|
||||
my $has_roles=0;
|
||||
my @assignable_roles=();
|
||||
for my $role (reverse sort {$a->{level} <=> $b->{level}} @$roles){
|
||||
my $has_roles = 0;
|
||||
my @assignable_roles = ();
|
||||
for my $role ( reverse sort { $a->{level} <=> $b->{level} } @$roles ) {
|
||||
|
||||
#next if ($role->{level}>$max_level);
|
||||
$role->{assigned}=0;
|
||||
my %role=%$role;
|
||||
for my $user_role (@user_roles){
|
||||
if ($role->{role} eq $user_role->{role}){
|
||||
$role{assigned}=1;
|
||||
# print "if ($role->{role} eq $user_role->{role}<br>";
|
||||
$has_roles=1;
|
||||
$role->{assigned} = 0;
|
||||
my %role = %$role;
|
||||
for my $user_role (@user_roles) {
|
||||
if ( $role->{role} eq $user_role->{role} ) {
|
||||
$role{assigned} = 1;
|
||||
|
||||
# print "if ($role->{role} eq $user_role->{role}<br>";
|
||||
$has_roles = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
push @assignable_roles,\%role;
|
||||
push @assignable_roles, \%role;
|
||||
}
|
||||
$user->{has_roles} = $has_roles;
|
||||
$user->{roles} = \@assignable_roles;
|
||||
$user->{studio_id} = $studio_id;
|
||||
$user->{project_id} = $project_id;
|
||||
uac::set_template_permissions($permissions,$user);
|
||||
$user->{has_roles} = $has_roles;
|
||||
$user->{roles} = \@assignable_roles;
|
||||
$user->{studio_id} = $studio_id;
|
||||
$user->{project_id} = $project_id;
|
||||
uac::set_template_permissions( $permissions, $user );
|
||||
}
|
||||
|
||||
my $sort_by='name';
|
||||
my @users=sort {lc($a->{$sort_by}) cmp lc($b->{$sort_by})} @$users;
|
||||
my $sort_by = 'name';
|
||||
my @users = sort { lc( $a->{$sort_by} ) cmp lc( $b->{$sort_by} ) } @$users;
|
||||
|
||||
my @users_with_roles=();
|
||||
my @users_without_roles=();
|
||||
for my $user (@users){
|
||||
if ($user->{has_roles}==1){
|
||||
push @users_with_roles,$user;
|
||||
}else{
|
||||
push @users_without_roles,$user;
|
||||
}
|
||||
}
|
||||
my @users_with_roles = ();
|
||||
my @users_without_roles = ();
|
||||
for my $user (@users) {
|
||||
if ( $user->{has_roles} == 1 ) {
|
||||
push @users_with_roles, $user;
|
||||
} else {
|
||||
push @users_without_roles, $user;
|
||||
}
|
||||
}
|
||||
|
||||
if($permissions->{update_user_role}==1){
|
||||
@users=(@users_with_roles,@users_without_roles);
|
||||
}else{
|
||||
@users=(@users_with_roles);
|
||||
}
|
||||
if ( $permissions->{update_user_role} == 1 ) {
|
||||
@users = ( @users_with_roles, @users_without_roles );
|
||||
} else {
|
||||
@users = (@users_with_roles);
|
||||
}
|
||||
|
||||
|
||||
$params->{users} = \@users;
|
||||
$params->{studios} = $studios;
|
||||
$params->{users} = \@users;
|
||||
$params->{studios} = $studios;
|
||||
$params->{permissions} = $permissions;
|
||||
$params->{errors} = $errors;
|
||||
$params->{loc} = localization::get($config, {user=>$params->{presets}->{user}, file=>'users'});
|
||||
uac::set_template_permissions($permissions, $params);
|
||||
$params->{errors} = $errors;
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'users' } );
|
||||
uac::set_template_permissions( $permissions, $params );
|
||||
|
||||
#print Dumper($permissions);
|
||||
template::process('print', $params->{template}, $params);
|
||||
# template::process('print', template::check('users'), $params);
|
||||
template::process( 'print', $params->{template}, $params );
|
||||
|
||||
# template::process('print', template::check('users'), $params);
|
||||
|
||||
}
|
||||
|
||||
sub update_user{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub update_user {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
|
||||
my $user={
|
||||
my $user = {
|
||||
full_name => $params->{user_full_name},
|
||||
email => $params->{user_email},
|
||||
id => $params->{user_id}
|
||||
email => $params->{user_email},
|
||||
id => $params->{user_id}
|
||||
};
|
||||
$user->{name}= $params->{user_name} if ( (defined $params->{user_name}) && ($params->{user_name} ne '') );
|
||||
$user->{name} = $params->{user_name} if ( ( defined $params->{user_name} ) && ( $params->{user_name} ne '' ) );
|
||||
|
||||
if ($permissions->{disable_user}==1){
|
||||
$user->{disabled}= $params->{disabled}||0;
|
||||
if ( $permissions->{disable_user} == 1 ) {
|
||||
$user->{disabled} = $params->{disabled} || 0;
|
||||
}
|
||||
|
||||
if ( (!defined $user->{id}) || ($user->{id}eq'') ){
|
||||
unless ($permissions->{create_user}==1){
|
||||
if ( ( !defined $user->{id} ) || ( $user->{id} eq '' ) ) {
|
||||
unless ( $permissions->{create_user} == 1 ) {
|
||||
uac::permissions_denied('create_user');
|
||||
return;
|
||||
}
|
||||
|
||||
return unless(check_password($params->{user_password}));
|
||||
return unless ( check_password( $params->{user_password} ) );
|
||||
|
||||
if ($params->{user_password} ne $params->{user_password2}){
|
||||
if ( $params->{user_password} ne $params->{user_password2} ) {
|
||||
error('password mismatch');
|
||||
return;
|
||||
return;
|
||||
}
|
||||
my $crypt=auth::crypt_password($params->{user_password});
|
||||
$user->{salt} = $crypt->{salt};
|
||||
$user->{pass} = $crypt->{crypt};
|
||||
#print '<pre>'.Dumper($user).'</pre>';
|
||||
$user->{created_at} = time::time_to_datetime(time());
|
||||
$user->{modified_at} = time::time_to_datetime(time());
|
||||
$user->{created_by} = $params->{presets}->{user};
|
||||
my $crypt = auth::crypt_password( $params->{user_password} );
|
||||
$user->{salt} = $crypt->{salt};
|
||||
$user->{pass} = $crypt->{crypt};
|
||||
|
||||
$config->{access}->{write}=1;
|
||||
uac::insert_user($config, $user);
|
||||
}else{
|
||||
unless ($permissions->{update_user}==1){
|
||||
#print '<pre>'.Dumper($user).'</pre>';
|
||||
$user->{created_at} = time::time_to_datetime( time() );
|
||||
$user->{modified_at} = time::time_to_datetime( time() );
|
||||
$user->{created_by} = $params->{presets}->{user};
|
||||
|
||||
$config->{access}->{write} = 1;
|
||||
uac::insert_user( $config, $user );
|
||||
} else {
|
||||
unless ( $permissions->{update_user} == 1 ) {
|
||||
uac::permissions_denied('update_user');
|
||||
return;
|
||||
}
|
||||
$user->{modified_at} = time::time_to_datetime(time());
|
||||
$config->{access}->{write}=1;
|
||||
uac::update_user($config, $user);
|
||||
$user->{modified_at} = time::time_to_datetime( time() );
|
||||
$config->{access}->{write} = 1;
|
||||
uac::update_user( $config, $user );
|
||||
}
|
||||
}
|
||||
|
||||
sub change_password{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
my $userName=shift;
|
||||
sub change_password {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
my $userName = shift;
|
||||
|
||||
my $params=$request->{params}->{checked};
|
||||
my $permissions=$request->{permissions};
|
||||
my $params = $request->{params}->{checked};
|
||||
my $permissions = $request->{permissions};
|
||||
|
||||
unless ( (defined $userName) || ($userName eq '') ){
|
||||
unless ( ( defined $userName ) || ( $userName eq '' ) ) {
|
||||
uac::print_error('user not found');
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
my $user=uac::get_user($config, $userName);
|
||||
my $user = uac::get_user( $config, $userName );
|
||||
|
||||
unless ( (defined $user) && (defined $user->{id}) && ($user->{id}ne'') ){
|
||||
unless ( ( defined $user ) && ( defined $user->{id} ) && ( $user->{id} ne '' ) ) {
|
||||
uac::print_error('user id not found');
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
unless(check_password($params->{user_password})){
|
||||
unless ( check_password( $params->{user_password} ) ) {
|
||||
error('password does not meet requirements');
|
||||
}
|
||||
}
|
||||
|
||||
if ($params->{user_password} ne $params->{user_password2}){
|
||||
if ( $params->{user_password} ne $params->{user_password2} ) {
|
||||
error('entered passwords do not match');
|
||||
}
|
||||
|
||||
print STDERR "error at changing password:".Dumper($errors);
|
||||
print STDERR "error at changing password:" . Dumper($errors);
|
||||
|
||||
if ( @$errors == 0 ) {
|
||||
my $crypt = auth::crypt_password( $params->{user_password} );
|
||||
$user = { id => $user->{id} };
|
||||
$user->{salt} = $crypt->{salt};
|
||||
$user->{pass} = $crypt->{crypt};
|
||||
|
||||
#print '<pre>'.Dumper($user).'</pre>';
|
||||
$config->{access}->{write} = 1;
|
||||
uac::update_user( $config, $user );
|
||||
$config->{access}->{write} = 0;
|
||||
print STDERR "password changed for $params->{presets}->{user}\n";
|
||||
}
|
||||
$params->{errors} = $errors; #join("<br>", (map {$_>{error}} (@$errors)) );
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'users' } );
|
||||
uac::set_template_permissions( $permissions, $params );
|
||||
|
||||
if(@$errors==0){
|
||||
my $crypt=auth::crypt_password($params->{user_password});
|
||||
$user={
|
||||
id => $user->{id}
|
||||
};
|
||||
$user->{salt}=$crypt->{salt};
|
||||
$user->{pass}=$crypt->{crypt};
|
||||
#print '<pre>'.Dumper($user).'</pre>';
|
||||
$config->{access}->{write}=1;
|
||||
uac::update_user($config, $user);
|
||||
$config->{access}->{write}=0;
|
||||
print STDERR "password changed for $params->{presets}->{user}\n";
|
||||
}
|
||||
$params->{errors}= $errors; #join("<br>", (map {$_>{error}} (@$errors)) );
|
||||
$params->{loc} = localization::get($config, {user=>$params->{presets}->{user}, file=>'users'});
|
||||
uac::set_template_permissions($permissions, $params);
|
||||
#print Dumper($permissions);
|
||||
template::process('print', template::check('change_password'), $params);
|
||||
template::process( 'print', template::check('change_password'), $params );
|
||||
}
|
||||
|
||||
sub check_password{
|
||||
my $password=shift;
|
||||
unless(defined $password || $password eq ''){
|
||||
error("password is empty");
|
||||
return;
|
||||
}
|
||||
if(length($password)<8){
|
||||
error("password to short");
|
||||
return 0;
|
||||
}
|
||||
unless($password=~/[a-z]/){
|
||||
error("password should contains at least one small character");
|
||||
return 0;
|
||||
}
|
||||
unless($password=~/[A-Z]/){
|
||||
error("password should contains at least one big character");
|
||||
return 0;
|
||||
}
|
||||
unless($password=~/[0-9]/){
|
||||
error("password should contains at least one number");
|
||||
return 0;
|
||||
}
|
||||
unless($password=~/[^a-zA-Z0-9]/){
|
||||
error("password should contains at least one special character");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
sub check_password {
|
||||
my $password = shift;
|
||||
unless ( defined $password || $password eq '' ) {
|
||||
error("password is empty");
|
||||
return;
|
||||
}
|
||||
if ( length($password) < 8 ) {
|
||||
error("password to short");
|
||||
return 0;
|
||||
}
|
||||
unless ( $password =~ /[a-z]/ ) {
|
||||
error("password should contains at least one small character");
|
||||
return 0;
|
||||
}
|
||||
unless ( $password =~ /[A-Z]/ ) {
|
||||
error("password should contains at least one big character");
|
||||
return 0;
|
||||
}
|
||||
unless ( $password =~ /[0-9]/ ) {
|
||||
error("password should contains at least one number");
|
||||
return 0;
|
||||
}
|
||||
unless ( $password =~ /[^a-zA-Z0-9]/ ) {
|
||||
error("password should contains at least one special character");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub delete_user{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub delete_user {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{delete_user}==1){
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{delete_user} == 1 ) {
|
||||
uac::permissions_denied('delete_user');
|
||||
return;
|
||||
}
|
||||
|
||||
$config->{access}->{write}=1;
|
||||
my $params=$request->{params}->{checked};
|
||||
uac::delete_user($config,$params->{user_id});
|
||||
$config->{access}->{write} = 1;
|
||||
my $params = $request->{params}->{checked};
|
||||
uac::delete_user( $config, $params->{user_id} );
|
||||
}
|
||||
|
||||
# add or remove user from role for given studio_id
|
||||
# add or remove user from role for given studio_id
|
||||
# todo: assign/unassign role oly if max(change user rank) is < max(users rank)
|
||||
sub update_user_roles{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub update_user_roles {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
# print Dumper($params).'<br>';
|
||||
# print Dumper($request->{params}->{checked});
|
||||
# print Dumper($params).'<br>';
|
||||
# print Dumper($request->{params}->{checked});
|
||||
|
||||
my $permissions=$request->{permissions};
|
||||
unless ($permissions->{update_user_role}==1){
|
||||
my $permissions = $request->{permissions};
|
||||
unless ( $permissions->{update_user_role} == 1 ) {
|
||||
uac::permissions_denied('update_user_role');
|
||||
return;
|
||||
}
|
||||
my $params = $request->{params}->{checked};
|
||||
my $params = $request->{params}->{checked};
|
||||
my $project_id = $params->{project_id};
|
||||
my $studio_id = $params->{studio_id};
|
||||
my $user_id = $params->{user_id}||'';
|
||||
# return undef if ($user_id eq '');
|
||||
my $user_id = $params->{user_id} || '';
|
||||
|
||||
#get all roles
|
||||
# return undef if ($user_id eq '');
|
||||
|
||||
#get all roles
|
||||
my $roles = uac::get_roles(
|
||||
$config, {
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id
|
||||
}
|
||||
);
|
||||
#get roles for the selected user
|
||||
my $user_roles = uac::get_user_roles(
|
||||
$config, {
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
user_id => $user_id
|
||||
}
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id
|
||||
}
|
||||
);
|
||||
|
||||
#maximum level of the user who wants to perform the update (given by $permissions)
|
||||
my $max_level = $permissions->{level};
|
||||
#get roles for the selected user
|
||||
my $user_roles = uac::get_user_roles(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
user_id => $user_id
|
||||
}
|
||||
);
|
||||
|
||||
#maximum level of the user who wants to perform the update (given by $permissions)
|
||||
my $max_level = $permissions->{level};
|
||||
|
||||
#maximum level of the user to be changed (given by $user_id)
|
||||
my $max_user_level=0;
|
||||
|
||||
my $max_user_level = 0;
|
||||
|
||||
#get all roles by id
|
||||
my $role_by_id={};
|
||||
for my $role (@$roles){
|
||||
$role_by_id->{$role->{id}}=$role;
|
||||
my $role_by_id = {};
|
||||
for my $role (@$roles) {
|
||||
$role_by_id->{ $role->{id} } = $role;
|
||||
}
|
||||
|
||||
#get user role by id
|
||||
my $user_role_by_id={};
|
||||
for my $role (@$user_roles){
|
||||
$user_role_by_id->{$role->{id}}=$role;
|
||||
$max_user_level=$role->{level} if $max_user_level<$role->{level};
|
||||
my $user_role_by_id = {};
|
||||
for my $role (@$user_roles) {
|
||||
$user_role_by_id->{ $role->{id} } = $role;
|
||||
$max_user_level = $role->{level} if $max_user_level < $role->{level};
|
||||
}
|
||||
|
||||
$config->{access}->{write}=1;
|
||||
$config->{access}->{write} = 1;
|
||||
|
||||
#remove unchecked user roles
|
||||
for my $user_role_id (keys %$user_role_by_id){
|
||||
for my $user_role_id ( keys %$user_role_by_id ) {
|
||||
my $user_role = $user_role_by_id->{$user_role_id};
|
||||
my $role = $role_by_id->{$user_role_id};
|
||||
# print "$user_role_id - $params->{role_ids}->{$user_role_id} ($studio_id)<br>";
|
||||
unless (defined $params->{role_ids}->{$user_role_id}){
|
||||
my $message="remove role '$role->{role}' (level $role->{level}) from user $user_id (level $max_user_level) for studio_id=$studio_id, project_id=$project_id. Your level is $max_level";
|
||||
my $update=0;
|
||||
$update = 1 if (defined $permissions->{is_admin});
|
||||
$update = 1 if (
|
||||
($role_by_id->{$user_role->{role_id}}->{level}<$max_level)
|
||||
&& ($max_user_level<$max_level)
|
||||
);
|
||||
if($update==0){
|
||||
|
||||
# print "$user_role_id - $params->{role_ids}->{$user_role_id} ($studio_id)<br>";
|
||||
unless ( defined $params->{role_ids}->{$user_role_id} ) {
|
||||
my $message =
|
||||
"remove role '$role->{role}' (level $role->{level}) from user $user_id (level $max_user_level) for studio_id=$studio_id, project_id=$project_id. Your level is $max_level";
|
||||
my $update = 0;
|
||||
$update = 1 if ( defined $permissions->{is_admin} );
|
||||
$update = 1 if ( ( $role_by_id->{ $user_role->{role_id} }->{level} < $max_level )
|
||||
&& ( $max_user_level < $max_level ) );
|
||||
if ( $update == 0 ) {
|
||||
uac::permissions_denied($message);
|
||||
next;
|
||||
}
|
||||
my $result=uac::remove_user_role(
|
||||
$config, {
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
user_id => $user_id,
|
||||
role_id => $user_role_id
|
||||
}
|
||||
);
|
||||
unless(defined $result){
|
||||
uac::print_error("missing parameter on remove user role");
|
||||
return;
|
||||
}
|
||||
if ($result==0){
|
||||
uac::print_error("no changes");
|
||||
return;
|
||||
}
|
||||
uac::print_info($message);
|
||||
next;
|
||||
}
|
||||
my $result = uac::remove_user_role(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
user_id => $user_id,
|
||||
role_id => $user_role_id
|
||||
}
|
||||
);
|
||||
unless ( defined $result ) {
|
||||
uac::print_error("missing parameter on remove user role");
|
||||
return;
|
||||
}
|
||||
if ( $result == 0 ) {
|
||||
uac::print_error("no changes");
|
||||
return;
|
||||
}
|
||||
uac::print_info($message);
|
||||
}
|
||||
}
|
||||
|
||||
#insert/update user roles
|
||||
for my $role_id (keys %{$params->{role_ids}}){
|
||||
my $role=$role_by_id->{$role_id};
|
||||
unless(defined $user_role_by_id->{$role_id}){
|
||||
my $message="assign role $role->{role} (level $role->{level}) to user (level $max_user_level). Your level is $max_level";
|
||||
# print "user role id: $role->{id}<br>\n";
|
||||
my $update=0;
|
||||
$update = 1 if (defined $permissions->{is_admin});
|
||||
$update = 1 if (
|
||||
($role_by_id->{$role->{id}}->{level}<$max_level)
|
||||
&& ($max_user_level<$max_level)
|
||||
);
|
||||
if ($update == 0){
|
||||
for my $role_id ( keys %{ $params->{role_ids} } ) {
|
||||
my $role = $role_by_id->{$role_id};
|
||||
unless ( defined $user_role_by_id->{$role_id} ) {
|
||||
my $message = "assign role $role->{role} (level $role->{level}) to user (level $max_user_level). Your level is $max_level";
|
||||
|
||||
# print "user role id: $role->{id}<br>\n";
|
||||
my $update = 0;
|
||||
$update = 1 if ( defined $permissions->{is_admin} );
|
||||
$update = 1 if ( ( $role_by_id->{ $role->{id} }->{level} < $max_level )
|
||||
&& ( $max_user_level < $max_level ) );
|
||||
if ( $update == 0 ) {
|
||||
uac::permissions_denied($message);
|
||||
next;
|
||||
}
|
||||
uac::assign_user_role(
|
||||
$config, {
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
user_id => $user_id,
|
||||
role_id => $role_id
|
||||
}
|
||||
);
|
||||
uac::print_info($message);
|
||||
next;
|
||||
}
|
||||
uac::assign_user_role(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
user_id => $user_id,
|
||||
role_id => $role_id
|
||||
}
|
||||
);
|
||||
uac::print_info($message);
|
||||
}
|
||||
}
|
||||
$config->{access}->{write}=0;
|
||||
$config->{access}->{write} = 0;
|
||||
}
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
my $checked={};
|
||||
my $checked = {};
|
||||
|
||||
#template
|
||||
my $template='';
|
||||
$template=template::check($params->{template},'users');
|
||||
$checked->{template}=$template;
|
||||
my $template = '';
|
||||
$template = template::check( $params->{template}, 'users' );
|
||||
$checked->{template} = $template;
|
||||
|
||||
#numeric values
|
||||
for my $param ('project_id', 'user_id', 'default_studio_id', 'studio_id', 'disabled'){
|
||||
if ((defined $params->{$param})&&($params->{$param}=~/^\d+$/)){
|
||||
$checked->{$param}=$params->{$param};
|
||||
for my $param ( 'project_id', 'user_id', 'default_studio_id', 'studio_id', 'disabled' ) {
|
||||
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /^\d+$/ ) ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
if (defined $checked->{studio_id}){
|
||||
$checked->{default_studio_id}=$checked->{studio_id};
|
||||
}else{
|
||||
$checked->{studio_id}=-1;
|
||||
}
|
||||
if ( defined $checked->{studio_id} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
|
||||
|
||||
for my $param ('user_name', 'user_full_name', 'user_email', 'user_password', 'user_password2'){
|
||||
if (defined $params->{$param}){
|
||||
$checked->{$param}=$params->{$param};
|
||||
for my $param ( 'user_name', 'user_full_name', 'user_email', 'user_password', 'user_password2' ) {
|
||||
if ( defined $params->{$param} ) {
|
||||
$checked->{$param} = $params->{$param};
|
||||
}
|
||||
}
|
||||
|
||||
#actions and roles
|
||||
if (defined $params->{action}){
|
||||
if ($params->{action}=~/^(save|assign|delete|change_password)$/){
|
||||
$checked->{action}=$params->{action};
|
||||
if ( defined $params->{action} ) {
|
||||
if ( $params->{action} =~ /^(save|assign|delete|change_password)$/ ) {
|
||||
$checked->{action} = $params->{action};
|
||||
}
|
||||
|
||||
if ($params->{action} eq 'assign'){
|
||||
$checked->{action}=$params->{action};
|
||||
for my $param (keys %$params){
|
||||
$checked->{role_ids}->{$1}=1 if ($param=~/^role_(\d+)$/);
|
||||
if ( $params->{action} eq 'assign' ) {
|
||||
$checked->{action} = $params->{action};
|
||||
for my $param ( keys %$params ) {
|
||||
$checked->{role_ids}->{$1} = 1 if ( $param =~ /^role_(\d+)$/ );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#print Dumper($params);
|
||||
#print '<pre>'.Dumper($checked).'</pre>';
|
||||
return $checked;
|
||||
}
|
||||
|
||||
sub error{
|
||||
push @$errors,{error=>$_[0]};
|
||||
sub error {
|
||||
push @$errors, { error => $_[0] };
|
||||
}
|
||||
|
||||
|
||||
|
||||
461
website/agenda/planung/work_time.cgi
Normal file → Executable file
461
website/agenda/planung/work_time.cgi
Normal file → Executable file
@@ -21,308 +21,321 @@ use localization;
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config = config::get('../config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my ($user,$expires) = auth::get_user($cgi, $config);
|
||||
return if ((!defined $user) || ($user eq ''));
|
||||
my ( $user, $expires ) = auth::get_user( $cgi, $config );
|
||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||
|
||||
#print 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
|
||||
});
|
||||
$params->{default_studio_id}=$user_presets->{studio_id};
|
||||
$params->{studio_id} = $params->{default_studio_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
$params->{project_id} = $user_presets->{project_id} if ((!(defined $params->{action}))||($params->{action}eq'')||($params->{action}eq'login'));
|
||||
my $user_presets = uac::get_user_presets(
|
||||
$config,
|
||||
{
|
||||
project_id => $params->{project_id},
|
||||
studio_id => $params->{studio_id},
|
||||
user => $user
|
||||
}
|
||||
);
|
||||
$params->{default_studio_id} = $user_presets->{studio_id};
|
||||
$params->{studio_id} = $params->{default_studio_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
$params->{project_id} = $user_presets->{project_id}
|
||||
if ( ( !( defined $params->{action} ) ) || ( $params->{action} eq '' ) || ( $params->{action} eq 'login' ) );
|
||||
|
||||
#print STDERR $params->{project_id}."\n";
|
||||
my $request={
|
||||
url => $ENV{QUERY_STRING}||'',
|
||||
params => {
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING} || '',
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($params),
|
||||
checked => check_params($params),
|
||||
},
|
||||
};
|
||||
$request = uac::prepare_request($request, $user_presets);
|
||||
$request = uac::prepare_request( $request, $user_presets );
|
||||
log::init($request);
|
||||
|
||||
$params=$request->{params}->{checked};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
#process header
|
||||
my $headerParams=uac::set_template_permissions($request->{permissions}, $params);
|
||||
$headerParams->{loc} = localization::get($config, {user=>$user, file=>'menu'});
|
||||
template::process('print', template::check('default.html'), $headerParams);
|
||||
return unless uac::check($config, $params, $user_presets)==1;
|
||||
my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
|
||||
$headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
|
||||
template::process( 'print', template::check('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');
|
||||
if ( defined $params->{action} ) {
|
||||
save_schedule( $config, $request ) if ( $params->{action} eq 'save_schedule' );
|
||||
delete_schedule( $config, $request ) if ( $params->{action} eq 'delete_schedule' );
|
||||
}
|
||||
|
||||
$config->{access}->{write}=0;
|
||||
$config->{access}->{write} = 0;
|
||||
print q{<script src="js/edit_work_time.js" type="text/javascript"></script>};
|
||||
show_work_schedule($config, $request);
|
||||
show_work_schedule( $config, $request );
|
||||
return;
|
||||
|
||||
#insert or update a schedule and update all schedule dates
|
||||
sub save_schedule{
|
||||
my $config=shift;
|
||||
my $request=shift;
|
||||
sub save_schedule {
|
||||
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){
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
#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);
|
||||
#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;
|
||||
}
|
||||
|
||||
|
||||
sub delete_schedule{
|
||||
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 $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!');
|
||||
#print Dumper($params);
|
||||
for my $attr ( 'project_id', 'studio_id', 'start' ) {
|
||||
unless ( defined $params->{$attr} ) {
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
#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 );
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
sub delete_schedule {
|
||||
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 $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");
|
||||
}
|
||||
|
||||
sub show_work_schedule {
|
||||
my $config = shift;
|
||||
my $request = shift;
|
||||
|
||||
sub show_work_schedule{
|
||||
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){
|
||||
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};
|
||||
|
||||
#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};
|
||||
#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;
|
||||
#add schedules
|
||||
my $schedules = work_schedule::get(
|
||||
$config,
|
||||
{
|
||||
project_id => $project_id,
|
||||
studio_id => $studio_id,
|
||||
}
|
||||
);
|
||||
|
||||
$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 '';
|
||||
#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};
|
||||
|
||||
$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};
|
||||
#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;
|
||||
}
|
||||
|
||||
#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;
|
||||
|
||||
$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};
|
||||
#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} =~ 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,
|
||||
}
|
||||
);
|
||||
|
||||
#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};
|
||||
|
||||
#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('print', $params->{template}, $params);
|
||||
$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'work_time' } );
|
||||
template::process( 'print', $params->{template}, $params );
|
||||
}
|
||||
|
||||
sub check_params{
|
||||
my $params=shift;
|
||||
sub check_params {
|
||||
my $params = shift;
|
||||
|
||||
my $checked={};
|
||||
my $checked = {};
|
||||
|
||||
my $debug=$params->{debug} || '';
|
||||
if ($debug=~/([a-z\_\,]+)/){
|
||||
$debug=$1;
|
||||
my $debug = $params->{debug} || '';
|
||||
if ( $debug =~ /([a-z\_\,]+)/ ) {
|
||||
$debug = $1;
|
||||
}
|
||||
$checked->{debug}=$debug;
|
||||
$checked->{debug} = $debug;
|
||||
|
||||
#actions and roles
|
||||
$checked->{action}='';
|
||||
if (defined $params->{action}){
|
||||
if ($params->{action}=~/^(show|save_schedule|delete_schedule)$/){
|
||||
$checked->{action}=$params->{action};
|
||||
$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};
|
||||
$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;
|
||||
}
|
||||
if ( defined $checked->{studio_id} ) {
|
||||
$checked->{default_studio_id} = $checked->{studio_id};
|
||||
} else {
|
||||
$checked->{studio_id} = -1;
|
||||
}
|
||||
|
||||
$checked->{template}=template::check($params->{template},'edit_work_time');
|
||||
$checked->{template} = template::check( $params->{template}, 'edit_work_time' );
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
#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 $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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
|
||||
#use utf8;
|
||||
use warnings "all";
|
||||
|
||||
#use diagnostics;
|
||||
use strict;
|
||||
use Data::Dumper;
|
||||
|
||||
use CGI qw(header param Vars);
|
||||
$CGI::POST_MAX = 1000;
|
||||
$CGI::POST_MAX = 1000;
|
||||
$CGI::DISABLE_UPLOADS = 1;
|
||||
|
||||
use params;
|
||||
@@ -21,187 +22,187 @@ use project;
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
|
||||
my $r=shift;
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
my $config = config::get('config/config.cgi');
|
||||
my $r = shift;
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
my $config = config::get('config/config.cgi');
|
||||
|
||||
my $debug=$config->{system}->{debug};
|
||||
my $debug = $config->{system}->{debug};
|
||||
|
||||
#get request
|
||||
my $request={
|
||||
url => $ENV{QUERY_STRING},
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params($config, $params)
|
||||
},
|
||||
my $request = {
|
||||
url => $ENV{QUERY_STRING},
|
||||
params => {
|
||||
original => $params,
|
||||
checked => check_params( $config, $params )
|
||||
},
|
||||
};
|
||||
log::init($request);
|
||||
|
||||
$params=$request->{params}->{checked};
|
||||
$params = $request->{params}->{checked};
|
||||
|
||||
#read cache
|
||||
my $cache={};
|
||||
if ($config->{cache}->{use_cache} eq '1'){
|
||||
cache::configure('series_names.html');
|
||||
log::write($config, 'cache_files',cache::get_map()) if ($debug);
|
||||
$cache=cache::load($config, $params);
|
||||
if (defined $cache->{content}){
|
||||
print $cache->{content};
|
||||
return;
|
||||
};
|
||||
my $cache = {};
|
||||
if ( $config->{cache}->{use_cache} eq '1' ) {
|
||||
cache::configure('series_names.html');
|
||||
log::write( $config, 'cache_files', cache::get_map() ) if ($debug);
|
||||
$cache = cache::load( $config, $params );
|
||||
if ( defined $cache->{content} ) {
|
||||
print $cache->{content};
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#connect
|
||||
my $dbh=db::connect($config);
|
||||
my $dbh = db::connect($config);
|
||||
|
||||
#fill template
|
||||
my $template_parameters={};
|
||||
$template_parameters->{projects} = getProjects($dbh, $config, $params);
|
||||
my $template_parameters = {};
|
||||
$template_parameters->{projects} = getProjects( $dbh, $config, $params );
|
||||
$template_parameters->{debug} = $config->{system}->{debug};
|
||||
$template_parameters->{server_cache} = $config->{cache}->{server_cache} if ($config->{cache}->{server_cache});
|
||||
$template_parameters->{use_client_cache} = $config->{cache}->{use_client_cache} if ($config->{cache}->{use_client_cache});
|
||||
$template_parameters->{server_cache} = $config->{cache}->{server_cache} if ( $config->{cache}->{server_cache} );
|
||||
$template_parameters->{use_client_cache} = $config->{cache}->{use_client_cache} if ( $config->{cache}->{use_client_cache} );
|
||||
|
||||
#output template
|
||||
my $template=$params->{template};
|
||||
my $out='';
|
||||
template::process($out, $params->{template}, $template_parameters);
|
||||
my $template = $params->{template};
|
||||
my $out = '';
|
||||
template::process( $out, $params->{template}, $template_parameters );
|
||||
print $out;
|
||||
|
||||
#write to cache
|
||||
if ($config->{cache}->{use_cache} eq '1'){
|
||||
$cache->{content}=$out;
|
||||
cache::save($cache);
|
||||
if ( $config->{cache}->{use_cache} eq '1' ) {
|
||||
$cache->{content} = $out;
|
||||
cache::save($cache);
|
||||
}
|
||||
$cache=undef;
|
||||
$out=undef;
|
||||
$cache = undef;
|
||||
$out = undef;
|
||||
|
||||
sub getProjects{
|
||||
my $dbh = shift;
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
sub getProjects {
|
||||
my $dbh = shift;
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $prev_series_names=undef;
|
||||
my $projects=project::get_sorted($config);
|
||||
my $prev_series_names = undef;
|
||||
my $projects = project::get_sorted($config);
|
||||
|
||||
my $excludedProjects={};
|
||||
if (defined $config->{filter}->{exclude_projects}){
|
||||
for my $project ( split(/\,/, $config->{filter}->{exclude_projects}) ){
|
||||
$project=~s/^\s+//g;
|
||||
$project=~s/\s+$//g;
|
||||
$excludedProjects->{$project}=1;
|
||||
}
|
||||
}
|
||||
my $excludedProjects = {};
|
||||
if ( defined $config->{filter}->{exclude_projects} ) {
|
||||
for my $project ( split( /\,/, $config->{filter}->{exclude_projects} ) ) {
|
||||
$project =~ s/^\s+//g;
|
||||
$project =~ s/\s+$//g;
|
||||
$excludedProjects->{$project} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
my $results=[];
|
||||
for my $project (@$projects){
|
||||
next if defined $excludedProjects->{$project->{name}};
|
||||
|
||||
my $series_names=getSeriesNames($dbh, $config, $project->{name}, $params);
|
||||
$project->{isEmpty}=1 if scalar(@$series_names)==0;
|
||||
$project->{series_names}=$series_names;
|
||||
my $results = [];
|
||||
for my $project (@$projects) {
|
||||
next if defined $excludedProjects->{ $project->{name} };
|
||||
|
||||
$project->{js_name}=$project->{name};
|
||||
$project->{js_name}=~s/[^a-zA-Z\_0-9]/\_/g;
|
||||
$project->{js_name}=~s/\_+/\_/g;
|
||||
my $series_names = getSeriesNames( $dbh, $config, $project->{name}, $params );
|
||||
$project->{isEmpty} = 1 if scalar(@$series_names) == 0;
|
||||
$project->{series_names} = $series_names;
|
||||
|
||||
#mark last series_name entry of all non empty projects
|
||||
if ((defined $series_names) && (@$series_names>0)){
|
||||
$series_names->[-1]->{last}=1;
|
||||
$prev_series_names->[-1]->{last}=0 if((defined $prev_series_names) && (@$prev_series_names>0));
|
||||
$prev_series_names=$series_names;
|
||||
}
|
||||
push @$results, $project;
|
||||
$project->{js_name} = $project->{name};
|
||||
$project->{js_name} =~ s/[^a-zA-Z\_0-9]/\_/g;
|
||||
$project->{js_name} =~ s/\_+/\_/g;
|
||||
|
||||
#mark last series_name entry of all non empty projects
|
||||
if ( ( defined $series_names ) && ( @$series_names > 0 ) ) {
|
||||
$series_names->[-1]->{last} = 1;
|
||||
$prev_series_names->[-1]->{last} = 0 if ( ( defined $prev_series_names ) && ( @$prev_series_names > 0 ) );
|
||||
$prev_series_names = $series_names;
|
||||
}
|
||||
push @$results, $project;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
sub getSeriesNames{
|
||||
my $dbh=shift;
|
||||
my $config = shift;
|
||||
my $project=shift;
|
||||
my $params=shift;
|
||||
sub getSeriesNames {
|
||||
my $dbh = shift;
|
||||
my $config = shift;
|
||||
my $project = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $debug=$config->{system}->{debug};
|
||||
my $bind_values=[];
|
||||
my $debug = $config->{system}->{debug};
|
||||
my $bind_values = [];
|
||||
|
||||
my @conds=();
|
||||
if (defined $config->{filter}->{exclude_locations}){
|
||||
my @exclude=();
|
||||
for my $location ( split(/\,/, $config->{filter}->{exclude_locations}) ){
|
||||
$location=~s/^\s+//g;
|
||||
$location=~s/\s+$//g;
|
||||
push @exclude,'?';
|
||||
push @$bind_values, $location;
|
||||
}
|
||||
push @conds,'location not in ('.join(',',@exclude).')';
|
||||
}
|
||||
my @conds = ();
|
||||
if ( defined $config->{filter}->{exclude_locations} ) {
|
||||
my @exclude = ();
|
||||
for my $location ( split( /\,/, $config->{filter}->{exclude_locations} ) ) {
|
||||
$location =~ s/^\s+//g;
|
||||
$location =~ s/\s+$//g;
|
||||
push @exclude, '?';
|
||||
push @$bind_values, $location;
|
||||
}
|
||||
push @conds, 'location not in (' . join( ',', @exclude ) . ')';
|
||||
}
|
||||
|
||||
if (defined $config->{filter}->{exclude_projects}){
|
||||
my @exclude=();
|
||||
for my $project ( split(/\,/, $config->{filter}->{exclude_projects}) ){
|
||||
$project=~s/^\s+//g;
|
||||
$project=~s/\s+$//g;
|
||||
push @exclude,'?';
|
||||
push @$bind_values, $project;
|
||||
}
|
||||
push @conds,'project not in ('.join(',',@exclude).')';
|
||||
}
|
||||
if ( defined $config->{filter}->{exclude_projects} ) {
|
||||
my @exclude = ();
|
||||
for my $project ( split( /\,/, $config->{filter}->{exclude_projects} ) ) {
|
||||
$project =~ s/^\s+//g;
|
||||
$project =~ s/\s+$//g;
|
||||
push @exclude, '?';
|
||||
push @$bind_values, $project;
|
||||
}
|
||||
push @conds, 'project not in (' . join( ',', @exclude ) . ')';
|
||||
}
|
||||
|
||||
if (($project ne '') && ($project ne 'all')){
|
||||
push @conds,'project=?';
|
||||
push @$bind_values,$project;
|
||||
}
|
||||
if ( ( $project ne '' ) && ( $project ne 'all' ) ) {
|
||||
push @conds, 'project=?';
|
||||
push @$bind_values, $project;
|
||||
}
|
||||
|
||||
if (($params->{search} ne '')){
|
||||
push @conds, 'series_name like ?';
|
||||
push @$bind_values,'%'.$params->{search}.'%';
|
||||
}
|
||||
if ( ( $params->{search} ne '' ) ) {
|
||||
push @conds, 'series_name like ?';
|
||||
push @$bind_values, '%' . $params->{search} . '%';
|
||||
}
|
||||
|
||||
my $where='';
|
||||
if (@conds>0){
|
||||
$where='where '.join(' and ',@conds);
|
||||
}
|
||||
my $where = '';
|
||||
if ( @conds > 0 ) {
|
||||
$where = 'where ' . join( ' and ', @conds );
|
||||
}
|
||||
|
||||
my $query=qq{
|
||||
my $query = qq{
|
||||
select series_name, count(series_name) sum
|
||||
from calcms_events
|
||||
$where
|
||||
group by series_name
|
||||
order by series_name
|
||||
};
|
||||
|
||||
my $series_names=db::get($dbh, $query, $bind_values);
|
||||
|
||||
for my $series(@$series_names){
|
||||
$series->{series_name}='' unless defined $series->{series_name};
|
||||
$series->{series_name}=~s/\"//g;
|
||||
$series->{series_name}='ohne' if $series->{series_name} eq '';
|
||||
$series->{series_name}='Einzelsendung' if $series->{series_name} eq '_single_';
|
||||
}
|
||||
my $series_names = db::get( $dbh, $query, $bind_values );
|
||||
|
||||
return $series_names;
|
||||
for my $series (@$series_names) {
|
||||
$series->{series_name} = '' unless defined $series->{series_name};
|
||||
$series->{series_name} =~ s/\"//g;
|
||||
$series->{series_name} = 'ohne' if $series->{series_name} eq '';
|
||||
$series->{series_name} = 'Einzelsendung' if $series->{series_name} eq '_single_';
|
||||
}
|
||||
|
||||
return $series_names;
|
||||
}
|
||||
|
||||
sub check_params{
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
sub check_params {
|
||||
my $config = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $template=template::check($params->{template}, 'series_names.html');
|
||||
my $template = template::check( $params->{template}, 'series_names.html' );
|
||||
|
||||
my $debug=$params->{debug}||'';
|
||||
if ($debug=~/([a-z\_\,]+)/){
|
||||
$debug=$1;
|
||||
}
|
||||
my $debug = $params->{debug} || '';
|
||||
if ( $debug =~ /([a-z\_\,]+)/ ) {
|
||||
$debug = $1;
|
||||
}
|
||||
|
||||
my $search=$params->{q}||$params->{search}||$params->{term}||'';
|
||||
if ($search=~/([a-z0-9A-Z\_\,]+)/){
|
||||
$search=$1;
|
||||
}
|
||||
my $search = $params->{q} || $params->{search} || $params->{term} || '';
|
||||
if ( $search =~ /([a-z0-9A-Z\_\,]+)/ ) {
|
||||
$search = $1;
|
||||
}
|
||||
|
||||
return {
|
||||
template => $template,
|
||||
debug => $debug,
|
||||
search => $search,
|
||||
}
|
||||
return {
|
||||
template => $template,
|
||||
debug => $debug,
|
||||
search => $search,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -3,22 +3,22 @@ Content-type:text/xml; charset=UTF-8
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<station lastupdate="<TMPL_VAR modified_at_datetime_utc>" xmlns:gml="http://www.opengis.net/gml">
|
||||
<info>
|
||||
<displayname>shortRadioName</displayname>
|
||||
<fullname>fullRadioName</fullname>
|
||||
<logo src="https://www.freie-radios.net/" />
|
||||
<displayname>Pi-Radio</displayname>
|
||||
<fullname>Pi-Radio</fullname>
|
||||
<logo src="https://piradio.de/agenda/image/logo.jpg" />
|
||||
<basecolor>#FF6600</basecolor>
|
||||
<city>Berlin</city>
|
||||
<studio>
|
||||
<street>street</street>
|
||||
<number>number</number>
|
||||
<city>city</city>
|
||||
<zip>plz</zip>
|
||||
<street>Lottumstrasse</street>
|
||||
<number>9</number>
|
||||
<city>Berlin</city>
|
||||
<zip>10119</zip>
|
||||
<studio-location>
|
||||
<gml:Point>
|
||||
<gml:pos>52.53119 13.4066</gml:pos>
|
||||
</gml:Point>
|
||||
</studio-location>
|
||||
<phone type="studio">+49 030 1234 5678</phone>
|
||||
<phone type="studio">+49 030 609 37 277</phone>
|
||||
</studio>
|
||||
</info>
|
||||
|
||||
@@ -33,10 +33,8 @@ Content-type:text/xml; charset=UTF-8
|
||||
<transmit-rds-id>88vier</transmit-rds-id>
|
||||
<transmit-times>
|
||||
<transmit-time recurrence="true" />
|
||||
<weekly day="DO" priority="0" time-from="06:00:00" time-to="24:00:00" />
|
||||
<weekly day="FR" priority="0" time-from="00:00:00" time-to="01:00:00" />
|
||||
<weekly day="FR" priority="0" time-from="06:00:00" time-to="24:00:00" />
|
||||
<weekly day="SA" priority="0" time-from="00:00:00" time-to="01:00:00" />
|
||||
<weekly day="MI" priority="0" time-from="19:00:00" time-to="06:00:00" />
|
||||
<weekly day="DO" priority="0" time-from="19:00:00" time-to="06:00:00" />
|
||||
</transmit-times>
|
||||
|
||||
<transmitter-location>
|
||||
@@ -45,9 +43,16 @@ Content-type:text/xml; charset=UTF-8
|
||||
</gml:Point>
|
||||
</transmitter-location>
|
||||
</transmitter>
|
||||
|
||||
<webstream>
|
||||
<transmit-times>
|
||||
<transmit-time time-from="00:00:00" time-to="23:59:59"/>
|
||||
</transmit-times>
|
||||
<url>http://ice.rosebud-media.de:8000/88vier</url>
|
||||
<format>audio/mpeg</format>
|
||||
<quality>160kbps</quality>
|
||||
</webstream>
|
||||
<website>
|
||||
<url>https://www.freie-radios.net/</url>
|
||||
<url>https://piradio.de</url>
|
||||
</website>
|
||||
</media-channels>
|
||||
|
||||
@@ -64,7 +69,7 @@ Content-type:text/xml; charset=UTF-8
|
||||
</categories>
|
||||
<feed>
|
||||
<title>Sendebeschreibung</title>
|
||||
<url>http://localhost<TMPL_VAR cache_base_url>/<TMPL_VAR .controllers.event>/<TMPL_VAR event_id>.html#<TMPL_VAR event_uri escape=url></url>
|
||||
<url>https://piradio.de<TMPL_VAR cache_base_url>/<TMPL_VAR .controllers.event>/<TMPL_VAR event_id>.html#<TMPL_VAR event_uri escape=url></url>
|
||||
</feed>
|
||||
<transmit-times>
|
||||
<transmit-time date-from="<TMPL_VAR start_datetime_utc>" date-to="<TMPL_VAR end_datetime_utc>" recurrence="false" rerun="<TMPL_IF rerun>true<TMPL_ELSE>false</TMPL_IF>" />
|
||||
|
||||
@@ -10,97 +10,114 @@
|
||||
<meta http-equiv="Content-Style-Type" content="text/css" />
|
||||
<title>Playlist <TMPL_VAR project_title></title>
|
||||
|
||||
<style>
|
||||
#coming_shows .eventContainer {
|
||||
display:inline-block;
|
||||
vertical-align:top;
|
||||
text-align:center;
|
||||
cursor:pointer;
|
||||
width:100px;
|
||||
height:100px;
|
||||
margin:0;
|
||||
overflow:hidden;
|
||||
padding:6px;
|
||||
}
|
||||
#coming_shows .eventContainer:hover {
|
||||
background:#eeeeee;
|
||||
}
|
||||
#coming_shows a:hover {
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
#coming_shows div.event{
|
||||
position:relative;
|
||||
width:100px;
|
||||
height:100px;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center center;
|
||||
background-size: cover;
|
||||
}
|
||||
#coming_shows div.event .top,
|
||||
#coming_shows div.event .bottom{
|
||||
position:absolute;
|
||||
background:#222;
|
||||
color:#fff;
|
||||
opacity:0.8;
|
||||
width:100%;
|
||||
}
|
||||
#coming_shows div.event .top:hover,
|
||||
#coming_shows div.event .bottom:hover{
|
||||
opacity:1;
|
||||
}
|
||||
<script>
|
||||
/**
|
||||
* @fileoverview dragscroll - scroll area by dragging
|
||||
* @version 0.0.8
|
||||
*
|
||||
* @license MIT, see http://github.com/asvd/dragscroll
|
||||
* @copyright 2015 asvd <heliosframework@gmail.com>
|
||||
*/
|
||||
|
||||
|
||||
#coming_shows div.event .top{
|
||||
top:0;
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['exports'], factory);
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
factory(exports);
|
||||
} else {
|
||||
factory((root.dragscroll = {}));
|
||||
}
|
||||
}(this, function (exports) {
|
||||
var _window = window;
|
||||
var _document = document;
|
||||
var mousemove = 'mousemove';
|
||||
var mouseup = 'mouseup';
|
||||
var mousedown = 'mousedown';
|
||||
var EventListener = 'EventListener';
|
||||
var addEventListener = 'add'+EventListener;
|
||||
var removeEventListener = 'remove'+EventListener;
|
||||
var newScrollX, newScrollY;
|
||||
|
||||
var dragged = [];
|
||||
var reset = function(i, el) {
|
||||
for (i = 0; i < dragged.length;) {
|
||||
el = dragged[i++];
|
||||
el = el.container || el;
|
||||
el[removeEventListener](mousedown, el.md, 0);
|
||||
_window[removeEventListener](mouseup, el.mu, 0);
|
||||
_window[removeEventListener](mousemove, el.mm, 0);
|
||||
}
|
||||
|
||||
#coming_shows div.event .bottom{
|
||||
bottom:0;
|
||||
}
|
||||
|
||||
#coming_shows div.event{
|
||||
transition: all .2s ease-in-out;
|
||||
}
|
||||
// cloning into array since HTMLCollection is updated dynamically
|
||||
dragged = [].slice.call(_document.getElementsByClassName('dragscroll'));
|
||||
for (i = 0; i < dragged.length;) {
|
||||
(function(el, lastClientX, lastClientY, pushed, scroller, cont){
|
||||
(cont = el.container || el)[addEventListener](
|
||||
mousedown,
|
||||
cont.md = function(e) {
|
||||
if (!el.hasAttribute('nochilddrag') ||
|
||||
_document.elementFromPoint(
|
||||
e.pageX, e.pageY
|
||||
) == cont
|
||||
) {
|
||||
pushed = 1;
|
||||
lastClientX = e.clientX;
|
||||
lastClientY = e.clientY;
|
||||
|
||||
#coming_shows div.event:hover{
|
||||
transform: scale(1.1);
|
||||
e.preventDefault();
|
||||
}
|
||||
}, 0
|
||||
);
|
||||
|
||||
_window[addEventListener](
|
||||
mouseup, cont.mu = function() {pushed = 0;}, 0
|
||||
);
|
||||
|
||||
_window[addEventListener](
|
||||
mousemove,
|
||||
cont.mm = function(e) {
|
||||
if (pushed) {
|
||||
(scroller = el.scroller||el).scrollLeft -=
|
||||
newScrollX = (- lastClientX + (lastClientX=e.clientX));
|
||||
scroller.scrollTop -=
|
||||
newScrollY = (- lastClientY + (lastClientY=e.clientY));
|
||||
if (el == _document.body) {
|
||||
(scroller = _document.documentElement).scrollLeft -= newScrollX;
|
||||
scroller.scrollTop -= newScrollY;
|
||||
}
|
||||
}
|
||||
}, 0
|
||||
);
|
||||
})(dragged[i++]);
|
||||
}
|
||||
</style>
|
||||
}
|
||||
|
||||
|
||||
if (_document.readyState == 'complete') {
|
||||
reset();
|
||||
} else {
|
||||
_window[addEventListener]('load', reset, 0);
|
||||
}
|
||||
|
||||
exports.reset = reset;
|
||||
}));
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<script>
|
||||
//handler for sliding events bound to onmouseenter/onmouseleave at playlist_container
|
||||
var slideEvents=1;
|
||||
function enter_playlist(){
|
||||
slideEvents=0;
|
||||
}
|
||||
|
||||
function leave_playlist(){
|
||||
slideEvents=1;
|
||||
}
|
||||
</script>
|
||||
|
||||
<body>
|
||||
<div id="playlist_container" onmouseenter="enter_playlist()" onmouseleave="leave_playlist()">
|
||||
<div id="playlist_container" class="dragscroll">
|
||||
<TMPL_LOOP NAME=events>
|
||||
<div id="event_playlist_<TMPL_VAR event_id>" class="eventContainer"
|
||||
onclick="window.location.href='<TMPL_VAR cache_base_url>/<TMPL_VAR .controllers.event>/<TMPL_VAR event_id>.html#<TMPL_VAR event_uri escape=url>'"
|
||||
>
|
||||
<a href="<TMPL_VAR cache_base_url>/<TMPL_VAR .controllers.event>/<TMPL_VAR event_id>.html#<TMPL_VAR event_uri escape=url>"
|
||||
>
|
||||
<div class="event"
|
||||
style="background-image:url(<TMPL_VAR thumb>)"
|
||||
>
|
||||
<div class="top" title="<TMPL_VAR full_title><TMPL_IF excerpt>. <TMPL_VAR excerpt></TMPL_IF>">
|
||||
<TMPL_VAR weekday_short_name> <TMPL_VAR start_time_name>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<TMPL_IF series_name><TMPL_VAR series_name><TMPL_ELSE><TMPL_VAR title></TMPL_IF>
|
||||
</div>
|
||||
<a href="<TMPL_VAR cache_base_url>/<TMPL_VAR .controllers.event>/<TMPL_VAR event_id>.html#<TMPL_VAR event_uri escape=url>" >
|
||||
<div id="event_playlist_<TMPL_VAR event_id>" class="eventContainer event">
|
||||
<div class="top" title="<TMPL_VAR full_title><TMPL_IF excerpt>. <TMPL_VAR excerpt></TMPL_IF>">
|
||||
<TMPL_VAR weekday_short_name> <TMPL_VAR start_time_name>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<TMPL_IF series_name><TMPL_VAR series_name><TMPL_ELSE><TMPL_VAR title></TMPL_IF>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</TMPL_LOOP>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
52
website/agenda/upload_playout.cgi
Normal file → Executable file
52
website/agenda/upload_playout.cgi
Normal file → Executable file
@@ -5,10 +5,11 @@ use warnings "all";
|
||||
use strict;
|
||||
|
||||
use CGI qw(header param Vars);
|
||||
$CGI::POST_MAX = 1000;
|
||||
$CGI::POST_MAX = 1000;
|
||||
$CGI::DISABLE_UPLOADS = 1;
|
||||
|
||||
use Data::Dumper;
|
||||
|
||||
#use Apache2::Request;
|
||||
use JSON;
|
||||
use params;
|
||||
@@ -16,38 +17,39 @@ use config;
|
||||
use log;
|
||||
use playout;
|
||||
|
||||
my $r=shift;
|
||||
my $r = shift;
|
||||
|
||||
#binmode STDOUT, ":utf8";
|
||||
binmode STDOUT, ":encoding(UTF-8)";
|
||||
|
||||
if ($0=~/upload_playout.*?\.cgi$/){
|
||||
if ( $0 =~ /upload_playout.*?\.cgi$/ ) {
|
||||
|
||||
# read POST content
|
||||
my ($buf, $content);
|
||||
while( $r->read($buf,8192) ){
|
||||
$content .= $buf;
|
||||
}
|
||||
$content= "{}" unless $content;
|
||||
# read POST content
|
||||
my ( $buf, $content );
|
||||
while ( $r->read( $buf, 8192 ) ) {
|
||||
$content .= $buf;
|
||||
}
|
||||
$content = "{}" unless $content;
|
||||
|
||||
# parse GET content
|
||||
(my $cgi, my $params, my $error)=params::get($r);
|
||||
# parse GET content
|
||||
( my $cgi, my $params, my $error ) = params::get($r);
|
||||
|
||||
my $config=config::get('config/config.cgi');
|
||||
my $debug=$config->{system}->{debug};
|
||||
my $len = $r->headers_in()->get('Content-Length');
|
||||
print "Content-type:text/plain\n\n";
|
||||
my $config = config::get('config/config.cgi');
|
||||
my $debug = $config->{system}->{debug};
|
||||
my $len = $r->headers_in()->get('Content-Length');
|
||||
print "Content-type:text/plain\n\n";
|
||||
|
||||
my $json=decode_json($content);
|
||||
$json->{project_id}=$params->{project_id} if defined $params->{project_id};
|
||||
$json->{studio_id}=$params->{studio_id} if defined $params->{studio_id};
|
||||
$config->{access}->{write}=1;
|
||||
my $result=playout::sync($config, $json);
|
||||
$config->{access}->{write}=0;
|
||||
#print Dumper($content)."\n";
|
||||
#print Dumper($r);
|
||||
#print Dumper($json);
|
||||
print "result:".Dumper($result);
|
||||
my $json = decode_json($content);
|
||||
$json->{project_id} = $params->{project_id} if defined $params->{project_id};
|
||||
$json->{studio_id} = $params->{studio_id} if defined $params->{studio_id};
|
||||
$config->{access}->{write} = 1;
|
||||
my $result = playout::sync( $config, $json );
|
||||
$config->{access}->{write} = 0;
|
||||
|
||||
#print Dumper($content)."\n";
|
||||
#print Dumper($r);
|
||||
#print Dumper($json);
|
||||
print "result:" . Dumper($result);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
Reference in New Issue
Block a user