[Tutos-commits] CVS: tutos/php acl.pinc,1.37,1.38 acl_new.php,1.22,1.23 scheme.php,1.32,1.33 update.
Projects / CRM / PLM / Calendar / Tasks / SCRUM / Test / Inventory
Brought to you by:
gokohnert
From: Gero K. <gok...@us...> - 2002-10-30 19:37:42
|
Update of /cvsroot/tutos/tutos/php In directory usw-pr-cvs1:/tmp/cvs-serv8315/php Modified Files: acl.pinc acl_new.php scheme.php update.php Log Message: Major Database updates !! Please Backup before running update.php Added creator/creation for most classes/tables Changed ACL Perm from string to int (in order to support more DB types All changes should happen automagically when running update.php Index: acl.pinc =================================================================== RCS file: /cvsroot/tutos/tutos/php/acl.pinc,v retrieving revision 1.37 retrieving revision 1.38 diff -u -r1.37 -r1.38 --- acl.pinc 25 Oct 2002 17:14:25 -0000 1.37 +++ acl.pinc 30 Oct 2002 19:37:39 -0000 1.38 @@ -115,7 +115,7 @@ //$i = ""; //echo "". $i ." ". gettype($i) ."<BR>"; if ( ($i > -1) && (gettype($i) == "integer") && ($f > 0) ) { - $q = "INSERT INTO ". $obj->dbconn->prefix ."acl (obj_id,adr_id,perm) VALUES (". $id .",". $i .",'". $f ."')"; + $q = "INSERT INTO ". $obj->dbconn->prefix ."acl (obj_id,adr_id,perm) VALUES (". $id .",". $i .",". $f .")"; $r = $obj->dbconn->Exec($q); } } Index: acl_new.php =================================================================== RCS file: /cvsroot/tutos/tutos/php/acl_new.php,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- acl_new.php 27 Sep 2002 09:13:25 -0000 1.22 +++ acl_new.php 30 Oct 2002 19:37:39 -0000 1.23 @@ -167,7 +167,6 @@ $this->stop = true; } $this->obj = getObject($this->dbconn,$HTTP_GET_VARS['id']); - if ( $this->obj == -1 ) { $msg .= sprintf($lang['Err0040'],"Object"); $this->stop = true; Index: scheme.php =================================================================== RCS file: /cvsroot/tutos/tutos/php/scheme.php,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- scheme.php 9 Oct 2002 04:32:19 -0000 1.32 +++ scheme.php 30 Oct 2002 19:37:39 -0000 1.33 @@ -52,11 +52,10 @@ echo "<P>"; flush(); - @reset($table); - while ( list ($i,$f) = @each ($table) ) { + foreach ($table as $i => $f) { echo $f[Desc] ."<BR>\n"; if ($this->obj->droptable($f) == -1) { - echo "Table <B>". $this->obj->prefix . $f[name] ."</B> not dropped:<SPAN class=warn>". $this->obj->lasterror ."</SPAN><BR>\n"; + echo "Table <b>". $this->obj->prefix . $f[name] ."</b> not dropped:<span class=\"warn\">". $this->obj->lasterror ."</span><br>\n"; } else { echo "<span class=\"found\">Table <B>". $this->obj->prefix . $f[name] ."</B> dropped</span><br>\n"; } @@ -69,8 +68,7 @@ } # Build the inidces echo "<P>\n"; - @reset($tableidx); - while ( list ($i,$f) = @each ($tableidx) ) { + foreach ($tableidx as $i => $f) { echo $f[Desc] ."<BR>\n"; if ($this->obj->dropindex($f) == -1) { # echo "Index not dropped:<SPAN class=warn>". $this->obj->lasterror ."</SPAN><BR>\n"; Index: update.php =================================================================== RCS file: /cvsroot/tutos/tutos/php/update.php,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- update.php 29 Sep 2002 20:27:10 -0000 1.23 +++ update.php 30 Oct 2002 19:37:39 -0000 1.24 @@ -30,8 +30,8 @@ echo "<h2>". $this->dbc->getFullName() ."</h2>\n"; echo "<P>TABLES<P>\n"; - @reset($table); - while ( list ($i,$f) = @each ($table) ) { + + foreach ($table as $i => $f) { echo $f[Desc] ."<BR>\n"; if ($this->dbc->createtable($f) == -1) { # echo "Table ". $f[name] ." not created:<SPAN class=warn>". $this->dbc->lasterror ."</SPAN><BR>\n"; @@ -42,19 +42,18 @@ } echo "<P>COLUMNS<P>\n"; - @reset($table); - while ( list ($i,$f) = @each ($table) ) { + foreach ($table as $i => $f) { echo $f[Desc] ."<BR>\n"; @reset($f); while ( list ($i2,$f2) = @each ($f) ) { - if ( gettype($f2) != "array" ) { + if ( ! is_array($f2) ) { continue; - } - if ($this->dbc->createcolumn($f[name],$f2) == -1) { + } + if ($this->dbc->createcolumn($f[name],$i2,$f2) == -1) { # echo "Column ". $f[name] ." (". $f2[column] .") not created: <SPAN class=warn>". $this->dbc->lasterror ."</SPAN><BR>\n"; # nothing created (try an alter table to fix sizes) } else { - echo "Column <SPAN class=found>". $f[name] ." (". $f2[column] .")</SPAN> created<BR>\n"; + echo "Column <SPAN class=found>". $f[name] ." (". $i2 .")</SPAN> created<BR>\n"; } } flush(); @@ -85,9 +84,59 @@ # Update the DB entry # The current DB entry is always that with the ID 1 - $this->dbc->db->SetVersion($tutos[version]); $this->dbc->db->read_update(); + echo "DB Version:". $this->dbc->db->version ."<br>"; + echo "TUTOS Version:". $tutos[version] ."<br>"; + $oldv = (int)ereg_replace("\.","",$this->dbc->db->version); + $newv = (int)ereg_replace("\.","",$tutos[version]); + if ( $oldv < 1120021026 ) { + #special update + $updatefailed = false; + echo "<h3>Special update for ". $tutos[version] ."</h3><br>"; + $tmpname = 'acl_temp'; + # drop temp table + if ($this->dbc->droptable($tmpname) == -1) { + } + if ($this->dbc->dropindex($tableidx['acl1']) == -1) { + } + if ($this->dbc->dropindex($tableidx['acl2']) == -1) { + } + # rename acl + if ($this->dbc->renametable($table['acl'],$tmpname) == -1) { + $updatefailed = true; + echo "Table not renamed:<SPAN class=warn>". $this->dbc->lasterror ."</SPAN><BR>\n"; + } + # create acl + if ($this->dbc->createtable($table['acl']) == -1) { + $updatefailed = true; + echo "Table not created:<SPAN class=warn>". $this->dbc->lasterror ."</SPAN><BR>\n"; + } + if ($this->dbc->createindex($tableidx['acl1']) == -1) { + $updatefailed = true; + echo "Index not created:<SPAN class=warn>". $this->dbc->lasterror ."</SPAN><BR>\n"; + } + if ($this->dbc->createindex($tableidx['acl2']) == -1) { + $updatefailed = true; + echo "Index not created:<SPAN class=warn>". $this->dbc->lasterror ."</SPAN><BR>\n"; + } + # fill + $q = "insert into ". $this->dbc->prefix . $table['acl'][name] ." (obj_id,adr_id,perm)"; + if ( $this->dbc->getType() == "Postgres" ) { + $q .= " select obj_id,adr_id,int4(perm) from ". $this->dbc->prefix . $tmpname; + } else { + $q .= " select obj_id,adr_id,perm from ". $this->dbc->prefix . $tmpname; + } + $this->dbc->Exec($q,0); + if ( $updatefailed ) { + echo "Update failed<BR>\n"; + } + } + + $this->dbc->db->SetVersion($tutos[version]); + $this->dbc->db->save(); + + echo $this->error("If everything works disable this script"); } @@ -132,6 +181,7 @@ $dbc = null; $x = new tutos_user($dbc); + $current_user = &$x; $l = new admin_update($x); $l->display(); ?> |