|
Lines 28-33
require Exporter;
Link Here
|
| 28 |
use C4::Context; |
28 |
use C4::Context; |
| 29 |
use C4::Templates; # to get the template |
29 |
use C4::Templates; # to get the template |
| 30 |
use C4::Branch; # GetBranches |
30 |
use C4::Branch; # GetBranches |
|
|
31 |
use C4::Update::Database; |
| 31 |
use C4::VirtualShelves; |
32 |
use C4::VirtualShelves; |
| 32 |
use POSIX qw/strftime/; |
33 |
use POSIX qw/strftime/; |
| 33 |
use List::MoreUtils qw/ any /; |
34 |
use List::MoreUtils qw/ any /; |
|
Lines 133-141
sub get_template_and_user {
Link Here
|
| 133 |
my $in = shift; |
134 |
my $in = shift; |
| 134 |
my $template = |
135 |
my $template = |
| 135 |
C4::Templates::gettemplate( $in->{'template_name'}, $in->{'type'}, $in->{'query'} ); |
136 |
C4::Templates::gettemplate( $in->{'template_name'}, $in->{'type'}, $in->{'query'} ); |
| 136 |
my ( $user, $cookie, $sessionID, $flags ); |
137 |
my ( $user, $cookie, $sessionID, $flags, $new_session ); |
| 137 |
if ( $in->{'template_name'} !~m/maintenance/ ) { |
138 |
if ( $in->{'template_name'} !~m/maintenance/ ) { |
| 138 |
( $user, $cookie, $sessionID, $flags ) = checkauth( |
139 |
( $user, $cookie, $sessionID, $flags, $new_session ) = checkauth( |
| 139 |
$in->{'query'}, |
140 |
$in->{'query'}, |
| 140 |
$in->{'authnotrequired'}, |
141 |
$in->{'authnotrequired'}, |
| 141 |
$in->{'flagsrequired'}, |
142 |
$in->{'flagsrequired'}, |
|
Lines 477-482
sub get_template_and_user {
Link Here
|
| 477 |
|
478 |
|
| 478 |
$template->param(OpacPublic => '1') if ($user || C4::Context->preference("OpacPublic")); |
479 |
$template->param(OpacPublic => '1') if ($user || C4::Context->preference("OpacPublic")); |
| 479 |
} |
480 |
} |
|
|
481 |
|
| 482 |
if ( $new_session ) { |
| 483 |
# Check the version and redirect if DB is not up-to-date |
| 484 |
version_check($in->{query}, $in->{'type'}, $cookie); |
| 485 |
} |
| 486 |
|
| 480 |
return ( $template, $borrowernumber, $cookie, $flags); |
487 |
return ( $template, $borrowernumber, $cookie, $flags); |
| 481 |
} |
488 |
} |
| 482 |
|
489 |
|
|
Lines 565-570
sub _session_log {
Link Here
|
| 565 |
close L; |
572 |
close L; |
| 566 |
} |
573 |
} |
| 567 |
|
574 |
|
|
|
575 |
sub version_check { |
| 576 |
my ( $query, $type, $cookie ) = @_; |
| 577 |
# check we have a Version. Otherwise => go to installer |
| 578 |
unless ( C4::Context->preference('Version') ) { |
| 579 |
if ( $type ne 'opac' ) { |
| 580 |
$debug && warn "Install required, redirecting to Installer"; |
| 581 |
print $query->redirect("/cgi-bin/koha/installer/install.pl"); |
| 582 |
} else { |
| 583 |
$debug && warn "OPAC Install required, redirecting to maintenance"; |
| 584 |
print $query->redirect("/cgi-bin/koha/maintenance.pl"); |
| 585 |
} |
| 586 |
safe_exit; |
| 587 |
} |
| 588 |
|
| 589 |
# check if you're uptodate, and if you're not, head to updater |
| 590 |
my $koha39 =~ "3.0900000"; |
| 591 |
|
| 592 |
# Old updatedatabase method |
| 593 |
if (C4::Context->preference('Version') < $koha39) { |
| 594 |
print $query->redirect("/cgi-bin/koha/installer/install.pl?step=3"); |
| 595 |
safe_exit; |
| 596 |
} |
| 597 |
|
| 598 |
# New updatedatabase method |
| 599 |
unless ( C4::Update::Database::is_uptodate() ) { |
| 600 |
# not up-to-date, redirect to updatedatabase page |
| 601 |
warn "redirect to updatedatabase"; |
| 602 |
print $query->redirect(-location => "/cgi-bin/koha/admin/updatedatabase.pl", -cookie => $cookie); |
| 603 |
safe_exit; |
| 604 |
} |
| 605 |
} |
| 606 |
|
| 568 |
sub checkauth { |
607 |
sub checkauth { |
| 569 |
my $query = shift; |
608 |
my $query = shift; |
| 570 |
$debug and warn "Checking Auth"; |
609 |
$debug and warn "Checking Auth"; |
|
Lines 573-578
sub checkauth {
Link Here
|
| 573 |
my $flagsrequired = shift; |
612 |
my $flagsrequired = shift; |
| 574 |
my $type = shift; |
613 |
my $type = shift; |
| 575 |
$type = 'opac' unless $type; |
614 |
$type = 'opac' unless $type; |
|
|
615 |
my $new_session = 0; |
| 576 |
|
616 |
|
| 577 |
my $dbh = C4::Context->dbh; |
617 |
my $dbh = C4::Context->dbh; |
| 578 |
my $timeout = C4::Context->preference('timeout'); |
618 |
my $timeout = C4::Context->preference('timeout'); |
|
Lines 581-597
sub checkauth {
Link Here
|
| 581 |
$timeout = $1 * 86400; |
621 |
$timeout = $1 * 86400; |
| 582 |
}; |
622 |
}; |
| 583 |
$timeout = 600 unless $timeout; |
623 |
$timeout = 600 unless $timeout; |
| 584 |
# check we have a Version. Otherwise => go to installer |
|
|
| 585 |
unless ( C4::Context->preference('Version') ) { # assignment, not comparison |
| 586 |
if ( $type ne 'opac' ) { |
| 587 |
$debug && warn "Install required, redirecting to Installer"; |
| 588 |
print $query->redirect("/cgi-bin/koha/installer/install.pl"); |
| 589 |
} else { |
| 590 |
$debug && warn "OPAC Install required, redirecting to maintenance"; |
| 591 |
print $query->redirect("/cgi-bin/koha/maintenance.pl"); |
| 592 |
} |
| 593 |
safe_exit; |
| 594 |
} |
| 595 |
|
624 |
|
| 596 |
# state variables |
625 |
# state variables |
| 597 |
my $loggedin = 0; |
626 |
my $loggedin = 0; |
|
Lines 696-701
sub checkauth {
Link Here
|
| 696 |
my $sessionID = $session->id; |
725 |
my $sessionID = $session->id; |
| 697 |
C4::Context->_new_userenv($sessionID); |
726 |
C4::Context->_new_userenv($sessionID); |
| 698 |
$cookie = $query->cookie( CGISESSID => $sessionID ); |
727 |
$cookie = $query->cookie( CGISESSID => $sessionID ); |
|
|
728 |
|
| 699 |
$userid = $query->param('userid'); |
729 |
$userid = $query->param('userid'); |
| 700 |
if ( ( $cas && $query->param('ticket') ) |
730 |
if ( ( $cas && $query->param('ticket') ) |
| 701 |
|| $userid |
731 |
|| $userid |
|
Lines 710-715
sub checkauth {
Link Here
|
| 710 |
checkpw( $dbh, $userid, $password, $query ); |
740 |
checkpw( $dbh, $userid, $password, $query ); |
| 711 |
$userid = $retuserid; |
741 |
$userid = $retuserid; |
| 712 |
$info{'invalidCasLogin'} = 1 unless ($return); |
742 |
$info{'invalidCasLogin'} = 1 unless ($return); |
|
|
743 |
$new_session = 1; |
| 713 |
} |
744 |
} |
| 714 |
elsif ( |
745 |
elsif ( |
| 715 |
( $pki_field eq 'Common Name' && $ENV{'SSL_CLIENT_S_DN_CN'} ) |
746 |
( $pki_field eq 'Common Name' && $ENV{'SSL_CLIENT_S_DN_CN'} ) |
|
Lines 748-753
sub checkauth {
Link Here
|
| 748 |
( $return, $cardnumber, $retuserid ) = |
779 |
( $return, $cardnumber, $retuserid ) = |
| 749 |
checkpw( $dbh, $userid, $password, $query ); |
780 |
checkpw( $dbh, $userid, $password, $query ); |
| 750 |
$userid = $retuserid if ( $retuserid ne '' ); |
781 |
$userid = $retuserid if ( $retuserid ne '' ); |
|
|
782 |
$new_session = 1; |
| 751 |
} |
783 |
} |
| 752 |
if ($return) { |
784 |
if ($return) { |
| 753 |
#_session_log(sprintf "%20s from %16s logged in at %30s.\n", $userid,$ENV{'REMOTE_ADDR'},(strftime '%c', localtime)); |
785 |
#_session_log(sprintf "%20s from %16s logged in at %30s.\n", $userid,$ENV{'REMOTE_ADDR'},(strftime '%c', localtime)); |
|
Lines 889-895
sub checkauth {
Link Here
|
| 889 |
unless ($cookie) { |
921 |
unless ($cookie) { |
| 890 |
$cookie = $query->cookie( CGISESSID => '' ); |
922 |
$cookie = $query->cookie( CGISESSID => '' ); |
| 891 |
} |
923 |
} |
| 892 |
return ( $userid, $cookie, $sessionID, $flags ); |
924 |
return ( $userid, $cookie, $sessionID, $flags, $new_session ); |
| 893 |
} |
925 |
} |
| 894 |
|
926 |
|
| 895 |
# |
927 |
# |