From d1037dda9611a91c147aa2e7bf18cba4cc8eb28c Mon Sep 17 00:00:00 2001 From: tipaul Date: Tue, 29 Jun 2004 08:34:05 +0000 Subject: [PATCH] Adding "directory-select" feature to the "select sql file to insert to your DB". --- misc/Install.pm | 96 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 64 insertions(+), 32 deletions(-) diff --git a/misc/Install.pm b/misc/Install.pm index 477b3933f4..a07b37dbd3 100644 --- a/misc/Install.pm +++ b/misc/Install.pm @@ -1645,7 +1645,7 @@ sub installfiles { system("cp -R ".$src." ".$tgt); } - my ($auto_install) = @_; +# my ($auto_install) = @_; showmessage(getmessage('InstallFiles'),'none') unless ($auto_install->{NoPressEnter}); neatcopy("admin templates", 'intranet-html', "$intranetdir/htdocs"); @@ -1962,42 +1962,74 @@ sub populatedatabase { } startsysout(); system("$mysqldir/bin/mysql -u$user $database -e \"update systempreferences set value='$language' where variable='opaclanguages'\""); - # CHECK for any other file to append... - my @sql; - push @sql,"FINISHED"; + my @dirs; if (-d "scripts/misc/sql-datas") { - opendir D, "scripts/misc/sql-datas"; - foreach my $sql (readdir D) { - next unless ($sql =~ /.txt$/); - push @sql, $sql; - } - } - my $loopend=0; - while (not $loopend) { - print heading("SELECT SQL FILE"); - print qq| + # ask for directory to look for files to append + my @directories; + push @directories,"FINISHED"; + if (-d "scripts/misc/sql-datas") { + opendir D, "scripts/misc/sql-datas"; + foreach my $dir (readdir D) { + next if ($dir =~ /^\./); + push @directories, $dir; + } + } + my $loopend=0; + while (not $loopend) { + print heading("SELECT SQL DIRECTORY"); + print qq| +Select a directory. You will see every file included in this directory and be able to choose file(s) to import into Koha +This is a VERY important feature. By selecting the proper options, you can get a pre-setup Koha, almost ready to be put in production. +Choose wisely. +|; + for (my $i=0;$i<=$#directories;$i++) { + print "$i => ".$directories[$i]."\n"; + } + my $sqluploaddir =; + if ($sqluploaddir==0) { + $loopend = 1; + } else { + $sqluploaddir = $directories[$sqluploaddir]; + # CHECK for any other file to append... + my @sql; + push @sql,"FINISHED"; + if (-d "scripts/misc/sql-datas/$sqluploaddir") { + opendir D, "scripts/misc/sql-datas/$sqluploaddir"; + foreach my $sql (readdir D) { + next unless ($sql =~ /.txt$/); + push @sql, $sql; + } + } + $loopend=0; + while (not $loopend) { + print heading("SELECT SQL FILE"); + print qq| Select a file to append to the Koha DB. enter a number. A detailled explanation of the file will be given if you confirm, the file will be added to the DB |; - for (my $i=0;$i<=$#sql;$i++) { - print "$i => ".$sql[$i]."\n"; - } - my $response =; - if ($response==0) { - $loopend = 1; - } else { - # show the content of the file - my $FileToUpload = $sql[$response]; - open FILE,"scripts/misc/sql-datas/$FileToUpload"; - my $content = ; - print heading("INSERT $FileToUpload ?")."$content\n"; - # ask confirmation - $response=showmessage(getmessage('ConfirmFileUpload'), 'yn', 'y'); - # if confirmed, upload the file in the DB - unless ($response =~/^n/i) { - $FileToUpload =~ s/\.txt/\.sql/; - system("$mysqldir/bin/mysql -u$user $database ".$sql[$i]."\n"; + } + my $response =; + if ($response==0) { + $loopend = 1; + } else { + # show the content of the file + my $FileToUpload = $sql[$response]; + open FILE,"scripts/misc/sql-datas/$sqluploaddir/$FileToUpload"; + my $content = ; + print heading("INSERT $sqluploaddir/$FileToUpload ?")."$content\n"; + # ask confirmation + $response=showmessage(getmessage('ConfirmFileUpload'), 'yn', 'y'); + # if confirmed, upload the file in the DB + unless ($response =~/^n/i) { + $FileToUpload =~ s/\.txt/\.sql/; + system("$mysqldir/bin/mysql -u$user $database