function version_remove($p_version_id, $p_new_version = '') { $c_version_id = db_prepare_int($p_version_id); $c_new_version = db_prepare_string($p_new_version); version_ensure_exists($p_version_id); $t_old_version = version_get_field($p_version_id, 'version'); $t_project_id = version_get_field($p_version_id, 'project_id'); $c_old_version = db_prepare_string($t_old_version); $c_project_id = db_prepare_int($t_project_id); $t_project_version_table = config_get('mantis_project_version_table'); $t_bug_table = config_get('mantis_bug_table'); $query = "DELETE FROM {$t_project_version_table}\r\n\t\t\t\t WHERE id='{$c_version_id}'"; db_query($query); $query = "UPDATE {$t_bug_table}\r\n\t\t\t\t SET version='{$c_new_version}'\r\n\t\t\t\t WHERE project_id='{$c_project_id}' AND version='{$c_old_version}'"; db_query($query); $query = "UPDATE {$t_bug_table}\r\n\t\t\t\t SET fixed_in_version='{$c_new_version}'\r\n\t\t\t\t WHERE ( project_id='{$c_project_id}' ) AND ( fixed_in_version='{$c_old_version}' )"; db_query($query); # db_query() errors on failure so: return true; }
/** * Remove a version from the project * @param int $p_version_id * @param string $p_new_version * @return true */ function version_remove($p_version_id, $p_new_version = '') { $c_version_id = db_prepare_int($p_version_id); version_ensure_exists($p_version_id); $t_old_version = version_get_field($p_version_id, 'version'); $t_project_id = version_get_field($p_version_id, 'project_id'); $c_project_id = db_prepare_int($t_project_id); $t_project_version_table = db_get_table('project_version'); $t_bug_table = db_get_table('bug'); $query = "DELETE FROM {$t_project_version_table}\n\t\t\t\t WHERE id=" . db_param(); db_query_bound($query, array($c_version_id)); $t_project_list = array($c_project_id); if (config_get('subprojects_inherit_versions')) { $t_project_list = array_merge($t_project_list, project_hierarchy_get_all_subprojects($c_project_id, true)); } $t_project_list = implode(',', $t_project_list); $query = "UPDATE {$t_bug_table}\n\t\t\t\t SET version=" . db_param() . "\n\t\t\t\t WHERE project_id IN ( {$t_project_list} ) AND version=" . db_param(); db_query_bound($query, array($p_new_version, $t_old_version)); $query = "UPDATE {$t_bug_table}\n\t\t\t\t SET fixed_in_version=" . db_param() . "\n\t\t\t\t WHERE ( project_id IN ( {$t_project_list} ) ) AND ( fixed_in_version=" . db_param() . ')'; db_query_bound($query, array($p_new_version, $t_old_version)); $query = "UPDATE {$t_bug_table}\n\t\t\t\t SET target_version=" . db_param() . "\n\t\t\t\t WHERE ( project_id IN ( {$t_project_list} ) ) AND ( target_version=" . db_param() . ')'; db_query_bound($query, array($p_new_version, $t_old_version)); # db_query errors on failure so: return true; }
/** * Remove a version from the project * @param integer $p_version_id A valid version identifier. * @param string $p_new_version A version string to update issues using the old version with. * @return void */ function version_remove( $p_version_id, $p_new_version = '' ) { version_ensure_exists( $p_version_id ); $t_old_version = version_get_field( $p_version_id, 'version' ); $t_project_id = version_get_field( $p_version_id, 'project_id' ); $t_query = 'DELETE FROM {project_version} WHERE id=' . db_param(); db_query( $t_query, array( (int)$p_version_id ) ); $t_project_list = array( $t_project_id ); if( config_get( 'subprojects_inherit_versions' ) ) { $t_project_list = array_merge( $t_project_list, project_hierarchy_get_all_subprojects( $t_project_id, true ) ); } $t_project_list = implode( ',', $t_project_list ); $t_query = 'UPDATE {bug} SET version=' . db_param() . ' WHERE project_id IN ( ' . $t_project_list . ' ) AND version=' . db_param(); db_query( $t_query, array( $p_new_version, $t_old_version ) ); $t_query = 'UPDATE {bug} SET fixed_in_version=' . db_param() . ' WHERE ( project_id IN ( ' . $t_project_list . ' ) ) AND ( fixed_in_version=' . db_param() . ')'; db_query( $t_query, array( $p_new_version, $t_old_version ) ); $t_query = 'UPDATE {bug} SET target_version=' . db_param() . ' WHERE ( project_id IN ( ' . $t_project_list . ' ) ) AND ( target_version=' . db_param() . ')'; db_query( $t_query, array( $p_new_version, $t_old_version ) ); }