use C4::Koha;
use C4::Branch; # GetBranches
+# use utf8;
# use Net::LDAP;
# use Net::LDAP qw(:all);
{
template_name => "opac-main.tmpl",
query => $query,
- type => "opac",
- authnotrequired => 1,
- flagsrequired => {borrow => 1},
- }
+ type => "opac",
+ authnotrequired => 1,
+ flagsrequired => {borrow => 1},
+ }
);
print $query->header(
{
template_name => "opac-main.tmpl",
query => $query,
- type => "opac",
- authnotrequired => 1,
- flagsrequired => {borrow => 1},
- }
+ type => "opac",
+ authnotrequired => 1,
+ flagsrequired => {borrow => 1},
+ }
);
This call passes the C<query>, C<flagsrequired> and C<authnotrequired>
my $borrowernumber;
my $insecure = C4::Context->preference('insecure');
if ($user or $insecure) {
+
+ # load the template variables for stylesheets and JavaScript
+ $template->param( css_libs => $in->{'css_libs'} );
+ $template->param( css_module => $in->{'css_module'} );
+ $template->param( css_page => $in->{'css_page'} );
+ $template->param( css_widgets => $in->{'css_widgets'} );
+
+ $template->param( js_libs => $in->{'js_libs'} );
+ $template->param( js_module => $in->{'js_module'} );
+ $template->param( js_page => $in->{'js_page'} );
+ $template->param( js_widgets => $in->{'js_widgets'} );
+
+ # user info
$template->param( loggedinusername => $user );
$template->param( sessionID => $sessionID );
$template->param( CAN_user_updatecharge => 1 );
$template->param( CAN_user_acquisition => 1 );
$template->param( CAN_user_management => 1 );
- $template->param( CAN_user_tools => 1 );
+ $template->param( CAN_user_tools => 1 );
$template->param( CAN_user_editauthorities => 1 );
$template->param( CAN_user_serials => 1 );
$template->param( CAN_user_reports => 1 );
if ( $flags && $flags->{tools} == 1 ) {
$template->param( CAN_user_tools => 1 );
}
-
+
if ( $flags && $flags->{editauthorities} == 1 ) {
$template->param( CAN_user_editauthorities => 1 );
}
-
+
if ( $flags && $flags->{serials} == 1 ) {
$template->param( CAN_user_serials => 1 );
}
LibraryName => C4::Context->preference("LibraryName"),
LoginBranchcode => (C4::Context->userenv?C4::Context->userenv->{"branch"}:"insecure"),
LoginBranchname => (C4::Context->userenv?C4::Context->userenv->{"branchname"}:"insecure"),
+ LoginFirstname => (C4::Context->userenv?C4::Context->userenv->{"firstname"}:"Bel"),
+ LoginSurname => C4::Context->userenv?C4::Context->userenv->{"surname"}:"Inconnu",
AutoLocation => C4::Context->preference("AutoLocation"),
hide_marc => C4::Context->preference("hide_marc"),
patronimages => C4::Context->preference("patronimages"),
virtualshelves => C4::Context->preference("virtualshelves"),
LibraryName => C4::Context->preference("LibraryName"),
KohaAdminEmailAddress => "" . C4::Context->preference("KohaAdminEmailAddress"),
+ IntranetmainUserblock => C4::Context->preference("IntranetmainUserblock"),
);
}
else {
- warn "template type should be OPAC, here it is=[" . $in->{'type'} . "]"
- unless ( $in->{'type'} eq 'opac' );
+ warn "template type should be OPAC, here it is=[" . $in->{'type'} . "]" unless ( $in->{'type'} eq 'opac' );
my $LibraryNameTitle = C4::Context->preference("LibraryName");
$LibraryNameTitle =~ s/<(?:\/?)(?:br|p)\s*(?:\/?)>/ /sgi;
$LibraryNameTitle =~ s/<(?:[^<>'"]|'(?:[^']*)'|"(?:[^"]*)")*>//sg;
- $template->param(
+ $template->param(
KohaAdminEmailAddress => "" . C4::Context->preference("KohaAdminEmailAddress"),
suggestion => "" . C4::Context->preference("suggestion"),
virtualshelves => "" . C4::Context->preference("virtualshelves"),
LibraryNameTitle => "" . $LibraryNameTitle,
LoginBranchcode => (C4::Context->userenv?C4::Context->userenv->{"branch"}:"insecure"),
LoginBranchname => C4::Context->userenv?C4::Context->userenv->{"branchname"}:"",
+ LoginFirstname => (C4::Context->userenv?C4::Context->userenv->{"firstname"}:"Bel"),
+ LoginSurname => C4::Context->userenv?C4::Context->userenv->{"surname"}:"Inconnu",
OpacPasswordChange => C4::Context->preference("OpacPasswordChange"),
opacreadinghistory => C4::Context->preference("opacreadinghistory"),
opacuserjs => C4::Context->preference("opacuserjs"),
sub checkauth {
my $query = shift;
- # warn "Checking Auth";
+ # warn "Checking Auth";
# $authnotrequired will be set for scripts which will run without authentication
my $authnotrequired = shift;
my $flagsrequired = shift;
my $timeout = C4::Context->preference('timeout');
$timeout = 600 unless $timeout;
+
+ # If Version syspref is unavailable, it means Koha is beeing installed,
+ # and so we must redirect to OPAC maintenance page or to the WebInstaller
+ unless (C4::Context->preference('Version')) {
+ 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;
+ }
+
+
# state variables
my $loggedin = 0;
my %info;
$loggedin = 1;
}
elsif ( $sessionID = $query->cookie("CGISESSID")) {
- my $session = new CGI::Session("driver:MySQL", $sessionID, {Handle=>$dbh});
+ my $storage_method = C4::Context->preference('SessionStorage');
+ my $session;
+ if ($storage_method eq 'mysql'){
+ $session = new CGI::Session("driver:MySQL", $sessionID, {Handle=>$dbh});
+ }
+ else {
+ # catch all defaults to tmp should work on all systems
+ $session = new CGI::Session("driver:File", $sessionID, {Directory=>'/tmp'});
+ }
C4::Context->_new_userenv($sessionID);
if ($session){
C4::Context::set_userenv(
$session->param('branchname'), $session->param('flags'),
$session->param('emailaddress'), $session->param('branchprinter')
);
+# warn "".$session->param('cardnumber').", ".$session->param('firstname').",
+# ".$session->param('surname').", ".$session->param('branch');
}
my $ip;
- my $lasttime;
- if ($session) {
- $ip = $session->param('ip');
- $lasttime = $session->param('lasttime');
- $userid = $session->param('id');
- }
+ my $lasttime;
+ if ($session) {
+ $ip = $session->param('ip');
+ $lasttime = $session->param('lasttime');
+ $userid = $session->param('id');
+ }
-
+
if ($logout) {
# voluntary logout the user
- $session->delete;
+
+ $session->flush;
+ $session->delete();
C4::Context->_unset_userenv($sessionID);
$sessionID = undef;
$userid = undef;
$info{'oldip'} = $ip;
$info{'newip'} = $ENV{'REMOTE_ADDR'};
$info{'different_ip'} = 1;
- $session->delete();
+ $session->delete();
C4::Context->_unset_userenv($sessionID);
$sessionID = undef;
$userid = undef;
}
}
unless ($userid) {
- my $session = new CGI::Session("driver:MySQL", undef, {Handle=>$dbh});
+ my $storage_method = C4::Context->preference('SessionStorage');
+ my $session;
+ if ($storage_method eq 'mysql'){
+ $session = new CGI::Session("driver:MySQL", $sessionID, {Handle=>$dbh});
+ }
+ else {
+ # catch all defaults to tmp should work on all systems
+ $session = new CGI::Session("driver:File", $sessionID, {Directory=>'/tmp'});
+ }
+
my $sessionID;
if ($session) {
$sessionID = $session->id;
- }
+ }
$userid = $query->param('userid');
C4::Context->_new_userenv($sessionID);
my $password = $query->param('password');
= $sth->fetchrow
if ( $sth->rows );
-# warn "$cardnumber,$borrowernumber,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress";
+# warn "$cardnumber,$borrowernumber,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress";
unless ( $sth->rows ) {
my $sth =
$dbh->prepare(
= $sth->fetchrow
if ( $sth->rows );
-# warn "$cardnumber,$borrowernumber,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress";
+# warn "$cardnumber,$borrowernumber,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress";
unless ( $sth->rows ) {
$sth->execute($userid);
(
my $branches = GetBranches();
my @branchesloop;
foreach my $br ( keys %$branches ) {
- # now we work with the treatment of ip
+ # now we work with the treatment of ip
my $domain = $branches->{$br}->{'branchip'};
if ( $domain && $ip =~ /^$domain/ ) {
$branchcode = $branches->{$br}->{'branchcode'};
$session->param('emailaddress',$emailaddress);
$session->param('ip',$session->remote_addr());
$session->param('lasttime',time());
+# warn "".$session->param('cardnumber').", ".$session->param('firstname').",
+# ".$session->param('surname').", ".$session->param('branch');
}
elsif ( $return == 2 ) {
#We suppose the user is the superlibrarian
$session->param('id',C4::Context->config('user'));
$session->param('cardnumber',C4::Context->config('user'));
$session->param('firstname',C4::Context->config('user'));
- $session->param('surname',C4::Context->config('user'),);
+ $session->param('surname',C4::Context->config('user'));
$session->param('branch','NO_LIBRARY_SET');
$session->param('branchname','NO_LIBRARY_SET');
$session->param('flags',1);
$cookie = $query->cookie( CGISESSID => ''
);
}
- return ( $userid, $cookie, $sessionID, $flags );
+ return ( $userid, $cookie, $sessionID, $flags );
}
# check that database and koha version are the same
# there is no DB version, it's a fresh install,
# go to web installer
- warn "about to check version";
- unless (C4::Context->preference('Version')){
- 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;
- }
# 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
my $template = gettemplate( $template_name, $type, $query );
$template->param(branchloop => \@branch_loop,);
$template->param(
- login => 1,
+ login => 1,
INPUTS => \@inputs,
suggestion => C4::Context->preference("suggestion"),
virtualshelves => C4::Context->preference("virtualshelves"),
# $cookie = $query->cookie(CGISESSID => $session->id
# );
print $query->header(
- -type => 'utf-8',
+ -type => 'text/html',
+ -charset => 'utf-8',
-cookie => $cookie
),
$template->output;
{
# Koha superuser account
-# C4::Context->set_userenv(0,0,C4::Context->config('user'),C4::Context->config('user'),C4::Context->config('user'),"",1);
+# C4::Context->set_userenv(0,0,C4::Context->config('user'),C4::Context->config('user'),C4::Context->config('user'),"",1);
return 2;
}
if ( $userid && $userid eq 'demo'