koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] CVS: koha/updater updatedatabase,1.4.2.10,1.4.2.11


From: Alan Millar
Subject: [Koha-cvs] CVS: koha/updater updatedatabase,1.4.2.10,1.4.2.11
Date: Tue, 25 Jun 2002 23:04:49 -0700

Update of /cvsroot/koha/koha/updater
In directory usw-pr-cvs1:/tmp/cvs-serv3440

Modified Files:
      Tag: rel-1-2
        updatedatabase 
Log Message:
Clean up systempreferences code to be table-driven

Index: updatedatabase
===================================================================
RCS file: /cvsroot/koha/koha/updater/updatedatabase,v
retrieving revision 1.4.2.10
retrieving revision 1.4.2.11
diff -C2 -r1.4.2.10 -r1.4.2.11
*** updatedatabase      25 Jun 2002 18:24:33 -0000      1.4.2.10
--- updatedatabase      26 Jun 2002 06:04:46 -0000      1.4.2.11
***************
*** 12,15 ****
--- 12,17 ----
  # - Would also be a good idea to offer to do a backup at this time...
  
+ # NOTE:  If you do something more than once in here, make it table driven.
+ 
  use strict;
  
***************
*** 23,27 ****
  
  my (
!       $sth,
        $query,
        %existingtables,        # tables already in database
--- 25,29 ----
  
  my (
!       $sth, $sti,
        $query,
        %existingtables,        # tables already in database
***************
*** 30,33 ****
--- 32,36 ----
        $column,
        $type, $null, $key, $default, $extra,
+       $prefitem,              # preference item in systempreferences table
  );
  
***************
*** 88,91 ****
--- 91,100 ----
  );
  
+ # Default system preferences
+ my %defaultprefs=(
+     'autoMemberNum'=> '1',
+     'acquisitions'=> 'simple',
+ );
+ 
  #-------------------
  # Initialize
***************
*** 114,118 ****
  # Now add any missing tables
  foreach $table ( keys %requiretables ) {
!     print "Checking $table table...\n" if $debug;;
      unless ($existingtables{$table} ) {
        print "Adding $table table...\n";
--- 123,127 ----
  # Now add any missing tables
  foreach $table ( keys %requiretables ) {
!     print "Checking $table table...\n" if $debug;
      unless ($existingtables{$table} ) {
        print "Adding $table table...\n";
***************
*** 154,158 ****
  
  foreach $table ( keys %requirefields ) {
!     print "Check table $table\n";
      $sth=$dbh->prepare("show columns from $table");
      $sth->execute();
--- 163,167 ----
  
  foreach $table ( keys %requirefields ) {
!     print "Check table $table\n" if $debug;
      $sth=$dbh->prepare("show columns from $table");
      $sth->execute();
***************
*** 163,167 ****
      } # while 
      foreach $column ( keys %{ $requirefields{$table} } )  {
!       print "  Check column $column\n";
        if ( ! $types{$column} ) {
            # column doesn't exist
--- 172,176 ----
      } # while 
      foreach $column ( keys %{ $requirefields{$table} } )  {
!       print "  Check column $column\n" if $debug;
        if ( ! $types{$column} ) {
            # column doesn't exist
***************
*** 252,267 ****
  # Populate systempreferences if it is empty
  
! $sth=$dbh->prepare("select value from systempreferences where 
variable='autoMemberNum'");
! $sth->execute;
! unless ($sth->rows) {
!     my $sth=$dbh->prepare("insert into systempreferences (variable, value) 
values ('autoMemberNum', '1')");
!     $sth->execute;
! }
! $sth=$dbh->prepare("select value from systempreferences where 
variable='acquisitions'");
! $sth->execute;
! unless ($sth->rows) {
!     my $sth=$dbh->prepare("insert into systempreferences (variable, value) 
values ('acquisitions', 'simple')");
!     $sth->execute;
! }
  
  
--- 261,278 ----
  # Populate systempreferences if it is empty
  
! foreach $prefitem ( keys %defaultprefs ) {
!     $sth=$dbh->prepare("select value 
!       from systempreferences 
!       where variable=?");
!     $sth->execute($prefitem);
!     unless ($sth->rows) {
!       print "Adding system preference item $prefitem with value " .
!               $defaultprefs{$prefitem} ."\n";
!         $sti=$dbh->prepare("
!         insert into systempreferences (variable, value) 
!         values (?,?)");
!         $sti->execute($prefitem,$defaultprefs{$prefitem});
!     } # unless
! } # foreach
  
  
***************
*** 272,275 ****
--- 283,289 ----
  
  # $Log$
+ # Revision 1.4.2.11  2002/06/26 06:04:46  amillar
+ # Clean up systempreferences code to be table-driven
+ #
  # Revision 1.4.2.10  2002/06/25 18:24:33  tonnesen
  # Fixed missing semicolons.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]