#
# This file is part of Koha.
#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
use strict;
use warnings;
use C4::Languages;
use C4::Branch; # GetBranches
use C4::Search::History;
-use C4::VirtualShelves;
+use Koha;
use Koha::AuthUtils qw(hash_password);
use POSIX qw/strftime/;
use List::MoreUtils qw/ any /;
$template->param( loggedinusernumber => $borrowernumber );
$template->param( sessionID => $sessionID );
- my ( $total, $pubshelves, $barshelves ) = C4::VirtualShelves::GetSomeShelfNames( $borrowernumber, 'MASTHEAD' );
- $template->param(
- pubshelves => $total->{pubtotal},
- pubshelvesloop => $pubshelves,
- barshelves => $total->{bartotal},
- barshelvesloop => $barshelves,
- );
+ if ( $in->{'type'} eq 'opac' ) {
+ require C4::VirtualShelves;
+ my ( $total, $pubshelves, $barshelves ) = C4::VirtualShelves::GetSomeShelfNames( $borrowernumber, 'MASTHEAD' );
+ $template->param(
+ pubshelves => $total->{pubtotal},
+ pubshelvesloop => $pubshelves,
+ barshelves => $total->{bartotal},
+ barshelvesloop => $barshelves,
+ );
+ }
my ($borr) = C4::Members::GetMemberDetails($borrowernumber);
my @bordat;
if ($flags) {
foreach my $module ( keys %$all_perms ) {
- if ( $flags->{$module} == 1 ) {
+ if ( defined($flags->{$module}) && $flags->{$module} == 1 ) {
foreach my $subperm ( keys %{ $all_perms->{$module} } ) {
$template->param( "CAN_user_${module}_${subperm}" => 1 );
}
$template->param( sessionID => $sessionID );
- my ( $total, $pubshelves ) = C4::VirtualShelves::GetSomeShelfNames( undef, 'MASTHEAD' );
- $template->param(
- pubshelves => $total->{pubtotal},
- pubshelvesloop => $pubshelves,
- );
+ if ( $in->{'type'} eq 'opac' ){
+ require C4::VirtualShelves;
+ my ( $total, $pubshelves ) = C4::VirtualShelves::GetSomeShelfNames( undef, 'MASTHEAD' );
+ $template->param(
+ pubshelves => $total->{pubtotal},
+ pubshelvesloop => $pubshelves,
+ );
+ }
}
# Anonymous opac search history
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(
intranetreadinghistory => C4::Context->preference("intranetreadinghistory"),
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
IntranetUserCSS => C4::Context->preference("IntranetUserCSS"),
- intranetuserjs => C4::Context->preference("intranetuserjs"),
+ IntranetUserJS => C4::Context->preference("IntranetUserJS"),
intranetbookbag => C4::Context->preference("intranetbookbag"),
suggestion => C4::Context->preference("suggestion"),
virtualshelves => C4::Context->preference("virtualshelves"),
EnableBorrowerFiles => C4::Context->preference('EnableBorrowerFiles'),
UseKohaPlugins => C4::Context->preference('UseKohaPlugins'),
UseCourseReserves => C4::Context->preference("UseCourseReserves"),
+ useDischarge => C4::Context->preference('useDischarge'),
);
}
else {
$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(
- opaccolorstylesheet => C4::Context->preference("opaccolorstylesheet"),
+ OpacAdditionalStylesheet => C4::Context->preference("OpacAdditionalStylesheet"),
AnonSuggestions => "" . C4::Context->preference("AnonSuggestions"),
AuthorisedValueImages => C4::Context->preference("AuthorisedValueImages"),
BranchesLoop => GetBranchesLoop($opac_name),
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,
opacheader => "" . C4::Context->preference("opacheader"),
opaclanguagesdisplay => "" . C4::Context->preference("opaclanguagesdisplay"),
opacreadinghistory => C4::Context->preference("opacreadinghistory"),
- opacuserjs => C4::Context->preference("opacuserjs"),
+ OPACUserJS => C4::Context->preference("OPACUserJS"),
opacuserlogin => "" . C4::Context->preference("opacuserlogin"),
ShowReviewer => C4::Context->preference("ShowReviewer"),
ShowReviewerPhoto => C4::Context->preference("ShowReviewerPhoto"),
OPACLocalCoverImages => C4::Context->preference("OPACLocalCoverImages"),
PatronSelfRegistration => C4::Context->preference("PatronSelfRegistration"),
PatronSelfRegistrationDefaultCategory => C4::Context->preference("PatronSelfRegistrationDefaultCategory"),
+ useDischarge => C4::Context->preference('useDischarge'),
);
$template->param( OpacPublic => '1' ) if ( $user || C4::Context->preference("OpacPublic") );
# 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;
+ my $kohaversion = Koha::version();
# remove the 3 last . to have a Perl number
$kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
my $warning = "Database update needed, redirecting to %s. Database is $version and Koha is $kohaversion";
if ( $type ne 'opac' ) {
warn sprintf( $warning, 'Installer' );
- print $query->redirect("/cgi-bin/koha/installer/install.pl?step=3");
+ print $query->redirect("/cgi-bin/koha/installer/install.pl?step=1&op=updatestructure");
} else {
warn sprintf( "OPAC: " . $warning, 'maintenance' );
print $query->redirect("/cgi-bin/koha/maintenance.pl");
$sessionID = undef;
$userid = undef;
- if ( $cas and $caslogout ) {
- logout_cas($query);
+ if ($cas and $caslogout) {
+ logout_cas($query, $type);
}
# If we are in a shibboleth session (shibboleth is enabled, a shibboleth match attribute is set and matches koha matchpoint)
if ( $cas && $query->param('ticket') ) {
my $retuserid;
( $return, $cardnumber, $retuserid ) =
- checkpw( $dbh, $userid, $password, $query );
+ checkpw( $dbh, $userid, $password, $query, $type );
$userid = $retuserid;
$info{'invalidCasLogin'} = 1 unless ($return);
}
else {
my $retuserid;
( $return, $cardnumber, $retuserid ) =
- checkpw( $dbh, $userid, $password, $query );
+ checkpw( $dbh, $userid, $password, $query, $type );
$userid = $retuserid if ($retuserid);
$info{'invalid_username_or_password'} = 1 unless ($return);
}
my $template = C4::Templates::gettemplate( $template_name, $type, $query );
$template->param(
branchloop => GetBranchesLoop(),
- opaccolorstylesheet => C4::Context->preference("opaccolorstylesheet"),
+ OpacAdditionalStylesheet => C4::Context->preference("OpacAdditionalStylesheet"),
opaclayoutstylesheet => C4::Context->preference("opaclayoutstylesheet"),
login => 1,
INPUTS => \@inputs,
OpacFavicon => C4::Context->preference("OpacFavicon"),
opacreadinghistory => C4::Context->preference("opacreadinghistory"),
opaclanguagesdisplay => C4::Context->preference("opaclanguagesdisplay"),
- opacuserjs => C4::Context->preference("opacuserjs"),
+ OPACUserJS => C4::Context->preference("OPACUserJS"),
opacbookbag => "" . C4::Context->preference("opacbookbag"),
OpacCloud => C4::Context->preference("OpacCloud"),
OpacTopissue => C4::Context->preference("OpacTopissue"),
intranetbookbag => C4::Context->preference("intranetbookbag"),
IntranetNav => C4::Context->preference("IntranetNav"),
IntranetFavicon => C4::Context->preference("IntranetFavicon"),
- intranetuserjs => C4::Context->preference("intranetuserjs"),
+ IntranetUserJS => C4::Context->preference("IntranetUserJS"),
IndependentBranches => C4::Context->preference("IndependentBranches"),
AutoLocation => C4::Context->preference("AutoLocation"),
wrongip => $info{'wrongip'},
$template->param( loginprompt => 1 ) unless $info{'nopermission'};
if ( $type eq 'opac' ) {
+ require C4::VirtualShelves;
my ( $total, $pubshelves ) = C4::VirtualShelves::GetSomeShelfNames( undef, 'MASTHEAD' );
$template->param(
pubshelves => $total->{pubtotal},
my $casservers = C4::Auth_with_cas::getMultipleAuth();
my @tmplservers;
foreach my $key ( keys %$casservers ) {
- push @tmplservers, { name => $key, value => login_cas_url( $query, $key ) . "?cas=$key" };
+ push @tmplservers, { name => $key, value => login_cas_url( $query, $key, $type ) . "?cas=$key" };
}
$template->param(
casServersLoop => \@tmplservers
);
} else {
$template->param(
- casServerUrl => login_cas_url($query),
+ casServerUrl => login_cas_url($query, undef, $type),
);
}
# database has not been installed yet
return ( "maintenance", undef, undef );
}
- my $kohaversion = C4::Context::KOHAVERSION;
+ my $kohaversion = Koha::version();
$kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
if ( C4::Context->preference('Version') < $kohaversion ) {
# database has not been installed yet
return ( "maintenance", undef );
}
- my $kohaversion = C4::Context::KOHAVERSION;
+ my $kohaversion = Koha::version();
$kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
if ( C4::Context->preference('Version') < $kohaversion ) {
}
sub checkpw {
- my ( $dbh, $userid, $password, $query ) = @_;
+ my ( $dbh, $userid, $password, $query, $type ) = @_;
+ $type = 'opac' unless $type;
if ($ldap) {
$debug and print STDERR "## checkpw - checking LDAP\n";
my ( $retval, $retcard, $retuserid ) = checkpw_ldap(@_); # EXTERNAL AUTH
# In case of a CAS authentication, we use the ticket instead of the password
my $ticket = $query->param('ticket');
$query->delete('ticket'); # remove ticket to come back to original URL
- my ( $retval, $retcard, $retuserid ) = checkpw_cas( $dbh, $ticket, $query ); # EXTERNAL AUTH
+ my ( $retval, $retcard, $retuserid ) = checkpw_cas( $dbh, $ticket, $query, $type ); # EXTERNAL AUTH
($retval) and return ( $retval, $retcard, $retuserid );
return 0;
}
if ( $subperm eq '*' ) {
return 0 unless ( $flags->{$module} == 1 or ref( $flags->{$module} ) );
} else {
- return 0 unless ( $flags->{$module} == 1 or
+ return 0 unless (
+ ( defined $flags->{$module} and
+ $flags->{$module} == 1 )
+ or
( ref( $flags->{$module} ) and
exists $flags->{$module}->{$subperm} and
- $flags->{$module}->{$subperm} == 1
- )
+ $flags->{$module}->{$subperm} == 1 )
);
}
}