From 109644cdb41c039eb066c6019319a406dbdc9629 Mon Sep 17 00:00:00 2001 From: hdl Date: Fri, 6 Jul 2007 15:16:40 +0000 Subject: [PATCH] Bug Fixing: Authority display hierarchy had a problem. Feature porting : Adding SearchMyLibraryFirst feature to OPAC It select the user's library for research by default --- opac/opac-authoritiesdetail.pl | 53 ++++++++++++++-------------------- opac/opac-main.pl | 44 ++++++++++++++++------------ opac/opac-reserve.pl | 6 ++-- opac/opac-search.pl | 4 ++- opac/opac-topissues.pl | 22 ++++++++------ opac/opac-user.pl | 16 ++++++++-- 6 files changed, 81 insertions(+), 64 deletions(-) diff --git a/opac/opac-authoritiesdetail.pl b/opac/opac-authoritiesdetail.pl index a07b4e2c10..aa39e05328 100755 --- a/opac/opac-authoritiesdetail.pl +++ b/opac/opac-authoritiesdetail.pl @@ -68,38 +68,29 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( ); my $record; -if ( C4::Context->preference("AuthDisplayHierarchy") ) { - my $trees = BuildUnimarcHierarchies($authid); - - # warn "trees :$trees"; - my @trees = split /;/, $trees; - push @trees, $trees unless (@trees); - my @loophierarchies; - foreach my $tree (@trees) { - - # warn "tree :$tree"; - - my @tree = split /,/, $tree; - push @tree, $tree unless (@tree); - my $cnt = 0; - my @loophierarchy; - foreach my $element (@tree) { - - # warn "tree :$element"; - my %cell; - my $elementdata = GetAuthority( $element ); - $record = $elementdata if ( $authid == $element ); - push @loophierarchy, - BuildUnimarcHierarchy( $elementdata, "child" . $cnt, $authid ); - $cnt++; - } - push @loophierarchies, { 'loopelement' => \@loophierarchy }; - $template->param( - 'displayhierarchy' => - C4::Context->preference("AuthDisplayHierarchy"), - 'loophierarchies' => \@loophierarchies, - ); +if (C4::Context->preference("AuthDisplayHierarchy")){ + my $trees=BuildUnimarcHierarchies($authid); + my @trees = split /;/,$trees ; + push @trees,$trees unless (@trees); + my @loophierarchies; + foreach my $tree (@trees){ + my @tree=split /,/,$tree; + push @tree,$tree unless (@tree); + my $cnt=0; + my @loophierarchy; + foreach my $element (@tree){ + my $cell; + my $elementdata = GetAuthority($element); + $record= $elementdata if ($authid==$element); + push @loophierarchy, BuildUnimarcHierarchy($elementdata,"child".$cnt, $authid); + $cnt++; } + push @loophierarchies, { 'loopelement' =>\@loophierarchy}; + } + $template->param( + 'displayhierarchy' =>C4::Context->preference("AuthDisplayHierarchy"), + 'loophierarchies' =>\@loophierarchies, + ); } else { $record = GetAuthority( $authid ); diff --git a/opac/opac-main.pl b/opac/opac-main.pl index f9714a3730..e878d0f227 100755 --- a/opac/opac-main.pl +++ b/opac/opac-main.pl @@ -34,22 +34,6 @@ my $dbh = C4::Context->dbh; my $limit = $input->param('recentacqui'); -my @branches; -my @select_branch; -my %select_branches; -my $branches = GetBranches(); -my @branchloop; -foreach my $thisbranch ( keys %$branches ) { - my $selected = 1 - if ( C4::Context->userenv - && ( $thisbranch eq C4::Context->userenv->{branch} ) ); - my %row = ( - value => $thisbranch, - selected => $selected, - branchname => $branches->{$thisbranch}->{'branchname'}, - ); - push @branchloop, \%row; -} my ( $template, $borrowernumber, $cookie ) = get_template_and_user( { template_name => "opac-main.tmpl", @@ -68,7 +52,31 @@ if($limit) { ); } -my $borrower = GetMember( $borrowernumber,'borrowernumber' ); +# SearchMyLibraryFirst +if (C4::Context->preference("SearchMyLibraryFirst")){ + if (C4::Context->userenv){ + my $branches = GetBranches(); + my @branchloop; + + foreach my $thisbranch (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; my $langavail = getTranslatedLanguages('opac'); @@ -85,7 +93,6 @@ if ( $counter > 1 ) { } $template->param( - branchloop => \@branchloop, textmessaging => $borrower->{textmessaging}, opaclanguagesdisplay => 0, ); @@ -96,6 +103,7 @@ my $news_lang = $input->cookie('KohaOpacLanguage') || C4::Context->preference('o my $all_koha_news = &GetNewsToDisplay( $news_lang ); my $koha_news_count = scalar @$all_koha_news; + $template->param( koha_news => $all_koha_news, koha_news_count => $koha_news_count diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 31e209d40f..3c7f570ee3 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -296,12 +296,12 @@ else { debarred => 1 ); } - my ( $resnum, $reserves ) = GetReservesFromBorrowernumber( $borrowernumber ); + my $reserves = GetReservesFromBorrowernumber( $borrowernumber ); $template->param( RESERVES => $reserves ); - if ( $resnum >= $MAXIMUM_NUMBER_OF_RESERVES ) { + if ( scalar(@$reserves) >= $MAXIMUM_NUMBER_OF_RESERVES ) { $template->param( message => 1 ); $noreserves = 1; - $template->param( too_many_reserves => $resnum ); + $template->param( too_many_reserves => scalar(@$reserves)); } foreach my $res (@$reserves) { if ( $res->{'biblionumber'} == $biblionumber ) { diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 21d6330b9b..2146854c6c 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -221,13 +221,15 @@ query parser. my $branches = GetBranches(); my @branch_loop; for my $branch_hash ( keys %$branches ) { + my $selected=(C4::Context->userenv && ($branch_hash eq C4::Context->userenv->{branch})) if (C4::Context->preference('SearchMyLibraryFirst')); push @branch_loop, { value => "branch: $branch_hash", branchname => $branches->{$branch_hash}->{'branchname'}, + selected => $selected }; } -$template->param( branchloop => \@branch_loop, ); +$template->param( branchloop => \@branch_loop, "mylibraryfirst"=>C4::Context->preference("SearchMyLibraryFirst")); # load the itemtypes (Called Collection Codes in the template -- used for circ rules ) my $itemtypes = GetItemTypes; diff --git a/opac/opac-topissues.pl b/opac/opac-topissues.pl index ca74b85ec4..e738403c47 100755 --- a/opac/opac-topissues.pl +++ b/opac/opac-topissues.pl @@ -92,14 +92,19 @@ $template->param(do_it => 1, results_loop => \@results, ); -my $branches = GetBranches; -my @branchloop; -foreach my $thisbranch (keys %$branches) { - my %row =(value => $thisbranch, - branchname => $branches->{$thisbranch}->{'branchname'}, - ); - push @branchloop, \%row; +# load the branches +my $branches = GetBranches(); +my @branch_loop; +for my $branch_hash ( keys %$branches ) { + my $selected=(C4::Context->userenv && ($branch_hash eq C4::Context->userenv->{branch})) if (C4::Context->preference('SearchMyLibraryFirst')); + push @branch_loop, + { + value => "branch: $branch_hash", + branchname => $branches->{$branch_hash}->{'branchname'}, + selected => $selected + }; } +$template->param( branchloop => \@branch_loop, "mylibraryfirst"=>C4::Context->preference("SearchMyLibraryFirst")); #doctype my $itemtypes = GetItemTypes; @@ -112,8 +117,7 @@ foreach my $thisitemtype (keys %$itemtypes) { } $template->param( - branchloop =>\@branchloop, - itemtypeloop =>\@itemtypeloop, + itemtypeloop =>\@itemtypeloop, ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 7fc1f91ef1..89fbe4eb75 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -138,7 +138,19 @@ $template->param( issues_count => $count ); $template->param( OVERDUES => \@overdues ); $template->param( overdues_count => $overdues_count ); +# load the branches my $branches = GetBranches(); +my @branch_loop; +for my $branch_hash ( keys %$branches ) { + my $selected=(C4::Context->userenv && ($branch_hash eq C4::Context->userenv->{branch})) if (C4::Context->preference('SearchMyLibraryFirst')); + push @branch_loop, + { + value => "branch: $branch_hash", + branchname => $branches->{$branch_hash}->{'branchname'}, + selected => $selected + }; +} +$template->param( branchloop => \@branch_loop, "mylibraryfirst"=>C4::Context->preference("SearchMyLibraryFirst")); # now the reserved items.... my @reserves = GetReservesFromBorrowernumber( $borrowernumber ); @@ -152,8 +164,8 @@ foreach my $res (@reserves) { $res->{'reserves_title'} = $biblioData->{'title'}; } -use Data::Dumper; -warn Dumper(@reserves); +# use Data::Dumper; +# warn Dumper(@reserves); $template->param( RESERVES => \@reserves ); $template->param( reserves_count => $#reserves+1 ); -- 2.39.5