From 24e1b3b0337231c91309f64f7c9ad7e68dc88421 Mon Sep 17 00:00:00 2001 From: Milan Date: Mon, 10 Apr 2023 22:39:29 +0200 Subject: [PATCH 1/7] default: menu wider --- website/agenda/planung/css/default.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/agenda/planung/css/default.css b/website/agenda/planung/css/default.css index 59ed096..bae8f03 100644 --- a/website/agenda/planung/css/default.css +++ b/website/agenda/planung/css/default.css @@ -240,7 +240,7 @@ select#project_id::after { text-align: left; vertical-align:middle; background: #004f9b; - min-width: 10rem; + min-width: 30ch; } #calcms_nav .dropdown-content a { From 172e03624214591a615c96b63c02195807c5af39 Mon Sep 17 00:00:00 2001 From: Milan Date: Mon, 10 Apr 2023 22:47:21 +0200 Subject: [PATCH 2/7] notify-events: i18n, show details, menu entry * add menu entry * toggle details * show status icons instead of text * internationalization --- website/agenda/planung/css/notify-events.css | 34 +++++------ website/agenda/planung/image/arrow-down.svg | 2 +- website/agenda/planung/image/arrow-up.svg | 1 + website/agenda/planung/image/notify.svg | 1 + website/agenda/planung/js/notify-events.js | 23 +++++++- website/agenda/planung/notify-events.cgi | 10 ++-- website/agenda/planung/pot/de/menu.po | 2 + .../agenda/planung/pot/de/notify-events.po | 27 +++++++++ website/agenda/planung/pot/en/menu.po | 3 + .../agenda/planung/pot/en/notify-events.po | 27 +++++++++ website/agenda/planung/templates/default.html | 4 ++ .../planung/templates/notify-events.html | 59 ++++++++++--------- 12 files changed, 141 insertions(+), 52 deletions(-) create mode 100644 website/agenda/planung/image/arrow-up.svg create mode 100644 website/agenda/planung/image/notify.svg diff --git a/website/agenda/planung/css/notify-events.css b/website/agenda/planung/css/notify-events.css index 97f50a3..bbc21ec 100644 --- a/website/agenda/planung/css/notify-events.css +++ b/website/agenda/planung/css/notify-events.css @@ -1,36 +1,34 @@ -.mailHeader{ - background:#ccc; +table#events{ + transition:all 2s; } -.mailSubject{ -} - -.mailBody{ - white-space:pre; -} - -.done{ +table#events.done{ background:#cfc; } table#events td:nth-of-type(1){ - width:15em; + width:15ch; } -table#events td:nth-of-type(2){ - width:60em; +table#events td:nth-of-type(4){ + width:12ch; } td.action, input.action{ - width:5em; + width:5ch; } form input{ - width:50em; + width:100%; } -form textarea{ - width:50em; - height:14em; +img.toggle{ + background:#1678c2; + cursor:grab; + transition:all 0.5s; } +img.toggle:hover{ + transform: scale(1.2); + box-shadow: 0 5px 11px 0 rgba(0, 0, 0, .18), 0 4px 15px 0 rgba(0, 0, 0, .15); +} diff --git a/website/agenda/planung/image/arrow-down.svg b/website/agenda/planung/image/arrow-down.svg index 67ed999..6ca6eec 100644 --- a/website/agenda/planung/image/arrow-down.svg +++ b/website/agenda/planung/image/arrow-down.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/website/agenda/planung/image/arrow-up.svg b/website/agenda/planung/image/arrow-up.svg new file mode 100644 index 0000000..1105bee --- /dev/null +++ b/website/agenda/planung/image/arrow-up.svg @@ -0,0 +1 @@ + diff --git a/website/agenda/planung/image/notify.svg b/website/agenda/planung/image/notify.svg new file mode 100644 index 0000000..8ba5390 --- /dev/null +++ b/website/agenda/planung/image/notify.svg @@ -0,0 +1 @@ + diff --git a/website/agenda/planung/js/notify-events.js b/website/agenda/planung/js/notify-events.js index 7e4b88d..98d0cf1 100644 --- a/website/agenda/planung/js/notify-events.js +++ b/website/agenda/planung/js/notify-events.js @@ -7,12 +7,33 @@ function register_buttons() { var content = $(data).find("#content"); $('#result').html(content); var formId = form.attr('id'); - $('#'+formId+" .mailHeader").addClass("done"); + $('#' + formId+" table").addClass("done"); }); }); } +function hide_details() { + $('table.panel tbody').each(function(){ + $(this).children("tr.details").each(function() { + $(this).hide(); + }) + }) + + $('table.panel img.toggle').on("click", function() { + if( $(this).attr("src").indexOf("arrow-up") < 0 ){ + $(this).attr("src", "image/arrow-up.svg"); + } else { + $(this).attr("src", "image/arrow-down.svg"); + } + $(this).closest('tbody').children("tr.details").each(function() { + $(this).toggle(); + }) + }) +} + + $(document).ready(function() { + hide_details(); register_buttons(); }); diff --git a/website/agenda/planung/notify-events.cgi b/website/agenda/planung/notify-events.cgi index ff6366a..9c755af 100755 --- a/website/agenda/planung/notify-events.cgi +++ b/website/agenda/planung/notify-events.cgi @@ -79,7 +79,7 @@ sub show_events { my $params = $request->{params}->{checked}; my $permissions = $request->{permissions}; - for my $attr ( 'project_id', 'studio_id', 'duration' ) { # 'series_id','event_id' + for my $attr ( 'project_id', 'studio_id') { # 'series_id','event_id' unless ( defined $params->{$attr} ) { uac::print_error( "missing " . $attr . " to show changes" ); return; @@ -92,7 +92,7 @@ sub show_events { } # get events - my $duration = $params->{duration}; + my $duration = $params->{duration} // 7; my $options = { project_id => $params->{project_id}, studio_id => $params->{studio_id}, @@ -108,6 +108,8 @@ sub show_events { for my $event (@$events) { my $mail = getMail( $config, $request, $event ); $event->{mail} = $mail; + $event->{start} = substr($event->{start}, 0, 16); + $event->{preproduction} = !$event->{live}; } return unless defined $events; @@ -202,13 +204,13 @@ sub getMail { $event->{noRecipient} = 1; return; } - my $sender = $config->{location}->{event_sender_email}; + my $sender = $config->{locations}->{event_sender_email}; my $mail = { 'From' => $sender, 'To' => join( ', ', @$userMails ), 'Cc' => $sender, 'Reply-To' => $sender, - 'Subject' => "$event->{start} - $event->{full_title}", + 'Subject' => substr($event->{start},0,16) . " - $event->{full_title}", 'Data' => "Hallo " . join( ' und ', @$userNames ) . ",\n\n" }; diff --git a/website/agenda/planung/pot/de/menu.po b/website/agenda/planung/pot/de/menu.po index 6ab82df..f8f8339 100644 --- a/website/agenda/planung/pot/de/menu.po +++ b/website/agenda/planung/pot/de/menu.po @@ -67,4 +67,6 @@ msgstr "Sendungen anlegen" msgid "edit-help-texts" msgstr "Hilfe bearbeiten" +msgid "notify-events" +msgstr "Erinnerungen verschicken" diff --git a/website/agenda/planung/pot/de/notify-events.po b/website/agenda/planung/pot/de/notify-events.po index bc66a9f..dc8c301 100644 --- a/website/agenda/planung/pot/de/notify-events.po +++ b/website/agenda/planung/pot/de/notify-events.po @@ -1,3 +1,30 @@ +msgid "title" +msgstr "Redaktionen an ihre Sendungen erinnern" + msgid "button_send" msgstr "Senden" +msgid "subject" +msgstr "Betreff" + +msgid "to" +msgstr "Empfänger" + +msgid "from" +msgstr "Absender" + +msgid "cc" +msgstr "Kopie" + +msgid "bcc" +msgstr "Blindkopie" + +msgid "reply-to" +msgstr "Antwort an" + +msgid "body" +msgstr "Inhalt" + +msgid "show_details" +msgstr "Zeige Details" + diff --git a/website/agenda/planung/pot/en/menu.po b/website/agenda/planung/pot/en/menu.po index b784fb9..9720b4f 100644 --- a/website/agenda/planung/pot/en/menu.po +++ b/website/agenda/planung/pot/en/menu.po @@ -64,6 +64,9 @@ msgstr "User Stats" msgid "create-events" msgstr "Create Events" +msgid "notify-events" +msgstr "Remind Of Editors Broadcasts" + msgid "edit-help-texts" msgstr "Edit Help" diff --git a/website/agenda/planung/pot/en/notify-events.po b/website/agenda/planung/pot/en/notify-events.po index 9885f4b..a25913e 100644 --- a/website/agenda/planung/pot/en/notify-events.po +++ b/website/agenda/planung/pot/en/notify-events.po @@ -1,3 +1,30 @@ +msgid "title" +msgstr "Remind Editors For Their Programme" + msgid "button_send" msgstr "Send" +msgid "subject" +msgstr "Subject" + +msgid "to" +msgstr "Recipient" + +msgid "from" +msgstr "Sender" + +msgid "cc" +msgstr "Copy" + +msgid "bcc" +msgstr "Blind copy" + +msgid "reply-to" +msgstr "Reply To" + +msgid "body" +msgstr "Content" + +msgid "show_details" +msgstr "Show Details" + diff --git a/website/agenda/planung/templates/default.html b/website/agenda/planung/templates/default.html index 2ea6113..b942414 100644 --- a/website/agenda/planung/templates/default.html +++ b/website/agenda/planung/templates/default.html @@ -21,6 +21,10 @@
 
