From c455153f987d51ce7771503cea64a315aac78253 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Fri, 11 Apr 2014 13:44:16 -0400 Subject: [PATCH] Bug 5010: Fix incomplete links in carts and lists sent from the staff client While the list email hardcoded http:// in front of the URL, the cart email was missing http(s)://. As there seems to be no reliable way to determine in staff if the OPAC is using SSL or not, this patch introduces a new OPAC system preference, OpacProtocol, in the Policy subsection. It defaults to "doesn't use" (http://), but can be changed to "uses" (https://). Both basket/sendbasket.pl and virtualshelves/sendshelf.pl were tweaked to always set OPACBaseURL. If OPACBaseURL is undef or not set, the URL is not given in the corresponding template files. opac/opac-sendshelf.pl was returned to previous state, because it affects doc-head-close.inc if OPACBaseURL is not passed. This should be fixed to use the OpacProtocol system preference in another bug fix. However, this is OPAC, not Staff, and outside of the bugs scope. Both basket/sendbasket.tt and virtualshelves/sendshelf.tt template files contain the suggested Koha.Preference logic recommended by Kyle in comment #21. TEST PLAN --------- 1) Back up your database 2) Drop your koha database and recreate it empty 3) In the mysql client: > SOURCE .../installer/data/mysql/sysprefs.sql; -- It should run without error. > SELECT variable,value from systempreferences WHERE variable='OpacProtocol'; -- It should have the value 'http://' 4) Restore your database 5) $ ./installer/data/mysql/updatedatabase.pl -- It should run the upgrade to insert OpacProtocol. 6) In the mysql client: > SELECT variable,value from systempreferences WHERE variable='OpacProtocol'; -- It should have the value 'http://' 7) Log into the staff client 8) Click 'Koha administration' 9) Click 'Global system preferences' 10) Click the 'OPAC' tab on the left side. 11) Scroll down to the Policy section, and find the OpacProtocol preference. -- It should have a value of "doesn't use" in the drop down. 12) Fill your cart with something(s). 13) Make sure you have a list filled with something(s). 14) Click 'Cart' in the top menu bar area. 15) Click 'Send', and send it to yourself. 16) Click 'Close window' 17) Click 'Hide window' 18) Click 'More' and click 'Lists' 19) Choose a list and 'Send list' to yourself. 20) Check your email -- both emails should have OPAC URLs which start with http:// 21) Change the OPAC system preference OpacProtocol to 'uses' (https://), log out and log in (to force refresh of cached system preferences), and repeat steps 14 through 19. 22) Check your email -- the two new emails should have OPAC URLS which start with https:// NOTE: Other URLs may be broken as well, this bug only fixes carts and lists sent from staff. --- basket/sendbasket.pl | 5 +---- installer/data/mysql/sysprefs.sql | 2 +- installer/data/mysql/updatedatabase.pl | 4 ++-- .../prog/en/modules/admin/preferences/opac.pref | 6 +++--- .../prog/en/modules/basket/sendbasket.tt | 4 ++-- .../prog/en/modules/virtualshelves/sendshelf.tt | 4 ++-- opac/opac-sendshelf.pl | 4 ++++ virtualshelves/sendshelf.pl | 5 +---- 8 files changed, 16 insertions(+), 18 deletions(-) diff --git a/basket/sendbasket.pl b/basket/sendbasket.pl index 265b269..fc7516a 100755 --- a/basket/sendbasket.pl +++ b/basket/sendbasket.pl @@ -100,10 +100,7 @@ if ( $email_add ) { push( @results, $dat ); } - my $protocol = C4::Context->preference('PublicCatalogUsesSSL') ? "https://" : "http://"; - if (C4::Context->preference('OPACBaseURL')){ - $template2->param( OPACBaseURL => $protocol . C4::Context->preference('OPACBaseURL') ); - } + $template2->param( OPACBaseURL => C4::Context->preference('OPACBaseURL') ); my $resultsarray = \@results; $template2->param( diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 71e817d..69966b3 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -257,6 +257,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OPACPatronDetails','1','','If OFF the patron details tab in the OPAC is disabled.','YesNo'), ('OPACpatronimages','0',NULL,'Enable patron images in the OPAC','YesNo'), ('OpacPrivacy','0',NULL,'if ON, allows patrons to define their privacy rules (reading history)','YesNo'), +('OpacProtocol','http://','http://|https://','Public catalog/OPAC uses SSL','Choice'), ('OpacPublic','1',NULL,'Turn on/off public OPAC','YesNo'), ('opacreadinghistory','1','','If ON, enables display of Patron Circulation History in OPAC','YesNo'), ('OpacRenewalAllowed','0',NULL,'If ON, users can renew their issues directly from their OPAC account','YesNo'), @@ -310,7 +311,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('previousIssuesDefaultSortOrder','asc','asc|desc','Specify the sort order of Previous Issues on the circulation page','Choice'), ('printcirculationslips','1','','If ON, enable printing circulation receipts','YesNo'), ('PrintNoticesMaxLines','0','','If greater than 0, sets the maximum number of lines an overdue notice will print. If the number of items is greater than this number, the notice will end with a warning asking the borrower to check their online account for a full list of overdue items.','Integer'), -('PublicCatalogUsesSSL',0,'','Public catalog/OPAC uses SSL','YesNo'), ('QueryAutoTruncate','1',NULL,'If ON, query truncation is enabled by default','YesNo'), ('QueryFuzzy','1',NULL,'If ON, enables fuzzy option for searches','YesNo'), ('QueryStemming','1',NULL,'If ON, enables query stemming','YesNo'), diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 2634cd8..05cb905 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8205,8 +8205,8 @@ if ( CheckVersion($DBversion) ) { $DBversion = "3.15.00.XXX"; if ( CheckVersion($DBversion) ) { $dbh->do(q{INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES - ('PublicCatalogUsesSSL',0,'','Public catalog/OPAC uses SSL','YesNo');}); - print "Upgrade to $DBversion done (Bug 5010: Add PublicCatalogUsesSSL system preference)\n"; + ('OpacProtocol','http://','http://|https://','Public catalog/OPAC uses SSL','Choice');}); + print "Upgrade to $DBversion done (Bug 5010: Add OpacProtocol system preference)\n"; SetVersion($DBversion); } 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 f822683..02e9d2a 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 @@ -455,10 +455,10 @@ OPAC: - patrons to select their branch on the OPAC or show branch names with callnumbers. - - The public catalog - - pref: PublicCatalogUsesSSL + - pref: OpacProtocol choices: - yes: uses - no: "doesn't use" + "https://": uses + "http://": "doesn't use" - SSL. - - pref: SearchMyLibraryFirst diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/sendbasket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/sendbasket.tt index 09ce7dd..6f835a6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/sendbasket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/sendbasket.tt @@ -1,4 +1,4 @@ - +[%- USE Koha -%] Your cart @@ -134,7 +134,7 @@ Your cart [% IF ( OPACBaseURL ) %]

