# HG changeset patch # User Dan # Date 1231727739 18000 # Node ID 97cd1a3229d0e802c45036d4b1c6516560b4b21c # Parent 34e8bf0f25e15ae20552c229aea980725b7a80f0 Plugin manager: added support for having specific install and uninstall blocks per DBMS diff -r 34e8bf0f25e1 -r 97cd1a3229d0 includes/plugins.php --- a/includes/plugins.php Sun Jan 11 21:35:03 2009 -0500 +++ b/includes/plugins.php Sun Jan 11 21:35:39 2009 -0500 @@ -557,10 +557,36 @@ $schema = $this->parse_plugin_blocks( ENANO_ROOT . '/plugins/' . $filename, 'install' ); $sql = array(); + global $dbdriver; if ( !empty($schema) ) { + // Decide which schema to use + $use_schema = false; + foreach ( $schema as $current_schema ) + { + if ( isset($current_schema['dbms']) && $current_schema['dbms'] === $dbdriver ) + { + $use_schema =& $current_schema['value']; + break; + } + } + if ( !$use_schema ) + { + if ( !isset($schema[0]['dbms']) ) + { + $use_schema =& $schema[0]['value']; + } + else + { + $return = array( + 'mode' => 'error', + 'error' => $lang->get('acppl_err_dmbs_not_supported', array('dbdriver' => $db->dbms_name)) + ); + break; + } + } // parse SQL - $parser = new SQL_Parser($schema[0]['value'], true); + $parser = new SQL_Parser($use_schema, true); $parser->assign_vars(array( 'TABLE_PREFIX' => table_prefix )); @@ -640,6 +666,7 @@ { global $db, $session, $paths, $template, $plugins; // Common objects global $lang; + global $cache; if ( defined('ENANO_DEMO_MODE') ) { @@ -683,10 +710,36 @@ $schema = $this->parse_plugin_blocks( ENANO_ROOT . '/plugins/' . $filename, 'uninstall' ); $sql = array(); + global $dbdriver; if ( !empty($schema) ) { + // Decide which schema to use + $use_schema = false; + foreach ( $schema as $current_schema ) + { + if ( isset($current_schema['dbms']) && $current_schema['dbms'] === $dbdriver ) + { + $use_schema =& $current_schema['value']; + break; + } + } + if ( !$use_schema ) + { + if ( !isset($schema[0]['dbms']) ) + { + $use_schema =& $schema[0]['value']; + } + else + { + $return = array( + 'mode' => 'error', + 'error' => $lang->get('acppl_err_dmbs_not_supported', array('dbdriver' => $db->dbms_name)) + ); + break; + } + } // parse SQL - $parser = new SQL_Parser($schema[0]['value'], true); + $parser = new SQL_Parser($use_schema, true); $parser->assign_vars(array( 'TABLE_PREFIX' => table_prefix ));