+sub _version_check ($$) {
+ my $type = shift;
+ my $query = shift;
+ my $version;
+ # If Version syspref is unavailable, it means Koha is beeing installed,
+ # and so we must redirect to OPAC maintenance page or to the WebInstaller
+ #warn "about to check version";
+ unless ($version = C4::Context->preference('Version')) { # assignment, not comparison
+ if ($type ne 'opac') {
+ warn "Install required, redirecting to Installer";
+ print $query->redirect("/cgi-bin/koha/installer/install.pl");
+ }
+ else {
+ warn "OPAC Install required, redirecting to maintenance";
+ print $query->redirect("/cgi-bin/koha/maintenance.pl");
+ }
+ exit;
+ }
+
+ # check that database and koha version are the same
+ # there is no DB version, it's a fresh install,
+ # go to web installer
+ # there is a DB version, compare it to the code version
+ my $kohaversion=C4::Context::KOHAVERSION;
+ # remove the 3 last . to have a Perl number
+ $kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
+ # warn "kohaversion : $kohaversion";
+ if ($version < $kohaversion){
+ my $warning = "Database update needed, redirecting to %s. Database is $version and Koha is "
+ . C4::Context->config("kohaversion");
+ if ($type ne 'opac'){
+ warn sprintf($warning, 'Installer');
+ print $query->redirect("/cgi-bin/koha/installer/install.pl?step=3");
+ } else {
+ warn sprintf("OPAC: " . $warning, 'maintenance');
+ print $query->redirect("/cgi-bin/koha/maintenance.pl");
+ }
+ exit;
+ }
+}
+
+sub _session_log {
+ (@_) or return 0;
+ open L, ">>/tmp/sessionlog";
+ printf L join("\n",@_);
+ close L;
+}
+