From 3a1a118eeb41c47861de7e6586ab62108b4fdc42 Mon Sep 17 00:00:00 2001 From: Milan Date: Thu, 18 May 2023 11:17:14 +0200 Subject: [PATCH] lib: replace shift by @_ --- lib/calcms/aggregator.pm | 3 +- lib/calcms/audio_recordings.pm | 19 ++----- lib/calcms/auth.pm | 40 ++++---------- lib/calcms/calendar.pm | 7 +-- lib/calcms/eventOps.pm | 25 +++------ lib/calcms/event_history.pm | 15 ++---- lib/calcms/images.pm | 3 +- lib/calcms/password_requests.pm | 12 ++--- lib/calcms/playout.pm | 38 ++++--------- lib/calcms/project.pm | 63 ++++++++-------------- lib/calcms/series.pm | 83 ++++++++++------------------- lib/calcms/series_dates.pm | 8 ++- lib/calcms/series_events.pm | 32 ++++------- lib/calcms/series_schedule.pm | 11 ++-- lib/calcms/studio_timeslot_dates.pm | 8 ++- lib/calcms/studios.pm | 22 +++----- lib/calcms/time.pm | 2 +- lib/calcms/uac.pm | 83 +++++++++-------------------- lib/calcms/user_day_start.pm | 11 ++-- lib/calcms/user_default_studios.pm | 11 ++-- lib/calcms/user_selected_events.pm | 11 ++-- lib/calcms/user_sessions.pm | 26 ++++----- lib/calcms/user_settings.pm | 11 ++-- lib/calcms/user_stats.pm | 9 ++-- lib/calcms/work_dates.pm | 9 ++-- lib/calcms/work_schedule.pm | 12 ++--- 26 files changed, 184 insertions(+), 390 deletions(-) diff --git a/lib/calcms/aggregator.pm b/lib/calcms/aggregator.pm index 95f6b9f..53acc65 100644 --- a/lib/calcms/aggregator.pm +++ b/lib/calcms/aggregator.pm @@ -138,8 +138,7 @@ sub get_newest_comments($$) { } sub check_params($$) { - my $config = shift; - my $params = shift; + my ($config, $params) = @_; #get start and stop from projects my $range = project::get_date_range($config); diff --git a/lib/calcms/audio_recordings.pm b/lib/calcms/audio_recordings.pm index c9a77e0..58c4dcd 100644 --- a/lib/calcms/audio_recordings.pm +++ b/lib/calcms/audio_recordings.pm @@ -17,8 +17,7 @@ our @EXPORT_OK = qw(get_columns get); # audioDuration, eventDuration, rmsLeft, rmsRight sub get_columns($) { - my $config = shift; - + my ($config) = @_; my $dbh = db::connect($config); return db::get_columns_hash( $dbh, 'calcms_audio_recordings' ); } @@ -97,9 +96,7 @@ sub get($$) { # update playout entry if differs to old values sub update($$$) { - my $config = shift; - my $dbh = shift; - my $entry = shift; + my ($config, $dbh, $entry) = @_; my $day_start = $config->{date}->{day_starting_hour}; @@ -134,9 +131,7 @@ sub update($$$) { # insert playout entry sub insert ($$$) { - my $config = shift; - my $dbh = shift; - my $entry = shift; + my ($config, $dbh, $entry) = @_; return undef unless defined $entry->{project_id}; return undef unless defined $entry->{studio_id}; @@ -165,9 +160,7 @@ sub insert ($$$) { # delete playout entry sub delete ($$$) { - my $config = shift; - my $dbh = shift; - my $entry = shift; + my ($config, $dbh, $entry) = @_; return undef unless defined $entry->{project_id}; return undef unless defined $entry->{studio_id}; @@ -187,9 +180,7 @@ sub delete ($$$) { } sub update_active($$$) { - my $config = shift; - my $dbh = shift; - my $entry = shift; + my ($config, $dbh, $entry) = @_; return undef unless defined $entry->{project_id}; return undef unless defined $entry->{studio_id}; diff --git a/lib/calcms/auth.pm b/lib/calcms/auth.pm index 3df3fb7..6840d2d 100644 --- a/lib/calcms/auth.pm +++ b/lib/calcms/auth.pm @@ -52,7 +52,7 @@ sub get_user($$$) { } sub crypt_password($) { - my $password = shift; + my ($password) = @_; my $ppr = Authen::Passphrase::BlowfishCrypt->new( cost => 8, @@ -66,10 +66,7 @@ sub crypt_password($) { } sub login($$$) { - my $config = shift; - my $user = shift; - my $password = shift; - + my ($config, $user, $password) = @_; my $result = authenticate( $config, $user, $password ); return show_login_form( $user, 'Could not authenticate you' ) unless defined $result; @@ -86,9 +83,7 @@ sub login($$$) { #TODO: remove cgi sub logout($$) { - my $config = shift; - my $cgi = shift; - + my ($config, $cgi) = @_; my $session_id = read_cookie(); unless ( delete_session($config, $session_id) ) { return show_login_form( 'Cant delete session', 'logged out' ); @@ -104,9 +99,7 @@ sub logout($$) { #read and write data from browser, http://perldoc.perl.org/CGI/Cookie.html sub create_cookie($$) { - my $session_id = shift; - my $timeout = shift; - + my ($session_id, $timeout) = @_; my $cookie = CGI::Cookie->new( -name => 'sessionID', -value => $session_id, @@ -129,8 +122,7 @@ sub read_cookie() { #TODO: remove CGI sub delete_cookie($) { - my $cgi = shift; - + my ($cgi) = @_; my $cookie = $cgi->cookie( -name => 'sessionID', -value => '', @@ -143,10 +135,7 @@ sub delete_cookie($) { # read and write server-side session data # timeout is in seconds sub create_session ($$$) { - my $config = shift; - my $user = shift; - my $timeout = shift; - + my ($config, $user, $timeout) = @_; my $session_id = user_sessions::start( $config, { user => $user, @@ -157,8 +146,7 @@ sub create_session ($$$) { } sub read_session($$) { - my $config = shift; - my $session_id = shift; + my ($config, $session_id) = @_; return undef unless defined $session_id; @@ -172,20 +160,15 @@ sub read_session($$) { } sub delete_session($$) { - my $config = shift; - my $session_id = shift; - - return undef unless defined $session_id; - + my ($config, $session_id) = @_; + return unless defined $session_id; user_sessions::stop( $config, { session_id => $session_id } ); return 1; } #check user authentication sub authenticate($$$) { - my $config = shift; - my $user = shift; - my $password = shift; + my ($config, $user, $password) = @_; $config->{access}->{write} = 0; my $dbh = db::connect($config); @@ -223,9 +206,8 @@ sub authenticate($$$) { } sub show_login_form ($$) { - my $user = shift || ''; + my ($user, $message) = @_; my $uri = $ENV{HTTP_REFERER} || ''; - my $message = shift || ''; my $requestReset = ''; if ( ( $user ne '' ) && ( $message ne '' ) ) { diff --git a/lib/calcms/calendar.pm b/lib/calcms/calendar.pm index 5131920..73d84c6 100644 --- a/lib/calcms/calendar.pm +++ b/lib/calcms/calendar.pm @@ -289,9 +289,7 @@ sub render($$$$) { } sub get_calendar_weeks($$$) { - my $config = shift; - my $start = shift; - my $end = shift; + my ($config, $start, $end) = @_; $start = time::date_to_array($start); $end = time::date_to_array($end); @@ -407,8 +405,7 @@ sub getWeeksOfMonth($$) { } sub check_params($$) { - my $config = shift; - my $params = shift; + my ($config, $params) = @_; #get start and stop from projects my $range = project::get_date_range($config); diff --git a/lib/calcms/eventOps.pm b/lib/calcms/eventOps.pm index 6c2fd39..6036cc1 100644 --- a/lib/calcms/eventOps.pm +++ b/lib/calcms/eventOps.pm @@ -24,9 +24,7 @@ our @EXPORT_OK = qw( # functions: to be separated sub setAttributesFromSeriesTemplate($$$) { - my $config = shift; - my $params = shift; - my $event = shift; + my ($config, $params, $event) = @_; #get attributes from series my $series = series::get( @@ -57,9 +55,7 @@ sub setAttributesFromSeriesTemplate($$$) { } sub setAttributesFromSchedule ($$$){ - my $config = shift; - my $params = shift; - my $event = shift; + my ($config, $params, $event) = @_; #set attributes from schedule my $schedules = series_dates::get( @@ -89,9 +85,7 @@ sub setAttributesFromSchedule ($$$){ } sub setAttributesFromOtherEvent ($$$){ - my $config = shift; - my $params = shift; - my $event = shift; + my ($config, $params, $event) = @_; my $event2 = series::get_event( $config, @@ -121,8 +115,7 @@ sub setAttributesFromOtherEvent ($$$){ } sub setAttributesForCurrentTime ($$){ - my $serie = shift; - my $event = shift; + my ($serie, $event) = @_; #on new event not from schedule use current time if ( $event->{start} eq '' ) { @@ -140,16 +133,14 @@ sub setAttributesForCurrentTime ($$){ # get recurrence base id sub getRecurrenceBaseId ($){ - my $event = shift; + my ($event) = @_; return $event->{recurrence} if ( defined $event->{recurrence} ) && ( $event->{recurrence} ne '' ) && ( $event->{recurrence} ne '0' ); return $event->{event_id}; } # get a new event for given series sub getNewEvent($$$) { - my $config = shift; - my $params = shift; - my $action = shift; + my ($config, $params, $action) = @_; # check for missing parameters my $required_fields = [ 'project_id', 'studio_id', 'series_id' ]; @@ -206,9 +197,7 @@ sub getNewEvent($$$) { # add user, action sub createEvent($$$) { - my $request = shift; - my $event = shift; - my $action = shift; + my ($request, $event, $action) = @_; my $config = $request->{config}; my $permissions = $request->{permissions}; diff --git a/lib/calcms/event_history.pm b/lib/calcms/event_history.pm index 591a9fd..fec59bb 100644 --- a/lib/calcms/event_history.pm +++ b/lib/calcms/event_history.pm @@ -10,15 +10,14 @@ use Data::Dumper; our @EXPORT_OK = qw(get_columns get get_by_id insert insert_by_event_id delete); sub get_columns ($){ - my $config = shift; + my ($config) = @_; my $dbh = db::connect($config); return db::get_columns_hash( $dbh, 'calcms_event_history' ); } sub get ($$){ - my $config = shift; - my $condition = shift; + my ($config, $condition) = @_; return undef unless defined $condition->{studio_id}; @@ -78,9 +77,7 @@ sub get ($$){ } sub get_by_id($$) { - my $config = shift; - my $id = shift; - + my ($config, $id) = @_; my $dbh = db::connect($config); my $query = qq{ @@ -95,8 +92,7 @@ sub get_by_id($$) { } sub insert($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; $entry->{modified_at} = time::time_to_datetime( time() ); @@ -150,8 +146,7 @@ sub insert_by_event_id ($$){ } sub delete ($$){ - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; my $dbh = db::connect($config); db::put( $dbh, 'delete from calcms_event_history where event_id=?', [ $entry->{id} ] ); diff --git a/lib/calcms/images.pm b/lib/calcms/images.pm index cf7db0c..bb46de1 100644 --- a/lib/calcms/images.pm +++ b/lib/calcms/images.pm @@ -454,8 +454,7 @@ sub depublish ($$) { } sub checkLicence ($$) { - my $config = shift; - my $result = shift; + my ($config, $result) = @_; print STDERR "depublish\n"; return undef unless defined $config; diff --git a/lib/calcms/password_requests.pm b/lib/calcms/password_requests.pm index f7e8789..2e2f3ae 100644 --- a/lib/calcms/password_requests.pm +++ b/lib/calcms/password_requests.pm @@ -17,8 +17,7 @@ use db; use auth; sub get_columns ($) { - my $config = shift; - + my ($config) = @_; my $dbh = db::connect($config); return db::get_columns_hash( $dbh, 'calcms_password_requests' ); } @@ -56,8 +55,7 @@ sub get ($$) { } sub update($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return unless defined $entry->{user}; @@ -76,8 +74,7 @@ sub update($$) { } sub insert ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{user}; @@ -117,8 +114,7 @@ sub delete ($$) { } sub sendToken ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{user}; diff --git a/lib/calcms/playout.pm b/lib/calcms/playout.pm index ec2aa03..1bb4d55 100644 --- a/lib/calcms/playout.pm +++ b/lib/calcms/playout.pm @@ -14,8 +14,7 @@ use series_events(); our @EXPORT_OK = qw(get_columns get sync); sub get_columns ($) { - my $config = shift; - + my ($config) = @_; my $dbh = db::connect($config); return db::get_columns_hash( $dbh, 'calcms_playout' ); } @@ -24,9 +23,7 @@ sub get_columns ($) { # get playout entries sub get_scheduled($$) { - my $config = shift; - my $condition = shift; - + my ($config, $condition) = @_; return undef unless defined $condition->{studio_id}; my $date_range_include = 0; @@ -129,8 +126,7 @@ sub get_scheduled($$) { # get playout entries sub get($$) { - my $config = shift; - my $condition = shift; + my ($config, $condition) = @_; return undef unless defined $condition->{studio_id}; @@ -229,8 +225,7 @@ sub get($$) { # update playout entries for a given date span # insert, update and delete entries sub sync ($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; return undef unless defined $options->{project_id}; return undef unless defined $options->{studio_id}; @@ -329,9 +324,7 @@ sub sync ($$) { } sub has_changed ($$) { - my $oldEntry = shift; - my $newEntry = shift; - + my ($oldEntry, $newEntry) = @_; for my $key ( 'duration', 'errors', 'file', 'channels', 'format', 'format_version', 'format_profile', 'format_settings', @@ -346,13 +339,7 @@ sub has_changed ($$) { # update playout entry if differs to old values sub update ($$$$) { - my $config = shift; - my $dbh = shift; - my $oldEntry = shift; - my $newEntry = shift; - - #return if has_changed( $oldEntry, $newEntry ) == 0; - + my ($config, $dbh, $oldEntry, $newEntry) = @_; for my $key ( 'duration', 'errors', 'file', 'channels', 'format', 'format_version', 'format_profile', 'format_settings', @@ -395,9 +382,7 @@ sub update ($$$$) { # insert playout entry sub insert ($$$) { - my $config = shift; - my $dbh = shift; - my $entry = shift; + my ($config, $dbh, $entry) = @_; return undef unless defined $entry->{project_id}; return undef unless defined $entry->{studio_id}; @@ -445,10 +430,7 @@ sub insert ($$$) { # delete playout entry sub delete($$$) { - my $config = shift; - my $dbh = shift; - my $entry = shift; - + my ($config, $dbh, $entry) = @_; return undef unless defined $entry->{project_id}; return undef unless defined $entry->{studio_id}; return undef unless defined $entry->{start}; @@ -463,9 +445,7 @@ sub delete($$$) { } sub getEnd ($$) { - my $start = shift; - my $duration = shift; - + my ($start, $duration) = @_; # calculate end from start + duration my @start = @{ time::datetime_to_array($start) }; next unless @start >= 6; diff --git a/lib/calcms/project.pm b/lib/calcms/project.pm index 9462e3e..b3b819a 100644 --- a/lib/calcms/project.pm +++ b/lib/calcms/project.pm @@ -24,7 +24,7 @@ our @EXPORT_OK = qw( # get project columns sub get_columns ($) { - my $config = shift; + my ($config) = @_; my $dbh = db::connect($config); return db::get_columns_hash( $dbh, 'calcms_projects' ); @@ -32,8 +32,7 @@ sub get_columns ($) { # get projects sub get ($;$) { - my $config = shift; - my $condition = shift; + my ($config, $condition) = @_; my $dbh = db::connect($config); @@ -72,8 +71,7 @@ sub get ($;$) { # requires at least project_id sub getImageById($$) { - my $config = shift; - my $conditions = shift; + my ($config, $conditions) = @_; return undef unless defined $conditions->{project_id}; my $projects = project::get( $config, $conditions ); @@ -82,7 +80,7 @@ sub getImageById($$) { } sub get_date_range($) { - my $config = shift; + my ($config) = @_; my $query = qq{ select min(start_date) start_date, max(end_date) end_date @@ -96,8 +94,7 @@ sub get_date_range($) { # insert project sub insert($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; my $columns = get_columns($config); my $project = {}; @@ -114,8 +111,7 @@ sub insert($$) { # update project sub update($$) { - my $config = shift; - my $project = shift; + my ($config, $project) = @_; my $columns = project::get_columns($config); my $entry = {}; @@ -141,17 +137,14 @@ sub update($$) { # delete project sub delete ($$) { - my $config = shift; - my $entry = shift; - + my ($config, $entry) = @_; my $dbh = db::connect($config); db::put( $dbh, 'delete from calcms_projects where project_id=?', [ $entry->{project_id} ] ); } # get studios of a project sub get_studios($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; return undef unless defined $options->{project_id}; my $project_id = $options->{project_id}; @@ -168,8 +161,7 @@ sub get_studios($$) { } sub get_studio_assignments($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; my @conditions = (); my @bind_values = (); @@ -201,8 +193,7 @@ sub get_studio_assignments($$) { # is studio assigned to project sub is_studio_assigned ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return 0 unless defined $entry->{project_id}; return 0 unless defined $entry->{studio_id}; @@ -225,8 +216,7 @@ sub is_studio_assigned ($$) { # assign studio to project sub assign_studio($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{project_id}; return undef unless defined $entry->{studio_id}; @@ -244,8 +234,7 @@ sub assign_studio($$) { # unassign studio from project sub unassign_studio($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{project_id}; return undef unless defined $entry->{studio_id}; @@ -260,8 +249,7 @@ sub unassign_studio($$) { # get series by project and studio sub get_series ($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; return undef unless defined $options->{project_id}; return undef unless defined $options->{studio_id}; @@ -281,8 +269,7 @@ sub get_series ($$) { } sub get_series_assignments ($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; my @conditions = (); my @bind_values = (); @@ -319,8 +306,7 @@ sub get_series_assignments ($$) { # is series assigned to project and studio sub is_series_assigned ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return 0 unless defined $entry->{project_id}; return 0 unless defined $entry->{studio_id}; @@ -345,8 +331,7 @@ sub is_series_assigned ($$) { # assign series to project and studio sub assign_series($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{project_id}; return undef unless defined $entry->{studio_id}; @@ -369,8 +354,7 @@ sub assign_series($$) { # unassign series from project # TODO: remove series _single_ if no event is assigned to sub unassign_series ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{project_id}; return undef unless defined $entry->{studio_id}; @@ -387,8 +371,7 @@ sub unassign_series ($$) { } sub get_with_dates($;$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; my $language = $config->{date}->{language} || 'en'; my $projects = project::get( $config, {} ); @@ -404,7 +387,7 @@ sub get_with_dates($;$) { #TODO: add config sub get_sorted($) { - my $config = shift; + my ($config) = @_; my $projects = project::get( $config, {} ); my @projects = reverse sort { $a->{end_date} cmp $b->{end_date} } (@$projects); @@ -421,9 +404,8 @@ sub get_sorted($) { # internal sub get_months ($$;$) { - my $config = shift; - my $project = shift; - my $language = shift || $config->{date}->{language} || 'en'; + my ($config, $project, $language) = @_; + $language ||= $config->{date}->{language} || 'en'; my $start = $project->{start_date}; my $end = $project->{end_date}; @@ -469,8 +451,7 @@ sub get_months ($$;$) { # check project_id sub check ($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; return "missing project_id at checking project" unless defined $options->{project_id}; return "Please select a project" if ( $options->{project_id} eq '-1' ); return "Please select a project" if ( $options->{project_id} eq '' ); diff --git a/lib/calcms/series.pm b/lib/calcms/series.pm index 7c84a31..03125ff 100644 --- a/lib/calcms/series.pm +++ b/lib/calcms/series.pm @@ -28,7 +28,7 @@ our @EXPORT_OK = qw( # get series columns sub get_columns ($) { - my $config = shift; + my ($config) = @_; my $dbh = db::connect($config); return db::get_columns_hash( $dbh, 'calcms_series' ); @@ -36,8 +36,7 @@ sub get_columns ($) { # get series content sub get ($$) { - my $config = shift; - my $condition = shift; + my ($config, $condition) = @_; my @conditions = (); my @bind_values = (); @@ -124,8 +123,7 @@ sub get ($$) { # insert series sub insert ($$) { - my $config = shift; - my $series = shift; + my ($config, $series) = @_; return undef unless defined $series->{project_id}; return undef unless defined $series->{studio_id}; @@ -162,8 +160,7 @@ sub insert ($$) { # update series sub update ($$) { - my $config = shift; - my $series = shift; + my ($config, $series) = @_; return undef unless defined $series->{project_id}; return undef unless defined $series->{studio_id}; @@ -199,8 +196,7 @@ sub update ($$) { # delete series, its schedules and series dates # unassign its users and events sub delete($$) { - my $config = shift; - my $series = shift; + my ($config, $series) = @_; return undef unless defined $series->{project_id}; return undef unless defined $series->{studio_id}; @@ -287,8 +283,7 @@ sub delete($$) { # get users directly assigned to project, studio, series (editors) sub get_users ($$) { - my $config = shift; - my $condition = shift; + my ($config, $condition) = @_; my @conditions = (); my @bind_values = (); @@ -331,8 +326,7 @@ sub get_users ($$) { # assign user to series sub add_user ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return unless defined $entry->{project_id}; return unless defined $entry->{studio_id}; @@ -362,8 +356,7 @@ sub add_user ($$) { # remove user(s) from series. sub remove_user ($$) { - my $config = shift; - my $condition = shift; + my ($config, $condition) = @_; return unless defined $condition->{project_id}; return unless defined $condition->{studio_id}; @@ -406,9 +399,7 @@ sub remove_user ($$) { #search events by series_name and title (for events not assigned yet) #TODO: add location sub search_events ($$$) { - my $config = shift; - my $request = shift; - my $options = shift; + my ($config, $request, $options) = @_; my $series_name = $options->{series_name} || ''; my $title = $options->{title} || ''; @@ -449,8 +440,7 @@ sub search_events ($$$) { #get events (only assigned ones) by project_id,studio_id,series_id, sub get_events ($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; return [] if defined( $options->{series_id} ) && ( $options->{series_id} <= 0 ); @@ -555,8 +545,7 @@ sub get_events ($$) { # helper for gui - errors are written to gui output # return undef on error sub get_event ($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; my $project_id = $options->{project_id} || ''; my $studio_id = $options->{studio_id} || ''; @@ -620,8 +609,7 @@ sub get_event ($$) { # get name and title of series and age in days ('days_over') sub get_event_age($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; return undef unless defined $options->{project_id}; return undef unless defined $options->{studio_id}; @@ -675,8 +663,7 @@ sub get_event_age($$) { # is event older than max_age days sub is_event_older_than_days ($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; return 1 unless defined $options->{project_id}; return 1 unless defined $options->{studio_id}; @@ -705,8 +692,7 @@ sub is_event_older_than_days ($$) { } sub get_next_episode($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; return 0 unless defined $options->{project_id}; return 0 unless defined $options->{studio_id}; @@ -745,8 +731,7 @@ sub get_next_episode($$) { } sub get_images ($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; return undef unless defined $options->{project_id}; return undef unless defined $options->{studio_id}; @@ -806,8 +791,7 @@ sub get_images ($$) { #assign event to series #TODO: manual assign needs to update automatic one sub assign_event($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{project_id}; return undef unless defined $entry->{studio_id}; @@ -849,8 +833,7 @@ sub assign_event($$) { #unassign event from series sub unassign_event($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return unless defined $entry->{project_id}; return unless defined $entry->{studio_id}; @@ -875,8 +858,7 @@ sub unassign_event($$) { # used by calendar # TODO: optionally add project_id and studio_id to conditions sub add_series_ids_to_events ($$) { - my $config = shift; - my $events = shift; + my ($config, $events) = @_; #get event ids from given events my @event_ids = (); @@ -923,11 +905,7 @@ sub add_series_ids_to_events ($$) { # add event_ids to series and remove all event ids from series, not given event_ids # for scan only, used at series sub set_event_ids ($$$$$) { - my $config = shift; - my $project_id = shift; - my $studio_id = shift; - my $serie = shift; - my $event_ids = shift; + my ($config, $project_id, $studio_id, $serie, $event_ids) = @_; my $serie_id = $serie->{series_id}; return unless defined $project_id; @@ -988,8 +966,7 @@ sub set_event_ids ($$$$$) { # check if user allowed to update series events # evaluate permissions and consider editors directly assigned to series sub can_user_update_events ($$) { - my $request = shift; - my $options = shift; + my ($request, $options) = @_; my $config = $request->{config}; my $permissions = $request->{permissions}; @@ -1009,8 +986,7 @@ sub can_user_update_events ($$) { # check if user allowed to create series events # evaluate permissions and consider editors directly assigned to series sub can_user_create_events ($$) { - my $request = shift; - my $options = shift; + my ($request, $options) = @_; my $config = $request->{config}; my $permissions = $request->{permissions}; @@ -1028,8 +1004,7 @@ sub can_user_create_events ($$) { } sub is_series_assigned_to_user ($$) { - my $request = shift; - my $options = shift; + my ($request, $options) = @_; my $config = $request->{config}; my $permissions = $request->{permissions}; @@ -1055,8 +1030,7 @@ sub is_series_assigned_to_user ($$) { # check if user is assigned to studio where location matchs to event # return 1 on success or error text sub is_event_assigned_to_user ($$) { - my $request = shift; - my $options = shift; + my ($request, $options) = @_; my $config = $request->{config}; @@ -1105,8 +1079,7 @@ sub is_event_assigned_to_user ($$) { } sub get_rebuilt_episodes ($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; return "missing project_id" unless defined $options->{project_id}; return "missing studio_id" unless defined $options->{studio_id}; @@ -1157,7 +1130,7 @@ sub get_rebuilt_episodes ($$) { # to find multiple recurrences this does not include the recurrence_count # use events::get_key to add the recurrence sub get_event_key ($) { - my $event = shift; + my ($event) = @_; my $program = $event->{program} || ''; my $series_name = $event->{series_name} || ''; @@ -1176,8 +1149,7 @@ sub get_event_key ($) { } sub update_recurring_events ($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; return "missing project_id" unless defined $options->{project_id}; return "missing studio_id" unless defined $options->{studio_id}; @@ -1247,8 +1219,7 @@ sub update_recurring_events ($$) { } sub update_recurring_event($$) { - my $config = shift; - my $event = shift; + my ($config, $event) = @_; return undef unless defined $event->{event_id}; return undef unless defined $event->{recurrence}; diff --git a/lib/calcms/series_dates.pm b/lib/calcms/series_dates.pm index f0cb1ea..8668658 100644 --- a/lib/calcms/series_dates.pm +++ b/lib/calcms/series_dates.pm @@ -20,7 +20,7 @@ use series_schedule(); our @EXPORT_OK = qw(get_columns get insert update delete get_dates get_series); sub get_columns ($) { - my $config = shift; + my ($config) = @_; my $dbh = db::connect($config); return db::get_columns_hash( $dbh, 'calcms_series_dates' ); @@ -283,8 +283,7 @@ sub addSeriesScheduleAttributes ($$) { #update series dates for all schedules of a series and studio_id sub update($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{project_id}; return undef unless defined $entry->{studio_id}; @@ -518,8 +517,7 @@ sub get_dates($$$$) { #remove all series_dates for studio_id and series_id sub delete ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return unless defined $entry->{project_id}; return unless defined $entry->{studio_id}; diff --git a/lib/calcms/series_events.pm b/lib/calcms/series_events.pm index 686b2a3..0f3437c 100644 --- a/lib/calcms/series_events.pm +++ b/lib/calcms/series_events.pm @@ -39,9 +39,7 @@ sub get_content_columns($) { # do not check for project,studio,series # all changed columns are returned for history handling sub save_content($$) { - my $config = shift; - my $entry = shift; - + my ($config, $entry) = @_; return undef unless defined $entry->{id}; for my $attr ( keys %$entry ) { @@ -96,8 +94,7 @@ sub save_content($$) { } sub set_episode{ - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{id}; return undef unless defined $entry->{episode}; @@ -121,8 +118,7 @@ sub set_episode{ # do not check project, studio, series # for history handling all changed columns are returned sub save_event_time($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{id}; return undef unless defined $entry->{duration}; @@ -171,8 +167,7 @@ sub save_event_time($$) { } sub set_playout_status ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{project_id}; return undef unless defined $entry->{studio_id}; @@ -209,8 +204,7 @@ sub set_playout_status ($$) { # is event assigned to project, studio and series? sub is_event_assigned($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return 0 unless defined $entry->{project_id}; return 0 unless defined $entry->{studio_id}; @@ -231,8 +225,7 @@ sub is_event_assigned($$) { } sub delete_event ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{project_id}; return undef unless defined $entry->{studio_id}; @@ -270,8 +263,7 @@ sub delete_event ($$) { # key check_for: user, studio, series, events, schedule # return error text or 1 if okay sub check_permission($$) { - my $request = shift; - my $options = shift; + my ($request, $options) = @_; return "missing permission at check" unless defined $options->{permission}; return "missing check_for at check" unless defined $options->{check_for}; @@ -410,8 +402,7 @@ sub check_permission($$) { #insert event sub insert_event ($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; my $project_id = $options->{project_id}; my $studio = $options->{studio}; @@ -496,9 +487,7 @@ sub insert_event ($$) { #set start, end, start-date, end_date to an event sub add_event_dates($$$) { - my $config = shift; - my $event = shift; - my $params = shift; + my ($config, $event, $params) = @_; #start and end datetime $event->{start} = $params->{start_date}; @@ -512,8 +501,7 @@ sub add_event_dates($$$) { } sub update_series_images ($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; return "missing project_id" unless defined $options->{project_id}; return "missing studio_id" unless defined $options->{studio_id}; diff --git a/lib/calcms/series_schedule.pm b/lib/calcms/series_schedule.pm index 1e0064b..7ac3883 100644 --- a/lib/calcms/series_schedule.pm +++ b/lib/calcms/series_schedule.pm @@ -22,7 +22,7 @@ use series_dates(); our @EXPORT_OK = qw(get_columns get insert update delete); sub get_columns ($) { - my $config = shift; + my ($config) = @_; my $dbh = db::connect($config); return db::get_columns_hash( $dbh, 'calcms_series_schedule' ); @@ -99,8 +99,7 @@ sub get($$) { } sub insert($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{project_id}; return undef unless defined $entry->{studio_id}; @@ -112,8 +111,7 @@ sub insert($$) { #schedule id to id sub update($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{project_id}; return undef unless defined $entry->{studio_id}; @@ -146,8 +144,7 @@ sub update($$) { #map schedule id to id sub delete($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{project_id}; return undef unless defined $entry->{studio_id}; diff --git a/lib/calcms/studio_timeslot_dates.pm b/lib/calcms/studio_timeslot_dates.pm index 9a844d2..4657768 100644 --- a/lib/calcms/studio_timeslot_dates.pm +++ b/lib/calcms/studio_timeslot_dates.pm @@ -16,7 +16,7 @@ use time(); our @EXPORT_OK = qw(get_columns get insert update delete get_dates); sub get_columns ($){ - my $config = shift; + my ($config) = @_; my $dbh = db::connect($config); return db::get_columns_hash( $dbh, 'calcms_studio_timeslot_dates' ); @@ -113,8 +113,7 @@ sub get ($$){ #get all studio_timeslot_schedules for studio_id and update studio_timeslot_dates sub update { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{schedule_id}; @@ -264,8 +263,7 @@ sub get_dates { #remove all studio_timeslot_dates for studio_id and schedule_id sub delete { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return unless defined $entry->{project_id}; return unless defined $entry->{studio_id}; diff --git a/lib/calcms/studios.pm b/lib/calcms/studios.pm index 17069c1..32c8837 100644 --- a/lib/calcms/studios.pm +++ b/lib/calcms/studios.pm @@ -11,14 +11,14 @@ use images(); our @EXPORT_OK = qw(get_columns get get_by_id insert update delete check check_studio); sub get_columns($) { - my $config = shift; + my ($config) = @_; my $dbh = db::connect($config); return db::get_columns_hash( $dbh, 'calcms_studios' ); } sub get($;$) { - my $config = shift; - my $condition = shift || {}; + my ($config, $condition) = @_; + $condition ||= {}; my @conditions = (); my @bind_values = (); @@ -72,8 +72,7 @@ sub get($;$) { } sub getImageById($$) { - my $config = shift; - my $conditions = shift; + my ($config, $conditions) = @_; return undef unless defined $conditions->{project_id}; return undef unless defined $conditions->{studio_id}; @@ -83,8 +82,7 @@ sub getImageById($$) { } sub insert ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; $entry->{created_at} = time::time_to_datetime( time() ); $entry->{modified_at} = time::time_to_datetime( time() ); @@ -96,8 +94,7 @@ sub insert ($$) { } sub update ($$) { - my $config = shift; - my $studio = shift; + my ($config, $studio) = @_; $studio->{modified_at} = time::time_to_datetime( time() ); @@ -124,17 +121,14 @@ sub update ($$) { } sub delete ($$) { - my $config = shift; - my $studio = shift; - + my ($config, $studio) = @_; my $dbh = db::connect($config); db::put( $dbh, 'delete from calcms_studios where id=?', [ $studio->{id} ] ); } #TODO rename to check sub check_studio($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; return check( $config, $options ); } diff --git a/lib/calcms/time.pm b/lib/calcms/time.pm index 4c77d49..60cea17 100644 --- a/lib/calcms/time.pm +++ b/lib/calcms/time.pm @@ -551,7 +551,7 @@ sub weekday($$$) { #get current date, related to starting day_starting_hour #TODO: remove config dependency sub get_event_date($) { - my $config = shift; + my ($config) = @_; my $datetime = time::time_to_datetime( time() ); my $hour = ( time::datetime_to_array($datetime) )->[3]; diff --git a/lib/calcms/uac.pm b/lib/calcms/uac.pm index cb4f837..713aa47 100644 --- a/lib/calcms/uac.pm +++ b/lib/calcms/uac.pm @@ -30,8 +30,7 @@ our @EXPORT_OK = qw( # get user by name sub get_user($$) { - my $config = shift; - my $user = shift; + my ($config, $user) = @_; my $query = qq{ select id, name, full_name, email, disabled, modified_at, created_at @@ -51,8 +50,7 @@ sub get_user($$) { # get all users sub get_users($;$) { - my $config = shift; - my $condition = shift; + my ($config, $condition) = @_; my @conditions = (); my @bind_values = (); @@ -84,9 +82,7 @@ sub get_users($;$) { # get all users of a given studio id # used at series (previously named get_studio_users) sub get_users_by_studio ($$) { - my $config = shift; - my $condition = shift; - + my ($config, $condition) = @_; return unless defined $condition->{studio_id}; my @conditions = (); @@ -119,8 +115,7 @@ sub get_users_by_studio ($$) { # get projects a user is assigned by name sub get_projects_by_user ($$) { - my $config = shift; - my $condition = shift; + my ($config, $condition) = @_; my @conditions = (); my @bind_values = (); @@ -158,8 +153,7 @@ sub get_projects_by_user ($$) { # get all studios a user is assigned to by role # used at series (previously named get_user_studios) sub get_studios_by_user ($$) { - my $config = shift; - my $condition = shift; + my ($config, $condition) = @_; my @conditions = (); my @bind_values = (); @@ -194,8 +188,7 @@ sub get_studios_by_user ($$) { } sub insert_user($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; $entry->{created_at} = time::time_to_datetime( time() ); $entry->{modified_at} = time::time_to_datetime( time() ); @@ -205,8 +198,7 @@ sub insert_user($$) { } sub update_user($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; $entry->{modified_at} = time::time_to_datetime( time() ); @@ -226,8 +218,7 @@ sub update_user($$) { } sub delete_user($$) { - my $config = shift; - my $id = shift; + my ($config, $id) = @_; return unless ( defined $id && ( $id =~ /^\d+$/ ) ); my $query = qq{ @@ -241,8 +232,7 @@ sub delete_user($$) { # get all roles used by all users of a studio # available conditions: project_id, studio_id sub get_studio_roles($$) { - my $config = shift; - my $condition = shift; + my ($config, $condition) = @_; return [] if ( $condition->{studio_id} eq '' ); @@ -276,7 +266,7 @@ sub get_studio_roles($$) { # get role columns (for external use only) sub get_role_columns($) { - my $config = shift; + my ($config) = @_; my $dbh = db::connect($config); my $columns = db::get_columns_hash( $dbh, 'calcms_roles' ); return $columns; @@ -285,8 +275,7 @@ sub get_role_columns($) { # get roles # filter: studio_id project_id sub get_roles($$) { - my $config = shift; - my $condition = shift; + my ($config, $condition) = @_; my @conditions = (); my @bind_values = (); @@ -316,8 +305,7 @@ sub get_roles($$) { #insert role to database, set created_at and modified_at sub insert_role ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; $entry->{created_at} = time::time_to_datetime( time() ); $entry->{modified_at} = time::time_to_datetime( time() ); @@ -333,8 +321,7 @@ sub insert_role ($$) { #update role, set modified_at sub update_role($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; $entry->{modified_at} = time::time_to_datetime( time() ); @@ -356,8 +343,7 @@ sub update_role($$) { # delete role from database sub delete_role($$) { - my $config = shift; - my $id = shift; + my ($config, $id) = @_; return unless ( defined $id && ( $id =~ /^\d+$/ ) ); @@ -372,8 +358,7 @@ sub delete_role($$) { # get all roles for given conditions: project_id, studio_id, user_id, name # includes global admin user role sub get_user_roles($$) { - my $config = shift; - my $condition = shift; + my ($config, $condition) = @_; my @conditions = (); my @bind_values = (); @@ -427,8 +412,7 @@ sub get_user_roles($$) { #return admin user roles for given conditions: project_id, studio_id, user, user_id sub get_admin_user_roles ($$) { - my $config = shift; - my $condition = shift; + my ($config, $condition) = @_; my @conditions = (); my @bind_values = (); @@ -470,9 +454,7 @@ sub get_admin_user_roles ($$) { # return user_permissions # studio_id, user_id, name sub get_user_permissions ($$;$) { - my $config = shift; - my $conditions = shift; - my $user_permissions = shift; + my ($config, $conditions, $user_permissions) = @_; my $user_roles = get_user_roles( $config, $conditions ); my $admin_roles = get_admin_user_roles( $config, $conditions ); @@ -512,9 +494,7 @@ sub get_user_permissions ($$;$) { #get user id by user name sub get_user_id ($$) { - my $config = shift; - my $user = shift; - + my ($config, $user) = @_; return undef unless defined $user; my $query = qq{ @@ -530,9 +510,7 @@ sub get_user_id ($$) { #get role id by role name sub get_role_id ($$) { - my $config = shift; - my $role = shift; - + my ($config, $role) = @_; return undef unless defined $role; my $query = qq{ @@ -581,8 +559,7 @@ sub assign_user_role($$) { # unassign a user from a role of (for a studio) sub remove_user_role($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; return undef unless defined $options->{project_id}; return undef unless defined $options->{studio_id}; @@ -604,8 +581,7 @@ sub remove_user_role($$) { #checks sub is_user_assigned_to_studio ($$) { - my $request = shift; - my $options = shift; + my ($request, $options) = @_; my $config = $request->{config}; @@ -627,10 +603,7 @@ sub is_user_assigned_to_studio ($$) { # print errors at get_user_presets and check for project id and studio id # call after header is printed sub check($$$) { - my $config = shift; - my $params = shift; - my $user_presets = shift; - + my ($config, $params, $user_presets) = @_; if ( defined $user_presets->{error} ) { uac::print_error( $user_presets->{error} ); return 0; @@ -654,8 +627,7 @@ sub check($$$) { # set permissions for selected project and studio # return request sub get_user_presets($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; my $user = $options->{user} || ''; my $error = undef; @@ -787,8 +759,7 @@ sub get_user_presets($$) { } sub setDefaultProject ($$) { - my $params = shift; - my $user_presets = shift; + my ($params, $user_presets) = @_; $params->{project_id} = $user_presets->{project_id} if ( !defined $params->{authAction} ) || ( $params->{authAction} eq '' ) || ( $params->{authAction} eq 'login' ); @@ -806,8 +777,7 @@ sub setDefaultStudio($$) { #set user preset properties to request sub prepare_request ($$) { - my $request = shift; - my $user_presets = shift; + my ($request, $user_presets) = @_; for my $key ( keys %$user_presets ) { $request->{$key} = $user_presets->{$key}; @@ -822,8 +792,7 @@ sub prepare_request ($$) { #TODO: shift to permissions sub entry sub set_template_permissions ($$) { - my $permissions = shift; - my $params = shift; + my ($permissions, $params) = @_; for my $usecase ( keys %$permissions ) { $params->{'allow'}->{$usecase} = 1 if ( $permissions->{$usecase} eq '1' ); diff --git a/lib/calcms/user_day_start.pm b/lib/calcms/user_day_start.pm index 9fce22e..ac6e985 100644 --- a/lib/calcms/user_day_start.pm +++ b/lib/calcms/user_day_start.pm @@ -10,7 +10,7 @@ use Data::Dumper; # columns: user, project_id, studio_id, series_id, day_start sub get_columns($) { - my $config = shift; + my ($config) = @_; my $dbh = db::connect($config); return db::get_columns_hash( $dbh, 'calcms_user_day_start' ); @@ -60,8 +60,7 @@ sub insert_or_update($$){ } sub insert ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return unless defined $entry->{user}; return unless defined $entry->{project_id}; @@ -74,8 +73,7 @@ sub insert ($$) { } sub update($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; my $fields = [ 'user', 'project_id', 'studio_id' ]; for (@$fields){ @@ -99,8 +97,7 @@ sub update($$) { } sub delete ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return unless defined $entry->{user}; return unless defined $entry->{project_id}; diff --git a/lib/calcms/user_default_studios.pm b/lib/calcms/user_default_studios.pm index 4d2e619..8a5133a 100644 --- a/lib/calcms/user_default_studios.pm +++ b/lib/calcms/user_default_studios.pm @@ -10,7 +10,7 @@ use Data::Dumper; # columns: user, project_id, studio_id sub get_columns($) { - my $config = shift; + my ($config) = @_; my $dbh = db::connect($config); return db::get_columns_hash( $dbh, 'calcms_user_default_studios' ); @@ -51,8 +51,7 @@ sub get ($$) { } sub insert ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return unless defined $entry->{user}; @@ -61,8 +60,7 @@ sub insert ($$) { } sub update($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return unless defined $entry->{user}; @@ -84,8 +82,7 @@ sub update($$) { } sub delete ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return unless defined $entry->{user}; diff --git a/lib/calcms/user_selected_events.pm b/lib/calcms/user_selected_events.pm index 052def5..7dba5ce 100644 --- a/lib/calcms/user_selected_events.pm +++ b/lib/calcms/user_selected_events.pm @@ -12,7 +12,7 @@ use Data::Dumper; # selected_project, selected_studio, selected_series, selected_event <-result sub get_columns($) { - my $config = shift; + my ($config) = @_; my $dbh = db::connect($config); return db::get_columns_hash( $dbh, 'calcms_user_selected_events' ); @@ -54,8 +54,7 @@ sub get ($$) { } sub insert ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return unless defined $entry->{user}; return unless defined $entry->{project_id}; @@ -69,8 +68,7 @@ sub insert ($$) { } sub update($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; my $fields = [ 'user', 'project_id', 'studio_id', 'series_id', @@ -97,8 +95,7 @@ sub update($$) { } sub delete ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return unless defined $entry->{user}; return unless defined $entry->{project_id}; diff --git a/lib/calcms/user_sessions.pm b/lib/calcms/user_sessions.pm index ef3917a..8463e7d 100644 --- a/lib/calcms/user_sessions.pm +++ b/lib/calcms/user_sessions.pm @@ -22,7 +22,7 @@ use time; our @EXPORT_OK = qw(get_columns get insert update delete); sub get_columns($) { - my $config = shift; + my ($config) = @_; my $dbh = db::connect($config); return db::get_columns_hash( $dbh, 'calcms_user_sessions' ); @@ -30,8 +30,7 @@ sub get_columns($) { #map schedule id to id sub get($$) { - my $config = shift; - my $condition = shift; + my ($config, $condition) = @_; my $dbh = db::connect($config); @@ -74,8 +73,7 @@ sub get($$) { # insert entry and return database id sub insert ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{user}; return undef unless defined $entry->{timeout}; @@ -95,8 +93,7 @@ sub insert ($$) { # start session and return generated session id sub start($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{user}; return undef unless defined $entry->{timeout}; @@ -121,8 +118,7 @@ sub start($$) { # expand session by timeout sub keep_alive ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry; @@ -135,8 +131,7 @@ sub keep_alive ($$) { # get session by session id and expand session if valid sub check($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry; my $entries = get( $config, { session_id => $entry->{session_id} } ); @@ -158,8 +153,7 @@ sub check($$) { # stop session sub stop ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry; @@ -177,8 +171,7 @@ sub stop ($$) { #schedule id to id sub update ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{session_id}; @@ -199,8 +192,7 @@ sub update ($$) { #map schedule id to id sub delete($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{session_id}; diff --git a/lib/calcms/user_settings.pm b/lib/calcms/user_settings.pm index 6ca6da8..6861224 100644 --- a/lib/calcms/user_settings.pm +++ b/lib/calcms/user_settings.pm @@ -132,7 +132,7 @@ sub getColorCss ($$) { } sub get_columns($) { - my $config = shift; + my ($config) = @_; my $dbh = db::connect($config); return db::get_columns_hash( $dbh, 'calcms_user_settings' ); @@ -166,8 +166,7 @@ sub get ($$) { } sub insert ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return unless defined $entry->{user}; @@ -176,8 +175,7 @@ sub insert ($$) { } sub update($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return unless ( defined $entry->{user} ); @@ -198,8 +196,7 @@ sub update($$) { } sub delete ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return unless ( defined $entry->{user} ); diff --git a/lib/calcms/user_stats.pm b/lib/calcms/user_stats.pm index afd50af..87f5e0a 100644 --- a/lib/calcms/user_stats.pm +++ b/lib/calcms/user_stats.pm @@ -9,8 +9,7 @@ use Data::Dumper; our @EXPORT_OK = qw(get_columns get update insert get_stats increase); sub get_columns($) { - my $config = shift; - + my ($config) = @_; my $dbh = db::connect($config); return db::get_columns_hash( $dbh, 'calcms_user_stats' ); } @@ -130,8 +129,7 @@ sub get_stats($$) { } sub insert($$) { - my $config = shift; - my $stats = shift; + my ($config, $stats) = @_; return undef unless defined $stats->{project_id}; return undef unless defined $stats->{studio_id}; @@ -153,8 +151,7 @@ sub insert($$) { # update project sub update ($$) { - my $config = shift; - my $stats = shift; + my ($config, $stats) = @_; return undef unless defined $stats->{project_id}; return undef unless defined $stats->{studio_id}; diff --git a/lib/calcms/work_dates.pm b/lib/calcms/work_dates.pm index 4cb361d..bf289ba 100644 --- a/lib/calcms/work_dates.pm +++ b/lib/calcms/work_dates.pm @@ -20,8 +20,7 @@ use work_schedule(); our @EXPORT_OK = qw(get_columns get insert update delete get_dates); sub get_columns($) { - my $config = shift; - + my ($config) = @_; my $dbh = db::connect($config); return db::get_columns_hash( $dbh, 'calcms_work_dates' ); } @@ -118,8 +117,7 @@ sub get ($$) { #update work dates for all schedules of a work and studio_id sub update($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{project_id}; return undef unless defined $entry->{studio_id}; @@ -348,8 +346,7 @@ sub get_dates($$$$) { #remove all work_dates for studio_id and schedule_id sub delete($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{project_id}; return undef unless defined $entry->{studio_id}; diff --git a/lib/calcms/work_schedule.pm b/lib/calcms/work_schedule.pm index 56bff79..8296bb0 100644 --- a/lib/calcms/work_schedule.pm +++ b/lib/calcms/work_schedule.pm @@ -21,8 +21,7 @@ use series_dates(); our @EXPORT_OK = qw(get_columns get insert update delete); sub get_columns($) { - my $config = shift; - + my ($config) = @_; my $dbh = db::connect($config); return db::get_columns_hash( $dbh, 'calcms_work_schedule' ); } @@ -82,8 +81,7 @@ sub get($$) { } sub insert ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{project_id}; return undef unless defined $entry->{studio_id}; @@ -94,8 +92,7 @@ sub insert ($$) { #schedule id to id sub update ($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{project_id}; return undef unless defined $entry->{studio_id}; @@ -122,8 +119,7 @@ sub update ($$) { #map schedule id to id sub delete($$) { - my $config = shift; - my $entry = shift; + my ($config, $entry) = @_; return undef unless defined $entry->{project_id}; return undef unless defined $entry->{studio_id};