SearchMyLibraryFirst : reintroducing behaviour (from 2.2)
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>
This commit is contained in:
parent
865036b43c
commit
847bf18dad
3 changed files with 7 additions and 40 deletions
|
@ -260,7 +260,7 @@ sub get_template_and_user {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
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");
|
my $LibraryNameTitle = C4::Context->preference("LibraryName");
|
||||||
$LibraryNameTitle =~ s/<(?:\/?)(?:br|p)\s*(?:\/?)>/ /sgi;
|
$LibraryNameTitle =~ s/<(?:\/?)(?:br|p)\s*(?:\/?)>/ /sgi;
|
||||||
$LibraryNameTitle =~ s/<(?:[^<>'"]|'(?:[^']*)'|"(?:[^"]*)")*>//sg;
|
$LibraryNameTitle =~ s/<(?:[^<>'"]|'(?:[^']*)'|"(?:[^"]*)")*>//sg;
|
||||||
|
@ -297,6 +297,7 @@ sub get_template_and_user {
|
||||||
reviewson => C4::Context->preference("reviewson"),
|
reviewson => C4::Context->preference("reviewson"),
|
||||||
hide_marc => C4::Context->preference("hide_marc"),
|
hide_marc => C4::Context->preference("hide_marc"),
|
||||||
patronimages => C4::Context->preference("patronimages"),
|
patronimages => C4::Context->preference("patronimages"),
|
||||||
|
mylibraryfirst => C4::Context->preference("SearchMyLibraryFirst"),
|
||||||
"BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
|
"BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,12 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="opac-main-search">
|
<div id="opac-main-search">
|
||||||
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">
|
<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" />
|
<input type="submit" value="OK" class="submit" />
|
||||||
</form>
|
</form>
|
||||||
<a href="/cgi-bin/koha/opac-search.pl">more search options</a>
|
<a href="/cgi-bin/koha/opac-search.pl">more search options</a>
|
||||||
|
|
|
@ -32,8 +32,6 @@ use C4::Acquisition; # GetRecentAcqui
|
||||||
my $input = new CGI;
|
my $input = new CGI;
|
||||||
my $dbh = C4::Context->dbh;
|
my $dbh = C4::Context->dbh;
|
||||||
|
|
||||||
my $limit = $input->param('recentacqui');
|
|
||||||
|
|
||||||
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
|
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
|
||||||
{
|
{
|
||||||
template_name => "opac-main.tmpl",
|
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 $borrower = GetMember( $borrowernumber, 'borrowernumber' );
|
||||||
my @languages;
|
my @languages;
|
||||||
my $counter = 0;
|
my $counter = 0;
|
||||||
|
|
Loading…
Reference in a new issue