From efcb3f748c3d3f7211251f57dae55f28fe8d4fc4 Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Wed, 11 Dec 2013 19:31:00 +0100 Subject: [PATCH] [SIGNED OFF] 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 system preference: PublicCatalogUsesSSL. To test: - Create a list - Send yourself the list from the staff interface - Verify that the links are http:// - Put some records into your cart - Send yourself the cart from the staff interface - Verify that the links are missing http(s):// in front of them - Apply patch - Run database update - Verify that the default setting for PublicCatalogUsesSSL is 'doesn't use' - Resent both emails - Verfiy the catalog links are now both http:// links - Change system preference setting to 'uses' - Resent both emails - Verify the catalog links are now https:// links NOTE: My cart didn't have a 'In online catalog:' line on master. My list had http:// on master. System preference affected both cart and list sending. System preference necessary, because there is no way to determine http or https in the middle of an email. Signed-off-by: Mark Tompsett --- basket/sendbasket.pl | 7 ++++++- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 12 ++++++++++++ .../prog/en/modules/admin/preferences/opac.pref | 7 +++++++ .../prog/en/modules/virtualshelves/sendshelf.tt | 2 +- virtualshelves/sendshelf.pl | 3 ++- 6 files changed, 29 insertions(+), 3 deletions(-) diff --git a/basket/sendbasket.pl b/basket/sendbasket.pl index 885ee41..265b269 100755 --- a/basket/sendbasket.pl +++ b/basket/sendbasket.pl @@ -86,7 +86,7 @@ if ( $email_add ) { if($dat->{'author'} || @$marcauthorsarray) { $hasauthors = 1; } - + $dat->{MARCNOTES} = $marcnotesarray; $dat->{MARCSUBJCTS} = $marcsubjctsarray; @@ -100,6 +100,11 @@ 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') ); + } + my $resultsarray = \@results; $template2->param( BIBLIO_RESULTS => $resultsarray, diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 2c45345..c30e530 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -306,6 +306,7 @@ 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 c8e883f..d2f0e4f 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8012,6 +8012,18 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { SetVersion($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"; + 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 d541440..2b10221 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 @@ -446,6 +446,13 @@ OPAC: no: Allow - patrons to select their branch on the OPAC or show branch names with callnumbers. - + - The public catalog + - pref: PublicCatalogUsesSSL + choices: + yes: uses + no: "doesn't use" + - SSL. + - - pref: SearchMyLibraryFirst choices: yes: Limit 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 12e53ee..7a2a90e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/sendshelf.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/sendshelf.tt @@ -35,7 +35,7 @@ Classification: [% BIBLIO_RESULT.classification %][% END %][% IF ( BIBLIO_RESULT LCCN: [% BIBLIO_RESULT.lccn %][% END %][% IF ( BIBLIO_RESULT.url ) %] URL : [% BIBLIO_RESULT.url %][% END %][% IF ( OPACBaseURL ) %] In the online catalog: - http://[% OPACBaseURL %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% BIBLIO_RESULT.biblionumber |url %][% END %] + [% OPACBaseURL %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% BIBLIO_RESULT.biblionumber |url %][% END %] Items : [% FOREACH ITEM_RESULT IN BIBLIO_RESULT.ITEM_RESULTS %] [% ITEM_RESULT.branchname %] [% ITEM_RESULT.location %] [% IF ( ITEM_RESULT.itemcallnumber ) %]([% ITEM_RESULT.itemcallnumber %])[% END %] [% ITEM_RESULT.barcode %][% END %] diff --git a/virtualshelves/sendshelf.pl b/virtualshelves/sendshelf.pl index 37a98ec..f8c46a8 100755 --- a/virtualshelves/sendshelf.pl +++ b/virtualshelves/sendshelf.pl @@ -100,8 +100,9 @@ if ( $email ) { push( @results, $dat ); } + my $protocol = C4::Context->preference('PublicCatalogUsesSSL') ? "https://" : "http://"; if (C4::Context->preference('OPACBaseURL')){ - $template2->param( OPACBaseURL => C4::Context->preference('OPACBaseURL') ); + $template2->param( OPACBaseURL => $protocol . C4::Context->preference('OPACBaseURL') ); } $template2->param( -- 1.7.9.5