[Koha-patches] [PATCH] Bug 6494 - opacmysummaryhtml on reading history

Owen Leonard oleonard at myacpl.org
Thu Aug 16 19:01:18 CEST 2012


This patch re-uses code and markup from opac-user.tt & .pl
to place the contents of the opacmysummaryhtml preference
on the circulation history page in exactly the same way
it appears on the "my summary" page.

The wording of the system preference description has
been modified to reflect this addition.
---
 installer/data/mysql/sysprefs.sql                  |    2 +-
 .../prog/en/modules/admin/preferences/opac.pref    |    2 +-
 .../prog/en/modules/opac-readingrecord.tt          |    6 ++++++
 opac/opac-readingrecord.pl                         |   11 +++++++++++
 4 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql
index f5a18b2..e17b51f 100644
--- a/installer/data/mysql/sysprefs.sql
+++ b/installer/data/mysql/sysprefs.sql
@@ -280,7 +280,7 @@ INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanatio
 INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` ) VALUES ( 'DisplayClearScreenButton', '0', '', 'If set to ON, a clear screen button will appear on the circulation page.', 'YesNo');
 INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('HidePatronName', '0', '', 'If this is switched on, patron''s cardnumber will be shown instead of their name on the holds and catalog screens', 'YesNo');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACSearchForTitleIn','<li><a  href="http://worldcat.org/search?q={TITLE}" target="_blank">Other Libraries (WorldCat)</a></li>\n<li><a href="http://www.scholar.google.com/scholar?q={TITLE}" target="_blank">Other Databases (Google Scholar)</a></li>\n<li><a href="http://www.bookfinder.com/search/?author={AUTHOR}&amp;title={TITLE}&amp;st=xl&amp;ac=qr" target="_blank">Online Stores (Bookfinder.com)</a></li>\n<li><a href="http://openlibrary.org/search/?author=({AUTHOR})&title=({TITLE})" target="_blank">Open Library (openlibrary.org)</a></li>','Enter the HTML that will appear in the \'Search for this title in\' box on the detail page in the OPAC.  Enter {TITLE}, {AUTHOR}, or {ISBN} in place of their respective variables in the URL. Leave blank to disable \'More Searches\' menu.','70|10','Textarea');
-INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACMySummaryHTML','','Enter the HTML that will appear in a column on the \'my profile\' tab when a user is logged in to the OPAC. Enter {BIBLIONUMBER}, {TITLE}, {AUTHOR}, or {ISBN} in place of their respective variables in the HTML. Leave blank to disable.','70|10','Textarea');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACMySummaryHTML','','Enter the HTML that will appear in a column on the \'my summary\' and \'my reading history\' tabs when a user is logged in to the OPAC. Enter {BIBLIONUMBER}, {TITLE}, {AUTHOR}, or {ISBN} in place of their respective variables in the HTML. Leave blank to disable.','70|10','Textarea');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACPatronDetails','1','If OFF the patron details tab in the OPAC is disabled.','','YesNo');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACFinesTab','1','If OFF the patron fines tab in the OPAC is disabled.','','YesNo');
 INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('DisplayOPACiconsXSLT', '1', '', 'If ON, displays the format, audience, type icons in XSLT MARC21 results and display pages.', 'YesNo');
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 0fe79d4..50abfeb 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
@@ -199,7 +199,7 @@ OPAC:
               type: textarea
               class: code
         -
-            - 'Include a "Links" column on the "my summary" tab when a user is logged in to the OPAC, with the following HTML (leave blank to disable):'
+            - 'Include a "Links" column on the "my summary" and "my reading history" tabs when a user is logged in to the OPAC, with the following HTML (leave blank to disable):'
             - '<br />Note: The placeholders {BIBLIONUMBER}, {TITLE}, {ISBN} and {AUTHOR} will be replaced with information from the displayed record.'
             - pref: OPACMySummaryHTML
               type: textarea
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-readingrecord.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-readingrecord.tt
index 8786925..213deeb 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-readingrecord.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-readingrecord.tt
@@ -59,6 +59,9 @@ You have never borrowed anything from this library.
 <th>Item type</th>
 <th>Call no.</th>
 <th>Date</th>
+[% IF ( OPACMySummaryHTML ) %]
+<th>Links</th>
+[% END %]
 </tr>
 
 [% FOREACH READING_RECOR IN READING_RECORD %]
@@ -85,6 +88,9 @@ You have never borrowed anything from this library.
 <td>[% UNLESS ( noItemTypeImages ) %][% IF ( READING_RECOR.imageurl ) %]<img src="[% READING_RECOR.imageurl %]" alt="" />[% END %][% END %] [% READING_RECOR.description %]</td>
 <td>[% READING_RECOR.itemcallnumber %]</td>
 <td>[% IF ( READING_RECOR.returndate ) %][% READING_RECOR.returndate | $KohaDates %][% ELSE %]<em>(Checked out)</em>[% END %]</td>
+[% IF ( OPACMySummaryHTML ) %]
+<td>[% READING_RECOR.MySummaryHTML %]</td>
+[% END %]
 </tr>
 
 [% END %]
diff --git a/opac/opac-readingrecord.pl b/opac/opac-readingrecord.pl
index 3e78c9a..0c92de6 100755
--- a/opac/opac-readingrecord.pl
+++ b/opac/opac-readingrecord.pl
@@ -97,6 +97,16 @@ foreach my $issue (@{$issues} ) {
         $line{'description'}   = $itemtypes->{ $issue->{'itemtype'} }->{'description'};
         $line{imageurl}        = getitemtypeimagelocation( 'opac', $itemtypes->{ $issue->{'itemtype'}  }->{'imageurl'} );
     }
+    # My Summary HTML
+    if (my $my_summary_html = C4::Context->preference('OPACMySummaryHTML')){
+        $line{author} ? $my_summary_html =~ s/{AUTHOR}/$line{author}/g : $my_summary_html =~ s/{AUTHOR}//g;
+        $line{title} =~ s/\/+$//; # remove trailing slash
+        $line{title} =~ s/\s+$//; # remove trailing space
+        $line{title} ? $my_summary_html =~ s/{TITLE}/$line{title}/g : $my_summary_html =~ s/{TITLE}//g;
+        $line{normalized_isbn} ? $my_summary_html =~ s/{ISBN}/$line{normalized_isbn}/g : $my_summary_html =~ s/{ISBN}//g;
+        $line{biblionumber} ? $my_summary_html =~ s/{BIBLIONUMBER}/$line{biblionumber}/g : $my_summary_html =~ s/{BIBLIONUMBER}//g;
+        $line{MySummaryHTML} = $my_summary_html;
+    }
     push( @loop_reading, \%line );
     $line{subtitle} = GetRecordValue('subtitle', $record, GetFrameworkCode($issue->{'biblionumber'}));
 }
@@ -130,6 +140,7 @@ $template->param(
     showfulllink   => 1,
 	readingrecview => 1,
 	count          => scalar @loop_reading,
+    OPACMySummaryHTML => (C4::Context->preference("OPACMySummaryHTML")) ? 1 : 0,
 );
 
 output_html_with_http_headers $query, $cookie, $template->output;
-- 
1.7.9.5



More information about the Koha-patches mailing list