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(
$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"),
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,
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;
}
$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 )
$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;
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.
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.'
);
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.'
);
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.'
);
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.'
);
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.'
);
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.'
);
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.'
);
('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'),
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.'
);
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.
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
</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">
<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>
<!-- 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>
[% 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 -->
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=";
BEGIN {
if ( check_install( module => 'Test::DBIx::Class' ) ) {
- plan tests => 6;
+ plan tests => 9;
} else {
plan skip_all => "Need Test::DBIx::Class"
}
}
### Mock ->preference
+my $OPACBaseURL = "testopac.com";
$context->mock( 'preference', \&mockedPref );
sub mockedPref {
my $return;
if ( $param eq 'OPACBaseURL' ) {
- $return = "testopac.com";
+ $return = $OPACBaseURL;
}
return $return;
};
## _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
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/;
'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');
$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');
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');
my @keys = keys %$koha;
my $width = 0;
if (ok(@keys)) {
push( @results, $dat );
}
- if ( C4::Context->preference('OPACBaseURL') ) {
- $template2->param(
- OPACBaseURL => C4::Context->preference('OPACBaseURL') );
- }
-
$template2->param(
BIBLIO_RESULTS => \@results,
email_sender => $mail{'from'},