From 03e2337c07d79ae53a5a2705d225105c50bf9b58 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 NOTE: The rebase removed sendshelf.tt, because bug 11248 removed the hardcoded http:// in the template file. That may have been a mistake, since nothing was added to the corresponding sendshelf.pl file. Signed-off-by: Bernardo Gonzalez Kriegel Add a sign --- basket/sendbasket.pl | 7 ++++++- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 9 +++++++++ .../prog/en/modules/admin/preferences/opac.pref | 7 +++++++ virtualshelves/sendshelf.pl | 3 ++- 5 files changed, 25 insertions(+), 2 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 05a0031..71e817d 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -310,6 +310,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 8917081..2634cd8 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8202,6 +8202,15 @@ if ( CheckVersion($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 5483e0a..f822683 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 @@ -454,6 +454,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/virtualshelves/sendshelf.pl b/virtualshelves/sendshelf.pl index cc3afde..0341ab9 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