@@ -, +, @@ search results/detail page in OPAC --- installer/data/mysql/sysprefs.sql | 2 ++ installer/data/mysql/updatedatabase.pl | 8 +++++ .../prog/en/modules/admin/preferences/opac.pref | 11 +++++++ koha-tmpl/opac-tmpl/prog/en/css/opac.css | 8 +++++ koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt | 3 +- .../opac-tmpl/prog/en/modules/opac-results.tt | 2 ++ opac/opac-detail.pl | 32 ++++++++++++++++++ opac/opac-search.pl | 34 ++++++++++++++++++++ 8 files changed, 99 insertions(+), 1 deletion(-) --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -421,3 +421,5 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UseKohaPlugins','1','Enable or disable the ability to use Koha Plugins.','','YesNo'); INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('TimeFormat','24hr','12hr|24hr','Defines the global time format for visual output.','Choice'); INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('DisplayIconsXSLT', '1', '', 'If ON, displays the format, audience, and material type icons in XSLT MARC21 results and detail pages.', 'YesNo'); +INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('HighlightOwnItemsOnOPAC','0','','If on, and a patron is logged into the OPAC, items from his or her home library will be emphasized and shown first in search results and item details.','YesNo'); +INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('HighlightOwnItemsOnOPACWhich','PatronBranch','PatronBranch|OpacURLBranch','Decides which branch''s items to emphasize. If PatronBranch, emphasize the logged in user''s library''s items. If OpacURLBranch, highlight the items of the Apache var BRANCHCODE defined in Koha''s Apache configuration file.','Choice') --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -6700,6 +6700,14 @@ if ( CheckVersion($DBversion) ) { SetVersion ($DBversion); } +$DBversion = "3.11.00.XXX"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('HighlightOwnItemsOnOPAC','0','','If on, and a patron is logged into the OPAC, items from his or her home library will be emphasized and shown first in search results and item details.','YesNo')"); + $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('HighlightOwnItemsOnOPACWhich','PatronBranch','PatronBranch|OpacURLBranch','Decides which branch''s items to emphasize. If PatronBranch, emphasize the logged in user''s library''s items. If OpacURLBranch, highlight the items of the Apache var BRANCHCODE defined in Koha''s Apache configuration file.','Choice')"); + print "Upgrade to $DBversion done (Bug 7740: Add syspref HighlightOwnItemsOnOPAC)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -22,6 +22,17 @@ OPAC: no: Disable - "Koha OPAC as public. Private OPAC requires authentification before accessing the OPAC." - + - pref: HighlightOwnItemsOnOPAC + choices: + yes: Emphasize + no: "Don't emphasize" + - "results from the " + - pref: HighlightOwnItemsOnOPACWhich + choices: + PatronBranch: "patron's home branch" + OpacURLBranch: "OPAC's branch via the URL" + - " by moving the results to the front and increasing the size or highlighting the rows for those results." + - - "Show star-ratings on" - pref: OpacStarRatings choices: --- a/koha-tmpl/opac-tmpl/prog/en/css/opac.css +++ a/koha-tmpl/opac-tmpl/prog/en/css/opac.css @@ -2920,3 +2920,11 @@ a.reviewlink,a.reviewlink:visited { .idbresult img { padding-right: 6px; } + +.highlight-row-results { + font-size: 120%; +} + +.highlight-row-detail { + font-weight: bold; +} --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt +++ a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt @@ -1471,7 +1471,8 @@ YAHOO.util.Event.onContentReady("furtherm", function () { [% END %] [% FOREACH ITEM_RESULT IN items %] - [% IF ( item_level_itypes ) %][% UNLESS ( noItemTypeImages ) %][% IF ( ITEM_RESULT.imageurl ) %][% ITEM_RESULT.description %][% END %][% END %] [% ITEM_RESULT.description %][% END %] + [% IF ITEM_RESULT.this_branch %][% ELSE %][% END %] + [% IF ( item_level_itypes ) %][% UNLESS ( noItemTypeImages ) %][% IF ( ITEM_RESULT.imageurl ) %][% ITEM_RESULT.description %][% END %][% END %] [% ITEM_RESULT.description %][% END %] [% UNLESS ( singleBranchMode ) %] --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt +++ a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt @@ -532,6 +532,7 @@ $(document).ready(function(){ [% IF ( SEARCH_RESULT.available_items_loop.size() ) %] Copies available: [% FOREACH available_items_loo IN SEARCH_RESULT.available_items_loop %] + [% IF available_items_loo.this_branch %][% ELSE %][% END %] [% IF ( singleBranchMode ) %] [% available_items_loo.location %] [% ELSE %] @@ -543,6 +544,7 @@ $(document).ready(function(){ [% IF ( available_items_loo.itemcallnumber ) %][[% available_items_loo.itemcallnumber %]][% END %] [% END %] ([% available_items_loo.count %]), + [% END %] [% ELSE %] --- a/opac/opac-detail.pl +++ a/opac/opac-detail.pl @@ -441,6 +441,38 @@ if ($hideitems) { @items = @all_items; } +my $branches = GetBranches(); +my $branch = C4::Context->userenv->{branch}; +if ( C4::Context->preference('HighlightOwnItemsOnOPAC') ) { + if ( + ( ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) && $branch ) + || + C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch' + ) { + my $branchname; + if ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) { + $branchname = $branches->{$branch}->{'branchname'}; + } + elsif ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch' ) { + $branchname = $branches->{ $ENV{'BRANCHCODE'} }->{'branchname'}; + } + + my @our_items; + my @other_items; + + foreach my $item ( @items ) { + if ( $item->{'branchname'} eq $branchname ) { + $item->{'this_branch'} = 1; + push( @our_items, $item ); + } else { + push( @other_items, $item ); + } + } + + @items = ( @our_items, @other_items ); + } +} + my $dat = &GetBiblioData($biblionumber); my $itemtypes = GetItemTypes(); --- a/opac/opac-search.pl +++ a/opac/opac-search.pl @@ -699,6 +699,40 @@ for (my $i=0;$i<@servers;$i++) { $template->param(results_per_page => $results_per_page); my $hide = C4::Context->preference('OpacHiddenItems'); $hide = ($hide =~ m/\S/) if $hide; # Just in case it has some spaces/new lines + + my $branch = C4::Context->userenv->{branch}; + if ( C4::Context->preference('HighlightOwnItemsOnOPAC') ) { + if ( + ( ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) && $branch ) + || + C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch' + ) { + my $branchname; + if ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) { + $branchname = $branches->{$branch}->{'branchname'}; + } + elsif ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch' ) { + $branchname = $branches->{ $ENV{'BRANCHCODE'} }->{'branchname'}; + } + + foreach my $res ( @newresults ) { + my @new_loop; + my @top_loop; + my @old_loop = @{$res->{'available_items_loop'}}; + foreach my $item ( @old_loop ) { + if ( $item->{'branchname'} eq $branchname ) { + $item->{'this_branch'} = 1; + push( @top_loop, $item ); + } else { + push( @new_loop, $item ); + } + } + my @complete_loop = ( @top_loop, @new_loop ); + $res->{'available_items_loop'} = \@complete_loop; + } + } + } + $template->param( SEARCH_RESULTS => \@newresults, OPACItemsResultsDisplay => (C4::Context->preference("OPACItemsResultsDisplay")), --