lib/calcms: remove comments and shorten expressions

This commit is contained in:
Milan
2024-04-24 23:20:20 +02:00
parent 6436822ec5
commit df0982c0a6
39 changed files with 252 additions and 366 deletions

View File

@@ -10,7 +10,6 @@ use calendar();
use project();
use Date::Calc;
#use base 'Exporter';
our @EXPORT_OK = qw(get_cache configure_cache put_cache get_list check_params);
sub get_list($$) {

View File

@@ -7,7 +7,6 @@ no warnings 'redefine';
use Data::Dumper;
use db();
#use base 'Exporter';
our @EXPORT_OK = qw(get_columns get);
# columns:
@@ -164,10 +163,9 @@ sub update($$) {
sub insert ($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{project_id};
return undef unless defined $entry->{studio_id};
return undef unless defined $entry->{event_id};
return undef unless defined $entry->{path};
for ('project_id', 'studio_id', 'event_id', 'path') {
return undef unless defined $entry->{$_}
};
my $dbh = db::connect($config);
$entry = {
@@ -194,10 +192,9 @@ sub insert ($$) {
sub delete ($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{project_id};
return undef unless defined $entry->{studio_id};
return undef unless defined $entry->{event_id};
return undef unless defined $entry->{path};
for ('project_id', 'studio_id', 'event_id', 'path') {
return undef unless defined $entry->{$_}
};
my $dbh = db::connect($config);
my $query = qq{

View File

@@ -10,7 +10,6 @@ use Date::Calc();
use template();
use events();
#use base 'Exporter';
our @EXPORT_OK = qw(init get_cached_or_render get render get_calendar_weeks configure_cache);
sub init() {

View File

@@ -11,7 +11,6 @@ use markup();
use template();
use time();
#use base 'Exporter';
our @EXPORT_OK =
qw(init get_cached_or_render get modify_results render configure_cache get_query get_by_event get_level get_events check insert set_lock_status set_news_status lock update_comment_count sort);

View File

@@ -4,15 +4,10 @@ use strict;
use warnings;
no warnings 'redefine';
use FindBin();
#use base 'Exporter';
our @EXPORT_OK = qw(get set);
my $config = undef;
sub get($) {
my ($filename) = @_;
return read_config($filename);

View File

@@ -7,7 +7,6 @@ no warnings 'redefine';
use Data::Dumper;
use markup();
#use base 'Exporter';
our @EXPORT_OK =
qw(extractEventFromWikiText removeMeta eventToWikiText extractMeta removeMeta metaToWiki);

View File

@@ -13,7 +13,6 @@ use studios();
use series_events();
use user_stats();
#use base 'Exporter';
our @EXPORT_OK = qw(
setAttributesFromSeriesTemplate
setAttributesFromSchedule
@@ -204,9 +203,7 @@ sub createEvent($$$) {
my $user = $request->{user};
my $checklist = [ 'studio', 'user', 'create_events', 'studio_timeslots' ];
if ( $action eq 'create_event_from_schedule' ) {
push @$checklist, 'schedule' if $action eq 'create_event_from_schedule';
}
my $start = $event->{start_date}, my $end = time::add_minutes_to_datetime( $event->{start_date}, $event->{duration} );

View File

@@ -6,7 +6,6 @@ no warnings 'redefine';
use Data::Dumper;
#use base 'Exporter';
our @EXPORT_OK = qw(get_columns get get_by_id insert insert_by_event_id delete);
sub get_columns ($){
@@ -79,13 +78,11 @@ sub get ($$){
sub get_by_id($$) {
my ($config, $id) = @_;
my $dbh = db::connect($config);
my $query = qq{
select *
from calcms_event_history
where event_id=?
};
my $studios = db::get( $dbh, $query, [$id] );
return undef if ( @$studios != 1 );
return $studios->[0];
@@ -95,7 +92,6 @@ sub insert($$) {
my ($config, $entry) = @_;
$entry->{modified_at} = time::time_to_datetime( time() );
$entry->{event_id} = $entry->{id} if ( defined $entry->{id} ) && ( !( defined $entry->{event_id} ) );
delete $entry->{id};
@@ -115,11 +111,9 @@ sub insert($$) {
sub insert_by_event_id ($$){
my ($config, $options) = @_;
return undef unless defined $options->{project_id};
return undef unless defined $options->{studio_id};
return undef unless defined $options->{series_id};
return undef unless defined $options->{event_id};
return undef unless defined $options->{user};
for ('project_id', 'studio_id', 'series_id', 'event_id', 'user') {
return undef unless defined $options->{$_}
};
my $sql = q{
select * from calcms_events

View File

@@ -9,10 +9,8 @@ $Data::Dumper::Sortkeys=1;
use MIME::Base64();
use Encode();
use Storable 'dclone';
use DBI();
use template();
use config();
use time();
use db();
@@ -22,7 +20,6 @@ use log();
use project();
use studios();
#use base 'Exporter';
our @EXPORT_OK = qw(
init
get_cached_or_render
@@ -184,12 +181,6 @@ sub modify_results ($$$$) {
$result->{excerpt} = '' unless defined( $result->{excerpt} );
$result->{excerpt} = "lass dich ueberraschen"
if ( $result->{excerpt} eq '' );
# $result->{excerpt} =markup::plain_to_xml($result->{excerpt});
# $result->{title} =markup::plain_to_xml($result->{title});
# $result->{series_name} =markup::plain_to_xml($result->{series_name});
# $result->{program} =markup::plain_to_xml($result->{program});
#print STDERR "created:$result->{created_at} modified:$result->{modified_at}\n";
$result->{modified_at} =
time::datetime_to_rfc822( $result->{modified_at} );
if ( $result->{created_at} =~ /[1-9]/ ) {
@@ -343,8 +334,6 @@ sub modify_results ($$$$) {
}
}
#$result->{'project_title'}=$project->{title} if (defined $project->{title} && $project->{title} ne '');
for my $name ( keys %{ $config->{mapping}->{events} } ) {
my $val = '';
if ( ( defined $name )
@@ -357,10 +346,6 @@ sub modify_results ($$$$) {
}
}
#for my $name (keys %{$config->{controllers}}){
# $result->{"controller_$name"}=$config->{controllers}->{$name};
#}
$previous_result = $result;
$result->{ 'counter_' . $counter } = 1;
@@ -642,8 +627,10 @@ sub set_listen_key{
sub set_upload_status($$){
my ($config, $event) = @_;
return undef unless defined $event->{event_id};
return undef unless defined $event->{upload_status};
for ('event_id', 'upload_status') {
return undef unless defined $event->{$_}
};
my $bindValues = [ $event->{upload_status}, $event->{event_id}, $event->{upload_status} ];
my $query = qq{
@@ -655,9 +642,9 @@ sub set_upload_status($$){
my $recordings = db::put( $dbh, $query, $bindValues );
}
# returns all recordings for a event
sub add_recordings($$$$) {
my ($dbh, $config, $request, $events) = @_;
return $events unless defined $events;
my $eventsById = { map { $_->{event_id} => $_ } @$events };

View File

@@ -10,7 +10,6 @@ use Data::Dumper;
# columns: id, studio_id, series_id,
# table, column, text
#use base 'Exporter';
our @EXPORT_OK = qw(get_columns get insert update delete);
sub get_columns($) {

View File

@@ -6,9 +6,7 @@ no warnings 'redefine';
use config();
use template();
use Data::Dumper;
#use base 'Exporter';
our @EXPORT_OK = qw(get insert update insert_or_update delete delete_files);
#column 'created_at' will be set at insert

View File

@@ -8,7 +8,6 @@ use Data::Dumper;
use uac();
use user_settings();
#use base 'Exporter';
our @EXPORT_OK = qw(get getJavascript);
# get localisation
@@ -46,17 +45,8 @@ sub get($$) {
#get all comma separated po files
for my $file ( split /\,/, $files ) {
#read default language
#my $po_file=$config->{locations}->{admin_pot_dir}.'/en/'.$file.'.po';
#$loc=read_po_file($po_file, $loc);
#read selected language
#if($language ne 'en'){
my $po_file = $config->{locations}->{admin_pot_dir} . '/' . $language . '/' . $file . '.po';
$loc = read_po_file( $po_file, $loc );
#}
}
return $loc;
}
@@ -79,7 +69,6 @@ sub read_po_file($$) {
while (<$file>) {
my $line = $_;
#print STDERR $line;
if ( $line =~ /^msgid\s*\"(.*)\"\s*$/ ) {
$key = $1;
$key =~ s/\'//g;

View File

@@ -4,7 +4,6 @@ use strict;
use warnings;
no warnings 'redefine';
#use base 'Exporter';
our @EXPORT_OK = qw(error load_file save_file append_file);
use config();

View File

@@ -14,7 +14,6 @@ use Text::Markdown();
use log();
#use base 'Exporter';
our @EXPORT_OK =
qw(fix_line_ends html_to_creole creole_to_html creole_to_plain plain_to_ical ical_to_plain ical_to_xml html_to_plain fix_utf8 uri_encode compress base26);

View File

@@ -1,5 +1,4 @@
package params;
use strict;
use warnings;
no warnings 'redefine';
@@ -7,7 +6,6 @@ no warnings 'redefine';
use Data::Dumper;
use Apache2::Request();
#use base 'Exporter';
our @EXPORT_OK = qw(get isJson);
my $isJson = 0;

View File

@@ -8,7 +8,6 @@ use Data::Dumper;
use Session::Token();
# table: calcms_password_requests
#use base 'Exporter';
our @EXPORT_OK = qw(get insert delete get_columns);
use mail;
@@ -26,7 +25,6 @@ sub get ($$) {
my ($config, $condition) = @_;
my $dbh = db::connect($config);
my @conditions = ();
my @bind_values = ();

View File

@@ -6,11 +6,11 @@ no warnings 'redefine';
use Data::Dumper;
use Date::Calc();
use db();
use time();
use series_events();
#use base 'Exporter';
our @EXPORT_OK = qw(get_columns get sync);
sub get_columns ($) {
@@ -19,8 +19,6 @@ sub get_columns ($) {
return db::get_columns_hash( $dbh, 'calcms_playout' );
}
# get playout entries
sub get_scheduled($$) {
my ($config, $condition) = @_;
@@ -127,8 +125,9 @@ sub get_scheduled($$) {
# get playout entries
sub get($$) {
my ($config, $condition) = @_;
return undef unless defined $condition->{studio_id};
for ('studio_id') {
return undef unless defined $condition->{$_}
};
my $date_range_include = 0;
$date_range_include = 1
@@ -227,11 +226,9 @@ sub get($$) {
sub sync ($$) {
my ($config, $options) = @_;
return undef unless defined $options->{project_id};
return undef unless defined $options->{studio_id};
return undef unless defined $options->{from};
return undef unless defined $options->{till};
return undef unless defined $options->{events};
for ('project_id', 'studio_id', 'from', 'till', 'events') {
return undef unless defined $options->{$_}
};
my $project_id = $options->{project_id};
my $studio_id = $options->{studio_id};

View File

@@ -12,7 +12,6 @@ use log();
use template();
use images();
#use base 'Exporter';
our @EXPORT_OK = qw(
check get_columns get insert delete get_date_range
get_studios assign_studio unassign_studio is_studio_assigned get_studio_assignments
@@ -73,7 +72,10 @@ sub get ($;$) {
sub getImageById($$) {
my ($config, $conditions) = @_;
return undef unless defined $conditions->{project_id};
for ('project_id') {
return undef unless defined $conditions->{$_};
};
my $projects = project::get( $config, $conditions );
return undef if scalar(@$projects) != 1;
return $projects->[0]->{image};
@@ -146,7 +148,9 @@ sub delete ($$) {
sub get_studios($$) {
my ($config, $options) = @_;
return undef unless defined $options->{project_id};
for ('project_id') {
return undef unless defined $options->{$_}
};
my $project_id = $options->{project_id};
my $query = qq{
@@ -195,8 +199,9 @@ sub get_studio_assignments($$) {
sub is_studio_assigned ($$) {
my ($config, $entry) = @_;
return 0 unless defined $entry->{project_id};
return 0 unless defined $entry->{studio_id};
for ('project_id', 'studio_id') {
return 0 unless defined $entry->{$_}
};
my $project_id = $entry->{project_id};
my $studio_id = $entry->{studio_id};
@@ -218,8 +223,9 @@ sub is_studio_assigned ($$) {
sub assign_studio($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{project_id};
return undef unless defined $entry->{studio_id};
for ('project_id', 'studio_id') {
return undef unless defined $entry->{$_}
};
my $project_id = $entry->{project_id};
my $studio_id = $entry->{studio_id};
@@ -236,8 +242,9 @@ sub assign_studio($$) {
sub unassign_studio($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{project_id};
return undef unless defined $entry->{studio_id};
for ('project_id', 'studio_id') {
return undef unless defined $entry->{$_}
};
my $project_id = $entry->{project_id};
my $studio_id = $entry->{studio_id};
@@ -251,8 +258,9 @@ sub unassign_studio($$) {
sub get_series ($$) {
my ($config, $options) = @_;
return undef unless defined $options->{project_id};
return undef unless defined $options->{studio_id};
for ('project_id', 'studio_id') {
return undef unless defined $options->{$_}
};
my $project_id = $options->{project_id};
my $studio_id = $options->{studio_id};
@@ -308,9 +316,9 @@ sub get_series_assignments ($$) {
sub is_series_assigned ($$) {
my ($config, $entry) = @_;
return 0 unless defined $entry->{project_id};
return 0 unless defined $entry->{studio_id};
return 0 unless defined $entry->{series_id};
for ('project_id', 'studio_id', 'series_id') {
return undef unless defined $entry->{$_}
};
my $project_id = $entry->{project_id};
my $studio_id = $entry->{studio_id};
@@ -333,9 +341,9 @@ sub is_series_assigned ($$) {
sub assign_series($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{project_id};
return undef unless defined $entry->{studio_id};
return undef unless defined $entry->{series_id};
for ('project_id', 'studio_id', 'series_id') {
return undef unless defined $entry->{$_}
};
my $project_id = $entry->{project_id};
my $studio_id = $entry->{studio_id};
@@ -356,9 +364,9 @@ sub assign_series($$) {
sub unassign_series ($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{project_id};
return undef unless defined $entry->{studio_id};
return undef unless defined $entry->{series_id};
for ('project_id', 'studio_id', 'series_id') {
return undef unless defined $entry->{$_}
};
my $project_id = $entry->{project_id};
my $studio_id = $entry->{studio_id};

View File

@@ -5,11 +5,9 @@ use warnings;
no warnings 'redefine';
use Data::Dumper;
use events();
use images();
#use base 'Exporter';
our @EXPORT_OK = qw(
get_columns get insert update delete
get_users add_user remove_user
@@ -125,8 +123,9 @@ sub get ($$) {
sub insert ($$) {
my ($config, $series) = @_;
return undef unless defined $series->{project_id};
return undef unless defined $series->{studio_id};
for ('project_id', 'studio_id') {
return undef unless defined $series->{$_}
};
my $project_id = $series->{project_id};
my $studio_id = $series->{studio_id};
@@ -162,9 +161,9 @@ sub insert ($$) {
sub update ($$) {
my ($config, $series) = @_;
return undef unless defined $series->{project_id};
return undef unless defined $series->{studio_id};
return undef unless defined $series->{series_id};
for ('project_id', 'studio_id', 'series_id') {
return undef unless defined $series->{$_}
};
my $columns = series::get_columns($config);
my $entry = {};
@@ -198,9 +197,9 @@ sub update ($$) {
sub delete($$) {
my ($config, $series) = @_;
return undef unless defined $series->{project_id};
return undef unless defined $series->{studio_id};
return undef unless defined $series->{series_id};
for ('project_id', 'studio_id', 'series_id') {
return undef unless defined $series->{$_}
};
my $project_id = $series->{project_id};
my $studio_id = $series->{studio_id};
@@ -328,11 +327,9 @@ sub get_users ($$) {
sub add_user ($$) {
my ($config, $entry) = @_;
return unless defined $entry->{project_id};
return unless defined $entry->{studio_id};
return unless defined $entry->{series_id};
return unless defined $entry->{user_id};
return unless defined $entry->{user};
for ('project_id', 'studio_id', 'series_id', 'user_id', 'user') {
return unless defined $entry->{$_}
};
my $query = qq{
select id
@@ -358,9 +355,9 @@ sub add_user ($$) {
sub remove_user ($$) {
my ($config, $condition) = @_;
return unless defined $condition->{project_id};
return unless defined $condition->{studio_id};
return unless defined $condition->{series_id};
for ('project_id', 'studio_id', 'series_id') {
return unless defined $condition->{$_}
};
my @conditions = ();
my @bind_values = ();
@@ -441,7 +438,6 @@ sub search_events ($$$) {
#get events (only assigned ones) by project_id,studio_id,series_id,
sub get_events ($$) {
my ($config, $options) = @_;
return [] if defined( $options->{series_id} ) && ( $options->{series_id} <= 0 );
my @conditions = ();
@@ -611,8 +607,9 @@ sub get_event ($$) {
sub get_event_age($$) {
my ($config, $options) = @_;
return undef unless defined $options->{project_id};
return undef unless defined $options->{studio_id};
for ('project_id', 'studio_id') {
return undef unless defined $options->{$_}
};
my @conditions = ();
my @bind_values = ();
@@ -694,9 +691,9 @@ sub is_event_older_than_days ($$) {
sub get_next_episode($$) {
my ($config, $options) = @_;
return 0 unless defined $options->{project_id};
return 0 unless defined $options->{studio_id};
return 0 unless defined $options->{series_id};
for ('project_id', 'studio_id', 'series_id') {
return 0 unless defined $options->{$_}
};
#return if episodes should not be counted for this series
my $query = q{
@@ -733,9 +730,9 @@ sub get_next_episode($$) {
sub get_images ($$) {
my ($config, $options) = @_;
return undef unless defined $options->{project_id};
return undef unless defined $options->{studio_id};
return undef unless defined $options->{series_id};
for ('project_id', 'studio_id', 'series_id') {
return undef unless defined $options->{$_}
};
#get images from all events of the series
my $dbh = db::connect($config);
@@ -793,10 +790,9 @@ sub get_images ($$) {
sub assign_event($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{project_id};
return undef unless defined $entry->{studio_id};
return undef unless defined $entry->{series_id};
return undef unless defined $entry->{event_id};
for ('project_id', 'studio_id', 'series_id', 'event_id') {
return undef unless defined $entry->{$_}
};
$entry->{manual} = 0 unless ( defined $entry->{manual} ) && ( $entry->{manual} eq '1' );
my $conditions = '';
@@ -835,10 +831,9 @@ sub assign_event($$) {
sub unassign_event($$) {
my ($config, $entry) = @_;
return unless defined $entry->{project_id};
return unless defined $entry->{studio_id};
return unless defined $entry->{series_id};
return unless defined $entry->{event_id};
for ('project_id', 'studio_id', 'series_id', 'event_id') {
return undef unless defined $entry->{$_}
};
my $conditions = '';
$conditions = 'and manual=1' if ( defined $entry->{manual} ) && ( $entry->{manual} eq '1' );
@@ -908,10 +903,9 @@ sub set_event_ids ($$$$$) {
my ($config, $project_id, $studio_id, $serie, $event_ids) = @_;
my $serie_id = $serie->{series_id};
return unless defined $project_id;
return unless defined $studio_id;
return unless defined $serie_id;
return unless defined $event_ids;
for ('project_id', 'studio_id', 'series_id', 'event_id') {
return unless defined $serie->{$_}
};
#make lookup table from events
my $event_id_hash = { map { $_ => 1 } @$event_ids };
@@ -933,7 +927,6 @@ sub set_event_ids ($$$$$) {
#insert events from list, not found in db
for my $event_id (@$event_ids) {
#print "insert event_id $event_id\n";
series::assign_event(
$config,
{
@@ -947,7 +940,6 @@ sub set_event_ids ($$$$$) {
#delete events found in db, but not in list
for my $event_id ( keys %$found ) {
#print "delete event_id $event_id\n";
series::unassign_event(
$config,
@@ -971,10 +963,10 @@ sub can_user_update_events ($$) {
my $config = $request->{config};
my $permissions = $request->{permissions};
for ('project_id', 'studio_id', 'series_id') {
return 0 unless defined $options->{$_}
};
return 0 unless defined $request->{user};
return 0 unless defined $options->{project_id};
return 0 unless defined $options->{studio_id};
return 0 unless defined $options->{series_id};
return 1 if ( defined $permissions->{update_event_of_others} ) && ( $permissions->{update_event_of_others} eq '1' );
return 1 if ( defined $permissions->{is_admin} ) && ( $permissions->{is_admin} eq '1' );
@@ -991,10 +983,10 @@ sub can_user_create_events ($$) {
my $config = $request->{config};
my $permissions = $request->{permissions};
for ('project_id', 'studio_id', 'series_id') {
return 0 unless defined $options->{$_}
};
return 0 unless defined $request->{user};
return 0 unless defined $options->{project_id};
return 0 unless defined $options->{studio_id};
return 0 unless defined $options->{series_id};
return 1 if ( defined $permissions->{create_event} ) && ( $permissions->{create_event} eq '1' );
return 1 if ( defined $permissions->{is_admin} ) && ( $permissions->{is_admin} eq '1' );
@@ -1009,9 +1001,9 @@ sub is_series_assigned_to_user ($$) {
my $config = $request->{config};
my $permissions = $request->{permissions};
return 0 unless defined $options->{project_id};
return 0 unless defined $options->{studio_id};
return 0 unless defined $options->{series_id};
for ('project_id', 'studio_id', 'series_id') {
return 0 unless defined $options->{$_}
};
return 0 unless defined $request->{user};
my $series_users = series::get_users(
@@ -1034,11 +1026,10 @@ sub is_event_assigned_to_user ($$) {
my $config = $request->{config};
for ('project_id', 'studio_id', 'series_id', 'event_id') {
return "missing $_" unless defined $options->{$_}
};
return "missing user" unless defined $request->{user};
return "missing project_id" unless defined $options->{project_id};
return "missing studio_id" unless defined $options->{studio_id};
return "missing series_id" unless defined $options->{series_id};
return "missing event_id" unless defined $options->{event_id};
#check roles
my $user_studios = uac::get_studios_by_user(
@@ -1081,9 +1072,9 @@ sub is_event_assigned_to_user ($$) {
sub get_rebuilt_episodes ($$) {
my ($config, $options) = @_;
return "missing project_id" unless defined $options->{project_id};
return "missing studio_id" unless defined $options->{studio_id};
return "missing series_id" unless defined $options->{series_id};
for ('project_id', 'studio_id', 'series_id') {
return undef unless defined $options->{$_}
};
# ignore project and studio as series can be used in multiple studios
my $events = series::get_events(
@@ -1151,10 +1142,9 @@ sub get_event_key ($) {
sub update_recurring_events ($$) {
my ($config, $options) = @_;
return "missing project_id" unless defined $options->{project_id};
return "missing studio_id" unless defined $options->{studio_id};
return "missing series_id" unless defined $options->{series_id};
return "missing event_id" unless defined $options->{event_id};
for ('project_id', 'studio_id', 'series_id', 'event_id') {
return "missing $_" unless defined $options->{$_};
};
my $events = series::get_events(
$config,
@@ -1221,10 +1211,9 @@ sub update_recurring_events ($$) {
sub update_recurring_event($$) {
my ($config, $event) = @_;
return undef unless defined $event->{event_id};
return undef unless defined $event->{recurrence};
return undef unless defined $event->{recurrence_count};
return undef unless defined $event->{rerun};
for ('event_id', 'recurrence', 'recurrence_count', 'rerun') {
return undef unless defined $event->{$_}
};
return unless $event->{event_id} =~ /^\d+$/;
return unless $event->{recurrence} =~ /^\d+$/;

View File

@@ -6,6 +6,7 @@ no warnings 'redefine';
use Data::Dumper;
use Date::Calc();
use time();
use db();
use log();
@@ -16,7 +17,6 @@ use series_schedule();
# table: calcms_series_dates
# columns: id, studio_id, series_id, start(datetime), end(datetime)
# TODO: delete column schedule_id
#use base 'Exporter';
our @EXPORT_OK = qw(get_columns get insert update delete get_dates get_series);
sub get_columns ($) {
@@ -108,10 +108,9 @@ sub get ($;$) {
sub is_event_scheduled($$) {
my ($request, $options) = @_;
return 0 unless defined $options->{project_id};
return 0 unless defined $options->{studio_id};
return 0 unless defined $options->{series_id};
return 0 unless defined $options->{start_at};
for ('project_id', 'studio_id', 'series_id', 'start_at') {
return 0 unless defined $options->{$_}
};
my $config = $request->{config};
my $schedules = series_dates::get(
@@ -281,9 +280,9 @@ sub addSeriesScheduleAttributes ($$) {
sub update($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{project_id};
return undef unless defined $entry->{studio_id};
return undef unless defined $entry->{series_id};
for ('project_id', 'studio_id', 'series_id') {
return undef unless defined $entry->{$_}
};
my $dbh = db::connect($config);
@@ -350,7 +349,6 @@ sub update($$) {
$j++;
}
}
#print STDERR "$i series_dates updates\n";
return $j . " dates out of studio times, " . $i;
}
@@ -457,8 +455,6 @@ sub get_dates($$$$) {
my @start_date = ( $start[0], $start[1], $start[2] );
my $start_time = sprintf( '%02d:%02d:%02d', $start[3], $start[4], $start[5] );
#print STDERR "$start_datetime,$end_date,$duration,$frequency\n";
#return on single date
my $date = {};
$date->{start} = sprintf( "%04d-%02d-%02d", @start_date ) . ' ' . $start_time;
@@ -505,9 +501,9 @@ sub get_dates($$$$) {
sub delete ($$) {
my ($config, $entry) = @_;
return unless defined $entry->{project_id};
return unless defined $entry->{studio_id};
return unless defined $entry->{series_id};
for ('project_id', 'studio_id', 'series_id') {
return unless defined $entry->{$_}
};
my $dbh = db::connect($config);
@@ -525,10 +521,9 @@ sub delete ($$) {
sub getDatesWithoutEvent ($$) {
my ($config, $options) = @_;
return unless defined $options->{project_id};
return unless defined $options->{studio_id};
return unless defined $options->{from};
return unless defined $options->{till};
for ('project_id', 'studio_id', 'form', 'till') {
return unless defined $options->{$_}
};
my $dbh = db::connect($config);
my $cond = $options->{series_id} ? 'and sd.series_id = ?' : '';

View File

@@ -6,8 +6,8 @@ no warnings 'redefine';
use Data::Dumper;
use Date::Calc;
use markup();
use markup();
use db();
use log();
use time();
@@ -40,7 +40,9 @@ sub get_content_columns($) {
# all changed columns are returned for history handling
sub save_content($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{id};
for ('id') {
return undef unless defined $entry->{$_}
};
for my $attr ( keys %$entry ) {
next unless defined $entry->{$attr};
@@ -96,8 +98,9 @@ sub save_content($$) {
sub set_episode{
my ($config, $entry) = @_;
return undef unless defined $entry->{id};
return undef unless defined $entry->{episode};
for ('id', 'episode') {
return undef unless defined $entry->{$_}
};
my $query = qq{
update calcms_events
@@ -120,9 +123,9 @@ sub set_episode{
sub save_event_time($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{id};
return undef unless defined $entry->{duration};
return undef unless defined $entry->{start_date};
for ('id', 'duration', 'start_date') {
return undef unless defined $entry->{$_}
};
my $dbh = db::connect($config);
my $event = {
@@ -161,7 +164,6 @@ sub save_event_time($$) {
where id=?
};
push @$bind_values, $event->{id};
db::put( $dbh, $update_sql, $bind_values );
return $event;
}
@@ -169,13 +171,11 @@ sub save_event_time($$) {
sub set_playout_status ($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{project_id};
return undef unless defined $entry->{studio_id};
return undef unless defined $entry->{start};
return undef unless defined $entry->{playout};
for ('project_id', 'studio_id', 'start', 'playout') {
return undef unless defined $entry->{$_}
};
my $dbh = db::connect($config);
# check if event is assigned to project and studio
my $sql = qq{
select se.event_id event_id
@@ -206,10 +206,9 @@ sub set_playout_status ($$) {
sub is_event_assigned($$) {
my ($config, $entry) = @_;
return 0 unless defined $entry->{project_id};
return 0 unless defined $entry->{studio_id};
return 0 unless defined $entry->{series_id};
return 0 unless defined $entry->{event_id};
for ('project_id', 'studio_id', 'series_id', 'event_id') {
return 0 unless defined $entry->{$_}
};
my $dbh = db::connect($config);
@@ -227,11 +226,9 @@ sub is_event_assigned($$) {
sub delete_event ($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{project_id};
return undef unless defined $entry->{studio_id};
return undef unless defined $entry->{series_id};
return undef unless defined $entry->{event_id};
return undef unless defined $entry->{user};
for ('project_id', 'studio_id', 'series_id', 'event_id', 'user') {
return undef unless defined $entry->{$_}
};
#is event assigned to project, studio and series?
unless ( is_event_assigned( $config, $entry ) == 1 ) {
@@ -404,16 +401,16 @@ sub check_permission($$) {
sub insert_event ($$) {
my ($config, $options) = @_;
for ('project_id', 'studio', 'serie', 'event', 'user') {
return 0 unless defined $options->{$_}
};
my $project_id = $options->{project_id};
my $studio = $options->{studio};
my $serie = $options->{serie};
my $params = $options->{event};
my $user = $options->{user};
return 0 unless defined $studio;
return 0 unless defined $serie;
return 0 unless defined $params;
return 0 unless defined $user;
return 0 unless defined $studio->{location};
my $projects = project::get( $config, { project_id => $project_id } );
@@ -427,7 +424,6 @@ sub insert_event ($$) {
location => $studio->{location}, # location from studio
};
#print '<pre>';
$event = series_events::add_event_dates( $config, $event, $params );
#get event content from series

View File

@@ -18,7 +18,6 @@ use series_dates();
# month
# nextDay (add 24 hours to start)
#use base 'Exporter';
our @EXPORT_OK = qw(get_columns get insert update delete);
sub get_columns ($) {
@@ -99,11 +98,9 @@ sub get($$) {
sub insert($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{project_id};
return undef unless defined $entry->{studio_id};
return undef unless defined $entry->{series_id};
return undef unless defined $entry->{start};
for ('project_id', 'studio_id', 'series_id', 'start') {
return undef unless defined $entry->{$_}
};
my $dbh = db::connect($config);
return db::insert( $dbh, 'calcms_series_schedule', $entry );
}
@@ -112,11 +109,10 @@ sub insert($$) {
sub update($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{project_id};
return undef unless defined $entry->{studio_id};
return undef unless defined $entry->{series_id};
return undef unless defined $entry->{schedule_id};
return undef unless defined $entry->{start};
for ('project_id', 'studio_id', 'series_id', 'start', 'schedule_id') {
return undef unless defined $entry->{$_}
};
$entry->{nextDay} = 0 unless defined $entry->{nextDay};
$entry->{id} = $entry->{schedule_id};
@@ -145,10 +141,9 @@ sub update($$) {
sub delete($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{project_id};
return undef unless defined $entry->{studio_id};
return undef unless defined $entry->{series_id};
return undef unless defined $entry->{schedule_id};
for ('project_id', 'studio_id', 'series_id', 'schedule_id') {
return undef unless defined $entry->{$_}
};
my $dbh = db::connect($config);

View File

@@ -20,5 +20,8 @@ use time();
use db();
use template();
# build compile check include list:
# ls -1 lib/calcms/*.pm | perl -ne 'if (/([^\/]+).pm/){ print "use $1(); "}'
#do not delete last line!
return 1;

View File

@@ -303,9 +303,9 @@ sub get_week_of_month_dates ($$$$$$$$) {
sub delete {
my ($config, $entry) = @_;
return unless defined $entry->{project_id};
return unless defined $entry->{studio_id};
return unless defined $entry->{schedule_id};
for ('project_id', 'studio_id', 'schedule_id') {
return unless defined $entry->{$_}
};
my $dbh = db::connect($config);
@@ -327,10 +327,9 @@ sub can_studio_edit_events {
my @conditions = ();
my @bind_values = ();
#return 0 unless defined $condition->{project_id};
return 0 unless defined $condition->{studio_id};
return 0 unless defined $condition->{start};
return 0 unless defined $condition->{end};
for ('studio_id', 'start', 'end') {
return 0 unless defined $condition->{$_}
};
if ( ( defined $condition->{project_id} ) && ( $condition->{project_id} ne '' ) ) {
push @conditions, 'project_id=?';
@@ -373,8 +372,6 @@ sub can_studio_edit_events {
if ( ( $condition->{start} ge $timeslot->{start} )
&& ( $condition->{end} le $timeslot->{end} ) )
{
#print STDERR "($condition->{start} ge $timeslot->{start}) ".($condition->{start} ge $timeslot->{start});
#print STDERR "($condition->{end} le $timeslot->{end}) ".($condition->{end} le $timeslot->{end});
return 1;
}
}
@@ -390,10 +387,9 @@ sub getMergedDays {
my @conditions = ();
my @bind_values = ();
#return 0 unless defined $condition->{project_id};
return 0 unless defined $condition->{studio_id};
return 0 unless defined $condition->{start};
return 0 unless defined $condition->{end};
for ('studio_id', 'start', 'end') {
return 0 unless defined $condition->{$_}
};
if ( ( defined $condition->{project_id} ) && ( $condition->{project_id} ne '' ) ) {
push @conditions, 'project_id=?';

View File

@@ -10,7 +10,6 @@ use studio_timeslot_dates();
# table: calcms_studio_timeslot_schedule
# columns: id, project_id, studio_id, start(datetime), end(datetime), end_date(date),
# frequency(days), duration(minutes), create_events(days), publish_events(days)
#use base 'Exporter';
our @EXPORT_OK = qw(get_columns get insert update delete);
sub get_columns($) {
@@ -63,10 +62,9 @@ sub get($$) {
sub insert($$) {
my ($config, $entry) = @_;
return unless defined $entry->{project_id};
return unless defined $entry->{studio_id};
return unless defined $entry->{start};
return unless defined $entry->{end};
for ('project_id', 'studio_id', 'start', 'end') {
return unless defined $entry->{$_}
};
my $dbh = db::connect($config);
return db::insert( $dbh, 'calcms_studio_timeslot_schedule', $entry );
@@ -76,11 +74,9 @@ sub insert($$) {
sub update($$) {
my ($config, $entry) = @_;
return unless defined $entry->{project_id};
return unless defined $entry->{studio_id};
return unless defined $entry->{schedule_id};
return unless defined $entry->{start};
return unless defined $entry->{end};
for ('project_id', 'studio_id', 'schedule_id', 'start', 'end') {
return unless defined $entry->{$_}
};
$entry->{id} = $entry->{schedule_id};
delete $entry->{schedule_id};
@@ -107,7 +103,9 @@ sub update($$) {
sub delete ($$){
my ($config, $entry) = @_;
return unless defined $entry->{schedule_id};
for ('schedule_id') {
return unless defined $entry->{$_}
};
my $dbh = db::connect($config);

View File

@@ -7,7 +7,6 @@ no warnings 'redefine';
use Data::Dumper;
use images();
#use base 'Exporter';
our @EXPORT_OK = qw(get_columns get get_by_id insert update delete check check_studio);
sub get_columns($) {
@@ -74,8 +73,9 @@ sub get($;$) {
sub getImageById($$) {
my ($config, $conditions) = @_;
return undef unless defined $conditions->{project_id};
return undef unless defined $conditions->{studio_id};
for ('project_id', 'studio_id') {
return undef unless defined $conditions->{$_}
};
my $studios = studios::get( $config, $conditions );
return undef if scalar(@$studios) != 1;
return $studios->[0]->{image};

View File

@@ -4,8 +4,6 @@ use strict;
use warnings;
no warnings 'redefine';
use Data::Dumper;
#use base 'Exporter';
our @EXPORT_OK = qw(get_tags);
sub get_tags($) {

View File

@@ -10,7 +10,6 @@ use HTML::Template::Compiled();
use HTML::Template::Compiled::Plugin::XMLEscape();
use HTML::Template::Compiled::Plugin::Hyphen();
#use HTML::Template::JIT();
use JSON();
use Cwd();
use Digest::MD5 qw(md5_hex);
@@ -19,7 +18,6 @@ use params();
use project();
use log();
#use base 'Exporter';
our @EXPORT_OK = qw(check process exit_on_missing_permission clear_cache);
# TODO:config

View File

@@ -14,7 +14,6 @@ use Data::Dumper;
use config();
#use base 'Exporter';
our @EXPORT_OK = qw(
format_datetime format_time
date_format time_format
@@ -164,7 +163,6 @@ sub format_time($) {
sub datetime_to_time ($){
my $datetime = $_[0];
# print $datetime."\n";
if ( $datetime =~ /(\d\d\d\d)\-(\d+)\-(\d+)[T\s](\d+)\:(\d+)(\:(\d+))?/ ) {
my $year = $1;
my $month = $2 - 1;
@@ -548,7 +546,6 @@ sub get_event_date($) {
my $datetime = time::time_to_datetime( time() );
my $hour = ( time::datetime_to_array($datetime) )->[3];
#print STDERR "datetime=$datetime hour=$hour\n";
#today: between 0:00 and starting_hour show last day
if ( $hour < $config->{date}->{day_starting_hour} ) {
my $date = time::datetime_to_array( time::add_days_to_datetime( $datetime, -1 ) );

View File

@@ -15,7 +15,6 @@ use studios();
use user_settings();
use user_default_studios();
#use base 'Exporter';
our @EXPORT_OK = qw(
get_user get_users update_user insert_user delete_user
get_roles insert_role update_role get_role_columns
@@ -404,10 +403,7 @@ sub get_user_roles($$) {
my $admin_roles = get_admin_user_roles( $config, $condition );
#add admin roles to user roles
my @user_roles = ( @$admin_roles, @$user_roles );
$user_roles = \@user_roles;
return $user_roles;
return [@$admin_roles, @$user_roles];
}
#return admin user roles for given conditions: project_id, studio_id, user, user_id
@@ -528,10 +524,9 @@ sub get_role_id ($$) {
sub assign_user_role($$) {
my ($config, $options) = @_;
return undef unless defined $options->{project_id};
return undef unless defined $options->{studio_id};
return undef unless defined $options->{user_id};
return undef unless defined $options->{role_id};
for ('project_id', 'studio_id', 'user_id', 'role_id') {
return undef unless defined $options->{$_}
}
#return if already exists
my $query = qq{
@@ -560,10 +555,9 @@ sub assign_user_role($$) {
sub remove_user_role($$) {
my ($config, $options) = @_;
return undef unless defined $options->{project_id};
return undef unless defined $options->{studio_id};
return undef unless defined $options->{user_id};
return undef unless defined $options->{role_id};
for ('project_id', 'studio_id', 'user_id', 'role_id') {
return undef unless defined $options->{$_}
}
my $query = qq{
delete
@@ -583,20 +577,17 @@ sub is_user_assigned_to_studio ($$) {
my ($request, $options) = @_;
my $config = $request->{config};
for ('project_id', 'studio_id') {
return 0 unless defined $options->{$_}
}
return 0 unless defined $request->{user};
return 0 unless defined $options->{studio_id};
return 0 unless defined $options->{project_id};
my $options2 = {
my $user_studios = uac::get_studios_by_user( $config, {
user => $request->{user},
studio_id => $options->{studio_id},
project_id => $options->{project_id}
};
my $user_studios = uac::get_studios_by_user( $config, $options2 );
return 1 if scalar @$user_studios == 1;
return 0;
});
return (@$user_studios == 1);
}
# print errors at get_user_presets and check for project id and studio id
@@ -712,11 +703,6 @@ sub get_user_presets($$) {
}
}
#only admin is allowed to select all projects
# if($permissions->{is_admin}==1){
# $projects=project::get($config);
# }
#set studios and projects as selected, TODO:do in JS
my $selectedProject = {};
for my $project (@$projects) {

View File

@@ -3,7 +3,6 @@ package user_day_start;
use strict;
use warnings;
no warnings 'redefine';
use Data::Dumper;
# table: calcms_user_day_start
@@ -22,9 +21,9 @@ sub get ($$) {
my @conditions = ();
my @bind_values = ();
return unless defined $condition->{user};
return unless defined $condition->{project_id};
return unless defined $condition->{studio_id};
for ('user', 'project_id', 'studio_id') {
return unless defined $condition->{$_}
};
for my $field ('user', 'project_id', 'studio_id'){
if ( ( defined $condition->{$field} ) && ( $condition->{$field} ne '' ) ) {
@@ -59,10 +58,9 @@ sub insert_or_update($$){
sub insert ($$) {
my ($config, $entry) = @_;
return unless defined $entry->{user};
return unless defined $entry->{project_id};
return unless defined $entry->{studio_id};
return unless defined $entry->{day_start};
for ('user', 'project_id', 'studio_id', 'day_start') {
return unless defined $entry->{$_};
}
my $dbh = db::connect($config);
print STDERR "insert".Dumper($entry );
@@ -96,9 +94,9 @@ sub update($$) {
sub delete ($$) {
my ($config, $entry) = @_;
return unless defined $entry->{user};
return unless defined $entry->{project_id};
return unless defined $entry->{studio_id};
for ('user', 'project_id', 'studio_id') {
return unless defined $entry->{$_}
};
my $query = qq{
delete

View File

@@ -3,7 +3,6 @@ package user_default_studios;
use strict;
use warnings;
no warnings 'redefine';
use Data::Dumper;
# table: calcms_user_default_studios

View File

@@ -3,7 +3,6 @@ package user_selected_events;
use strict;
use warnings;
no warnings 'redefine';
use Data::Dumper;
# table: calcms_user_selected_events
@@ -24,10 +23,9 @@ sub get ($$) {
my @conditions = ();
my @bind_values = ();
return unless defined $condition->{user};
return unless defined $condition->{project_id};
return unless defined $condition->{studio_id};
return unless defined $condition->{series_id};
for ('user', 'project_id', 'studio_id', 'series_id') {
return unless defined $condition->{$_}
};
for my $field ('user', 'project_id', 'studio_id', 'series_id',
'filter_project_studio', 'filter_series'
@@ -55,11 +53,9 @@ sub get ($$) {
sub insert ($$) {
my ($config, $entry) = @_;
return unless defined $entry->{user};
return unless defined $entry->{project_id};
return unless defined $entry->{studio_id};
return unless defined $entry->{series_id};
return unless defined $entry->{selected_event};
for ('user', 'project_id', 'studio_id', 'series_id', 'selected_event') {
return unless defined $entry->{$_}
};
my $dbh = db::connect($config);
print STDERR "insert".Dumper($entry );
@@ -96,10 +92,9 @@ sub update($$) {
sub delete ($$) {
my ($config, $entry) = @_;
return unless defined $entry->{user};
return unless defined $entry->{project_id};
return unless defined $entry->{studio_id};
return unless defined $entry->{series_id};
for ('user', 'project_id', 'studio_id', 'series_id') {
return unless defined $entry->{$_}
};
my $query = qq{
delete

View File

@@ -3,11 +3,9 @@ package user_sessions;
use strict;
use warnings;
no warnings 'redefine';
use Digest::MD5();
use time;
# access user name by session id
# table: calcms_user_sessions
@@ -47,7 +45,8 @@ sub get($$) {
push @bind_values, $condition->{user};
}
if ( ( defined $condition->{session_id} ) && ( $condition->{session_id} ne '' ) ) {
if ((defined $condition->{session_id}) && ($condition->{session_id} ne ''))
{
push @conditions, 'session_id=?';
push @bind_values, $condition->{session_id};
}
@@ -75,8 +74,9 @@ sub get($$) {
sub insert ($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{user};
return undef unless defined $entry->{timeout};
for ('user', 'timeout') {
return undef unless defined $entry->{$_}
};
unless ( defined $entry->{session_id} ) {
my $md5 = Digest::MD5->new();
@@ -95,8 +95,9 @@ sub insert ($$) {
sub start($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{user};
return undef unless defined $entry->{timeout};
for ('user', 'timeout') {
return undef unless defined $entry->{$_}
};
my $id = insert(
$config,
@@ -179,7 +180,6 @@ sub update ($$) {
my @keys = sort keys %$entry;
my $values = join( ",", map { $_ . '=?' } @keys );
my @bind_values = map { $entry->{$_} } @keys;
push @bind_values, $entry->{session_id};
my $query = qq{
@@ -197,14 +197,12 @@ sub delete($$) {
return undef unless defined $entry->{session_id};
my $dbh = db::connect($config);
my $query = qq{
delete
from calcms_user_sessions
where session_id=?
};
my $bind_values = [ $entry->{session_id} ];
return db::put( $dbh, $query, $bind_values );
}

View File

@@ -9,7 +9,6 @@ use series_dates();
# table: calcms_user_settings
# columns: user, colors
#use base 'Exporter';
our @EXPORT_OK = qw(getColors getColorCss get insert update delete get_columns defaultColors);
our $defaultColors = [
@@ -166,7 +165,9 @@ sub get ($$) {
sub insert ($$) {
my ($config, $entry) = @_;
return unless defined $entry->{user};
for ('user') {
return unless defined $entry->{$_};
}
my $dbh = db::connect($config);
return db::insert( $dbh, 'calcms_user_settings', $entry );
@@ -175,7 +176,9 @@ sub insert ($$) {
sub update($$) {
my ($config, $entry) = @_;
return unless ( defined $entry->{user} );
for ('user') {
return unless defined $entry->{$_};
}
my $dbh = db::connect($config);
my @keys = sort keys %$entry;
@@ -196,7 +199,9 @@ sub update($$) {
sub delete ($$) {
my ($config, $entry) = @_;
return unless ( defined $entry->{user} );
for ('user') {
return unless defined $entry->{$_};
}
my $dbh = db::connect($config);

View File

@@ -5,7 +5,6 @@ use warnings;
no warnings 'redefine';
use Data::Dumper;
#use base 'Exporter';
our @EXPORT_OK = qw(get_columns get update insert get_stats increase);
sub get_columns($) {
@@ -129,10 +128,9 @@ sub get_stats($$) {
sub insert($$) {
my ($config, $stats) = @_;
return undef unless defined $stats->{project_id};
return undef unless defined $stats->{studio_id};
return undef unless defined $stats->{series_id};
return undef unless defined $stats->{user};
for ('user', 'project_id', 'studio_id', 'series_id') {
return undef unless defined $stats->{$_}
};
#TODO:filter for existing attributes
my $columns = get_columns($config);
@@ -151,10 +149,9 @@ sub insert($$) {
sub update ($$) {
my ($config, $stats) = @_;
return undef unless defined $stats->{project_id};
return undef unless defined $stats->{studio_id};
return undef unless defined $stats->{series_id};
return undef unless defined $stats->{user};
for ('user', 'project_id', 'studio_id', 'series_id') {
return undef unless defined $stats->{$_}
};
my $columns = get_columns($config);
my $entry = {};
@@ -185,10 +182,9 @@ sub increase ($$$) {
my ($config, $usecase, $options) = @_;
return undef unless defined $usecase;
return undef unless defined $options->{project_id};
return undef unless defined $options->{studio_id};
return undef unless defined $options->{series_id};
return undef unless defined $options->{user};
for ('user', 'project_id', 'studio_id', 'series_id', ) {
return undef unless defined $options->{$_}
};
my $columns = get_columns($config);
return undef unless exists $columns->{$usecase};

View File

@@ -6,6 +6,7 @@ no warnings 'redefine';
use Data::Dumper;
use Date::Calc();
use time();
use db();
use log();
@@ -16,7 +17,6 @@ use work_schedule();
# table: calcms_work_dates
# columns: id, studio_id, schedule_id, start(datetime), end(datetime)
# TODO: delete column schedule_id
#use base 'Exporter';
our @EXPORT_OK = qw(get_columns get insert update delete get_dates);
sub get_columns($) {
@@ -118,9 +118,9 @@ sub get ($$) {
sub update($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{project_id};
return undef unless defined $entry->{studio_id};
return undef unless defined $entry->{schedule_id};
for ('project_id', 'studio_id', 'schedule_id' ) {
return undef unless defined $entry->{$_}
};
my $dbh = db::connect($config);
@@ -183,15 +183,12 @@ sub update($$) {
$entry->{start_date} = time::add_hours_to_datetime( $entry->{start}, -$day_start );
$entry->{end_date} = time::add_hours_to_datetime( $entry->{end}, -$day_start );
db::insert( $dbh, 'calcms_work_dates', $entry );
#print STDERR "$entry->{start_date}\n";
$i++;
} else {
$j++;
}
}
#print STDERR "$i work_dates updates\n";
return $j . " dates out of studio times, " . $i;
}
@@ -286,8 +283,6 @@ sub get_dates($$$$) {
my @start_date = ( $start[0], $start[1], $start[2] );
my $start_time = sprintf( '%02d:%02d:%02d', $start[3], $start[4], $start[5] );
#print STDERR "$start_datetime,$end_date,$duration,$frequency\n";
#return on single date
my $date = {};
$date->{start} = sprintf( "%04d-%02d-%02d", @start_date ) . ' ' . $start_time;
@@ -338,9 +333,9 @@ sub get_dates($$$$) {
sub delete($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{project_id};
return undef unless defined $entry->{studio_id};
return undef unless defined $entry->{schedule_id};
for ('project_id', 'studio_id', 'schedule_id') {
return undef unless defined $entry->{$_}
};
my $dbh = db::connect($config);

View File

@@ -17,7 +17,6 @@ use series_dates();
# week_of_month (1..5)
# month
#use base 'Exporter';
our @EXPORT_OK = qw(get_columns get insert update delete);
sub get_columns($) {
@@ -82,9 +81,9 @@ sub get($$) {
sub insert ($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{project_id};
return undef unless defined $entry->{studio_id};
return undef unless defined $entry->{start};
for ('project_id', 'studio_id', 'start' ) {
return undef unless defined $entry->{$_}
};
my $dbh = db::connect($config);
return db::insert( $dbh, 'calcms_work_schedule', $entry );
}
@@ -93,10 +92,9 @@ sub insert ($$) {
sub update ($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{project_id};
return undef unless defined $entry->{studio_id};
return undef unless defined $entry->{schedule_id};
return undef unless defined $entry->{start};
for ('project_id', 'studio_id', 'schedule_id', 'start' ) {
return undef unless defined $entry->{$_}
};
my $dbh = db::connect($config);
my @keys = sort keys %$entry;
@@ -120,9 +118,9 @@ sub update ($$) {
sub delete($$) {
my ($config, $entry) = @_;
return undef unless defined $entry->{project_id};
return undef unless defined $entry->{studio_id};
return undef unless defined $entry->{schedule_id};
for ('project_id', 'studio_id', 'schedule_id' ) {
return undef unless defined $entry->{$_}
};
my $dbh = db::connect($config);