Authority display hierarchy had a problem.
Feature porting :
Adding SearchMyLibraryFirst feature to OPAC
It select the user's library for research by default
);
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 );
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",
);
}
-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');
}
$template->param(
- branchloop => \@branchloop,
textmessaging => $borrower->{textmessaging},
opaclanguagesdisplay => 0,
);
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
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 ) {
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;
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;
}
$template->param(
- branchloop =>\@branchloop,
- itemtypeloop =>\@itemtypeloop,
+ itemtypeloop =>\@itemtypeloop,
);
output_html_with_http_headers $input, $cookie, $template->output;
$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 );
$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 );