phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: etemplate/inc class.db_tools.inc.php,1.8,1.9


From: Ralf Becker <address@hidden>
Subject: [Phpgroupware-cvs] CVS: etemplate/inc class.db_tools.inc.php,1.8,1.9
Date: Sun, 01 Sep 2002 15:54:49 -0400

Update of /cvsroot/phpgroupware/etemplate/inc
In directory subversions:/tmp/cvs-serv6917

Modified Files:
        class.db_tools.inc.php 
Log Message:
1) correct update_script for more than one droped column
2) updates tables_names in $app/setup/setup.inc.php
3) suggest new version-number

Index: class.db_tools.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.db_tools.inc.php,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** class.db_tools.inc.php      2 Jun 2002 20:47:38 -0000       1.8
--- class.db_tools.inc.php      1 Sep 2002 19:54:47 -0000       1.9
***************
*** 303,307 ****
                                'changes' => $this->changes
                        );
!                       $content['new_version'] = $content['version'];
  
                        $tmpl = new etemplate('etemplate.db-tools.ask_save');
--- 303,310 ----
                                'changes' => $this->changes
                        );
!                       $new_version = explode('.',$content['version']);
!                       $minor = count($new_version)-1;
!                       $new_version[$minor] = 
sprintf('%03d',1+$new_version[$minor]);
!                       $content['new_version'] = implode('.',$new_version);
  
                        $tmpl = new etemplate('etemplate.db-tools.ask_save');
***************
*** 550,560 ****
  
                /*!
!               @function setup_version($app,$new = '')
                @abstract reads and updates the version in file 
$app/setup/setup.inc.php if $new != ''
                @return the version or False if the file could not be read or 
written
                */
!               function setup_version($app,$new = '')
                {
!                       //echo 
"<p>etemplate.db_tools.setup_version('$app','$new')</p>\n";
  
                        $file = PHPGW_SERVER_ROOT."/$app/setup/setup.inc.php";
--- 553,563 ----
  
                /*!
!               @function setup_version($app,$new = '',$tables='')
                @abstract reads and updates the version in file 
$app/setup/setup.inc.php if $new != ''
                @return the version or False if the file could not be read or 
written
                */
!               function setup_version($app,$new = '',$tables='')
                {
!                       //echo 
"<p>etemplate.db_tools.setup_version('$app','$new','$tables')</p>\n";
  
                        $file = PHPGW_SERVER_ROOT."/$app/setup/setup.inc.php";
***************
*** 583,586 ****
--- 586,591 ----
                        }
                        $fnew = 
eregi_replace("(.*\\$"."setup_info\\['$app'\\]\\['version'\\][ \\t]*=[ 
\\t]*')[^']*('.*)","\\1$new"."\\2",$fcontent);
+                       if ($tables != '')
+                               $fnew = 
eregi_replace("(.*\\$"."setup_info\\['$app'\\]\\['tables'\\][ \\t]*=[ 
\\t]*array\()[^)]*","\\1$tables",$fnew);
  
                        if (!is_writeable(PHPGW_SERVER_ROOT."/$app/setup") || 
!($f = fopen($file,'w')))
***************
*** 639,643 ****
        {\n";
  
!                       $update .= $this->update_schema($app,$current);
  
                        $update .= "\n
--- 644,648 ----
        {\n";
  
!                       $update .= $this->update_schema($app,$current,$tables);
  
                        $update .= "\n
***************
*** 654,658 ****
                        fclose($f);
  
!                       $this->setup_version($app,$version);
  
                        return True;
--- 659,663 ----
                        fclose($f);
  
!                       $this->setup_version($app,$version,$tables);
  
                        return True;
***************
*** 671,678 ****
                }
  
!               function update_schema($app,$current)
                {
                        $this->read($app,$old);
  
                        reset($old);
                        while (list($name,$table_def) = each($old))
--- 676,684 ----
                }
  
!               function update_schema($app,$current,&$tables)
                {
                        $this->read($app,$old);
  
+                       $tables = '';
                        reset($old);
                        while (list($name,$table_def) = each($old))
***************
*** 684,688 ****
--- 690,697 ----
                                else
                                {
+                                       $tables .= ($tables ? ',' : '') . 
"'$name'";
+ 
                                        reset($table_def['fd']);
+                                       $new_table_def = $table_def;
                                        while(list($col,$col_def) = 
each($table_def['fd']))
                                        {
***************
*** 691,695 ****
                                                        if 
(!isset($this->changes[$name][$col]) || $this->changes[$name][$col] == 
'**deleted**')
                                                        {
-                                                               $new_table_def 
= $table_def;
                                                                
unset($new_table_def['fd'][$col]);
                                                                
$this->remove_from_array($new_table_def['pk'],$col);
--- 700,703 ----
***************
*** 723,726 ****
--- 731,736 ----
                                if (!isset($old[$name]))        // table $name 
added
                                {
+                                       $tables .= ($tables ? ',' : '') . 
"'$name'";
+ 
                                        $update .= 
"\t\t\$GLOBALS['phpgw_setup']->oProc->CreateTable('$name',";
                                        $update .= 
$this->write_array($table_def,2).");\n";





reply via email to

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