SearchMyLibraryFirst : reintroducing behaviour (from 2.2)
authorPaul POULAIN <paul@koha-fr.org>
Tue, 16 Oct 2007 21:02:45 +0000 (16:02 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Wed, 17 Oct 2007 12:15:06 +0000 (07:15 -0500)
If the SearchMyLibraryFirst is set, then a logged user will automatically limit the search
to it's own library.

I also did some code cleaning

Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/Auth.pm
koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc
opac/opac-main.pl

index 6d792ea..0d4e825 100755 (executable)
@@ -260,7 +260,7 @@ sub get_template_and_user {
         );
     }
     else {
-               warn "template type should be OPAC, here it is=[" . $in->{'type'} . "]" unless ( $in->{'type'} eq 'opac' );
+        warn "template type should be OPAC, here it is=[" . $in->{'type'} . "]" unless ( $in->{'type'} eq 'opac' );
         my $LibraryNameTitle = C4::Context->preference("LibraryName");
         $LibraryNameTitle =~ s/<(?:\/?)(?:br|p)\s*(?:\/?)>/ /sgi;
         $LibraryNameTitle =~ s/<(?:[^<>'"]|'(?:[^']*)'|"(?:[^"]*)")*>//sg;
@@ -297,6 +297,7 @@ sub get_template_and_user {
             reviewson              => C4::Context->preference("reviewson"),
             hide_marc              => C4::Context->preference("hide_marc"),
             patronimages           => C4::Context->preference("patronimages"),
+            mylibraryfirst   => C4::Context->preference("SearchMyLibraryFirst"),
             "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
         );
     }
index b375e2c..1d4408b 100644 (file)
 </div>
 <div id="opac-main-search">
     Search
+    <!-- TMPL_IF name="mylibraryfirst" --> <!-- TMPL_IF name="loggedinusername" -->(in <!-- TMPL_VAR name="LoginBranchcode" --> only)<!-- /TMPL_IF --><!-- /TMPL_IF -->
     <form name="searchform" method="post" action="/cgi-bin/koha/opac-search.pl" id="searchform">
-        <input type="text" name="q" style="width: 30%;"/>
+        <input type="text" name="q" style="width: 30%;" />
+        <!-- TMPL_IF name="mylibraryfirst" --><!-- TMPL_IF name="loggedinusername" -->
+            <input name="limit" value="<!-- TMPL_VAR name="LoginBranchcode" -->" type="hidden" />
+        <!-- /TMPL_IF --><!-- /TMPL_IF -->
         <input type="submit" value="OK" class="submit" />
     </form>
     <a href="/cgi-bin/koha/opac-search.pl">more search options</a>
index 0a548a9..dfaf06d 100755 (executable)
@@ -32,8 +32,6 @@ use C4::Acquisition;     # GetRecentAcqui
 my $input = new CGI;
 my $dbh   = C4::Context->dbh;
 
-my $limit = $input->param('recentacqui');
-
 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
     {
         template_name   => "opac-main.tmpl",
@@ -44,42 +42,6 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
     }
 );
 
-if ($limit) {
-    my $recentacquiloop = GetRecentAcqui($limit);
-
-    #     warn Data::Dumper::Dumper($recentacquiloop);
-    $template->param( recentacquiloop => $recentacquiloop, );
-}
-
-# SearchMyLibraryFirst
-if ( C4::Context->preference("SearchMyLibraryFirst") ) {
-    if ( C4::Context->userenv ) {
-        my $branches = GetBranches();
-        my @branchloop;
-
-        foreach my $thisbranch (sort keys %$branches ) {
-            my $selected = 1
-              if ( C4::Context->userenv
-                && ( $thisbranch eq C4::Context->userenv->{branch} ) );
-
-#         warn $thisbranch;
-#         warn C4::Context->userenv;
-#         warn C4::Context->userenv->{branch};
-#         warn " => ".C4::Context->userenv && ($thisbranch eq C4::Context->userenv->{branch});
-            my %row = (
-                value      => $thisbranch,
-                selected   => $selected,
-                branchname => $branches->{$thisbranch}->{'branchname'},
-            );
-            push @branchloop, \%row;
-        }
-        $template->param( "mylibraryfirst" => 1, branchloop => \@branchloop );
-    }
-    else {
-        $template->param( "mylibraryfirst" => 0 );
-    }
-}
-
 my $borrower = GetMember( $borrowernumber, 'borrowernumber' );
 my @languages;
 my $counter   = 0;