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.12,1.13


From: Ralf Becker <address@hidden>
Subject: [Phpgroupware-cvs] CVS: etemplate/inc class.db_tools.inc.php,1.12,1.13
Date: Mon, 17 Mar 2003 15:54:08 -0500

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

Modified Files:
        class.db_tools.inc.php 
Log Message:
some fixes:
- new table-names are added now to setup.inc.php (was only done if 
tables_update.inc.php was updated)
- fixed prob. with empty tables_current if [write Table] was hit and no changes 
made
- added some defaults for the precision, as setup does not install the tables 
if precision not set for int, float, char, varchar

Index: class.db_tools.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.db_tools.inc.php,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** class.db_tools.inc.php      4 Oct 2002 23:53:00 -0000       1.12
--- class.db_tools.inc.php      17 Mar 2003 20:54:05 -0000      1.13
***************
*** 34,37 ****
--- 34,38 ----
                        'writen' => 'File writen',
                        'error_writing' => 'Error: writing file (no 
write-permission for the webserver) !!!',
+                       'no_write_necessary' => 'Table unchanged, no write 
necessary !!!',
                        'give_table_name' => 'Please enter table-name first 
!!!',
                        'new_table' => 'New table created',
***************
*** 45,52 ****
                        'decimal'       => 'decimal',
                        'float'         => 'float',
!                       'int'                   => 'int',
                        'longtext'      => 'longtext',
                        'text'          => 'text',
                        'timestamp'     => 'timestamp',
                        'varchar'       => 'varchar'
                );
--- 46,54 ----
                        'decimal'       => 'decimal',
                        'float'         => 'float',
!                       'int'           => 'int',
                        'longtext'      => 'longtext',
                        'text'          => 'text',
                        'timestamp'     => 'timestamp',
+ //                    'abstime'   => 'abstime (mysql:timestamp)',
                        'varchar'       => 'varchar'
                );
***************
*** 155,159 ****
                                        return;
                                }
!                               $msg .= 
$this->messages[$this->write($this->app,$this->data) ? 'writen' : 
'error_writing'];
                        }
                        elseif ($content['delete'])
--- 157,161 ----
                                        return;
                                }
!                               $msg .= $this->messages['no_write_necessary'];
                        }
                        elseif ($content['delete'])
***************
*** 272,275 ****
--- 274,285 ----
                                                
$this->update($this->app,$this->data,$cont['new_version']);
                                        }
+                                       else
+                                       {
+                                               foreach($this->data as $tname 
=> $tinfo)
+                                               {
+                                                       $tables .= ($tables ? 
',' : '') . "'$tname'";
+                                               }
+                                               
$this->setup_version($this->app,'',$tables);
+                                       }
                                        $msg .= 
$this->messages[$this->write($this->app,$this->data) ?
                                                'writen' : 'error_writing'];
***************
*** 366,369 ****
--- 376,380 ----
                @abstract creates table-definition from posted content
                @param $content posted content-array
+               @note  It sets some reasonalbe defaults for not set precisions 
(else setup will not install)
                @result table-definition
                */
***************
*** 397,400 ****
--- 408,421 ----
                                                //echo "<p>content2table: 
$posted_table.$old_name renamed to $col[name]</p>\n";
                                        }
+                                       if ($col['precision'] <= 0)
+                                       {
+                                               switch ($col['type']) // set 
some defaults for precision, else setup fails
+                                               {
+                                                       case 'float':   
+                                                       case 'int':     
$col['precision'] = 4; break;
+                                                       case 'char':    
$col['precision'] = 1; break;
+                                                       case 'varchar': 
$col['precision'] = 255; break;
+                                               }
+                                       }
                                        while (list($prop,$val) = each($col))
                                        {
***************
*** 571,575 ****
                @syntax setup_version( $app,$new = '',$tables='' )
                @author ralfbecker
!               @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
                */
--- 592,599 ----
                @syntax setup_version( $app,$new = '',$tables='' )
                @author ralfbecker
!               @abstract reads and updates the version and tables info in file 
$app/setup/setup.inc.php
!               @param $app the app
!               @param $new new version number to set, if $new != ''
!               @param $tables new tables to include, if $tables != ''
                @return the version or False if the file could not be read or 
written
                */
***************
*** 587,593 ****
                                return False;
                        }
!                       if ($new == '' || $setup_info[$app]['version'] == $new)
                        {
!                               return $setup_info[$app]['version'];
                        }
                        if (!($f = fopen($file,'r')))
--- 611,622 ----
                                return False;
                        }
!                       if (($new == '' || $setup_info[$app]['version'] == 
$new) &&     
!                           (!$tables || $setup_info[$app]['tables'] && 
"'".implode("','",$setup_info[$app]['tables'])."'" == $tables))
!                       {
!                               return $setup_info[$app]['version'];    // no 
change requested or not necessary 
!                       }
!                       if ($new == '') 
                        {
!                               $new = $setup_info[$app]['version'];
                        }
                        if (!($f = fopen($file,'r')))
***************
*** 603,609 ****
                        }
                        $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')))
                        {
--- 632,651 ----
                        }
                        $fnew = 
eregi_replace("(.*\\$"."setup_info\\['$app'\\]\\['version'\\][ \\t]*=[ 
\\t]*')[^']*('.*)","\\1$new"."\\2",$fcontent);
+                       
                        if ($tables != '')
!                       {
!                               if ($setup_info[$app]['tables'])        // if 
there is already tables array, update it
!                               {
!                                       $fnew = 
eregi_replace("(.*\\$"."setup_info\\['$app'\\]\\['tables'\\][ \\t]*=[ 
\\t]*array\()[^)]*","\\1$tables",$fnew);
!                               }
!                               else    // add the tables array
!                               {
!                                       if (strstr($fnew,'?>')) // remove a 
closeing tag
!                                       {
!                                               $fnew = 
str_replace('?>','',$fnew);
!                                       }
!                                       $fnew .= 
"\t\$setup_info['$app']['tables'] = array($tables);\n";
!                               }
!                       }
                        if (!is_writeable(PHPGW_SERVER_ROOT."/$app/setup") || 
!($f = fopen($file,'w')))
                        {





reply via email to

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