Bugzilla – Attachment 38658 Details for
Bug 5010
Fix OPACBaseURL to include protocol
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 5010 - Fix OPACBaseURL to include protocol
Bug-5010---Fix-OPACBaseURL-to-include-protocol.patch (text/plain), 35.59 KB, created by
Jonathan Druart
on 2015-04-29 11:32:04 UTC
(
hide
)
Description:
Bug 5010 - Fix OPACBaseURL to include protocol
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2015-04-29 11:32:04 UTC
Size:
35.59 KB
patch
obsolete
>From 0c4bb9a9ccc57f100b41b28ad9ee86427dda14b8 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Wed, 11 Feb 2015 15:26:13 +0000 >Subject: [PATCH] Bug 5010 - Fix OPACBaseURL to include protocol > >First, it is strongly recommended to set the OPACBaseURL. But >this patch allows the inclusion of the protocol and not just >a site. > >Next, C4/Auth now puts OPACBaseURL into the template parameters >regardless of OPAC or Staff clients. t/db_dependent/Auth.t was >tweaked to add a check for confirming that get_template_and_user >adds OPACBaseURL to both OPAC and Staff templates. > >In the staff client, once the OPACBaseURL is set, you get a nice >OPAC View link when viewing a biblio's detail. It should reflect >the protocol used now. > >Hard coded 'http://' strings were removed from the >sample_notices.sql files. This is what required also updating >the letters table in the updatedatabase.pl script. > >The explanation text in the sysprefs.sql needed updating too to >reflect the inclusion of the protocol. And this was the other >update done in the updatedatabase.pl script. The opac.pref file >was similarly changed as well. > >catalogue/detail.pl had no need to pass a custom OpacUrl value, >since C4/Auth passes the required OPACBaseURL, so it and the >corresponding template were modified. > >Both the MARC21 and NORMARC intranet details files had 'http://' >hard coded in them. This was removed. > >Both the bootstrap and prog theme opac-detail template had a >protocol parameter that was used. The logic for the parameter >was not removed, because it is used extensively in one template. >Perhaps it should be used to simplify the other. However, the >calculated current_url parameter had references to the protocol >removed, because of the changes to OPACBaseURL. > >opac/opac-shareshelf.pl had a hard coded 'http://' which was >removed. > >t/db_dependent/Auth_with_cas.t had 'http://' added to the value >set for OPACBaseURL. > >In virtualshelves/sendshelf.pl explicit code which sent the >OPACBaseURL preference was removed, since C4/Auth sends it all >the time now. > >C4::Context::set_preference was tweaked to ensure that >OPACBaseURL would always start with http. >t/db_dependent/Context.t was tweaked to specifically test this. > >The Shibboleth authentication needs OPACBaseURL set, and that >it be https protocol. The _get_uri routine was tweaked to always >pass back https:// as the protocol on the OPACBaseURL. >t/Auth_with_shibboleth.t was tweaked to specifically test the >changes. > >TEST PLAN >--------- >This is not an easy patch to test. Difficulties include: >- configuring Koha to run under https > (tweaking apache2 isn't so hard, just tricky) >- configuring Koha to run OPAC and Staff with Plak > (since code with comments about plak were sliced out) >- configuring Koha to use CAS > (may be requires for the CAS test) > > 1) Apply patch > 2) Make sure OPACBaseURL is set without the protocol included. > >UPDATEDATABASE > 3) back up your DB > 4) ./installer/data/mysql/updatedatabase.pl > -- It should run without errors. > 5) Look up the OPACBaseURL system preference in the staff > client > -- It should have http:// prepended. > 6) Run the mysqlclient from your koha git directory > USE koha_library; > SELECT content FROM letter WHERE content LIKE "%<<OPACBaseURL>>%"; > -- There should be no prepended http:// on the > <<OPACBaseURL>>. > 7) restore your DB > 8) Make sure OPACBaseURL is set with the protocol included, > preferably https. > -- Using https requires a bunch of apache2 tweaks. > >AUTH > 9) Call up staff client. >10) Call up OPAC. > -- C4/Auth.pm doesn't barf. >11) Call up Plack staff client >12) Call up Plack OPAC. > -- C4/Auth.pm doesn't barf. >13) prove -v t/db_dependent/Auth.t > >CONTEXT >14) Home -> Koha administration -> Global System Preferences > -> OPAC >15) Modify and save OPACBaseURL to not have http:// or https:// > on it. > -- It should be modified to include http:// >16) Modify and save another system preference. > -- It should save normally >17) prove -v t/db_dependent/Context.t > >CATALOGUE/DETAIL (tt & pl) >18) Confirm the OPACBaseURL is set >19) Navigate to any biblio details in the staff client > -- There should be a "OPAC view" link which has the > correct http:// or https:// in it. > >SQL (sample notices and sysprefs) >20) Run the mysqlclient from your koha git directory > USE koha_library; > DELETE FROM letter; > source installer/data/mysql/de-DE/mandatory/sample_notices.sql; > SELECT content FROM letter WHERE content LIKE "%<<OPACBaseURL>>%"; > DELETE FROM letter; > source installer/data/mysql/en/mandatory/sample_notices.sql; > SELECT content FROM letter WHERE content LIKE "%<<OPACBaseURL>>%"; > DELETE FROM letter; > source installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql; > SELECT content FROM letter WHERE content LIKE "%<<OPACBaseURL>>%"; > DELETE FROM letter; > source installer/data/mysql/es-ES/mandatory/sample_notices.sql; > SELECT content FROM letter WHERE content LIKE "%<<OPACBaseURL>>%"; > DELETE FROM letter; > source installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql; > SELECT content FROM letter WHERE content LIKE "%<<OPACBaseURL>>%"; > DELETE FROM letter; > source installer/data/mysql/it-IT/necessari/notices.sql; > SELECT content FROM letter WHERE content LIKE "%<<OPACBaseURL>>%"; > DELETE FROM letter; > source installer/data/mysql/pl-PL/mandatory/sample_notices.sql; > SELECT content FROM letter WHERE content LIKE "%<<OPACBaseURL>>%"; > DELETE FROM letter; > source installer/data/mysql/ru-RU/mandatory/sample_notices.sql; > SELECT content FROM letter WHERE content LIKE "%<<OPACBaseURL>>%"; > DELETE FROM letter; > source installer/data/mysql/uk-UA/mandatory/sample_notices.sql; > SELECT content FROM letter WHERE content LIKE "%<<OPACBaseURL>>%"; > -- Each of the selects should should lines that have > <<OPACBaseURL>> starting them, but no hard-coded http:// > DELETE FROM systempreferences; > source installer/data/mysql/sysprefs.sql; > SELECT * FROM systempreferences WHERE variable='OPACBaseURL'; > -- The explanation should reflect the new explanation. > QUIT >21) restore your DB >22) Make sure OPACBaseURL is set with the protocol included, > preferably https. > -- Using https requires a bunch of apache2 tweaks. > >SLIM2INTRANETDETAIL >23) Set 'XSLTDetailsDisplay' system preference to default. >24) Set 'marcflavour' system preference to MARC21. >25) View any biblio's details. > -- the URL beside 'OPAC View' should have the appropriate > http:// or https:// >26) Set 'marcflavour' system preference to NORMARC. >27) View any biblio's details. > -- the URL beside 'OPAC View' should have the appropriate > http:// or https:// > >OPAC-DETAIL >28) Set 'opacthemes' to bootstrap. >29) Set 'SocialNetworks' to enabled. >30) In OPAC, view any biblio's details. > -- the Share links should have the appropriate protocol on > the OPACBaseURL. >31) Set 'opacthemes' to prog. >32) In OPAC, view any biblio's details. > -- the Share links should have the appropriate protocol on > the OPACBaseURL. > >AUTH_WITH_CAS >33) prove -v t/db_dependent/Auth_with_cas.t > >OPAC-SHARESHELF >34) Set 'OpacAllowSharingPrivateLists' to allow. >35) In OPAC, 'Save to Lists' a search result. >36) Save it to a new private list. >37) Click the Lists button, and select the new list. >38) Click the Share button. > >AUTH_WITH_SHIBBOLETH >39) prove -v t/Auth_with_shibboleth.t > -- needs to be tests on Debian, because I can't get > the Test::DBIx::Class installed in Ubuntu. :( > >Rebased again on kohadevbox... > >Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> >--- > C4/Auth.pm | 7 +---- > C4/Auth_with_shibboleth.pm | 16 +++++++++++- > C4/Context.pm | 5 ++++ > catalogue/detail.pl | 6 ----- > .../data/mysql/de-DE/mandatory/sample_notices.sql | 2 +- > .../data/mysql/en/mandatory/sample_notices.sql | 2 +- > .../data/mysql/es-ES/mandatory/sample_notices.sql | 2 +- > .../mysql/fr-FR/1-Obligatoire/sample_notices.sql | 2 +- > installer/data/mysql/it-IT/necessari/notices.sql | 2 +- > .../mysql/nb-NO/1-Obligatorisk/sample_notices.sql | 2 +- > .../data/mysql/pl-PL/mandatory/sample_notices.sql | 2 +- > .../data/mysql/ru-RU/mandatory/sample_notices.sql | 2 +- > installer/data/mysql/sysprefs.sql | 2 +- > .../data/mysql/uk-UA/mandatory/sample_notices.sql | 2 +- > installer/data/mysql/updatedatabase.pl | 24 +++++++++++++++++ > .../prog/en/modules/admin/preferences/opac.pref | 4 +-- > .../prog/en/modules/catalogue/detail.tt | 4 +-- > .../prog/en/xslt/MARC21slim2intranetDetail.xsl | 2 +- > .../prog/en/xslt/NORMARCslim2intranetDetail.xsl | 2 +- > .../opac-tmpl/bootstrap/en/modules/opac-detail.tt | 10 ++++---- > opac/opac-shareshelf.pl | 3 +-- > t/Auth_with_shibboleth.t | 26 +++++++++++++++++-- > t/db_dependent/Auth.t | 30 +++++++++++++++++++++- > t/db_dependent/Auth_with_cas.t | 2 +- > t/db_dependent/Context.t | 28 +++++++++++++++++++- > virtualshelves/sendshelf.pl | 5 ---- > 26 files changed, 148 insertions(+), 46 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 0e1b03f..2d04922 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -388,6 +388,7 @@ sub get_template_and_user { > noItemTypeImages => C4::Context->preference("noItemTypeImages"), > marcflavour => C4::Context->preference("marcflavour"), > persona => C4::Context->preference("persona"), >+ OPACBaseURL => C4::Context->preference('OPACBaseURL'), > ); > if ( $in->{'type'} eq "intranet" ) { > $template->param( >@@ -458,11 +459,6 @@ sub get_template_and_user { > $opac_name = C4::Context->userenv->{'branch'}; > } > >- # FIXME Under Plack the CGI->https method always returns 'OFF' ($using_https will be set to 0 in this case) >- my $opac_base_url = C4::Context->preference("OPACBaseURL"); #FIXME uses $using_https below as well >- if ( !$opac_base_url ) { >- $opac_base_url = $ENV{'SERVER_NAME'} . ( $ENV{'SERVER_PORT'} eq ( $using_https ? "443" : "80" ) ? '' : ":$ENV{'SERVER_PORT'}" ); >- } > $template->param( > OpacAdditionalStylesheet => C4::Context->preference("OpacAdditionalStylesheet"), > AnonSuggestions => "" . C4::Context->preference("AnonSuggestions"), >@@ -481,7 +477,6 @@ sub get_template_and_user { > OPACUserCSS => "" . C4::Context->preference("OPACUserCSS"), > OPACViewOthersSuggestions => "" . C4::Context->preference("OPACViewOthersSuggestions"), > OpacAuthorities => C4::Context->preference("OpacAuthorities"), >- OPACBaseURL => ( $using_https ? "https://" : "http://" ) . $opac_base_url, > opac_css_override => $ENV{'OPAC_CSS_OVERRIDE'}, > opac_search_limit => $opac_search_limit, > opac_limit_override => $opac_limit_override, >diff --git a/C4/Auth_with_shibboleth.pm b/C4/Auth_with_shibboleth.pm >index f9555fb..6c53c79 100644 >--- a/C4/Auth_with_shibboleth.pm >+++ b/C4/Auth_with_shibboleth.pm >@@ -113,7 +113,21 @@ sub _get_uri { > > my $protocol = "https://"; > >- my $return = $protocol . C4::Context->preference('OPACBaseURL'); >+ my $uri = C4::Context->preference('OPACBaseURL') // ''; >+ if ($uri eq '') { >+ $debug and warn 'OPACBaseURL not set!'; >+ } >+ if ($uri =~ /(.*):\/\/(.*)/) { >+ my $oldprotocol = $1; >+ if ($oldprotocol ne 'https') { >+ $debug >+ and warn >+ 'Shibboleth requires OPACBaseURL to use the https protocol!'; >+ } >+ $uri = $2; >+ } >+ >+ my $return = $protocol . $uri; > return $return; > } > >diff --git a/C4/Context.pm b/C4/Context.pm >index 42e7aa2..2fd39d4 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -638,6 +638,11 @@ sub set_preference { > > $value = 0 if ( $type && $type eq 'YesNo' && $value eq '' ); > >+ # force explicit protocol on OPACBaseURL >+ if ($var eq 'opacbaseurl' && substr($value,0,4) !~ /http/) { >+ $value = 'http://' . $value; >+ } >+ > my $sth = $dbh->prepare( " > INSERT INTO systempreferences > ( variable, value ) >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index d3b34eb..8fe6d74 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -396,12 +396,6 @@ if ( (C4::Context->preference("HTML5MediaEnabled") eq 'both') or (C4::Context->p > $template->param( C4::HTML5Media->gethtml5media($record)); > } > >- >-# Get OPAC URL >-if (C4::Context->preference('OPACBaseURL')){ >- $template->param( OpacUrl => C4::Context->preference('OPACBaseURL') ); >-} >- > # Displaying tags > > my $tag_quantity; >diff --git a/installer/data/mysql/de-DE/mandatory/sample_notices.sql b/installer/data/mysql/de-DE/mandatory/sample_notices.sql >index 5afc419..2398b69 100644 >--- a/installer/data/mysql/de-DE/mandatory/sample_notices.sql >+++ b/installer/data/mysql/de-DE/mandatory/sample_notices.sql >@@ -100,7 +100,7 @@ VALUES ( > > Ihr Bibliothekskonto wurde angelegt. Bitte bestätigen Sie Ihre E-Mail-Adresse indem Sie auf folgenden Link klicken: > >-http://<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower_modifications.verification_token>> >+<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower_modifications.verification_token>> > > Wenn Sie keine Kontoanmeldung durchgeführt haben, können Sie diese Benachrichtigung ignorieren. Sie wird in Kürze ungültig. > >diff --git a/installer/data/mysql/en/mandatory/sample_notices.sql b/installer/data/mysql/en/mandatory/sample_notices.sql >index 378be05..d6521c5 100644 >--- a/installer/data/mysql/en/mandatory/sample_notices.sql >+++ b/installer/data/mysql/en/mandatory/sample_notices.sql >@@ -113,7 +113,7 @@ VALUES ( > > Your library account has been created. Please verify your email address by clicking this link to complete the signup process: > >-http://<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower_modifications.verification_token>> >+<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower_modifications.verification_token>> > > If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly.' > ); >diff --git a/installer/data/mysql/es-ES/mandatory/sample_notices.sql b/installer/data/mysql/es-ES/mandatory/sample_notices.sql >index 3d0ca99..6bee039 100644 >--- a/installer/data/mysql/es-ES/mandatory/sample_notices.sql >+++ b/installer/data/mysql/es-ES/mandatory/sample_notices.sql >@@ -111,7 +111,7 @@ VALUES ( > > Your library account has been created. Please verify your email address by clicking this link to complete the signup process: > >-http://<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower_modifications.verification_token>> >+<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower_modifications.verification_token>> > > If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly.' > ); >diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql b/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql >index 9fd43a7..abe9b23 100644 >--- a/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql >+++ b/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql >@@ -114,7 +114,7 @@ VALUES ( > > Votre compte de bibliothèque a été créé. Veuillez valider votre adresse email et le processus d''inscription en cliquant sur ce lien: > >-http://<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower_modifications.verification_token>> >+<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower_modifications.verification_token>> > > Si vous n''êtes pas à l''origine de cette inscription, vous pouvez ignorer ce message.' > ); >diff --git a/installer/data/mysql/it-IT/necessari/notices.sql b/installer/data/mysql/it-IT/necessari/notices.sql >index c74df45..41faa9c 100644 >--- a/installer/data/mysql/it-IT/necessari/notices.sql >+++ b/installer/data/mysql/it-IT/necessari/notices.sql >@@ -113,7 +113,7 @@ VALUES ( > > Your library account has been created. Please verify your email address by clicking this link to complete the signup process: > >-http://<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower_modifications.verification_token>> >+<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower_modifications.verification_token>> > > If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly.' > ); >diff --git a/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql b/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql >index cb40756..1e6026e 100644 >--- a/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql >+++ b/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql >@@ -134,7 +134,7 @@ VALUES ( > > D har blitt registrert som bruker av biblioteket. Verifiser epostadressen din ved å klikke på lenka nedenfor: > >-http://<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower_modifications.verification_token>> >+<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower_modifications.verification_token>> > > Dersom du ikke har bedt om å bli registret som bruker av biblioteket kan du se bort fra denne engangsmeldingen. Forespørselen vil snart gå ut på dato.' > ); >diff --git a/installer/data/mysql/pl-PL/mandatory/sample_notices.sql b/installer/data/mysql/pl-PL/mandatory/sample_notices.sql >index 378be05..d6521c5 100644 >--- a/installer/data/mysql/pl-PL/mandatory/sample_notices.sql >+++ b/installer/data/mysql/pl-PL/mandatory/sample_notices.sql >@@ -113,7 +113,7 @@ VALUES ( > > Your library account has been created. Please verify your email address by clicking this link to complete the signup process: > >-http://<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower_modifications.verification_token>> >+<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower_modifications.verification_token>> > > If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly.' > ); >diff --git a/installer/data/mysql/ru-RU/mandatory/sample_notices.sql b/installer/data/mysql/ru-RU/mandatory/sample_notices.sql >index ff767c2..794c404 100644 >--- a/installer/data/mysql/ru-RU/mandatory/sample_notices.sql >+++ b/installer/data/mysql/ru-RU/mandatory/sample_notices.sql >@@ -114,7 +114,7 @@ VALUES ( > > Your library account has been created. Please verify your email address by clicking this link to complete the signup process: > >-http://<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower_modifications.verification_token>> >+<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower_modifications.verification_token>> > > If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly.' > ); >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index f3b0847..518eef2 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -242,7 +242,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('OPACAllowUserToChooseBranch','1','1','Allow the user to choose the branch they want to pickup their hold from','YesNo'), > ('OPACAmazonCoverImages','0','','Display cover images on OPAC from Amazon Web Services','YesNo'), > ('OpacAuthorities','1',NULL,'If ON, enables the search authorities link on OPAC','YesNo'), >-('OPACBaseURL',NULL,NULL,'Specify the Base URL of the OPAC, e.g., opac.mylibrary.com, the http:// will be added automatically by Koha.','Free'), >+('OPACBaseURL',NULL,NULL,'Specify the Base URL of the OPAC, e.g., http://opac.mylibrary.com, including the protocol (http:// or https://). Otherwise, the http:// will be added automatically by Koha upon saving.','Free'), > ('opacbookbag','1','','If ON, enables display of Cart feature','YesNo'), > ('OpacBrowser','0',NULL,'If ON, enables subject authorities browser on OPAC (needs to set misc/cronjob/sbuild_browser_and_cloud.pl)','YesNo'), > ('OpacBrowseResults','1',NULL,'Disable/enable browsing and paging search results from the OPAC detail page.','YesNo'), >diff --git a/installer/data/mysql/uk-UA/mandatory/sample_notices.sql b/installer/data/mysql/uk-UA/mandatory/sample_notices.sql >index 547a3f7..1904286 100644 >--- a/installer/data/mysql/uk-UA/mandatory/sample_notices.sql >+++ b/installer/data/mysql/uk-UA/mandatory/sample_notices.sql >@@ -113,7 +113,7 @@ VALUES ( > > Your library account has been created. Please verify your email address by clicking this link to complete the signup process: > >-http://<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower_modifications.verification_token>> >+<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower_modifications.verification_token>> > > If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly.' > ); >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 5d1b778..024324b 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -10267,6 +10267,29 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = '3.19.00.XXX'; >+if ( CheckVersion($DBversion) ) { >+ my $OPACBaseURL = C4::Context->preference('OPACBaseURL'); >+ if (defined($OPACBaseURL) && substr($OPACBaseURL,0,4) ne "http") { >+ my $explanation = q{Specify the Base URL of the OPAC, e.g., http://opac.mylibrary.com, including the protocol (http:// or https://). Otherwise, the http:// will be added automatically by Koha upon saving.}; >+ $OPACBaseURL = 'http://' . $OPACBaseURL; >+ my $sth_OPACBaseURL = $dbh->prepare( q{ >+ UPDATE systempreferences SET value=?,explanation=? >+ WHERE variable='OPACBaseURL'; } ); >+ $sth_OPACBaseURL->execute($OPACBaseURL,$explanation); >+ } >+ if (defined($OPACBaseURL)) { >+ $dbh->do( q{ UPDATE letter >+ SET content=replace(content, >+ 'http://<<OPACBaseURL>>', >+ '<<OPACBaseURL>>') >+ WHERE content LIKE "%http://<<OPACBaseURL>>%"; } ); >+ } >+ >+ print "Upgrade to $DBversion done (Bug 5010: Fix OPACBaseURL to include protocol)\n"; >+ SetVersion($DBversion); >+} >+ > # DEVELOPER PROCESS, search for anything to execute in the db_update directory > # SEE bug 13068 > # if there is anything in the atomicupdate, read and execute it. >@@ -10280,6 +10303,7 @@ while ( my $file = readdir $dirh ) { > my $rv = $installer->load_sql( $update_dir . $file ) ? 0 : 1; > } > >+ > =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 c26d048..6529578 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 >@@ -13,10 +13,10 @@ OPAC: > prog: prog > - theme as the fallback theme on the OPAC. > - >- - "The OPAC is located at http://" >+ - "The OPAC is located at " > - pref: OPACBaseURL > class: url >- - . Do not include a trailing slash in the URL. (This must be filled in correctly for RSS, unAPI, and search plugins to work.) >+ - . This should be a complete URL, starting with <code>http://</code> or <code>https://</code>. Do not include a trailing slash in the URL. (This must be filled in correctly for RSS, unAPI, and search plugins to work.) > - > - Show > - pref: LibraryName >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >index a392e1a..566b8f1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -445,9 +445,9 @@ function verify_images() { > </li> > [% END %] > >- [% IF ( OpacUrl ) %] >+ [% IF ( OPACBaseURL ) %] > <li><strong>OPAC view:</strong> >- <a href="http://[% OpacUrl %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]" target="_blank">Open in new window</a> >+ <a href="[% OPACBaseURL %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]" target="_blank">Open in new window</a> > </li> > [% END %] > <li id="catalogue_detail_marc_preview"> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl >index 913a285..1ab7a68 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl >+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl >@@ -937,7 +937,7 @@ > > <xsl:if test="$OPACBaseURL!=''"> > <span class="results_summary"><span class="label">OPAC view: </span> >- <a><xsl:attribute name="href">http://<xsl:value-of select="$OPACBaseURL"/>/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="marc:datafield[@tag=999]/marc:subfield[@code='c']"/></xsl:attribute><xsl:attribute name="target">_blank</xsl:attribute>Open in new window</a>. >+ <a><xsl:attribute name="href"><xsl:value-of select="$OPACBaseURL"/>/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="marc:datafield[@tag=999]/marc:subfield[@code='c']"/></xsl:attribute><xsl:attribute name="target">_blank</xsl:attribute>Open in new window</a>. > </span> > </xsl:if> > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/NORMARCslim2intranetDetail.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/NORMARCslim2intranetDetail.xsl >index 9db138c..62df2a7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/xslt/NORMARCslim2intranetDetail.xsl >+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/NORMARCslim2intranetDetail.xsl >@@ -588,7 +588,7 @@ > <!-- This will only work if the OPACBaseURL syspref is set. --> > <xsl:if test="string-length($OPACBaseURL) > 0"> > <p>OPAC View: <a> >- <xsl:attribute name="href">http://<xsl:value-of select="$OPACBaseURL"/>/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="$biblionumber"/></xsl:attribute> >+ <xsl:attribute name="href"><xsl:value-of select="$OPACBaseURL"/>/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="$biblionumber"/></xsl:attribute> > <xsl:attribute name="target">_blank</xsl:attribute> > Open in new window > </a></p> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >index f0310d5..21b2871 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >@@ -1117,12 +1117,12 @@ > [% IF ( SocialNetworks ) %] > <div id="social_networks" class="clearfix"> > <span>Share</span> >- <div><a id="facebook" href="http://www.facebook.com/sharer.php?u=[% protocol %][% current_url |url %]&t=[% title |url %]" title="Share on Facebook">Facebook</a></div> >- <div><a id="linkedin" href="http://www.linkedin.com/shareArticle?mini=true&url=[% protocol %][% current_url |url %]&title=[% title |url %]" title="Share on LinkedIn">LinkedIn</a></div> >- <div><a id="delicious" href="http://www.delicious.com/save?url=[% protocol %][% current_url |url %]&title=[% title |url %]" title="Share on Delicious">Delicious</a></div> >- <div><a id="email" href="mailto:?subject=[% title |url %]&body=[% title |url %]%20([% protocol %][% current_url |url %])" title="Share by email">Email</a></div> >+ <div><a id="facebook" href="http://www.facebook.com/sharer.php?u=[% current_url |url %]&t=[% title |url %]" title="Share on Facebook">Facebook</a></div> >+ <div><a id="linkedin" href="http://www.linkedin.com/shareArticle?mini=true&url=[% current_url |url %]&title=[% title |url %]" title="Share on LinkedIn">LinkedIn</a></div> >+ <div><a id="delicious" href="http://www.delicious.com/save?url=[% current_url |url %]&title=[% title |url %]" title="Share on Delicious">Delicious</a></div> >+ <div><a id="email" href="mailto:?subject=[% title |url %]&body=[% title |url %]%20([% current_url |url %])" title="Share by email">Email</a></div> > <div><div class="g-plusone" data-size="small" data-count="false"></div></div> >- <div><a id="twitter" href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-text="[% title %]" data-lang="[% lang %]">Tweet</a></div> >+ <div><a id="twitter" href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-text="[% title |url %]" data-lang="[% lang %]">Tweet</a></div> > </div> > [% END %] > </div> <!-- / .ulactioncontainer --> >diff --git a/opac/opac-shareshelf.pl b/opac/opac-shareshelf.pl >index f29e170..ba962b2 100755 >--- a/opac/opac-shareshelf.pl >+++ b/opac/opac-shareshelf.pl >@@ -179,8 +179,7 @@ sub send_invitekey { > my ($param) = @_; > my $fromaddr = C4::Context->preference('KohaAdminEmailAddress'); > my $url = >- 'http://' >- . C4::Context->preference('OPACBaseURL') >+ C4::Context->preference('OPACBaseURL') > . "/cgi-bin/koha/opac-shareshelf.pl?shelfnumber=" > . $param->{shelfnumber} > . "&op=accept&key="; >diff --git a/t/Auth_with_shibboleth.t b/t/Auth_with_shibboleth.t >index 82c95b9..6b4a727 100644 >--- a/t/Auth_with_shibboleth.t >+++ b/t/Auth_with_shibboleth.t >@@ -27,7 +27,7 @@ use C4::Context; > > BEGIN { > if ( check_install( module => 'Test::DBIx::Class' ) ) { >- plan tests => 6; >+ plan tests => 9; > } else { > plan skip_all => "Need Test::DBIx::Class" > } >@@ -59,6 +59,7 @@ sub mockedConfig { > } > > ### Mock ->preference >+my $OPACBaseURL = "testopac.com"; > $context->mock( 'preference', \&mockedPref ); > > sub mockedPref { >@@ -66,7 +67,7 @@ sub mockedPref { > my $return; > > if ( $param eq 'OPACBaseURL' ) { >- $return = "testopac.com"; >+ $return = $OPACBaseURL; > } > > return $return; >@@ -237,8 +238,29 @@ subtest "checkpw_shib tests" => sub { > }; > > ## _get_uri >+$OPACBaseURL = "testopac.com"; > is( C4::Auth_with_shibboleth::_get_uri(), > "https://testopac.com", "https opac uri returned" ); > >+$OPACBaseURL = "http://testopac.com"; >+my $result; >+warnings_are { $result = C4::Auth_with_shibboleth::_get_uri() } >+ [ { carped => >+ 'Shibboleth requires OPACBaseURL to use the https protocol!' }, >+ ], >+ "improper protocol - received expected warning"; >+is( $result, "https://testopac.com", "https opac uri returned" ); >+ >+$OPACBaseURL = "https://testopac.com"; >+is( C4::Auth_with_shibboleth::_get_uri(), >+ "https://testopac.com", "https opac uri returned" ); >+ >+$OPACBaseURL = undef; >+warnings_are { $result = C4::Auth_with_shibboleth::_get_uri() } >+ [ { carped => 'OPACBaseURL not set!' }, >+ ], >+ "undefined OPACBaseURL - received expected warning"; >+is( $result, "https://", "https opac uri returned" ); >+ > ## _get_shib_config > # Internal helper function, covered in tests above >diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t >index f769040..2cb1d5f 100644 >--- a/t/db_dependent/Auth.t >+++ b/t/db_dependent/Auth.t >@@ -8,7 +8,7 @@ use Modern::Perl; > use CGI qw ( -utf8 ); > use Test::MockModule; > use List::MoreUtils qw/all any none/; >-use Test::More tests => 6; >+use Test::More tests => 8; > use C4::Members; > use Koha::AuthUtils qw/hash_password/; > >@@ -107,6 +107,34 @@ $dbh->{RaiseError} = 1; > 'BZ9735: invalid language, then default to en'); > } > >+# Check that there is always an OPACBaseURL set. >+my $input = CGI->new(); >+my ( $template1, $borrowernumber, $cookie ); >+( $template1, $borrowernumber, $cookie ) = get_template_and_user( >+ { >+ template_name => "opac-detail.tt", >+ type => "opac", >+ query => $input, >+ authnotrequired => 1, >+ } >+); >+ >+ok( ( any { 'OPACBaseURL' eq $_ } keys %{$template1->{VARS}} ), >+ 'OPACBaseURL is in OPAC template' ); >+ >+my ( $template2 ); >+( $template2, $borrowernumber, $cookie ) = get_template_and_user( >+ { >+ template_name => "catalogue/detail.tt", >+ type => "intranet", >+ query => $input, >+ authnotrequired => 1, >+ } >+); >+ >+ok( ( any { 'OPACBaseURL' eq $_ } keys %{$template2->{VARS}} ), >+ 'OPACBaseURL is in Staff template' ); >+ > my $hash1 = hash_password('password'); > my $hash2 = hash_password('password'); > >diff --git a/t/db_dependent/Auth_with_cas.t b/t/db_dependent/Auth_with_cas.t >index eb359a9..b67ba1e 100755 >--- a/t/db_dependent/Auth_with_cas.t >+++ b/t/db_dependent/Auth_with_cas.t >@@ -38,7 +38,7 @@ my $dbh = C4::Context->dbh; > $dbh->{ AutoCommit } = 0; > $dbh->{ RaiseError } = 1; > >-C4::Context->set_preference('OPACBaseURL','localhost'); >+C4::Context->set_preference('OPACBaseURL','http://localhost'); > C4::Context->set_preference('staffClientBaseURL','localhost:8080'); > > my $opac_base_url = C4::Context->preference('OpacBaseURL'); >diff --git a/t/db_dependent/Context.t b/t/db_dependent/Context.t >index feb2a43..e623bf7 100755 >--- a/t/db_dependent/Context.t >+++ b/t/db_dependent/Context.t >@@ -18,8 +18,34 @@ BEGIN { > use_ok('C4::Context'); > } > >-ok($koha = C4::Context->new, 'C4::Context->new'); > ok($dbh = C4::Context->dbh(), 'Getting dbh from C4::Context'); >+ >+$dbh->begin_work; >+C4::Context->disable_syspref_cache(); >+C4::Context->set_preference('OPACBaseURL','junk'); >+C4::Context->clear_syspref_cache(); >+my $OPACBaseURL = C4::Context->preference('OPACBaseURL'); >+is($OPACBaseURL,'http://junk','OPACBaseURL saved with http:// when missing it'); >+ >+C4::Context->set_preference('OPACBaseURL','https://junk'); >+C4::Context->clear_syspref_cache(); >+$OPACBaseURL = C4::Context->preference('OPACBaseURL'); >+is($OPACBaseURL,'https://junk','OPACBaseURL saved with https:// as specified'); >+ >+C4::Context->set_preference('OPACBaseURL','http://junk2'); >+C4::Context->clear_syspref_cache(); >+$OPACBaseURL = C4::Context->preference('OPACBaseURL'); >+is($OPACBaseURL,'http://junk2','OPACBaseURL saved with http:// as specified'); >+ >+C4::Context->set_preference('SillyPreference','random'); >+C4::Context->clear_syspref_cache(); >+my $SillyPeference = C4::Context->preference('SillyPreference'); >+is($SillyPeference,'random','SillyPreference saved as specified'); >+C4::Context->clear_syspref_cache(); >+C4::Context->enable_syspref_cache(); >+$dbh->rollback; >+ >+ok($koha = C4::Context->new, 'C4::Context->new'); > ok($ret = C4::Context->KOHAVERSION, ' (function) KOHAVERSION = ' . ($ret||'')); > ok($ret = $koha->KOHAVERSION, ' $koha->KOHAVERSION = ' . ($ret||'')); > ok( >diff --git a/virtualshelves/sendshelf.pl b/virtualshelves/sendshelf.pl >index 3696ba1..b2941e3 100755 >--- a/virtualshelves/sendshelf.pl >+++ b/virtualshelves/sendshelf.pl >@@ -101,11 +101,6 @@ if ($email) { > push( @results, $dat ); > } > >- if ( C4::Context->preference('OPACBaseURL') ) { >- $template2->param( >- OPACBaseURL => C4::Context->preference('OPACBaseURL') ); >- } >- > $template2->param( > BIBLIO_RESULTS => \@results, > email_sender => $mail{'from'}, >-- >2.1.0
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 5010
:
22945
|
23436
|
23457
|
25877
|
25878
|
25879
|
27049
|
27072
|
27431
|
27432
|
27433
|
27435
|
27436
|
27437
|
27673
|
27779
|
27951
|
27952
|
27953
|
27954
|
31727
|
31728
|
31729
|
31787
|
33726
|
35662
|
35760
|
35833
|
35847
|
35852
|
35853
|
35854
|
36177
|
37695
|
38128
|
38658
|
38659
|
38833
|
38834
|
39008
|
39009
|
39086
|
39087
|
39358
|
39359