[Linpha-cvs] SF.net SVN: linpha: [4803] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2007-12-01 17:14:19
|
Revision: 4803 http://linpha.svn.sourceforge.net/linpha/?rev=4803&view=rev Author: fangehrn Date: 2007-12-01 09:14:09 -0800 (Sat, 01 Dec 2007) Log Message: ----------- 2007-12-01 flo * creating plugin interface - create plugin tables only when plugin is enabled pay attention with oracles sequences and triggers any idea how to create them dynamically? Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/maintenance_db.php trunk/linpha2/admin/settings_plugins.php trunk/linpha2/install/manual_install.php trunk/linpha2/install/step8_testing.php trunk/linpha2/install/step9_createtables.php trunk/linpha2/reset_database.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-12-01 15:58:31 UTC (rev 4802) +++ trunk/linpha2/ChangeLog 2007-12-01 17:14:09 UTC (rev 4803) @@ -4,6 +4,11 @@ - moved whole install/sql folder to lib/include/sql we need still that files if we want to dynamically create the plugin tables + and changed hopefully all paths + + - create plugin tables only when plugin is enabled + pay attention with oracles sequences and triggers + any idea how to create them dynamically? 2007-11-20 flo * finished basic part of the map plugin Modified: trunk/linpha2/admin/maintenance_db.php =================================================================== --- trunk/linpha2/admin/maintenance_db.php 2007-12-01 15:58:31 UTC (rev 4802) +++ trunk/linpha2/admin/maintenance_db.php 2007-12-01 17:14:09 UTC (rev 4803) @@ -308,7 +308,7 @@ $_SESSION['cache_dir'] = ''; $_SESSION['tmp_dir'] = ''; - include(LINPHA_DIR.'/lib/include/sql.data.php'); + include(LINPHA_DIR.'/lib/include/sql/sql.data.php'); foreach($options AS $key=>$value) { $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".LIN_PREFIX."config " . Modified: trunk/linpha2/admin/settings_plugins.php =================================================================== --- trunk/linpha2/admin/settings_plugins.php 2007-12-01 15:58:31 UTC (rev 4802) +++ trunk/linpha2/admin/settings_plugins.php 2007-12-01 17:14:09 UTC (rev 4803) @@ -15,21 +15,47 @@ { foreach($arrPlugins as $value) { - $arrPlugins2[] = 'plugins_'.$value.'_enable'; + $arrPluginsFullName[] = 'plugins_'.$value.'_enable'; } - $LinAdmin->saveConfig($arrPlugins2); - /** * create database tables if necessary + * !!! WARNING: SAME CODE ALSO IN install/step9_createtables.php !!! */ - foreach($arrPlugins2 as $value) + include(LINPHA_DIR.'/lib/include/sql/sql.tables.php'); + foreach($linpha_tables AS $key=>$value) { - if( isset($_POST[$value]) && $_POST[$value]=='1' ) + $linpha_tables[$key] = LIN_PREFIX.$value; + } + include(LINPHA_DIR.'/lib/include/sql/sql.'.LIN_DB_TYPE.'.php'); + + // go through all plugins + foreach($arrPlugins as $value) + { + // if now enabled and before it was disabled + if( isset($_POST['plugins_'.$value.'_enable']) + && $_POST['plugins_'.$value.'_enable']=='1' + && $LinAdmin->option_value_system['plugins_'.$value.'_enable']=='0') { - + linSysLog(i18n("Creating tables for plugin: ").' '.$LinAdmin->description_array['plugins_'.$value]); + foreach($sql_tables as $sqlStr) + { + // if table starts with "CREATE TABLE linpha_plugins_$value" + $sqlStrSearch = "CREATE TABLE ".LIN_PREFIX."plugins_".$value; + if(substr($sqlStr,0,strlen($sqlStrSearch)) == $sqlStrSearch) + { + $result = $linpha->db->Execute($sqlStr); + + // it the table already exists, we get automatically a nice message like + // "Table 'linpha2_plugins_maps_markers' already exists" + if(!$result) { + linSysLog($linpha->db->ErrorMsg()); + } + } + } } } + $LinAdmin->saveConfig($arrPluginsFullName); } /** @@ -74,4 +100,5 @@ include_once($includeFile); } } + ?> \ No newline at end of file Modified: trunk/linpha2/install/manual_install.php =================================================================== --- trunk/linpha2/install/manual_install.php 2007-12-01 15:58:31 UTC (rev 4802) +++ trunk/linpha2/install/manual_install.php 2007-12-01 17:14:09 UTC (rev 4803) @@ -84,7 +84,7 @@ /** * get table names and add prefix */ - include_once(LINPHA_DIR.'/install/sql/sql.tables.php'); + include_once(LINPHA_DIR.'/lib/include/sql/sql.tables.php'); foreach($linpha_tables AS $key=>$value) { $linpha_tables[$key] = LIN_PREFIX.$value; @@ -93,7 +93,7 @@ /** * include sql strings */ - include_once(LINPHA_DIR."/install/sql/sql.".LIN_DB_TYPE.".php"); + include_once(LINPHA_DIR."/lib/include/sql/sql.".LIN_DB_TYPE.".php"); /** * finally create tables @@ -108,7 +108,7 @@ * insert data */ $str_query .= "\n\n"; - include_once(LINPHA_DIR.'/lib/include/sql.data.php'); + include_once(LINPHA_DIR.'/lib/include/sql/sql.data.php'); foreach($sql_queries AS $value) { $str_query .= $value.";\n"; @@ -128,7 +128,7 @@ $donotchange = ' // change only with installer !!'; $comment[1] = $donotchange; -include_once(LINPHA_DIR.'/install/sql/config.dir.php'); +include_once(LINPHA_DIR.'/lib/include/sql/config.dir.php'); ?> <br /><br /> <?php echo i18n_install("Folders To Create:")."<br />"; ?> @@ -166,7 +166,7 @@ $comment[6] = $donotchange; $comment[7] = $changeme; -include_once(LINPHA_DIR.'/install/sql/config.sql.php'); +include_once(LINPHA_DIR.'/lib/include/sql/config.sql.php'); ?> <br /><br /> <?php echo i18n_install("Database Connection File")." <b>".$_SESSION['sql_dir']."/config.sql.php</b><br />"; ?> Modified: trunk/linpha2/install/step8_testing.php =================================================================== --- trunk/linpha2/install/step8_testing.php 2007-12-01 15:58:31 UTC (rev 4802) +++ trunk/linpha2/install/step8_testing.php 2007-12-01 17:14:09 UTC (rev 4803) @@ -94,12 +94,12 @@ } else { - include_once(LINPHA_DIR.'/install/sql/sql.tables.php'); + include_once(LINPHA_DIR.'/lib/include/sql/sql.tables.php'); /** * add prefix */ - foreach($linpha_tables AS $key=>$value) + foreach($linpha_tables as $key=>$value) { $linpha_tables[$key] = $_SESSION['sql_prefix'].$value; } Modified: trunk/linpha2/install/step9_createtables.php =================================================================== --- trunk/linpha2/install/step9_createtables.php 2007-12-01 15:58:31 UTC (rev 4802) +++ trunk/linpha2/install/step9_createtables.php 2007-12-01 17:14:09 UTC (rev 4803) @@ -39,11 +39,12 @@ /** * create tables + * !!! WARNING: SAME CODE ALSO IN admin/settings_plugins.php !!! */ /** * get table names and add prefix */ - include_once(LINPHA_DIR.'/install/sql/sql.tables.php'); + include_once(LINPHA_DIR.'/lib/include/sql/sql.tables.php'); foreach($linpha_tables AS $key=>$value) { $linpha_tables[$key] = LIN_PREFIX.$value; @@ -52,7 +53,7 @@ /** * include sql strings */ - include_once(LINPHA_DIR."/install/sql/sql.".LIN_DB_TYPE.".php"); + include_once(LINPHA_DIR.'/lib/include/sql/sql.'.LIN_DB_TYPE.'.php'); /** * finally create tables @@ -62,13 +63,20 @@ $translation_array = array_keys($linpha_tables); // only used in error case while( list($key,$query) = each($sql_tables) ) { - $result = $linpha->db->Execute($query); - if(!$result) + /** + * ignore plugins_ tables + */ + $sqlStrSearch = "CREATE TABLE ".LIN_PREFIX."plugins_"; + if(substr($query,0,strlen($sqlStrSearch)) != $sqlStrSearch) { - echo LIN_PREFIX.$translation_array[$key].' '; - echo failed_msg(); - echo ' '.$linpha->db->ErrorMsg().'<br />'; - $error_nr = 1; + $result = $linpha->db->Execute($query); + if(!$result) + { + echo LIN_PREFIX.$translation_array[$key].' '; + echo failed_msg(); + echo ' '.$linpha->db->ErrorMsg().'<br />'; + $error_nr = 1; + } } } /** @@ -125,7 +133,7 @@ * insert data */ echo "<br />".i18n_install("Inserting Table Data...").' '; - include_once(LINPHA_DIR.'/lib/include/sql.data.php'); + include_once(LINPHA_DIR.'/lib/include/sql/sql.data.php'); foreach($sql_queries AS $value) { $result = $linpha->db->Execute($value); @@ -171,7 +179,7 @@ if($fp) { $comment[1] = ''; - include_once(LINPHA_DIR.'/install/sql/config.dir.php'); + include_once(LINPHA_DIR.'/lib/include/sql/config.dir.php'); fwrite( $fp, $str ); fclose($fp); @@ -209,7 +217,7 @@ $comment[6] = ''; $comment[7] = ''; - include_once(LINPHA_DIR.'/install/sql/config.sql.php'); + include_once(LINPHA_DIR.'/lib/include/sql/config.sql.php'); fwrite( $fp, $str ); fclose($fp); Modified: trunk/linpha2/reset_database.php =================================================================== --- trunk/linpha2/reset_database.php 2007-12-01 15:58:31 UTC (rev 4802) +++ trunk/linpha2/reset_database.php 2007-12-01 17:14:09 UTC (rev 4803) @@ -21,7 +21,7 @@ /** * get table names and add prefix */ - include_once(LINPHA_DIR.'/install/sql/sql.tables.php'); + include_once(LINPHA_DIR.'/lib/include/sql/sql.tables.php'); foreach($linpha_tables AS $key=>$value) { $linpha_tables[$key] = LIN_PREFIX.$value; @@ -51,7 +51,7 @@ /** * include sql strings */ - include_once(LINPHA_DIR."/install/sql/sql.".LIN_DB_TYPE.".php"); + include_once(LINPHA_DIR."/lib/include/sql/sql.".LIN_DB_TYPE.".php"); /** * finally create tables @@ -61,13 +61,20 @@ $translation_array = array_keys($linpha_tables); // only used in error case while( list($key,$query) = each($sql_tables) ) { - $result = $linpha->db->Execute($query); - if(!$result) + /** + * ignore plugins_ tables + */ + $sqlStrSearch = "CREATE TABLE ".LIN_PREFIX."plugins_"; + if(substr($query,0,strlen($sqlStrSearch)) != $sqlStrSearch) { - echo LIN_PREFIX.$translation_array[$key].' '; - echo failed_msg(); - echo ' '.$linpha->db->ErrorMsg().'<br />'; - $error_nr = 1; + $result = $linpha->db->Execute($query); + if(!$result) + { + echo LIN_PREFIX.$translation_array[$key].' '; + echo failed_msg(); + echo ' '.$linpha->db->ErrorMsg().'<br />'; + $error_nr = 1; + } } } if(!isset($error_nr)) @@ -81,7 +88,7 @@ * insert data */ echo "<br /><br />".tr("Inserting Table Data")."... "; - include_once(LINPHA_DIR.'/lib/include/sql.data.php'); + include_once(LINPHA_DIR.'/lib/include/sql/sql.data.php'); foreach($sql_queries AS $value) { $result = $linpha->db->Execute($value); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |