From ea9590f6dcf09d676c2e4f311d4d47514c8c3d62 Mon Sep 17 00:00:00 2001 From: Milan Date: Sat, 7 Mar 2020 23:18:42 +0100 Subject: [PATCH] remove brackets from conditions that are not needed --- lib/calcms/aggregator.pm | 2 +- lib/calcms/creole_wiki.pm | 6 +++--- lib/calcms/events.pm | 2 +- lib/calcms/localization.pm | 2 +- lib/calcms/roles.pm | 2 +- lib/calcms/series.pm | 12 ++++++------ website/agenda/planung/comment.cgi | 2 +- website/agenda/planung/image-upload.cgi | 2 +- website/agenda/planung/roles.cgi | 6 ++---- website/agenda/planung/series.cgi | 2 +- website/agenda/planung/studio-timeslots.cgi | 4 ++-- website/agenda/planung/users.cgi | 4 ++-- website/agenda/planung/work-time.cgi | 2 +- 13 files changed, 23 insertions(+), 25 deletions(-) diff --git a/lib/calcms/aggregator.pm b/lib/calcms/aggregator.pm index e61b421..3a8113e 100644 --- a/lib/calcms/aggregator.pm +++ b/lib/calcms/aggregator.pm @@ -103,7 +103,7 @@ sub get_calendar($$$) { my $debug = $config->{system}->{debug}; $request->{params}->{original}->{template} = 'calendar.html'; - $request->{params}->{original}->{date} = $date if ( defined $date ); + $request->{params}->{original}->{date} = $date if defined $date; $request->{params}->{checked} = calendar::check_params( $config, $request->{params}->{original} ); $params = $request->{params}->{checked}; diff --git a/lib/calcms/creole_wiki.pm b/lib/calcms/creole_wiki.pm index 1dfb2d7..ea50f08 100644 --- a/lib/calcms/creole_wiki.pm +++ b/lib/calcms/creole_wiki.pm @@ -71,14 +71,14 @@ sub extractEventFromWikiText($;$) { $category =~ s/\s+/ /g; $category =~ s/^\s+|\s+$//g; $category =~ s/\&/\+/g; - push @categories, $category if ( defined $category && $category =~ /\S/ ); + push @categories, $category if defined $category && $category =~ /\S/; $category = ''; $category = $2 if ( defined $2 ); $category =~ s/\s+/ /g; $category =~ s/^\s+|\s+$//g; $category =~ s/\&/\+/g; - push @categories, $category if ( defined $category && $category =~ /\S/ ); + push @categories, $category if defined $category && $category =~ /\S/; $title =~ s/\((.*?),(.*?)\)/\($2\)/; } if ( $title =~ /\((.*?)\)/ ) { @@ -87,7 +87,7 @@ sub extractEventFromWikiText($;$) { $category =~ s/^\s+|\s+$//g; $category =~ s/\&/\+/g; - push @categories, $category if ( defined $category && $category =~ /\S/ ); + push @categories, $category if defined $category && $category =~ /\S/; $title =~ s/\((.*?)\)//; } $event->{categories} = \@categories if ( @categories > 0 ); diff --git a/lib/calcms/events.pm b/lib/calcms/events.pm index 1b82878..8984926 100644 --- a/lib/calcms/events.pm +++ b/lib/calcms/events.pm @@ -371,7 +371,7 @@ sub modify_results ($$$$) { ) { for my $key ( keys %$result ) { - $result->{$key} =~ s/\|/\\\|/g if ( defined $result->{$key} ); + $result->{$key} =~ s/\|/\\\|/g if defined $result->{$key}; } # $result->{content}='no'; diff --git a/lib/calcms/localization.pm b/lib/calcms/localization.pm index c89a5f0..484674b 100644 --- a/lib/calcms/localization.pm +++ b/lib/calcms/localization.pm @@ -31,7 +31,7 @@ sub get($$) { my $language = undef; #get language from options - $language = $options->{language} if ( defined $options->{language} ); + $language = $options->{language} if defined $options->{language}; #get language from user if ( ( !( defined $language ) ) && ( defined $options->{user} ) ) { diff --git a/lib/calcms/roles.pm b/lib/calcms/roles.pm index aaf4f96..5572786 100644 --- a/lib/calcms/roles.pm +++ b/lib/calcms/roles.pm @@ -107,7 +107,7 @@ sub get_user($) { my $user = $ENV{REMOTE_USER}; my $users = $config->{users}; - return $user if ( defined $users->{$user} ); + return $user if defined $users->{$user}; return 'nobody'; } diff --git a/lib/calcms/series.pm b/lib/calcms/series.pm index eb43883..6840810 100644 --- a/lib/calcms/series.pm +++ b/lib/calcms/series.pm @@ -426,12 +426,12 @@ sub search_events ($$$) { template => 'no' }; if ( defined $options ) { - $params->{from_date} = $options->{from_date} if ( defined $options->{from_date} ); - $params->{till_date} = $options->{till_date} if ( defined $options->{till_date} ); - $params->{location} = $options->{location} if ( defined $options->{location} ); - $params->{limit} = $options->{limit} if ( defined $options->{limit} ); - $params->{archive} = $options->{archive} if ( defined $options->{archive} ); - $params->{get} = $options->{get} if ( defined $options->{get} ); + $params->{from_date} = $options->{from_date} if defined $options->{from_date}; + $params->{till_date} = $options->{till_date} if defined $options->{till_date}; + $params->{location} = $options->{location} if defined $options->{location}; + $params->{limit} = $options->{limit} if defined $options->{limit}; + $params->{archive} = $options->{archive} if defined $options->{archive}; + $params->{get} = $options->{get} if defined $options->{get}; } my $checked_params = events::check_params( $config, $params ); diff --git a/website/agenda/planung/comment.cgi b/website/agenda/planung/comment.cgi index 31afeb0..809b250 100755 --- a/website/agenda/planung/comment.cgi +++ b/website/agenda/planung/comment.cgi @@ -138,7 +138,7 @@ sub showComments { my $language = $config->{date}->{language} || 'en'; for my $event (@$events) { $event->{start} = time::date_time_format( $config, $event->{start}, $language ); - $comment_count += $event->{comment_count} if ( defined $event->{comment_count} ); + $comment_count += $event->{comment_count} if defined $event->{comment_count}; $event->{cache_base_url} = $config->{cache}->{base_url}; } } diff --git a/website/agenda/planung/image-upload.cgi b/website/agenda/planung/image-upload.cgi index b5cefe6..6af5886 100755 --- a/website/agenda/planung/image-upload.cgi +++ b/website/agenda/planung/image-upload.cgi @@ -69,7 +69,7 @@ if ( defined $r ) { if ( $status =~ /limit/i ) { $error = $status; } else { - $upload = $apr->upload('image') if ( defined $params->{image} ); + $upload = $apr->upload('image') if defined $params->{image}; } print STDERR "apr\n"; } else { diff --git a/website/agenda/planung/roles.cgi b/website/agenda/planung/roles.cgi index 11a21e1..04ab17c 100755 --- a/website/agenda/planung/roles.cgi +++ b/website/agenda/planung/roles.cgi @@ -366,7 +366,7 @@ sub show_roles { $out .= qq{}; } $out .= ''; - $out .= '' if ( defined $permissions->{update_role} ); + $out .= '' if defined $permissions->{update_role}; $out .= ''; $out .= ''; print $out. "\n"; @@ -383,10 +383,8 @@ sub sort_columns { my $action = shift @words; my $group = join( ' ', @words ); - #print "action:'$action' group:'$group'
\n"; - my $index = $groups->{$group} || 0; - $index += $actions->{$action} if ( defined $actions->{$action} ); + $index += $actions->{$action} if defined $actions->{$action}; $column_level->{$column} = $index; # print $index."
"; diff --git a/website/agenda/planung/series.cgi b/website/agenda/planung/series.cgi index 2f8a1a1..a8beedc 100755 --- a/website/agenda/planung/series.cgi +++ b/website/agenda/planung/series.cgi @@ -148,7 +148,7 @@ sub save_schedule { 'nextDay' ) { - $entry->{$attr} = $params->{$attr} if ( defined $params->{$attr} ); + $entry->{$attr} = $params->{$attr} if defined $params->{$attr}; } unless ( project::is_series_assigned( $config, $entry ) == 1 ) { diff --git a/website/agenda/planung/studio-timeslots.cgi b/website/agenda/planung/studio-timeslots.cgi index d171ad9..834918a 100755 --- a/website/agenda/planung/studio-timeslots.cgi +++ b/website/agenda/planung/studio-timeslots.cgi @@ -119,11 +119,11 @@ sub save_schedule { my $entry = {}; for my $attr ( 'project_id', 'start', 'end', 'end_date', 'frequency' ) { - $entry->{$attr} = $params->{$attr} if ( defined $params->{$attr} ); + $entry->{$attr} = $params->{$attr} if defined $params->{$attr}; } #set schedule's studio to value from schedule_studio_id - $entry->{studio_id} = $params->{schedule_studio_id} if ( defined $params->{schedule_studio_id} ); + $entry->{studio_id} = $params->{schedule_studio_id} if defined $params->{schedule_studio_id}; if ( ( $entry->{end} ne '' ) && ( $entry->{end} le $entry->{start} ) ) { uac::print_error('start date should be before end date!'); diff --git a/website/agenda/planung/users.cgi b/website/agenda/planung/users.cgi index 0066cd3..0abcbb2 100755 --- a/website/agenda/planung/users.cgi +++ b/website/agenda/planung/users.cgi @@ -327,7 +327,7 @@ sub update_user_roles { my $message = "remove role '$role->{role}' (level $role->{level}) from user $user_id (level $max_user_level) for studio_id=$studio_id, project_id=$project_id. Your level is $max_level"; my $update = 0; - $update = 1 if ( defined $permissions->{is_admin} ); + $update = 1 if defined $permissions->{is_admin}; $update = 1 if ( ( $role_by_id->{ $user_role->{role_id} }->{level} < $max_level ) && ( $max_user_level < $max_level ) ); @@ -365,7 +365,7 @@ sub update_user_roles { # print "user role id: $role->{id}
\n"; my $update = 0; - $update = 1 if ( defined $permissions->{is_admin} ); + $update = 1 if defined $permissions->{is_admin}; $update = 1 if ( ( $role_by_id->{ $role->{id} }->{level} < $max_level ) && ( $max_user_level < $max_level ) ); diff --git a/website/agenda/planung/work-time.cgi b/website/agenda/planung/work-time.cgi index b8119f8..3776558 100755 --- a/website/agenda/planung/work-time.cgi +++ b/website/agenda/planung/work-time.cgi @@ -94,7 +94,7 @@ sub save_schedule { 'type' ) { - $entry->{$attr} = $params->{$attr} if ( defined $params->{$attr} ); + $entry->{$attr} = $params->{$attr} if defined $params->{$attr}; } my $found = 0;