Bugzilla – Attachment 13426 Details for
Bug 7167
updatedatabase improvements
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7167: Now, we check versions on mainpage.pl and after login
Bug-7167-Now-we-check-versions-on-mainpagepl-and-a.patch (text/plain), 6.39 KB, created by
Chris Nighswonger
on 2012-11-13 15:57:50 UTC
(
hide
)
Description:
Bug 7167: Now, we check versions on mainpage.pl and after login
Filename:
MIME Type:
Creator:
Chris Nighswonger
Created:
2012-11-13 15:57:50 UTC
Size:
6.39 KB
patch
obsolete
>From 50906a313eb118db16dc8fe13e4f40af0a0ce715 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Fri, 6 Jul 2012 11:29:06 +0200 >Subject: [PATCH] Bug 7167: Now, we check versions on mainpage.pl and after > login >Content-Type: text/plain; charset="utf-8" > >Signed-off-by: Paul Poulain <paul.poulain@biblibre.com> >--- > C4/Auth.pm | 60 +++++++++++++++++++++++++++++++++++++++++++++-------------- > mainpage.pl | 17 +---------------- > 2 files changed, 47 insertions(+), 30 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index e3d5ad8..ff96cf3 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -28,6 +28,7 @@ require Exporter; > use C4::Context; > use C4::Templates; # to get the template > use C4::Branch; # GetBranches >+use C4::Update::Database; > use C4::VirtualShelves; > use POSIX qw/strftime/; > use List::MoreUtils qw/ any /; >@@ -134,9 +135,9 @@ sub get_template_and_user { > my $in = shift; > my $template = > C4::Templates::gettemplate( $in->{'template_name'}, $in->{'type'}, $in->{'query'} ); >- my ( $user, $cookie, $sessionID, $flags ); >+ my ( $user, $cookie, $sessionID, $flags, $new_session ); > if ( $in->{'template_name'} !~m/maintenance/ ) { >- ( $user, $cookie, $sessionID, $flags ) = checkauth( >+ ( $user, $cookie, $sessionID, $flags, $new_session ) = checkauth( > $in->{'query'}, > $in->{'authnotrequired'}, > $in->{'flagsrequired'}, >@@ -466,6 +467,12 @@ sub get_template_and_user { > > $template->param(OpacPublic => '1') if ($user || C4::Context->preference("OpacPublic")); > } >+ >+ if ( $new_session ) { >+ # Check the version and redirect if DB is not up-to-date >+ version_check($in->{query}, $in->{'type'}, $cookie); >+ } >+ > return ( $template, $borrowernumber, $cookie, $flags); > } > >@@ -563,6 +570,38 @@ sub _timeout_syspref { > return $timeout; > } > >+sub version_check { >+ my ( $query, $type, $cookie ) = @_; >+ # check we have a Version. Otherwise => go to installer >+ unless ( C4::Context->preference('Version') ) { >+ if ( $type ne 'opac' ) { >+ $debug && warn "Install required, redirecting to Installer"; >+ print $query->redirect("/cgi-bin/koha/installer/install.pl"); >+ } else { >+ $debug && warn "OPAC Install required, redirecting to maintenance"; >+ print $query->redirect("/cgi-bin/koha/maintenance.pl"); >+ } >+ safe_exit; >+ } >+ >+ # check if you're uptodate, and if you're not, head to updater >+ my $koha39 =~ "3.0900000"; >+ >+ # Old updatedatabase method >+ if (C4::Context->preference('Version') < $koha39) { >+ print $query->redirect("/cgi-bin/koha/installer/install.pl?step=3"); >+ safe_exit; >+ } >+ >+ # New updatedatabase method >+ unless ( C4::Update::Database::is_uptodate() ) { >+ # not up-to-date, redirect to updatedatabase page >+ warn "redirect to updatedatabase"; >+ print $query->redirect(-location => "/cgi-bin/koha/admin/updatedatabase.pl", -cookie => $cookie); >+ safe_exit; >+ } >+} >+ > sub checkauth { > my $query = shift; > $debug and warn "Checking Auth"; >@@ -571,6 +610,7 @@ sub checkauth { > my $flagsrequired = shift; > my $type = shift; > $type = 'opac' unless $type; >+ my $new_session = 0; > > my $dbh = C4::Context->dbh; > my $timeout = _timeout_syspref(); >@@ -579,17 +619,6 @@ sub checkauth { > $timeout = $1 * 86400; > }; > $timeout = 600 unless $timeout; >- # check we have a Version. Otherwise => go to installer >- unless ( C4::Context->preference('Version') ) { # assignment, not comparison >- if ( $type ne 'opac' ) { >- $debug && warn "Install required, redirecting to Installer"; >- print $query->redirect("/cgi-bin/koha/installer/install.pl"); >- } else { >- $debug && warn "OPAC Install required, redirecting to maintenance"; >- print $query->redirect("/cgi-bin/koha/maintenance.pl"); >- } >- safe_exit; >- } > > # state variables > my $loggedin = 0; >@@ -694,6 +723,7 @@ sub checkauth { > my $sessionID = $session->id; > C4::Context->_new_userenv($sessionID); > $cookie = $query->cookie( CGISESSID => $sessionID ); >+ > $userid = $query->param('userid'); > if ( ( $cas && $query->param('ticket') ) > || $userid >@@ -708,6 +738,7 @@ sub checkauth { > checkpw( $dbh, $userid, $password, $query ); > $userid = $retuserid; > $info{'invalidCasLogin'} = 1 unless ($return); >+ $new_session = 1; > } > elsif ( > ( $pki_field eq 'Common Name' && $ENV{'SSL_CLIENT_S_DN_CN'} ) >@@ -746,6 +777,7 @@ sub checkauth { > ( $return, $cardnumber, $retuserid ) = > checkpw( $dbh, $userid, $password, $query ); > $userid = $retuserid if ( $retuserid ne '' ); >+ $new_session = 1; > } > if ($return) { > #_session_log(sprintf "%20s from %16s logged in at %30s.\n", $userid,$ENV{'REMOTE_ADDR'},(strftime '%c', localtime)); >@@ -887,7 +919,7 @@ sub checkauth { > unless ($cookie) { > $cookie = $query->cookie( CGISESSID => '' ); > } >- return ( $userid, $cookie, $sessionID, $flags ); >+ return ( $userid, $cookie, $sessionID, $flags, $new_session ); > } > > # >diff --git a/mainpage.pl b/mainpage.pl >index 3e7dd3a..505c166 100755 >--- a/mainpage.pl >+++ b/mainpage.pl >@@ -28,7 +28,6 @@ use C4::NewsChannels; > use C4::Review qw/numberofreviews/; > use C4::Suggestions qw/CountSuggestion/; > use C4::Tags qw/get_count_by_tag_status/; >-use C4::Update::Database; > > my $query = new CGI; > >@@ -44,21 +43,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > } > ); > >-# >-# check if you're uptodate, and if you're not, head to updater >-# >-my $koha36= C4::Context::KOHAVERSION; >-$koha36 =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/; >- >-if (C4::Context->preference('Version') < $koha36) { >- print $query->redirect("/cgi-bin/koha/installer/install.pl?step=3"); >- exit; >-} >-unless ( C4::Update::Database::is_uptodate() ) { >- # not uptodate, redirect to updatedatabase page >- print $query->redirect("/cgi-bin/koha/admin/updatedatabase.pl"); >- exit; >-} >+C4::Auth::version_check($query, 'intranet', $cookie); > > my $all_koha_news = &GetNewsToDisplay("koha"); > my $koha_news_count = scalar @$all_koha_news; >-- >1.7.9.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7167
:
6377
|
6378
|
6379
|
6381
|
6414
|
6415
|
6416
|
6476
|
6477
|
6478
|
6479
|
6722
|
6832
|
7903
|
8178
|
9859
|
9860
|
9861
|
9862
|
10033
|
10034
|
10549
|
10666
|
10667
|
10668
|
10825
|
11129
|
11222
|
11223
|
11224
|
11225
|
11226
|
11227
|
11228
|
11229
|
11230
|
11231
|
11232
|
11235
|
11236
|
11237
|
11238
|
11239
|
11240
|
11241
|
11242
|
11243
|
11244
|
11245
|
11246
|
11571
|
13423
|
13424
|
13425
|
13426
|
13427
|
13428
|
13429
|
13430
|
13431
|
13432
|
13433
|
13434
|
13435
|
13436
|
13437
|
13456
|
13457
|
13509
|
13516
|
13517
|
13518
|
13519
|
13520
|
13521
|
13522
|
13523
|
13524
|
13525
|
13526
|
13527
|
13528
|
13529
|
13733
|
13734
|
13842
|
13845
|
13848
|
13851
|
13852
|
13853
|
13854
|
14310
|
16113
|
16114
|
16115
|
16116
|
16117
|
16596