Lines 30-35
use C4::Context;
Link Here
|
30 |
use C4::Templates; # to get the template |
30 |
use C4::Templates; # to get the template |
31 |
use C4::Languages; |
31 |
use C4::Languages; |
32 |
use C4::Search::History; |
32 |
use C4::Search::History; |
|
|
33 |
use C4::Installer; |
33 |
use Koha; |
34 |
use Koha; |
34 |
use Koha::Logger; |
35 |
use Koha::Logger; |
35 |
use Koha::Caches; |
36 |
use Koha::Caches; |
Lines 47-52
use Encode;
Link Here
|
47 |
use C4::Auth_with_shibboleth qw( shib_ok get_login_shib login_shib_url logout_shib checkpw_shib ); |
48 |
use C4::Auth_with_shibboleth qw( shib_ok get_login_shib login_shib_url logout_shib checkpw_shib ); |
48 |
use Net::CIDR; |
49 |
use Net::CIDR; |
49 |
use C4::Log qw( logaction ); |
50 |
use C4::Log qw( logaction ); |
|
|
51 |
use Koha::Migrations; |
50 |
|
52 |
|
51 |
# use utf8; |
53 |
# use utf8; |
52 |
|
54 |
|
Lines 595-601
sub get_template_and_user {
Link Here
|
595 |
OPACPrivacy => C4::Context->preference("OPACPrivacy"), |
597 |
OPACPrivacy => C4::Context->preference("OPACPrivacy"), |
596 |
OPACFinesTab => C4::Context->preference("OPACFinesTab"), |
598 |
OPACFinesTab => C4::Context->preference("OPACFinesTab"), |
597 |
OpacTopissue => C4::Context->preference("OpacTopissue"), |
599 |
OpacTopissue => C4::Context->preference("OpacTopissue"), |
598 |
'Version' => C4::Context->preference('Version'), |
|
|
599 |
hidelostitems => C4::Context->preference("hidelostitems"), |
600 |
hidelostitems => C4::Context->preference("hidelostitems"), |
600 |
mylibraryfirst => ( C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv ) ? C4::Context->userenv->{'branch'} : '', |
601 |
mylibraryfirst => ( C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv ) ? C4::Context->userenv->{'branch'} : '', |
601 |
opacbookbag => "" . C4::Context->preference("opacbookbag"), |
602 |
opacbookbag => "" . C4::Context->preference("opacbookbag"), |
Lines 729-735
has authenticated.
Link Here
|
729 |
sub _version_check { |
730 |
sub _version_check { |
730 |
my $type = shift; |
731 |
my $type = shift; |
731 |
my $query = shift; |
732 |
my $query = shift; |
732 |
my $version; |
|
|
733 |
|
733 |
|
734 |
# If version syspref is unavailable, it means Koha is being installed, |
734 |
# If version syspref is unavailable, it means Koha is being installed, |
735 |
# and so we must redirect to OPAC maintenance page or to the WebInstaller |
735 |
# and so we must redirect to OPAC maintenance page or to the WebInstaller |
Lines 739-745
sub _version_check {
Link Here
|
739 |
print $query->redirect("/cgi-bin/koha/maintenance.pl"); |
739 |
print $query->redirect("/cgi-bin/koha/maintenance.pl"); |
740 |
safe_exit; |
740 |
safe_exit; |
741 |
} |
741 |
} |
742 |
unless ( $version = C4::Context->preference('Version') ) { # assignment, not comparison |
742 |
unless ( C4::Installer::TableExists('systempreferences') ) { |
743 |
if ( $type ne 'opac' ) { |
743 |
if ( $type ne 'opac' ) { |
744 |
warn "Install required, redirecting to Installer"; |
744 |
warn "Install required, redirecting to Installer"; |
745 |
print $query->redirect("/cgi-bin/koha/installer/install.pl"); |
745 |
print $query->redirect("/cgi-bin/koha/installer/install.pl"); |
Lines 750-766
sub _version_check {
Link Here
|
750 |
safe_exit; |
750 |
safe_exit; |
751 |
} |
751 |
} |
752 |
|
752 |
|
753 |
# check that database and koha version are the same |
753 |
if (Koha::Migrations->pending_migrations > 0) { |
754 |
# there is no DB version, it's a fresh install, |
754 |
my $warning = "Database update needed, redirecting to %s"; |
755 |
# go to web installer |
|
|
756 |
# there is a DB version, compare it to the code version |
757 |
my $kohaversion = Koha::version(); |
758 |
|
759 |
# remove the 3 last . to have a Perl number |
760 |
$kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/; |
761 |
Koha::Logger->get->debug("kohaversion : $kohaversion"); |
762 |
if ( $version < $kohaversion ) { |
763 |
my $warning = "Database update needed, redirecting to %s. Database is $version and Koha is $kohaversion"; |
764 |
if ( $type ne 'opac' ) { |
755 |
if ( $type ne 'opac' ) { |
765 |
warn sprintf( $warning, 'Installer' ); |
756 |
warn sprintf( $warning, 'Installer' ); |
766 |
print $query->redirect("/cgi-bin/koha/installer/install.pl?step=1&op=updatestructure"); |
757 |
print $query->redirect("/cgi-bin/koha/installer/install.pl?step=1&op=updatestructure"); |
Lines 1440-1454
sub check_api_auth {
Link Here
|
1440 |
my $dbh = C4::Context->dbh; |
1431 |
my $dbh = C4::Context->dbh; |
1441 |
my $timeout = _timeout_syspref(); |
1432 |
my $timeout = _timeout_syspref(); |
1442 |
|
1433 |
|
1443 |
unless ( C4::Context->preference('Version') ) { |
1434 |
if ( Koha::Migrations->pending_migrations > 0 ) { |
1444 |
|
|
|
1445 |
# database has not been installed yet |
1446 |
return ( "maintenance", undef, undef ); |
1447 |
} |
1448 |
my $kohaversion = Koha::version(); |
1449 |
$kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/; |
1450 |
if ( C4::Context->preference('Version') < $kohaversion ) { |
1451 |
|
1452 |
# database in need of version update; assume that |
1435 |
# database in need of version update; assume that |
1453 |
# no API should be called while databsae is in |
1436 |
# no API should be called while databsae is in |
1454 |
# this condition. |
1437 |
# this condition. |
Lines 1644-1660
sub check_cookie_auth {
Link Here
|
1644 |
my $skip_version_check = $params->{skip_version_check}; # Only for checkauth |
1627 |
my $skip_version_check = $params->{skip_version_check}; # Only for checkauth |
1645 |
|
1628 |
|
1646 |
unless ( $skip_version_check ) { |
1629 |
unless ( $skip_version_check ) { |
1647 |
unless ( C4::Context->preference('Version') ) { |
1630 |
if ( Koha::Migrations->pending_migrations > 0 ) { |
1648 |
|
|
|
1649 |
# database has not been installed yet |
1650 |
return ( "maintenance", undef ); |
1651 |
} |
1652 |
my $kohaversion = Koha::version(); |
1653 |
$kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/; |
1654 |
if ( C4::Context->preference('Version') < $kohaversion ) { |
1655 |
|
1656 |
# database in need of version update; assume that |
1631 |
# database in need of version update; assume that |
1657 |
# no API should be called while databsae is in |
1632 |
# no API should be called while database is in |
1658 |
# this condition. |
1633 |
# this condition. |
1659 |
return ( "maintenance", undef ); |
1634 |
return ( "maintenance", undef ); |
1660 |
} |
1635 |
} |