Bugzilla – Attachment 13140 Details for
Bug 7740
Highlight items in own library in search results/detail page in OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7740 - Highlight items in own library in search results/detail page in OPAC [v3.08.03]
Bug-7740---Highlight-items-in-own-library-in-searc.patch (text/plain), 12.56 KB, created by
Kyle M Hall (khall)
on 2012-10-31 13:39:09 UTC
(
hide
)
Description:
Bug 7740 - Highlight items in own library in search results/detail page in OPAC [v3.08.03]
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2012-10-31 13:39:09 UTC
Size:
12.56 KB
patch
obsolete
>From bef07ca1c83f75a2940aa95a98a06b3da7e69aeb Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 31 Oct 2012 09:39:51 -0400 >Subject: [PATCH] Bug 7740 - Highlight items in own library in search results/detail page in OPAC >Content-Type: text/plain; charset="utf-8" > >This feature enables a particular library's items to be emphasized and moved >to the first position on the search results and details pages of the OPAC. > >It is enabled by the sytem preference HighlightOwnItemsOnOPAC. > >To choose which branches items are emphasized, use the system preference >HighlightOwnItemsOnOPACWhich. It has two modes. > >If set to PatronBranch, the items emphasized will be those of the same >library as the patron's library. If no one is logged into the opac, no >items will be highlighted. > >If set to OpacURLBranch, the library is chosen based on the Apache >environment variable BRANCHCODE. > >For example, this could be added to the OPAC section of koha-httpd.conf: >SetEnv BRANCHCODE "CPL" > >The point of this feature is to allow each library on a given Koha server >to have a specific subdomain for the opac where that library's items are >empasized. That was http://branch1.opac.mylibrary.org will emphasize the >items of branch1, while http://branch2.opac.mylibrary.org will emphasize >the items of branch2. > >Conflicts: > > installer/data/mysql/sysprefs.sql > installer/data/mysql/updatedatabase.pl > koha-tmpl/opac-tmpl/prog/en/css/opac.css > koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt > koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >--- > 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 | 5 ++- > .../opac-tmpl/prog/en/modules/opac-results.tt | 2 + > opac/opac-detail.pl | 32 ++++++++++++++++++ > opac/opac-search.pl | 34 ++++++++++++++++++++ > 8 files changed, 100 insertions(+), 2 deletions(-) > >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 05a3261..17087dc 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -365,3 +365,5 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' > INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights','Choice'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SuspendHoldsIntranet', '1', NULL , 'Allow holds to be suspended from the intranet.', 'YesNo'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SuspendHoldsOpac', '1', NULL , 'Allow holds to be suspended from the OPAC.', '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') >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 2d4d2ab..2ed238b 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -5249,6 +5249,14 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "3.09.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 (Add syspref HighlightOwnItemsOnOPAC)\n"; >+ SetVersion ($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index eb74d81..b8945fc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/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: >diff --git a/koha-tmpl/opac-tmpl/prog/en/css/opac.css b/koha-tmpl/opac-tmpl/prog/en/css/opac.css >index bdb2dc9..0393811 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/css/opac.css >+++ b/koha-tmpl/opac-tmpl/prog/en/css/opac.css >@@ -2520,3 +2520,11 @@ span.sep { > } > > */ >+ >+.highlight-row-results { >+ font-size: 120%; >+} >+ >+.highlight-row-detail { >+ font-weight: bold; >+} >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >index 7e68dfe..0436be8 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >@@ -720,8 +720,9 @@ YAHOO.util.Event.onContentReady("furtherm", function () { > <th id="item_datedue">Date due</th> > </tr></thead> > <tbody>[% FOREACH ITEM_RESULT IN ITEM_RESULTS %] >- <tr>[% IF ( item_level_itypes ) %]<td>[% UNLESS ( noItemTypeImages ) %][% IF ( ITEM_RESULT.imageurl ) %]<img src="[% ITEM_RESULT.imageurl %]" title="[% ITEM_RESULT.description %]" alt="[% ITEM_RESULT.description %]" />[% END %][% END %] [% ITEM_RESULT.description %]</td>[% END %] >- <td> >+ [% IF ITEM_RESULT.this_branch %]<tr class="highlight-row-detail">[% ELSE %]<tr>[% END %] >+ [% IF ( item_level_itypes ) %]<td class="itype">[% UNLESS ( noItemTypeImages ) %][% IF ( ITEM_RESULT.imageurl ) %]<img src="[% ITEM_RESULT.imageurl %]" title="[% ITEM_RESULT.description %]" alt="[% ITEM_RESULT.description %]" />[% END %][% END %] [% ITEM_RESULT.description %]</td>[% END %] >+ <td> > [% UNLESS ( singleBranchMode ) %] > <span class="[% ITEM_RESULT.branch_opac_info ? 'branch-info-tooltip-trigger' : '' %]"> > [% IF ( ITEM_RESULT.branchurl ) %] >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >index 9361419..0108a19 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >@@ -450,6 +450,7 @@ $(document).ready(function(){ > <span class="available"><strong>Copies available:</strong> > [% FOREACH available_items_loo IN SEARCH_RESULT.available_items_loop %] > [% UNLESS ( available_items_loo.hideatopac ) %] >+ [% IF available_items_loo.this_branch %]<span class="highlight-row-results">[% ELSE %]<span>[% END %] > [% IF ( singleBranchMode ) %] > [% available_items_loo.location %] > [% ELSE %] >@@ -461,6 +462,7 @@ $(document).ready(function(){ > [% IF ( available_items_loo.itemcallnumber ) %][<a href="/cgi-bin/koha/opac-search.pl?q=callnum:[% available_items_loo.itemcallnumber |url %]">[% available_items_loo.itemcallnumber %]</a>][% END %] > [% END %] > ([% available_items_loo.count %]), >+ </span> > [% END %] > [% END %] > </span> >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index d7e78d3..3a2a9cd 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -435,6 +435,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(); >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index 5f3ad86..a91515a 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -669,6 +669,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") eq "itemdetails"?1:0), >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7740
:
13135
|
13136
|
13140
|
15118
|
16036
|
16053
|
16741
|
16742
|
16743
|
16755
|
16756
|
16757
|
16758
|
16759
|
16760
|
16811
|
16812
|
16813
|
16814