From a1f055d42d75f6ac95ed605a49a6bf2400f69c98 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 19 Dec 2005 04:27:19 +0000 Subject: [PATCH] allow to use a constant for the app-name --- etemplate/inc/class.db_tools.inc.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/etemplate/inc/class.db_tools.inc.php b/etemplate/inc/class.db_tools.inc.php index 7f6de79902..c1d5428cf0 100644 --- a/etemplate/inc/class.db_tools.inc.php +++ b/etemplate/inc/class.db_tools.inc.php @@ -727,7 +727,12 @@ } $fcontent = fread($f,filesize($file)); 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")) { $old_file = EGW_SERVER_ROOT . "/$app/setup/setup.old.inc.php"; @@ -737,13 +742,13 @@ } 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 (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 { @@ -752,7 +757,7 @@ $stage = 0; // 0 = before, 1 = in, 2 = after tables section 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 { @@ -785,7 +790,7 @@ { $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')))