From 4b1030ae29193dfe0ff06a55db8341df1e494002 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 21 May 2013 08:43:41 -0700 Subject: [PATCH] bug 8215: (followup) run new files through perltidy Signed-off-by: Galen Charlton --- C4/CourseReserves.pm | 76 +++++++++++------------------- Koha/Template/Plugin/AuthorisedValues.pm | 2 +- Koha/Template/Plugin/Branches.pm | 2 +- Koha/Template/Plugin/ItemTypes.pm | 2 +- course_reserves/add_items.pl | 11 ++-- course_reserves/course-details.pl | 5 +- course_reserves/course.pl | 5 +- course_reserves/mod_course.pl | 11 ++--- opac/opac-course-details.pl | 9 ++-- opac/opac-course-reserves.pl | 5 +- 10 files changed, 49 insertions(+), 79 deletions(-) diff --git a/C4/CourseReserves.pm b/C4/CourseReserves.pm index 4737536..35fe269 100644 --- a/C4/CourseReserves.pm +++ b/C4/CourseReserves.pm @@ -241,7 +241,7 @@ sub EnableOrDisableCourseItems { warn identify_myself(%params) if $DEBUG; my $course_id = $params{'course_id'}; - my $enabled = $params{'enabled'} || 0; + my $enabled = $params{'enabled'} || 0; my $lookfor = ( $enabled eq 'yes' ) ? 'no' : 'yes'; @@ -252,13 +252,11 @@ sub EnableOrDisableCourseItems { if ( $enabled eq 'yes' ) { foreach my $course_reserve (@$course_reserves) { - if ( - CountCourseReservesForItem( + if (CountCourseReservesForItem( ci_id => $course_reserve->{'ci_id'}, enabled => 'yes' ) - ) - { + ) { EnableOrDisableCourseItem( ci_id => $course_reserve->{'ci_id'}, enabled => 'yes', @@ -273,8 +271,7 @@ sub EnableOrDisableCourseItems { ci_id => $course_reserve->{'ci_id'}, enabled => 'yes' ) - ) - { + ) { EnableOrDisableCourseItem( ci_id => $course_reserve->{'ci_id'}, enabled => 'no', @@ -376,7 +373,7 @@ sub ModCourseInstructors { return unless ( $cardnumbers || $borrowernumbers ); return if ( $cardnumbers && $borrowernumbers ); - my (@cardnumbers, @borrowernumbers); + my ( @cardnumbers, @borrowernumbers ); @cardnumbers = @$cardnumbers if ( ref($cardnumbers) eq 'ARRAY' ); @borrowernumbers = @$borrowernumbers if ( ref($borrowernumbers) eq 'ARRAY' ); @@ -387,8 +384,7 @@ sub ModCourseInstructors { my $dbh = C4::Context->dbh; - $dbh->do( "DELETE FROM course_instructors WHERE course_id = ?", - undef, $course_id ) + $dbh->do( "DELETE FROM course_instructors WHERE course_id = ?", undef, $course_id ) if ( $mode eq 'replace' ); my $query; @@ -400,8 +396,7 @@ sub ModCourseInstructors { FROM borrowers WHERE $field IN ( $placeholders ) "; - } - else { + } else { $query = " DELETE FROM course_instructors WHERE course_id = ? @@ -485,8 +480,7 @@ sub ModCourseItem { course_item => $course_item, %params ); - } - else { + } else { $ci_id = _AddCourseItem(%params); } @@ -570,8 +564,7 @@ sub _UpdateCourseItem { foreach (@FIELDS) { if ( $params{$_} && $course_item->{$_} - && $params{$_} ne $course_item->{$_} ) - { + && $params{$_} ne $course_item->{$_} ) { $mod_params{$_} = $params{$_}; } } @@ -618,10 +611,7 @@ sub _ModStoredFields { } } - my $query = - "UPDATE course_items SET " - . join( ',', map { "$_=?" } @fields_to_update ) - . " WHERE ci_id = ?"; + my $query = "UPDATE course_items SET " . join( ',', map { "$_=?" } @fields_to_update ) . " WHERE ci_id = ?"; C4::Context->dbh->do( $query, undef, @values_to_update, $params{'ci_id'} ) if (@values_to_update); @@ -660,10 +650,7 @@ sub _RevertFields { } ModItem( $mod_item_params, undef, $course_item->{'itemnumber'} ); - my $query = - "UPDATE course_items SET " - . join( ',', map { "$_=NULL" } @fields_to_null ) - . " WHERE ci_id = ?"; + my $query = "UPDATE course_items SET " . join( ',', map { "$_=NULL" } @fields_to_null ) . " WHERE ci_id = ?"; C4::Context->dbh->do( $query, undef, $ci_id ) if (@fields_to_null); } @@ -785,8 +772,7 @@ sub GetCourseReserve { "; $sth = $dbh->prepare($query); $sth->execute($cr_id); - } - else { + } else { my $query = " SELECT * FROM course_reserves WHERE course_id = ? AND ci_id = ? @@ -816,8 +802,7 @@ sub ModCourseReserve { return unless ( $course_id && $ci_id ); - my $course_reserve = - GetCourseReserve( course_id => $course_id, ci_id => $ci_id ); + my $course_reserve = GetCourseReserve( course_id => $course_id, ci_id => $ci_id ); my $cr_id; my $dbh = C4::Context->dbh; @@ -831,8 +816,7 @@ sub ModCourseReserve { WHERE cr_id = ? "; $dbh->do( $query, undef, $staff_note, $public_note, $cr_id ); - } - else { + } else { my $query = " INSERT INTO course_reserves SET course_id = ?, @@ -840,10 +824,8 @@ sub ModCourseReserve { staff_note = ?, public_note = ? "; - $dbh->do( $query, undef, $course_id, $ci_id, $staff_note, - $public_note ); - $cr_id = - $dbh->last_insert_id( undef, undef, 'course_reserves', 'cr_id' ); + $dbh->do( $query, undef, $course_id, $ci_id, $staff_note, $public_note ); + $cr_id = $dbh->last_insert_id( undef, undef, 'course_reserves', 'cr_id' ); } my $course = GetCourse($course_id); @@ -872,10 +854,10 @@ sub GetCourseReserves { my (%params) = @_; warn identify_myself(%params) if $DEBUG; - my $course_id = $params{'course_id'}; - my $ci_id = $params{'ci_id'}; - my $include_items = $params{'include_items'}; - my $include_count = $params{'include_count'}; + my $course_id = $params{'course_id'}; + my $ci_id = $params{'ci_id'}; + my $include_items = $params{'include_items'}; + my $include_count = $params{'include_count'}; my $include_courses = $params{'include_courses'}; return unless ( $course_id || $ci_id ); @@ -898,22 +880,20 @@ sub GetCourseReserves { if ($include_items) { foreach my $cr (@$course_reserves) { $cr->{'course_item'} = GetCourseItem( ci_id => $cr->{'ci_id'} ); - $cr->{'item'} = GetBiblioFromItemNumber( $cr->{'itemnumber'} ); - $cr->{'issue'} = GetOpenIssue( $cr->{'itemnumber'} ); + $cr->{'item'} = GetBiblioFromItemNumber( $cr->{'itemnumber'} ); + $cr->{'issue'} = GetOpenIssue( $cr->{'itemnumber'} ); } } if ($include_count) { foreach my $cr (@$course_reserves) { - $cr->{'reserves_count'} = - CountCourseReservesForItem( ci_id => $cr->{'ci_id'} ); + $cr->{'reserves_count'} = CountCourseReservesForItem( ci_id => $cr->{'ci_id'} ); } } if ($include_courses) { foreach my $cr (@$course_reserves) { - $cr->{'courses'} = - GetCourses( itemnumber => $cr->{'itemnumber'} ); + $cr->{'courses'} = GetCourses( itemnumber => $cr->{'itemnumber'} ); } } @@ -946,8 +926,7 @@ sub DelCourseReserve { ## If there are no other course reserves for this item ## delete the course_item as well - unless ( CountCourseReservesForItem( ci_id => $course_reserve->{'ci_id'} ) ) - { + unless ( CountCourseReservesForItem( ci_id => $course_reserve->{'ci_id'} ) ) { DelCourseItem( ci_id => $course_reserve->{'ci_id'} ); } @@ -1007,8 +986,7 @@ sub CountCourseReservesForItem { return unless ( $ci_id || $itemnumber ); - my $course_item = - GetCourseItem( ci_id => $ci_id, itemnumber => $itemnumber ); + my $course_item = GetCourseItem( ci_id => $ci_id, itemnumber => $itemnumber ); my @params = ( $course_item->{'ci_id'} ); push( @params, $enabled ) if ($enabled); @@ -1082,7 +1060,7 @@ sub SearchCourses { my $dbh = C4::Context->dbh; my $sth = $dbh->prepare($query); - $sth->execute(@params, $enabled); + $sth->execute( @params, $enabled ); my $courses = $sth->fetchall_arrayref( {} ); diff --git a/Koha/Template/Plugin/AuthorisedValues.pm b/Koha/Template/Plugin/AuthorisedValues.pm index 9df3f2e..683a0ff 100644 --- a/Koha/Template/Plugin/AuthorisedValues.pm +++ b/Koha/Template/Plugin/AuthorisedValues.pm @@ -28,7 +28,7 @@ use C4::Koha; sub GetByCode { my ( $self, $category, $code, $opac ) = @_; - return encode('UTF-8', GetAuthorisedValueByCode( $category, $code, $opac ) ); + return encode( 'UTF-8', GetAuthorisedValueByCode( $category, $code, $opac ) ); } 1; diff --git a/Koha/Template/Plugin/Branches.pm b/Koha/Template/Plugin/Branches.pm index e201ff7..e9ff105 100644 --- a/Koha/Template/Plugin/Branches.pm +++ b/Koha/Template/Plugin/Branches.pm @@ -32,7 +32,7 @@ sub GetName { my $sth = C4::Context->dbh->prepare($query); $sth->execute($branchcode); my $b = $sth->fetchrow_hashref(); - return encode('UTF-8', $b->{'branchname'}); + return encode( 'UTF-8', $b->{'branchname'} ); } 1; diff --git a/Koha/Template/Plugin/ItemTypes.pm b/Koha/Template/Plugin/ItemTypes.pm index abccbf4..f0edbc8 100644 --- a/Koha/Template/Plugin/ItemTypes.pm +++ b/Koha/Template/Plugin/ItemTypes.pm @@ -32,7 +32,7 @@ sub GetDescription { my $sth = C4::Context->dbh->prepare($query); $sth->execute($itemtype); my $d = $sth->fetchrow_hashref(); - return encode('UTF-8', $d->{'description'}); + return encode( 'UTF-8', $d->{'description'} ); } diff --git a/course_reserves/add_items.pl b/course_reserves/add_items.pl index bb770a3..c94f373 100755 --- a/course_reserves/add_items.pl +++ b/course_reserves/add_items.pl @@ -40,10 +40,9 @@ my $item = GetBiblioFromItemNumber( undef, $barcode ); my $step = ( $action eq 'lookup' && $item ) ? '2' : '1'; -my $tmpl = ( $course_id ) ? "add_items-step$step.tt" : "invalid-course.tt"; +my $tmpl = ($course_id) ? "add_items-step$step.tt" : "invalid-course.tt"; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { - template_name => "course_reserves/$tmpl", + { template_name => "course_reserves/$tmpl", query => $cgi, type => "intranet", authnotrequired => 0, @@ -57,7 +56,8 @@ $template->param( course => GetCourse($course_id) ); if ( $action eq 'lookup' ) { my $course_item = GetCourseItem( itemnumber => $item->{'itemnumber'} ); - my $course_reserve = ($course_item) + my $course_reserve = + ($course_item) ? GetCourseReserve( course_id => $course_id, ci_id => $course_item->{'ci_id'} @@ -75,8 +75,7 @@ if ( $action eq 'lookup' ) { branches => GetBranchesLoop(), ); -} -elsif ( $action eq 'add' ) { +} elsif ( $action eq 'add' ) { my $ci_id = ModCourseItem( itemnumber => $cgi->param('itemnumber'), itype => $cgi->param('itype'), diff --git a/course_reserves/course-details.pl b/course_reserves/course-details.pl index e1440f1..bc224d4 100755 --- a/course_reserves/course-details.pl +++ b/course_reserves/course-details.pl @@ -36,10 +36,9 @@ my $course_id = $cgi->param('course_id'); my $flagsrequired; $flagsrequired->{coursereserves} = 'delete_reserves' if ( $action eq 'del_reserve' ); -my $tmpl = ( $course_id ) ? "course-details.tt" : "invalid-course.tt"; +my $tmpl = ($course_id) ? "course-details.tt" : "invalid-course.tt"; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { - template_name => "course_reserves/$tmpl", + { template_name => "course_reserves/$tmpl", query => $cgi, type => "intranet", authnotrequired => 0, diff --git a/course_reserves/course.pl b/course_reserves/course.pl index 1a3d4a4..fad7bad 100755 --- a/course_reserves/course.pl +++ b/course_reserves/course.pl @@ -31,8 +31,7 @@ use C4::CourseReserves; my $cgi = new CGI; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { - template_name => "course_reserves/course.tt", + { template_name => "course_reserves/course.tt", query => $cgi, type => "intranet", authnotrequired => 0, @@ -49,7 +48,7 @@ if ($course_id) { $template->param( departments => GetAuthorisedValues('DEPARTMENT'), - terms => GetAuthorisedValues('TERM'), + terms => GetAuthorisedValues('TERM'), ); output_html_with_http_headers $cgi, $cookie, $template->output; diff --git a/course_reserves/mod_course.pl b/course_reserves/mod_course.pl index 0df85f3..0ff6d74 100755 --- a/course_reserves/mod_course.pl +++ b/course_reserves/mod_course.pl @@ -29,8 +29,7 @@ use C4::CourseReserves; my $cgi = new CGI; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { - template_name => "about.tmpl", + { template_name => "about.tmpl", query => $cgi, type => "intranet", authnotrequired => 0, @@ -43,8 +42,7 @@ my $action = $cgi->param('action'); if ( $action eq 'del' ) { DelCourse( $cgi->param('course_id') ); print $cgi->redirect("/cgi-bin/koha/course_reserves/course-reserves.pl"); -} -else { +} else { my %params; $params{'course_id'} = $cgi->param('course_id') @@ -57,7 +55,7 @@ else { $params{'staff_note'} = $cgi->param('staff_note'); $params{'public_note'} = $cgi->param('public_note'); $params{'students_count'} = $cgi->param('students_count'); - $params{'enabled'} = ( $cgi->param('enabled') eq 'on' ) ? 'yes' : 'no'; + $params{'enabled'} = ( $cgi->param('enabled') eq 'on' ) ? 'yes' : 'no'; my $course_id = ModCourse(%params); @@ -67,6 +65,5 @@ else { cardnumbers => \@instructors, course_id => $course_id ); - print $cgi->redirect( - "/cgi-bin/koha/course_reserves/course-details.pl?course_id=$course_id"); + print $cgi->redirect("/cgi-bin/koha/course_reserves/course-details.pl?course_id=$course_id"); } diff --git a/opac/opac-course-details.pl b/opac/opac-course-details.pl index ee505c9..0787315 100755 --- a/opac/opac-course-details.pl +++ b/opac/opac-course-details.pl @@ -31,8 +31,7 @@ use C4::CourseReserves; my $cgi = new CGI; my ( $template, $borrowernumber, $cookie ) = get_template_and_user( - { - template_name => "opac-course-details.tmpl", + { template_name => "opac-course-details.tmpl", query => $cgi, type => "opac", authnotrequired => 1, @@ -43,17 +42,17 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( my $action = $cgi->param('action') || ''; my $course_id = $cgi->param('course_id'); -die( "No course_id given" ) unless ( $course_id ); +die("No course_id given") unless ($course_id); if ( $action eq 'del_reserve' ) { DelCourseReserve( cr_id => $cgi->param('cr_id') ); } -my $course = GetCourse( $course_id ); +my $course = GetCourse($course_id); my $course_reserves = GetCourseReserves( course_id => $course_id, include_items => 1, include_count => 1 ); $template->param( - course => $course, + course => $course, course_reserves => $course_reserves, ); diff --git a/opac/opac-course-reserves.pl b/opac/opac-course-reserves.pl index 60f8f15..cc94c4c 100755 --- a/opac/opac-course-reserves.pl +++ b/opac/opac-course-reserves.pl @@ -30,8 +30,7 @@ use C4::CourseReserves; my $cgi = new CGI; my ( $template, $borrowernumber, $cookie ) = get_template_and_user( - { - template_name => "opac-course-reserves.tmpl", + { template_name => "opac-course-reserves.tmpl", query => $cgi, type => "opac", authnotrequired => 1, @@ -44,7 +43,7 @@ my $search_on = $cgi->param('search_on'); my $courses = SearchCourses( term => $search_on, enabled => 'yes' ); if ( @$courses == 1 ) { - print $cgi->redirect("/cgi-bin/koha/opac-course-details.pl?course_id=" . $courses->[0]->{'course_id'}); + print $cgi->redirect( "/cgi-bin/koha/opac-course-details.pl?course_id=" . $courses->[0]->{'course_id'} ); } else { $template->param( courses => $courses ); output_html_with_http_headers $cgi, $cookie, $template->output; -- 1.7.2.5