allow to use a constant for the app-name

This commit is contained in:
Ralf Becker 2005-12-19 04:27:19 +00:00
parent 28fe36e769
commit a1f055d42d

View File

@ -728,6 +728,11 @@
$fcontent = fread($f,filesize($file)); $fcontent = fread($f,filesize($file));
fclose ($f); fclose ($f);
$app_pattern = "'$app'";
if (preg_match("/define\('([^']+)',$app_pattern\)/",$fcontent,$matches))
{
$app_pattern = $matches[1];
}
if (is_writable(EGW_SERVER_ROOT."/$app/setup")) if (is_writable(EGW_SERVER_ROOT."/$app/setup"))
{ {
$old_file = EGW_SERVER_ROOT . "/$app/setup/setup.old.inc.php"; $old_file = EGW_SERVER_ROOT . "/$app/setup/setup.old.inc.php";
@ -737,13 +742,13 @@
} }
rename($file,$old_file); rename($file,$old_file);
} }
$fnew = preg_replace('/(.*\\$'."setup_info\\['$app'\\]\\['version'\\][ \\t]*=[ \\t]*)'[^']*'(.*)/i","\\1'$new'\\2",$fcontent); $fnew = preg_replace('/(.*\\$'."setup_info\\[$app_pattern\\]\\['version'\\][ \\t]*=[ \\t]*)'[^']*'(.*)/i","\\1'$new'\\2",$fcontent);
if ($tables != '') if ($tables != '')
{ {
if (isset($setup_info[$app]['tables'])) // if there is already tables array, update it if (isset($setup_info[$app]['tables'])) // if there is already tables array, update it
{ {
$fnew = preg_replace('/(.*\\$'."setup_info\\['$app'\\]\\['tables'\\][ \\t]*=[ \\t]*array\()[^)]*/i","\\1$tables",$fwas=$fnew); $fnew = preg_replace('/(.*\\$'."setup_info\\[$app_pattern\\]\\['tables'\\][ \\t]*=[ \\t]*array\()[^)]*/i","\\1$tables",$fwas=$fnew);
if ($fwas == $fnew) // nothing changed => tables are in single lines if ($fwas == $fnew) // nothing changed => tables are in single lines
{ {
@ -752,7 +757,7 @@
$stage = 0; // 0 = before, 1 = in, 2 = after tables section $stage = 0; // 0 = before, 1 = in, 2 = after tables section
foreach($fwas as $line) foreach($fwas as $line)
{ {
if (preg_match('/(.*\\$'."setup_info\\['$app'\\]\\['tables'\\]\\[[ \\t]*\\][ \\t]*=[ \\t]*)'/i",$line,$parts)) if (preg_match('/(.*\\$'."setup_info\\[$app_pattern\\]\\['tables'\\]\\[[ \\t]*\\][ \\t]*=[ \\t]*)'/i",$line,$parts))
{ {
if ($stage == 0) // first line of tables-section if ($stage == 0) // first line of tables-section
{ {
@ -785,7 +790,7 @@
{ {
$fnew = str_replace('?>','',$fnew); $fnew = str_replace('?>','',$fnew);
} }
$fnew .= "\t\$setup_info['$app']['tables'] = array($tables);\n"; $fnew .= "\t\$setup_info[$app_pattern]['tables'] = array($tables);\n";
} }
} }
if (!is_writeable(EGW_SERVER_ROOT."/$app/setup") || !($f = fopen($file,'w'))) if (!is_writeable(EGW_SERVER_ROOT."/$app/setup") || !($f = fopen($file,'w')))