Bug 9457 - Followup - Ordering branches should be case independent (2)
authorBernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Fri, 15 Mar 2013 20:05:26 +0000 (17:05 -0300)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Wed, 20 Mar 2013 19:36:19 +0000 (15:36 -0400)
This follow up reinstates or add check for undef returned
by C4::Context->userenv, only where previous patch touch
code.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
members/memberentry.pl
opac/opac-suggestions.pl
reports/itemtypes.plugin
reserve/request.pl

index 79f1f93..6b0e846 100755 (executable)
@@ -572,7 +572,11 @@ foreach (keys(%flags)) {
 # in modify mod: userbranch value for GetBranchesLoop() comes from borrowers table
 # in add    mod: userbranch value come from branches table (ip correspondence)
 
-my $userbranch = C4::Context->userenv->{'branch'};
+my $userbranch = '';
+if (C4::Context->userenv && C4::Context->userenv->{'branch'}) {
+    $userbranch = C4::Context->userenv->{'branch'};
+}
+
 if (defined ($data{'branchcode'}) and ( $op eq 'modify' || ( $op eq 'add' && $category_type eq 'C' ) )) {
     $userbranch = $data{'branchcode'};
 }
index 1b353fd..32b5c3d 100755 (executable)
@@ -128,7 +128,11 @@ if ( C4::Context->preference("AllowPurchaseSuggestionBranchChoice") ) {
     my ( $borr ) = GetMemberDetails( $borrowernumber );
 
 # pass the pickup branch along....
-    my $branch = $input->param('branch') || $borr->{'branchcode'} || C4::Context->userenv->{branch} || '' ;
+    my $userbranch = '';
+    if (C4::Context->userenv && C4::Context->userenv->{'branch'}) {
+        $userbranch = C4::Context->userenv->{'branch'};
+    }
+    my $branch = $input->param('branch') || $borr->{'branchcode'} || $userbranch || '' ;
 
 # make branch selection options...
     my $branchloop = GetBranchesLoop($branch);
index 388649f..e4164a5 100755 (executable)
@@ -31,10 +31,13 @@ use C4::Branch; # GetBranches
 =cut
 
 sub set_parameters {
-       my ($template) = @_;
-    my $userbranch = C4::Context->userenv->{'branch'};
-     $template->param( branchloop => GetBranchesLoop($userbranch) );
-       return $template;
+    my ($template) = @_;
+    my $userbranch = '';
+    if (C4::Context->userenv && C4::Context->userenv->{'branch'}) {
+        $userbranch = C4::Context->userenv->{'branch'};
+    }
+    $template->param( branchloop => GetBranchesLoop($userbranch) );
+    return $template;
 }
 
 sub calculate {
index f8e26a2..5bcaca2 100755 (executable)
@@ -65,7 +65,11 @@ my $showallitems = $input->param('showallitems');
 my $branches = GetBranches();
 my $itemtypes = GetItemTypes();
 
-my $userbranch = C4::Context->userenv->{branch};
+my $userbranch = '';
+if (C4::Context->userenv && C4::Context->userenv->{'branch'}) {
+    $userbranch = C4::Context->userenv->{'branch'};
+}
+
 
 # Select borrowers infos
 my $findborrower = $input->param('findborrower');