[Koha-cvs] koha C4/Auth.pm installer/install.pl

Henri-Damien LAURENT laurenthdl at alinto.com
Fri Apr 6 17:53:18 CEST 2007


CVSROOT:	/cvsroot/koha
Module name:	koha
Changes by:	Henri-Damien LAURENT <hdl>	07/04/06 15:53:18

Modified files:
	C4             : Auth.pm 
	installer      : install.pl 

Log message:
	Adding Check for a systempreference Version Variable
	skips third party software check and mysql check to go to updatedatabase.
	
	Adding similar check to intranet and opac.
	
	BEWARE !!!!!
	You may be linked to install if you donot have Version variable set in your systempreferences table.
	If so, simply updatedatabase OR add Version 3.0  record to your systempreferences table.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Auth.pm?cvsroot=koha&r1=1.59&r2=1.60
http://cvs.savannah.gnu.org/viewcvs/koha/installer/install.pl?cvsroot=koha&r1=1.3&r2=1.4

Patches:
Index: C4/Auth.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Auth.pm,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -b -r1.59 -r1.60
--- C4/Auth.pm	4 Apr 2007 16:46:22 -0000	1.59
+++ C4/Auth.pm	6 Apr 2007 15:53:18 -0000	1.60
@@ -37,7 +37,7 @@
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.59 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.60 $' =~ /\d+/g;
     shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v );
 };
 
@@ -339,6 +339,10 @@
     $type = 'opac' unless $type;
 
     my $dbh     = C4::Context->dbh;
+    unless (C4::Context->preference('Version')){
+      print $query->redirect("/cgi-bin/koha/installer/install.pl?step=3");
+      exit;
+    }
     my $timeout = C4::Context->preference('timeout');
     $timeout = 600 unless $timeout;
 

Index: installer/install.pl
===================================================================
RCS file: /cvsroot/koha/koha/installer/install.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- installer/install.pl	17 Mar 2007 21:43:40 -0000	1.3
+++ installer/install.pl	6 Apr 2007 15:53:18 -0000	1.4
@@ -32,6 +32,16 @@
                 debug => 1,
                 });
 
+my %info;
+$info{'dbname'}=C4::Context->config("database");
+$info{'dbms'}=(C4::Context->config("db_scheme")?C4::Context->config("db_scheme"):"mysql");
+$info{'hostname'}=C4::Context->config("hostname");
+($info{'hostname'},$info{'port'})=($1,$2) if $info{'hostname'}=~/([^:]*):([0-9]+)/;
+$info{'user'}=C4::Context->config("user");
+$info{'password'}=C4::Context->config("pass");
+my $dbh= DBI->connect("DBI:$info{dbms}:$info{dbname}:$info{hostname}".($info{port}?":$info{port}":""),$info{'user'}, $info{'password'});
+
+
 if ($step && $step==1){
   #First Step
   #Checking ALL perl Modules and services needed are installed.
@@ -150,18 +160,10 @@
   
 } elsif ($step && $step==2){
   # Check Database connection and access
-  my %info;
-  $info{'dbname'}=C4::Context->config("database");
-  $info{'dbms'}=(C4::Context->config("db_scheme")?C4::Context->config("db_scheme"):"mysql");
-  $info{'hostname'}=C4::Context->config("hostname");
-  ($info{'hostname'},$info{'port'})=($1,$2) if $info{'hostname'}=~/([^:]*):([0-9]+)/;
-  $info{'user'}=C4::Context->config("user");
-  $info{'password'}=C4::Context->config("pass");
   $template->param(%info);
   my $checkmysql=$query->param("checkmysql");
   $template->param('mysqlconnection'=>$checkmysql);
   if ($checkmysql){
-    my $dbh= DBI->connect("DBI:$info{dbms}:$info{dbname}:$info{hostname}".($info{port}?":$info{port}":""),$info{'user'}, $info{'password'});
     if ($dbh){
       # Can connect to the mysql
       $template->param("checkdatabaseaccess"=>1);
@@ -198,22 +200,14 @@
     }
   }
 } elsif ($step && $step==3){
-  my %info;
-  $info{'dbname'}=C4::Context->config("database");
-  $info{'dbms'}=(C4::Context->config("db_scheme")?C4::Context->config("db_scheme"):"mysql");
-  $info{'hostname'}=C4::Context->config("hostname");
-  ($info{'hostname'},$info{'port'})=($1,$2) if $info{'hostname'}=~/([^:]*):([0-9]+)/;
-  $info{port} = 3306 unless ($info{port});
-  $info{'user'}=C4::Context->config("user");
-  $info{'password'}=C4::Context->config("pass");
   my $op=$query->param('op');
   if ($op && $op eq 'finish'){
     # Installation is finished.
     # We just deny anybody acess to install
     # And we redirect people to mainpage.
     # The installer wil have to relogin since we donot pass cookie to redirection.
-    my $dir=C4::Context->config('intranetdir');
-    qx(chmod -R uog-xw $dir/installer);
+    $template->param("$op"=>1);
+  }elsif ($op && $op eq 'finished'){
     print $query->redirect("/cgi-bin/koha/mainpage.pl");
     exit 1;
   } elsif ($op && $op eq 'addframeworks'){
@@ -223,9 +217,8 @@
    # sort by filename -> prepend with numbers to specify order of insertion. 
     
 	my @fnames = sort { my @aa = split /\/|\\/, ($a); my @bb = split /\/|\\/, ($b); $aa[-1] <=> $bb[-1] } $query->param('framework')  ;
-	
 	foreach my $file (@fnames){
-     warn $file;
+#      warn $file;
 	 undef $/;
       my $strcmd="mysql ".($info{hostname}?"-h $info{hostname} ":"").($info{port}?"-P $info{port} ":"").($info{user}?"-u $info{user} ":"").($info{password}?"-p$info{password}":"")." $info{dbname} ";
       my $str = qx($strcmd < $file 2>&1);
@@ -239,8 +232,8 @@
     map {push @list,{"level"=>$_,"fwklist"=>$hashlevel{$_}}} keys %hashlevel;
     my $fwk_language;
     for my $each_language(@$all_languages) {
-		warn "CODE".$each_language->{'language_code'};
-		warn "LANG:".$lang;
+# 		warn "CODE".$each_language->{'language_code'};
+# 		warn "LANG:".$lang;
 		if ($lang eq $each_language->{'language_code'}) {
 			$fwk_language = $each_language->{language_locale_name};
 		}
@@ -320,7 +313,7 @@
 	my $str = qx(mysql -h $info{hostname} -P $info{port} -u $info{user} -p$info{password} $info{dbname} <$filename 2>&1);
 	$str=~s/\n|\r/<br \/>/g;
 	$template->param("error"=>$str , 
-					importdatastructure => 1, );
+	                 "$op"=> 1, );
   } else {
     #Check if there are enough tables.
     # Version 2_2 was 74 tables, so we check if there is more than 75
@@ -348,5 +341,13 @@
 	push @languages,{'value'=>$_->{'language_code'}, 'description'=>$_->{'language_name'} } if ($_->{'language_code'});
   }
   $template->param(languages=>\@languages);
+  if ($dbh){
+    my $rq=$dbh->prepare("SELECT * from systempreferences WHERE variable='Version'");
+    $rq->execute;
+    my ($version)=$rq->fetchrow;
+    if ($version){
+      $query->redirect("install.pl?step=3");
+    }
+  }
 }
 output_html_with_http_headers $query, $cookie, $template->output;





More information about the Koha-cvs mailing list