- In online catalog: [% OPACBaseURL %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% BIBLIO_RESULT.biblionumber %] + In online catalog: [% Koha.Preference( 'OPACProtocol' ) %][% OPACBaseURL %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% BIBLIO_RESULT.biblionumber %]

[% END %] [% IF ( BIBLIO_RESULT.ITEM_RESULTS.size ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/sendshelf.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/sendshelf.tt index 062b5da..d2ff70c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/sendshelf.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/sendshelf.tt @@ -1,4 +1,4 @@ - +[%- USE Koha -%] Your list: [% shelfname %] @@ -141,7 +141,7 @@ Your list: [% shelfname %] [% IF ( OPACBaseURL ) %]

- In online catalog: [% OPACBaseURL %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% BIBLIO_RESULT.biblionumber %] + In online catalog: [% Koha.Preference('OpacProtocol') %][% OPACBaseURL %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% BIBLIO_RESULT.biblionumber %]

[% END %] [% IF ( BIBLIO_RESULT.ITEM_RESULTS.size ) %] diff --git a/opac/opac-sendshelf.pl b/opac/opac-sendshelf.pl index 470282a..3f9b719 100755 --- a/opac/opac-sendshelf.pl +++ b/opac/opac-sendshelf.pl @@ -107,6 +107,10 @@ if ( $email ) { my $user = GetMember(borrowernumber => $borrowernumber); + if (C4::Context->preference('OPACBaseURL')){ + $template2->param( OPACBaseURL => C4::Context->preference('OPACBaseURL') ); + } + $template2->param( BIBLIO_RESULTS => \@results, email_sender => $email_from, diff --git a/virtualshelves/sendshelf.pl b/virtualshelves/sendshelf.pl index 0341ab9..87d0d9c 100755 --- a/virtualshelves/sendshelf.pl +++ b/virtualshelves/sendshelf.pl @@ -100,10 +100,7 @@ if ( $email ) { push( @results, $dat ); } - my $protocol = C4::Context->preference('PublicCatalogUsesSSL') ? "https://" : "http://"; - if (C4::Context->preference('OPACBaseURL')){ - $template2->param( OPACBaseURL => $protocol . C4::Context->preference('OPACBaseURL') ); - } + $template2->param( OPACBaseURL => C4::Context->preference('OPACBaseURL') ); $template2->param( BIBLIO_RESULTS => \@results, -- 1.7.9.5