diff --git a/Source/Source.API.php b/Source/Source.API.php index f37b2fb..7427f0f 100644 --- a/Source/Source.API.php +++ b/Source/Source.API.php @@ -44,6 +44,24 @@ } /** + * Determine if the Product Matrix integration is enabled, and trigger + * an error if integration is enabled but the plugin is not running. + * @param boolean Trigger error + * @return boolean Integration enabled + */ +function Source_PVM( $p_trigger_error=true ) { + if ( config_get( 'plugin_Source_enable_product_matrix' ) ) { + if ( plugin_is_loaded( 'ProductMatrix' ) || !$p_trigger_error ) { + return true; + } else { + trigger_error( ERROR_GENERIC, ERROR ); + } + } else { + return false; + } +} + +/** * Parse basic bug links from a changeset commit message * and return a list of referenced bug IDs. * @param string Changeset commit message @@ -1264,6 +1282,7 @@ var $version; var $regex; + var $pvm_version_id; /** * Initialize a mapping object. @@ -1271,12 +1290,13 @@ * @param string Branch name * @param int Mapping type */ - function __construct( $p_repo_id, $p_branch, $p_type, $p_version='', $p_regex='' ) { + function __construct( $p_repo_id, $p_branch, $p_type, $p_version='', $p_regex='', $p_pvm_version_id=0 ) { $this->repo_id = $p_repo_id; $this->branch = $p_branch; $this->type = $p_type; $this->version = $p_version; $this->regex = $p_regex; + $this->pvm_version_id = $p_pvm_version_id; } /** @@ -1286,15 +1306,15 @@ $t_branch_table = plugin_table( 'branch' ); if ( $this->_new ) { - $t_query = "INSERT INTO $t_branch_table ( repo_id, branch, type, version, regex ) VALUES (" . - db_param() . ', ' .db_param() . ', ' .db_param() . ', ' .db_param() . ', ' . db_param() . ')'; - db_query_bound( $t_query, array( $this->repo_id, $this->branch, $this->type, $this->version, $this->regex ) ); + $t_query = "INSERT INTO $t_branch_table ( repo_id, branch, type, version, regex, pvm_version_id ) VALUES (" . + db_param() . ', ' .db_param() . ', ' .db_param() . ', ' .db_param() . ', ' . db_param() . ', ' . db_param() . ')'; + db_query_bound( $t_query, array( $this->repo_id, $this->branch, $this->type, $this->version, $this->regex, $this->pvm_version_id ) ); } else { $t_query = "UPDATE $t_branch_table SET branch=" . db_param() . ', type=' . db_param() . ', version=' . db_param() . - ', regex=' . db_param() . ' WHERE repo_id=' . db_param() . ' AND branch=' . db_param(); + ', regex=' . db_param() . ', pvm_version_id=' . db_param() . ' WHERE repo_id=' . db_param() . ' AND branch=' . db_param(); db_query_bound( $t_query, array( $this->branch, $this->type, $this->version, - $this->regex, $this->repo_id, $this->branch ) ); + $this->regex, $this->pvm_version_id, $this->repo_id, $this->branch ) ); } } @@ -1326,7 +1346,7 @@ $t_mappings = array(); while( $t_row = db_fetch_array( $t_result ) ) { - $t_mapping = new SourceMapping( $t_row['repo_id'], $t_row['branch'], $t_row['type'], $t_row['version'], $t_row['regex'] ); + $t_mapping = new SourceMapping( $t_row['repo_id'], $t_row['branch'], $t_row['type'], $t_row['version'], $t_row['regex'], $t_row['pvm_version_id'] ); $t_mapping->_new = false; $t_mappings[$t_mapping->branch] = $t_mapping; diff --git a/Source/Source.php b/Source/Source.php index 94a8597..f4ea725 100644 --- a/Source/Source.php +++ b/Source/Source.php @@ -48,6 +48,7 @@ 'enable_porting' => OFF, 'enable_resolving' => OFF, 'enable_message' => OFF, + 'enable_product_matrix' => OFF, 'buglink_regex_1' => '/(?:bugs?|issues?|reports?)+\s+(?:#(?:\d+)[,\.\s]*)+/i', 'buglink_regex_2' => '/#?(\d+)/', @@ -220,6 +221,10 @@ array( 'CreateIndexSQL', array( 'idx_source_user_username', plugin_table( 'user' ), 'username', array( 'UNIQUE' ) ) ), # 2010-02-11 - Update repo types from svn->websvn array( 'UpdateSQL', array( plugin_table( 'repository' ), " SET type='websvn' WHERE type='svn'" ) ), + # 2010-07-29 - Integrate with the Product Matrix plugin + array( 'AddColumnSQL', array( plugin_table( 'branch' ), " + pvm_version_id I NOTNULL UNSIGNED DEFAULT '0' + " ) ), ); } diff --git a/Source/lang/strings_english.txt b/Source/lang/strings_english.txt index 02464ea..b4959be 100644 --- a/Source/lang/strings_english.txt +++ b/Source/lang/strings_english.txt @@ -104,6 +104,7 @@ $s_plugin_Source_enable_resolving = 'Resolve Fixed Issues'; $s_plugin_Source_enable_message = 'Bug Fixed Message'; $s_plugin_Source_enable_porting = 'Porting Status'; +$s_plugin_Source_enable_product_matrix = 'Product Matrix Integration'; $s_plugin_Source_branch_mapping = 'Branch Mappings'; $s_plugin_Source_mapping_update = 'Update Mappings'; diff --git a/Source/pages/manage_config.php b/Source/pages/manage_config.php index 2e96bb2..563b93d 100644 --- a/Source/pages/manage_config.php +++ b/Source/pages/manage_config.php @@ -21,6 +21,7 @@ $f_enable_resolving = gpc_get_bool( 'enable_resolving', OFF ); $f_enable_message = gpc_get_bool( 'enable_message', OFF ); $f_enable_porting = gpc_get_bool( 'enable_porting', OFF ); +$f_enable_product_matrix = gpc_get_bool( 'enable_product_matrix', OFF ); $f_buglink_regex_1 = gpc_get_string( 'buglink_regex_1' ); $f_buglink_reset_1 = gpc_get_string( 'buglink_reset_1', OFF ); @@ -81,6 +82,7 @@ maybe_set_option( 'enable_resolving', $f_enable_resolving ); maybe_set_option( 'enable_message', $f_enable_message ); maybe_set_option( 'enable_porting', $f_enable_porting ); +maybe_set_option( 'enable_product_matrix', $f_enable_product_matrix ); if ( ! $f_buglink_reset_1 ) { maybe_set_option( 'buglink_regex_1', $f_buglink_regex_1 ); diff --git a/Source/pages/manage_config_page.php b/Source/pages/manage_config_page.php index fea9d25..3b36623 100644 --- a/Source/pages/manage_config_page.php +++ b/Source/pages/manage_config_page.php @@ -73,6 +73,10 @@

+ +
+ diff --git a/Source/pages/repo_manage_page.php b/Source/pages/repo_manage_page.php index 53b1b33..9d9afc6 100644 --- a/Source/pages/repo_manage_page.php +++ b/Source/pages/repo_manage_page.php @@ -18,17 +18,38 @@ } echo '', - ''; + if ( !Source_PVM() ) { + echo '', '', - ''; + } + echo '', ''; } +function display_pvm_versions($t_version_id=null) { + static $s_products = null; + + if ( is_null( $s_products ) ) { + $s_products = PVMProduct::load_all( true ); + } + + if ( is_null( $t_version_id ) ) { + echo ""; + } + + foreach( $s_products as $t_product ) { + foreach( $t_product->versions as $t_version ) { + echo ""; + } + } +} + html_page_top1( plugin_lang_get( 'title' ) ); html_page_top2(); ?> @@ -125,7 +146,11 @@ > + + + + @@ -136,7 +161,11 @@ > + + + diff --git a/Source/pages/repo_update_mappings.php b/Source/pages/repo_update_mappings.php index fdcfc02..6672d7d 100644 --- a/Source/pages/repo_update_mappings.php +++ b/Source/pages/repo_update_mappings.php @@ -25,7 +25,11 @@ $f_mapping_branch = gpc_get_string( $t_posted_branch . '_branch', $t_mapping->branch ); $f_mapping_type = gpc_get_int( $t_posted_branch . '_type', $t_mapping->type ); - $f_mapping_version = gpc_get_string( $t_posted_branch . '_version', $t_mapping->version ); + if ( Source_PVM() ) { + $f_mapping_pvm_version_id = gpc_get_int( $t_posted_branch . '_pvm_version_id', $t_mapping->pvm_version_id ); + } else { + $f_mapping_version = gpc_get_string( $t_posted_branch . '_version', $t_mapping->version ); + } $f_mapping_regex = gpc_get_string( $t_posted_branch . '_regex', $t_mapping->regex ); $t_update = false; @@ -39,9 +43,16 @@ $t_mapping->type = $f_mapping_type; $t_update = true; } - if ( $t_mapping->version != $f_mapping_version ) { - $t_mapping->version = $f_mapping_version; - $t_update = true; + if ( Source_PVM() ) { + if ( $t_mapping->pvm_version_id != $f_mapping_pvm_version_id ) { + $t_mapping->pvm_version_id = $f_mapping_pvm_version_id; + $t_update = true; + } + } else { + if ( $t_mapping->version != $f_mapping_version ) { + $t_mapping->version = $f_mapping_version; + $t_update = true; + } } if ( $t_mapping->regex != $f_mapping_regex && false !== preg_match( $f_mapping_regex, '' ) ) { $t_mapping->regex = $f_mapping_regex; @@ -57,7 +68,13 @@ # process the form elements for creating a new mapping $f_mapping_branch = gpc_get_string( '_branch', '' ); $f_mapping_type = gpc_get_int( '_type', 0 ); -$f_mapping_version = gpc_get_string( '_version', '' ); +if ( Source_PVM() ) { + $f_mapping_pvm_version_id = gpc_get_int( '_pvm_version_id', 0 ); + $f_mapping_version = ''; +} else { + $f_mapping_pvm_version_id = 0; + $f_mapping_version = gpc_get_string( '_version', '' ); +} $f_mapping_regex = gpc_get_string( '_regex', '' ); if ( !is_blank( $f_mapping_branch ) ) { @@ -69,11 +86,19 @@ die( 'error type' ); } - if ( $f_mapping_type == SOURCE_EXPLICIT && is_blank( $f_mapping_version ) ) { - die( 'error version' ); + if ( $f_mapping_type == SOURCE_EXPLICIT ) { + if ( Source_PVM() ) { + if ( $f_mapping_pvm_version_id < 1 ) { + die( 'error product version' ); + } + } else { + if ( is_blank( $f_mapping_version ) ) { + die( 'error version' ); + } + } } - $t_mapping = new SourceMapping( $t_repo->id, $f_mapping_branch, $f_mapping_type, $f_mapping_version, $f_mapping_regex ); + $t_mapping = new SourceMapping( $t_repo->id, $f_mapping_branch, $f_mapping_type, $f_mapping_version, $f_mapping_regex, $f_mapping_pvm_version_id ); $t_mapping->save(); }