[Koha-patches] [PATCH] Bug 5453 Do not declare variables in conditionals

Colin Campbell colin.campbell at ptfs-europe.com
Mon Nov 29 11:40:26 CET 2010


Removed occurences in acqui/*.pl
---
 acqui/basketgroup.pl |   16 ++++++----------
 acqui/booksellers.pl |    5 ++++-
 acqui/histsearch.pl  |   14 ++++++++++----
 3 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/acqui/basketgroup.pl b/acqui/basketgroup.pl
index 69de099..8df6b15 100755
--- a/acqui/basketgroup.pl
+++ b/acqui/basketgroup.pl
@@ -301,26 +301,22 @@ if ( $op eq "add" ) {
         # Build the combobox to select the billing place
         my @billingplaceloop;
         for (sort keys %$branches) {
-            my $selected = 1 if $_ eq $billingplace;
-            my %row = (
+            push @billingplaceloop, {
                 value      => $_,
-                selected   => $selected,
+                selected   => $_ eq $billingplace,
                 branchname => $branches->{$_}->{branchname},
-            );
-            push @billingplaceloop, \%row;
+            };
         }
         $template->param( billingplaceloop => \@billingplaceloop );
         
         # Build the combobox to select the delivery place
         my @deliveryplaceloop;
         for (sort keys %$branches) {
-            my $selected = 1 if $_ eq $deliveryplace;
-            my %row = (
+            push @deliveryplaceloop, {
                 value      => $_,
-                selected   => $selected,
+                selected   => $_ eq $deliveryplace,
                 branchname => $branches->{$_}->{branchname},
-            );
-            push @deliveryplaceloop, \%row;
+            };
         }
         $template->param( deliveryplaceloop => \@deliveryplaceloop );
 
diff --git a/acqui/booksellers.pl b/acqui/booksellers.pl
index 7641e68..cffc679 100755
--- a/acqui/booksellers.pl
+++ b/acqui/booksellers.pl
@@ -105,7 +105,10 @@ for ( my $i = 0 ; $i < $count ; $i++ ) {
     $line{name}       = $suppliers[$i]->{'name'};
     $line{active}     = $suppliers[$i]->{'active'};
     my @loop_basket;
-    my $uid = GetMember(borrowernumber => $loggedinuser)->{userid} if $loggedinuser;
+    my $uid = q{}; # initialized as haspermission does not check for undef
+    if ($loggedinuser) {
+        $uid = GetMember(borrowernumber => $loggedinuser)->{userid};
+    }
     for ( my $i2 = 0 ; $i2 < $ordcount ; $i2++ ) {
         if ( $orders->[$i2]{'authorisedby'} eq $loggedinuser || haspermission($uid, { flagsrequired   => { 'acquisition' => '*' } } ) ) {
             my %inner_line;
diff --git a/acqui/histsearch.pl b/acqui/histsearch.pl
index 0190e4a..2c41742 100755
--- a/acqui/histsearch.pl
+++ b/acqui/histsearch.pl
@@ -75,11 +75,17 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     }
 );
 
-my $from_iso = C4::Dates->new($input->param('from'))->output('iso') if $input->param('from');
-my   $to_iso =   C4::Dates->new($input->param('to'))->output('iso') if $input->param('iso');
+my ( $from_iso, $to_iso, $d );
+if ( $d = $input->param('from') ) {
+    $from_iso = C4::Dates->new($d)->output('iso');
+}
+if ( $d = $input->param('iso') ) {
+    $to_iso = C4::Dates->new($d)->output('iso');
+}
+
 my ( $order_loop, $total_qty, $total_price, $total_qtyreceived ) =
-  &GetHistory( $title, $author, $name, $from_iso, $to_iso );
-  
+  GetHistory( $title, $author, $name, $from_iso, $to_iso );
+
 $template->param(
     suggestions_loop        => $order_loop,
     total_qty               => $total_qty,
-- 
1.7.3.2



More information about the Koha-patches mailing list