BUG 12304: LDAP auto-provisioning set default messaging preferences
[koha_fer] / serials / member-search.pl
index f18c2f3..4fa88a0 100755 (executable)
@@ -1,5 +1,7 @@
 #!/usr/bin/perl
 
+# Parts copyright Catalyst IT 2010
+#
 # This file is part of Koha.
 #
 # Koha is free software; you can redistribute it and/or modify it under the
@@ -80,10 +82,13 @@ if (defined $member) {
 
 my ($count,$results);
 
-if (C4::Context->preference("IndependantBranches")){
-   if (C4::Context->userenv && C4::Context->userenv->{flags} % 2 !=1 && C4::Context->userenv->{'branch'}){
-        $$patron{branchcode}=C4::Context->userenv->{'branch'} unless (C4::Context->userenv->{'branch'} eq "insecure");
-   }
+if ( C4::Context->preference("IndependentBranches") ) {
+    if (   C4::Context->userenv
+        && !C4::Context->IsSuperLibrarian()
+        && C4::Context->userenv->{'branch'} )
+    {
+        $$patron{branchcode} = C4::Context->userenv->{'branch'};
+    }
 }
 $$patron{firstname}.="\%" if ($$patron{firstname});
 $$patron{surname}.="\%" if ($$patron{surname});
@@ -110,18 +115,20 @@ my @resultsdata;
 $to=($count>$to?$to:$count);
 my $index=$from;
 foreach my $borrower(@$results[$from..$to-1]){
-  #find out stats
-
-  $$borrower{'dateexpiry'}= C4::Dates->new($$borrower{'dateexpiry'},'iso')->output('syspref');
-
-  my %row = (
-    count => $index++,
-       %$borrower,
-       %{$categories_dislay{$$borrower{categorycode}}},
-    );
-  push(@resultsdata, \%row);
+    # find out stats
+    $borrower->{'dateexpiry'}= C4::Dates->new($borrower->{'dateexpiry'},'iso')->output('syspref');
+    if ($categories_dislay{$borrower->{'categorycode'}}){
+        my %row = (
+           count => $index++,
+           %$borrower,
+           %{$categories_dislay{$$borrower{categorycode}}},
+       );
+       push(@resultsdata, \%row);
+    }
+    else {
+        warn $borrower->{'cardnumber'} ." has a bad category code of " . $borrower->{'categorycode'} ."\n";
+    }
 }
-
 if ($$patron{branchcode}){
        foreach my $branch (grep{$_->{value} eq $$patron{branchcode}}@$branches){
                $$branch{selected}=1;