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
This commit is contained in:
hdl 2007-07-06 15:16:40 +00:00
parent 8ea463b843
commit 109644cdb4
6 changed files with 81 additions and 64 deletions

View File

@ -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 );

View File

@ -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

View File

@ -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 ) {

View File

@ -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;

View File

@ -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;

View File

@ -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 );