+ +
 
+
+
 
diff --git a/website/agenda/planung/templates/notify-events.html b/website/agenda/planung/templates/notify-events.html index 38b580c..667894b 100644 --- a/website/agenda/planung/templates/notify-events.html +++ b/website/agenda/planung/templates/notify-events.html @@ -23,7 +23,7 @@ - +

@@ -33,63 +33,66 @@ - +
- + - - - - - - + + + + + - - - - - - - - - - - + + + + + + + + + + - - + + - - + + - - + + - - + + From 3effdd6ef064a1bc8457d7f99915275448c684f4 Mon Sep 17 00:00:00 2001 From: Milan Date: Sun, 23 Apr 2023 12:15:18 +0200 Subject: [PATCH 3/7] mail.pm: replace MIME::Lite by Email::Sender * mail.pm uses Email:sender to use correct encoding on sending utf-8 encoded emails * notify-events.cgi now uses mail.pm. --- install/INSTALL.md | 4 +--- lib/calcms/mail.pm | 26 +++++++++++++----------- website/agenda/planung/notify-events.cgi | 23 +++++---------------- 3 files changed, 20 insertions(+), 33 deletions(-) diff --git a/install/INSTALL.md b/install/INSTALL.md index c9ed5cb..21bc1a7 100644 --- a/install/INSTALL.md +++ b/install/INSTALL.md @@ -85,14 +85,13 @@ apt-get install libdate-manip-perl libdbi-perl libdbd-mysql-perl + libemail-sender-perl libencode-perl libjson-perl libhtml-formattext-withlinks-andtables-perl libhtml-parser-perl libhtml-template-perl libhtml-template-compiled-perl - libmime-base64-urlsafe-perl - libmime-lite-perl libsession-token-perl libtext-multimarkdown-perl libtext-wikicreole-perl @@ -132,7 +131,6 @@ apt-get install Image::Magick Image::Magick::Square JSON - MIME::Lite ModPerl::Util Session::Token Text::Diff::FormatedHtml diff --git a/lib/calcms/mail.pm b/lib/calcms/mail.pm index 8fb4309..9b271f1 100644 --- a/lib/calcms/mail.pm +++ b/lib/calcms/mail.pm @@ -4,22 +4,24 @@ use strict; use warnings; no warnings 'redefine'; -use MIME::Lite(); +use Email::Sender::Simple(); +use Email::Simple(); sub send($) { - my $mail = shift; + my ($mail) = @_; - my $msg = MIME::Lite->new( - 'From' => $mail->{'From'}, - 'To' => $mail->{'To'}, - 'Cc' => $mail->{'Cc'}, - 'Reply-To' => $mail->{'Reply-To'}, - 'Subject' => $mail->{'Subject'}, - 'Data' => $mail->{'Data'}, + my $email = Email::Simple->create( + 'Content-Type' => 'text/plain; charset=utf-8', + header => [ + 'From' => $mail->{'From'}, + 'To' => $mail->{'To'}, + 'Cc' => $mail->{'Cc'}, + 'Reply-To' => $mail->{'Reply-To'}, + 'Subject' => $mail->{'Subject'} + ], + body => $mail->{'Data'}, ); - - $msg->print( \*STDERR ); - $msg->send; + Email::Sender::Simple->send($email); } # do not delete next line diff --git a/website/agenda/planung/notify-events.cgi b/website/agenda/planung/notify-events.cgi index 9c755af..4f2c331 100755 --- a/website/agenda/planung/notify-events.cgi +++ b/website/agenda/planung/notify-events.cgi @@ -3,10 +3,9 @@ use strict; use warnings; no warnings 'redefine'; +use utf8; -use URI::Escape(); use Data::Dumper; -use MIME::Lite(); use params(); use config(); @@ -21,6 +20,7 @@ use markup(); use studios(); use series(); use localization(); +use mail(); binmode STDOUT, ":utf8"; @@ -164,20 +164,7 @@ sub sendMail { $mail->{Cc} = $params->{cc} if defined $params->{cc}; $mail->{Subject} = $params->{subject} if defined $params->{subject}; $mail->{Data} = $params->{content} if defined $params->{content}; - - my $msg = MIME::Lite->new( - 'From' => $mail->{'From'}, - 'To' => $mail->{'To'}, - 'Cc' => $mail->{'Cc'}, - 'Reply-To' => $mail->{'Reply-To'}, - 'Subject' => $mail->{'Subject'}, - 'Data' => $mail->{'Data'}, - ); - - print '
';
-    $msg->print( \*STDOUT );
-    print '
'; - $msg->send; + mail::send($mail); } sub getMail { @@ -215,10 +202,10 @@ sub getMail { }; $mail->{Data} .= "nur zur Erinnerung...\n\n"; - $mail->{Data} .= "am $event->{weekday_name} ist die naechste '$event->{series_name}'-Sendung.\n\n"; + $mail->{Data} .= "am $event->{weekday_name} ist die nächste '$event->{series_name}'-Sendung.\n\n"; $mail->{Data} .= "$event->{source_base_url}$event->{widget_render_url}/$config->{controllers}->{event}/$event->{event_id}.html\n\n"; - $mail->{Data} .= "Gruss, $request->{user}\n"; + $mail->{Data} .= "Gruß, $request->{user}\n"; return $mail; } From 611fad43d4881f3e9efd06744a13a12665090919 Mon Sep 17 00:00:00 2001 From: Milan Date: Sat, 20 May 2023 07:58:07 +0200 Subject: [PATCH 4/7] mail.pm: encode UTF-8 header --- lib/calcms/mail.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/calcms/mail.pm b/lib/calcms/mail.pm index 9b271f1..be8addc 100644 --- a/lib/calcms/mail.pm +++ b/lib/calcms/mail.pm @@ -3,9 +3,11 @@ package mail; use strict; use warnings; no warnings 'redefine'; +use utf8; use Email::Sender::Simple(); use Email::Simple(); +use MIME::Words qw(encode_mimeword); sub send($) { my ($mail) = @_; @@ -17,7 +19,7 @@ sub send($) { 'To' => $mail->{'To'}, 'Cc' => $mail->{'Cc'}, 'Reply-To' => $mail->{'Reply-To'}, - 'Subject' => $mail->{'Subject'} + 'Subject' => encode_mimeword($mail->{'Subject'}, 'b', 'UTF-8') ], body => $mail->{'Data'}, ); From 3a1a118eeb41c47861de7e6586ab62108b4fdc42 Mon Sep 17 00:00:00 2001 From: Milan Date: Thu, 18 May 2023 11:17:14 +0200 Subject: [PATCH 5/7] 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}; From fe857c6f65b12a4ba6b2f075188d42b88a0f8e69 Mon Sep 17 00:00:00 2001 From: Milan Date: Fri, 19 May 2023 18:00:29 +0200 Subject: [PATCH 6/7] lib: replace shift my @_ (pt2) --- lib/calcms/ListenerAccess.pm | 2 +- lib/calcms/aggregator.pm | 16 +--- lib/calcms/audio.pm | 28 +++--- lib/calcms/audio_recordings.pm | 3 +- lib/calcms/calendar.pm | 7 +- lib/calcms/comments.pm | 54 +++-------- lib/calcms/config.pm | 4 +- lib/calcms/creole_wiki.pm | 13 ++- lib/calcms/db.pm | 11 +-- lib/calcms/event_history.pm | 3 +- lib/calcms/events.pm | 18 ++-- lib/calcms/images.pm | 55 +++++------- lib/calcms/localization.pm | 8 +- lib/calcms/log.pm | 8 +- lib/calcms/markup.pm | 18 ++-- lib/calcms/params.pm | 2 +- lib/calcms/password_requests.pm | 12 +-- lib/calcms/series_dates.pm | 37 +++----- lib/calcms/series_schedule.pm | 3 +- lib/calcms/studio_timeslot_dates.pm | 15 ++-- lib/calcms/studio_timeslot_schedule.pm | 14 ++- lib/calcms/studios.pm | 4 +- lib/calcms/template.pm | 9 +- lib/calcms/time.pm | 119 +++++++++++-------------- lib/calcms/uac.pm | 10 +-- lib/calcms/user_day_start.pm | 7 +- lib/calcms/user_default_studios.pm | 3 +- lib/calcms/user_selected_events.pm | 3 +- lib/calcms/user_settings.pm | 10 +-- lib/calcms/user_stats.pm | 12 +-- lib/calcms/work_dates.pm | 24 ++--- lib/calcms/work_schedule.pm | 3 +- 32 files changed, 203 insertions(+), 332 deletions(-) diff --git a/lib/calcms/ListenerAccess.pm b/lib/calcms/ListenerAccess.pm index d109d8d..5951215 100644 --- a/lib/calcms/ListenerAccess.pm +++ b/lib/calcms/ListenerAccess.pm @@ -12,7 +12,7 @@ use Apache2::Connection (); use Apache2::Const -compile => qw(FORBIDDEN OK); sub handler { - my $r = shift; + my ($r) = @_; my $DAYS = 24 * 60 * 60; my $OK = Apache2::Const::OK; diff --git a/lib/calcms/aggregator.pm b/lib/calcms/aggregator.pm index 53acc65..20302d8 100644 --- a/lib/calcms/aggregator.pm +++ b/lib/calcms/aggregator.pm @@ -14,9 +14,7 @@ use Date::Calc; our @EXPORT_OK = qw(get_cache configure_cache put_cache get_list check_params); sub get_list($$) { - my $config = shift; - my $request = shift; - + my ($config, $request) = @_; my $params = $request->{params}->{checked}; #customize prefiltered request parameters @@ -63,10 +61,7 @@ sub get_list($$) { } sub get_menu($$$$) { - my $config = shift; - my $request = shift; - my $date = shift; - my $results = shift; + my ($config, $request, $date, $results) = @_; my $params = $request->{params}->{checked}; @@ -89,9 +84,7 @@ sub get_menu($$$$) { } sub get_calendar($$$) { - my $config = shift; - my $request = shift; - my $date = shift; + my ($config, $request, $date) = @_; my $params = $request->{params}->{checked}; @@ -114,8 +107,7 @@ sub get_calendar($$$) { } sub get_newest_comments($$) { - my $config = shift; - my $request = shift; + my ($config, $request) = @_; my $params = { template => 'comments_newest.html', diff --git a/lib/calcms/audio.pm b/lib/calcms/audio.pm index 3db95a9..7155f38 100644 --- a/lib/calcms/audio.pm +++ b/lib/calcms/audio.pm @@ -3,7 +3,7 @@ use warnings; use strict; sub durationToSeconds($) { - my $duration = shift; + my ($duration) = @_; if ( $duration =~ /(\d+):(\d\d):(\d\d).(\d\d)/ ) { return $1 * 3600 + $2 * 60 + $3 + $4 / 100; @@ -12,10 +12,7 @@ sub durationToSeconds($) { } sub formatDuration($$$;$) { - my $audioDuration = shift; - my $eventDuration = shift; - my $value = shift; - my $mouseOver = shift; + my ($audioDuration, $eventDuration, $value, $mouseOver) = @_; return '' unless $audioDuration; return '' unless $eventDuration; @@ -52,7 +49,8 @@ sub formatDuration($$$;$) { } sub formatChannels($) { - my $channels = shift; + my ($channels) = @_; + return '' unless $channels; my $class = "ok"; $class = "error" if $channels != 2; @@ -60,7 +58,8 @@ sub formatChannels($) { } sub formatSamplingRate($) { - my $samplingRate = shift; + my ($samplingRate) = @_; + return '' unless $samplingRate; my $class = "ok"; $class = "error" if $samplingRate != 44100; @@ -68,7 +67,8 @@ sub formatSamplingRate($) { } sub formatBitrate($) { - my $bitrate = shift; + my ($bitrate) = @_; + return '' unless $bitrate; my $class = 'ok'; $class = 'warn' if $bitrate >= 200; @@ -77,7 +77,8 @@ sub formatBitrate($) { } sub formatBitrateMode($) { - my $mode = shift; + my ($mode) = @_; + return '' unless $mode; my $class = 'ok'; $class = 'error' if $mode ne 'CBR'; @@ -85,9 +86,9 @@ sub formatBitrateMode($) { } sub formatLoudness { - my $value = shift; - my $prefix = shift || ''; - my $round = shift || ''; + my ($value, $prefix, $round) = @_; + $prefix ||= ''; + $round ||= ''; return '' unless $value; $value = sprintf( "%.1f", $value ); @@ -103,8 +104,7 @@ sub formatLoudness { } sub formatFile{ - my $file = shift; - my $event_id = shift; + my ($file, $event_id) = @_; return '' unless $file; diff --git a/lib/calcms/audio_recordings.pm b/lib/calcms/audio_recordings.pm index 58c4dcd..12328f2 100644 --- a/lib/calcms/audio_recordings.pm +++ b/lib/calcms/audio_recordings.pm @@ -24,8 +24,7 @@ sub get_columns($) { # get playout entries sub get($$) { - my $config = shift; - my $condition = shift; + my ($config, $condition) = @_; my $date_range_include = 0; $date_range_include = 1 diff --git a/lib/calcms/calendar.pm b/lib/calcms/calendar.pm index 73d84c6..0762fd1 100644 --- a/lib/calcms/calendar.pm +++ b/lib/calcms/calendar.pm @@ -27,8 +27,7 @@ sub get_cached_or_render($$$) { } sub get($$) { - my $config = shift; - my $request = shift; + my ($config, $request) = @_; my $params = $request->{params}->{checked}; my $language = $config->{date}->{language} || 'en'; @@ -315,8 +314,8 @@ sub get_calendar_weeks($$$) { } sub getWeeksOfMonth($$) { - my $thisYear = shift; - my $thisMonth = shift; + my ($thisYear, $thisMonth) = @_; + my $thisDay = 1; # get weekday of 1st of month diff --git a/lib/calcms/comments.pm b/lib/calcms/comments.pm index 5673604..915e56d 100644 --- a/lib/calcms/comments.pm +++ b/lib/calcms/comments.pm @@ -70,8 +70,7 @@ sub get_cached_or_render($$$;$) { } sub get($$) { - my $config = shift; - my $request = shift; + my ($config, $request) = @_; my $params = $request->{params}->{checked}; my $dbh = db::connect( $config, $request ); @@ -81,9 +80,7 @@ sub get($$) { } sub get_query($$$) { - my $dbh = shift; - my $config = shift; - my $request = shift; + my ($dbh, $config, $request) = @_; my $params = $request->{params}->{checked}; @@ -229,9 +226,7 @@ sub render($$$$) { #check if comment exists already sub check ($$$) { - my $dbh = shift; - my $config = shift; - my $comment = shift; + my ($dbh, $config, $comment) = @_; my $query = qq{ select id @@ -259,9 +254,7 @@ sub check ($$$) { #used for insert sub get_level($$$) { - my $dbh = shift; - my $config = shift; - my $comment = shift; + my ($dbh, $config, $comment) = @_; my $parent_id = $comment->{parent_id}; return 0 unless defined $parent_id; @@ -294,9 +287,7 @@ sub get_level($$$) { } sub get_by_event($$$) { - my $dbh = shift; - my $config = shift; - my $request = $_[0]; + my ($dbh, $config, $request) = @_; my $params = $request->{params}->{checked}->{comment}; @@ -336,9 +327,7 @@ sub get_by_event($$$) { } sub get_by_time($$$) { - my $dbh = shift; - my $config = shift; - my $comment = shift; + my ($dbh, $config, $comment) = @_; my $where = ''; my $bind_values = []; @@ -375,10 +364,7 @@ sub get_by_time($$$) { } sub get_events($$$$) { - my $dbh = shift; - my $config = shift; - my $request = shift; - my $comments = shift; + my ($dbh, $config, $request, $comments) = @_; my $params = $request->{params}->{checked}->{comment}; @@ -438,9 +424,7 @@ sub get_events($$$$) { } sub insert ($$$) { - my $dbh = shift; - my $config = shift; - my $comment = shift; + my ($dbh, $config, $comment) = @_; $comment->{level} = comments::get_level( $dbh, $config, $comment ); @@ -461,9 +445,7 @@ sub insert ($$$) { } sub set_lock_status ($$$) { - my $dbh = shift; - my $config = shift; - my $comment = shift; + my ($dbh, $config, $comment) = @_; my $id = $comment->{id}; my $lock_status = $comment->{set_lock_status}; @@ -489,9 +471,7 @@ sub set_lock_status ($$$) { } sub set_news_status($$$) { - my $dbh = shift; - my $config = shift; - my $comment = shift; + my ($dbh, $config, $comment) = @_; my $id = $comment->{id}; my $news_status = $comment->{set_news_status}; @@ -505,9 +485,7 @@ sub set_news_status($$$) { } sub update_comment_count ($$$) { - my $dbh = shift; - my $config = shift; - my $comment = shift; + my ($dbh, $config, $comment) = @_; my $query = qq{ select count(id) count @@ -530,9 +508,7 @@ sub update_comment_count ($$$) { } sub sort_childs { - my $node = shift; - my $nodes = shift; - my $sorted_nodes = shift; + my ($node, $nodes, $sorted_nodes) = @_; #push node into list of sorted nodes push @{$sorted_nodes}, $node; @@ -549,8 +525,7 @@ sub sort_childs { #precondition: results are presorted by creation date (by sql) sub sort($$) { - my $config = shift; - my $results = shift; + my ($config, $results) = @_; #define parent nodes my $nodes = {}; @@ -578,8 +553,7 @@ sub sort($$) { } sub check_params ($$) { - my $config = shift; - my $params = shift; + my ($config, $params) = @_; my $comment = {}; $comment->{event_start} = ''; diff --git a/lib/calcms/config.pm b/lib/calcms/config.pm index 07ea1bf..a50b9be 100644 --- a/lib/calcms/config.pm +++ b/lib/calcms/config.pm @@ -14,7 +14,7 @@ my $config = undef; sub get($) { - my $filename = shift; + my ($filename) = @_; return read_config($filename); } @@ -25,7 +25,7 @@ sub getFromScriptLocation() { } sub read_config { - my $file = $_[0]; + my ($file) = @_; my $vars = {}; my @stack = (); diff --git a/lib/calcms/creole_wiki.pm b/lib/calcms/creole_wiki.pm index c5f35d7..71fe122 100644 --- a/lib/calcms/creole_wiki.pm +++ b/lib/calcms/creole_wiki.pm @@ -13,8 +13,7 @@ our @EXPORT_OK = #convert creole wiki text to event sub extractEventFromWikiText($;$) { - my $params = shift; - my $event = shift; + my ($params, $event) = @_; $event = {} unless defined $event; my $title = $params->{title} || ''; @@ -111,7 +110,7 @@ s/\{\{\s*thumbs\/+(.*?)\s*\|\s*(.*?)\s*\}\}/\[\[$local_media_url\/images\/$1\|\{ } sub eventToWikiText($$) { - my $event = shift; + my ($event) = @_; my $local_media_url = $event->{local_media_url} || ''; $event->{program} =~ s/^\s+|\s+$//g; @@ -163,8 +162,7 @@ s/\[\[.*?\/+media\/+images\/+(.*?)\s*\|.*?\{\{.*?\/+media\/+thumbs\/+(.*?)\s*\|\ #extrace meta tags from comment text sub extractMeta ($$) { - my $comments = shift; - my $meta = shift; + my ($comments, $meta) = @_; $meta = [] unless defined $meta; @@ -202,7 +200,8 @@ sub extractMeta ($$) { #remove meta tags from comment text sub removeMeta($) { - my $comments = shift || ''; + my ($comments) = @_; + $comments ||= ''; my $result = ''; for my $line ( split( /\n/, $comments ) ) { @@ -216,7 +215,7 @@ sub removeMeta($) { #add meta tags to comment text sub metaToWiki { - my $meta = shift; + my ($meta) = @_; my $result = ''; for my $pair (@$meta) { diff --git a/lib/calcms/db.pm b/lib/calcms/db.pm index f31965c..6d4ee4f 100644 --- a/lib/calcms/db.pm +++ b/lib/calcms/db.pm @@ -150,8 +150,7 @@ sub put($$$) { # deprecated sub quote($$) { - my $dbh = shift; - my $sql = shift; + my ($dbh, $sql) = @_; $sql =~ s/\_/\\\_/g; return $dbh->quote($sql); @@ -159,9 +158,7 @@ sub quote($$) { #subtract hours, deprecated(!) sub shift_date_by_hours($$$) { - my $dbh = shift; - my $date = shift; - my $offset = shift; + my ($dbh, $date, $offset) = @_; my $query = 'select date(? - INTERVAL ? HOUR) date'; my $bind_values = [ $date, $offset ]; @@ -171,9 +168,7 @@ sub shift_date_by_hours($$$) { #add minutes, deprecated(!) sub shift_datetime_by_minutes($$$) { - my $dbh = shift; - my $datetime = shift; - my $offset = shift; + my ($dbh, $datetime, $offset) = @_; my $query = "select ? + INTERVAL ? MINUTE date"; my $bind_values = [ $datetime, $offset ]; diff --git a/lib/calcms/event_history.pm b/lib/calcms/event_history.pm index fec59bb..48fafea 100644 --- a/lib/calcms/event_history.pm +++ b/lib/calcms/event_history.pm @@ -113,8 +113,7 @@ sub insert($$) { # insert event sub insert_by_event_id ($$){ - my $config = shift; - my $options = shift; + my ($config, $options) = @_; return undef unless defined $options->{project_id}; return undef unless defined $options->{studio_id}; diff --git a/lib/calcms/events.pm b/lib/calcms/events.pm index d5c0b77..27171c3 100644 --- a/lib/calcms/events.pm +++ b/lib/calcms/events.pm @@ -482,11 +482,10 @@ sub add_recurrence_dates { } sub calc_dates { - my $config = shift; - my $result = shift; - my $params = shift || {}; - my $previous_result = shift || {}; - my $time_diff = shift || ''; + my ($config, $result, $params, $previous_result, $time_diff) = @_; + $params ||= {}; + $previous_result ||= {}; + $time_diff ||= ''; $result->{utc_offset} = $time_diff; $result->{time_zone} = $config->{date}->{time_zone}; @@ -642,8 +641,7 @@ sub set_listen_key{ sub set_upload_status($$){ my ($config, $event) = @_; - - print STDERR "set upload_status=$event->{upload_status} for ".$event->{event_id}."\n"; + return undef unless defined $event->{event_id}; return undef unless defined $event->{upload_status}; my $bindValues = [ $event->{upload_status}, $event->{event_id}, $event->{upload_status} ]; @@ -1500,9 +1498,7 @@ sub get_by_image ($$$) { # deleting an event is currently disabled sub delete ($$$) { return; - my $request = shift; - my $config = shift; - my $event_id = shift; + my ($request, $config, $event_id) = @_; my $params = $request->{params}->{checked}; my $dbh = db::connect($config); @@ -1523,7 +1519,7 @@ sub delete ($$$) { sub get_duration ($$) { my ($config, $event) = @_; - + my $timezone = $config->{date}->{time_zone}; my $start = time::get_datetime( $event->{start}, $timezone ); my $end = time::get_datetime( $event->{end}, $timezone ); diff --git a/lib/calcms/images.pm b/lib/calcms/images.pm index bb46de1..4df699b 100644 --- a/lib/calcms/images.pm +++ b/lib/calcms/images.pm @@ -19,8 +19,7 @@ my $sql_columns = [ ]; sub get($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; my @cond = (); my $bind_values = []; @@ -99,8 +98,7 @@ sub get($$) { } sub insert_or_update($$) { - my $dbh = shift; - my $image = shift; + my ($dbh, $image) = @_; $image->{name} = 'new' if $image->{name} eq ''; my $entry = get_by_filename( $dbh, $image->{filename} ); @@ -112,8 +110,7 @@ sub insert_or_update($$) { } sub insert ($$) { - my $dbh = shift; - my $image = shift; + my ($dbh, $image) = @_; my @sql_columns = @$sql_columns; @@ -154,8 +151,7 @@ sub insert ($$) { } sub update($$) { - my $dbh = shift; - my $image = shift; + my ($dbh, $image) = @_; unless ( defined $image->{studio_id} ) { print STDERR "missing studio_id at images::update\n"; @@ -213,8 +209,7 @@ sub update($$) { } sub delete($$) { - my $dbh = shift; - my $image = shift; + my ($dbh, $image) = @_; unless ( defined $image->{project_id} ) { print STDERR "missing project_id at images::delete\n"; @@ -252,11 +247,7 @@ sub delete($$) { # deactivated sub delete_files($$$$$) { - my $config = $_[0]; - my $local_media_dir = $_[1]; - my $filename = $_[2]; - my $action_result = $_[3]; - my $errors = $_[4]; + my ($config, $local_media_dir, $filename, $action_result, $errors) = @_; return undef; @@ -320,8 +311,7 @@ sub delete_file ($$$$) { } sub getPath { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; my $dir = $config->{locations}->{local_media_dir}; return undef unless defined $dir; @@ -340,8 +330,7 @@ sub getPath { } sub getInternalPath ($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; my $dir = $config->{locations}->{local_media_dir}; return undef unless defined $dir; @@ -360,14 +349,16 @@ sub getInternalPath ($$) { } sub normalizeName (;$) { - my $name = shift; + my ($name) = @_; + return undef unless defined $name; $name =~ s/.*\///g; return $name; } sub readFile($) { - my $path = shift; + my ($path) = @_; + my $content = ''; print STDERR "read '$path'\n"; @@ -382,8 +373,7 @@ sub readFile($) { } sub writeFile ($$) { - my $path = shift; - my $content = shift; + my ($path, $content) = @_; print STDERR "save '$path'\n"; open my $fh, '> :raw', $path or return { error => 'could not save image. ' . $! . " $path" }; @@ -394,7 +384,8 @@ sub writeFile ($$) { } sub deleteFile($) { - my $path = shift; + my ($path) = @_; + return { error => "source '$path' does not exist" } unless -e $path; #unlink $path; @@ -403,9 +394,7 @@ sub deleteFile($) { } sub copyFile ($$$) { - my $source = shift; - my $target = shift; - my $errors = shift; + my ($source, $target, $errors) = @_; my $read = images::readFile($source); return $read if defined $read->{error}; @@ -415,8 +404,7 @@ sub copyFile ($$$) { } sub publish($$) { - my $config = shift; - my $filename = shift; + my ($config, $filename) = @_; print STDERR "publish\n"; return undef unless defined $config; @@ -435,8 +423,7 @@ sub publish($$) { } sub depublish ($$) { - my $config = shift; - my $filename = shift; + my ($config, $filename) = @_; print STDERR "depublish\n"; return undef unless defined $config; @@ -468,8 +455,7 @@ sub checkLicence ($$) { } sub setEventLabels($$) { - my $dbh = shift; - my $image = shift; + my ($dbh, $image) = @_; unless ( defined $image->{project_id} ) { print STDERR "missing project_id at images::setEventLabels\n"; @@ -495,8 +481,7 @@ sub setEventLabels($$) { } sub setSeriesLabels($$) { - my $dbh = shift; - my $image = shift; + my ($dbh, $image) = @_; unless ( defined $image->{project_id} ) { print STDERR "missing project_id at images::setSeriesLabels\n"; diff --git a/lib/calcms/localization.pm b/lib/calcms/localization.pm index 74f277d..760cc5f 100644 --- a/lib/calcms/localization.pm +++ b/lib/calcms/localization.pm @@ -17,8 +17,7 @@ our @EXPORT_OK = qw(get getJavascript); # user : get from user settings # loc : add to existing localization, optional sub get($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; #get pot file unless ( defined $options->{file} ) { @@ -63,8 +62,7 @@ sub get($$) { } sub read_po_file($$) { - my $po_file = shift; - my $loc = shift; + my ($po_file, $loc) = @_; unless ( -e $po_file ) { print STDERR "po file $po_file does not exist\n"; @@ -99,7 +97,7 @@ sub read_po_file($$) { } sub getJavascript ($){ - my $loc = shift; + my ($loc) = @_; my $out = '
| live preproduction playout + + + + +
Warning
no recipient configured at series!
Warning
no recipient configured at series!
Subject
To
From
Cc
Reply-To
Content