View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0004220 | Plugin - CsvImport | General | public | 2004-07-29 12:52 | 2020-07-30 03:24 |
Reporter | fusenigk | Assigned To | vboctor | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Summary | 0004220: * Import new Issues from file | ||||
Description | I found some php file extensions for the possibility to import new issues from an external file. These feature is developed by cas@nuy.info, but works for me and me 0.19.a2 installation. | ||||
Tags | patch | ||||
Attached Files | import_issues.php (22,471 bytes)
<?php # Mantis - a php based bugtracking system # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org # Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net # This program is distributed under the terms and conditions of the GPL # See the README and LICENSE files for details # -------------------------------------------------------- # $Id: import_issues.php 2005/11/04 10:23 gtomlin # -------------------------------------------------------- # # Changes # 03.03.06 / mgfeller (changes marked by @@@ mgf) # ?> <?php require_once( 'core.php' ) ; $t_core_path = config_get( 'core_path' ); require_once( $t_core_path.'custom_field_api.php' ); html_page_top1() ; html_page_top2() ; # get submitted data - input file characteristics. # $f_import_file = gpc_get_string( 'import_file' ); $f_import_file = gpc_get_file( 'import_file' ); echo '<p>' . lang_get( 'importing_from' ) . $f_import_file['name'] . '</p >'; $f_fieldlim = gpc_get_string( 'fieldlim' ); $f_linelim = gpc_get_string( 'linelim' ); $f_client = gpc_get_bool( 'client' ); # get submitted data - target project id. # go no further if current project is "All Projects". $t_project_id = helper_get_current_project(); if ( $t_project_id == ALL_PROJECTS ) { echo '<p>' . lang_get( 'import_reject_all_projects' ) . project_get_name( $t_project_id ) . '.</p>'; html_page_bottom1( __FILE__ ); return; } echo '<p>' . lang_get( 'importing_into_project' ) . project_get_name( $t_project_id ) . '</p>'; # get submitted data - column data sources. $f_reporterx = gpc_get_int( 'reporter' ); $f_const_reporter = gpc_get_int( 'const_reporter', auth_get_current_user_id() ); $f_handlerx = gpc_get_int( 'handler' ); $f_const_handler = gpc_get_int( 'const_handler', 0 ); $f_priorityx = gpc_get_int( 'priority' ); $f_const_priority = gpc_get_int( 'const_priority', config_get( 'default_bug_priority' ) ); $f_severityx = gpc_get_int( 'severity' ); $f_const_severity = gpc_get_int( 'const_severity', config_get( 'default_bug_severity' ) ); $f_reproducibilityx = gpc_get_int( 'reproducibility' ); $f_const_reproducibility = gpc_get_int( 'const_reproducibility', 0 ); $f_statusx = gpc_get_int( 'status' ); $f_const_status = gpc_get_int( 'const_status', config_get( 'bug_submit_status' ) ); $f_resolutionx = gpc_get_int( 'resolution' ); $f_const_resolution = gpc_get_int( 'const_resolution', OPEN ); $f_categoryx = gpc_get_int( 'category' ); $f_const_category = gpc_get_string( 'const_category', '' ); $f_date_submittedx = gpc_get_int( 'date_submitted' ); $f_const_date_submitted = gpc_get_string( 'const_date_submitted', '' ); $f_osx = gpc_get_int( 'os' ); $f_const_os = gpc_get_string( 'const_os' ); $f_os_buildx = gpc_get_int( 'os_build' ); $f_const_os_build = gpc_get_string( 'const_os_build' ); $f_platformx = gpc_get_int( 'platform' ); $f_const_platform = gpc_get_string( 'const_platform' ); $f_versionx = gpc_get_int( 'version' ); $f_const_version = gpc_get_string( 'const_version' ); $f_fixed_in_versionx = gpc_get_int( 'fixed_in_version' ); $f_const_fixed_in_version = gpc_get_string( 'const_fixed_in_version' ); $f_buildx = gpc_get_int( 'build' ); $f_const_build = gpc_get_string( 'const_build' ); $f_view_statex = gpc_get_int( 'view_state' ); $f_const_view_state = gpc_get_int( 'const_view_state', config_get( 'default_bug_view_status' ) ); $f_summaryx = gpc_get_int( 'summary' ); $f_descriptionx = gpc_get_int( 'description' ); $f_const_description = gpc_get_string( 'const_description' ); $f_steps_to_reproducex = gpc_get_int( 'steps_to_reproduce' ); $f_const_steps_to_reproduce = gpc_get_string( 'const_steps_to_reproduce' ); $f_additional_informationx = gpc_get_int( 'additional_information' ); $f_const_additional_information = gpc_get_string( 'const_additional_information' ); # check completeness if ( is_blank( $f_import_file['tmp_name'] ) || ( $f_import_file['size'] == 0 ) || is_blank( $f_fieldlim ) || is_blank( $f_linelim ) ) { trigger_error( ERROR_EMPTY_FIELD, ERROR ); } $t_related_custom_field_ids = custom_field_get_linked_ids( $t_project_id ); foreach( $t_related_custom_field_ids as $t_id ) { $t_def = custom_field_get_definition( $t_id ); if ( ( gpc_get_int( "choice_custom_field_$t_id" ) == IMPORT_USE_CONST_VALUE ) && ( !custom_field_validate( $t_id, gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], $t_def['default_value'] ) ) ) ) { error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) ); trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR ); } } # build column list for import $t_column_array = array(); $t_column_count = 0; if ( $f_reporterx == IMPORT_FROM_FILE ) { $t_column_array[$t_column_count++] = 'reporter'; } if ( $f_handlerx == IMPORT_FROM_FILE ) { $t_column_array[$t_column_count++] = 'handler'; } if ( $f_priorityx == IMPORT_FROM_FILE ) { $t_column_array[$t_column_count++] = 'priority'; } if ( $f_severityx == IMPORT_FROM_FILE ) { $t_column_array[$t_column_count++] = 'severity'; } if ( $f_reproducibilityx == IMPORT_FROM_FILE ) { $t_column_array[$t_column_count++] = 'reproducibility'; } if ( $f_statusx == IMPORT_FROM_FILE ) { $t_column_array[$t_column_count++] = 'status'; } if ( $f_resolutionx == IMPORT_FROM_FILE ) { $t_column_array[$t_column_count++] = 'resolution'; } if ( $f_categoryx == IMPORT_FROM_FILE ) { $t_column_array[$t_column_count++] = 'category'; } if ( $f_date_submittedx == IMPORT_FROM_FILE ) { $t_column_array[$t_column_count++] = 'date_submitted'; } if ( $f_osx == IMPORT_FROM_FILE ) { $t_column_array[$t_column_count++] = 'os'; } if ( $f_os_buildx == IMPORT_FROM_FILE ) { $t_column_array[$t_column_count++] = 'os_build'; } if ( $f_platformx == IMPORT_FROM_FILE ) { $t_column_array[$t_column_count++] = 'platform'; } if ( $f_versionx == IMPORT_FROM_FILE ) { $t_column_array[$t_column_count++] = 'version'; } if ( $f_fixed_in_versionx == IMPORT_FROM_FILE ) { $t_column_array[$t_column_count++] = 'fixed_in_version'; } if ( $f_buildx == IMPORT_FROM_FILE ) { $t_column_array[$t_column_count++] = 'build'; } if ( $f_view_statex == IMPORT_FROM_FILE ) { $t_column_array[$t_column_count++] = 'view_state'; } if ( $f_summaryx == IMPORT_FROM_FILE ) { $t_column_array[$t_column_count++] = 'summary'; } if ( $f_descriptionx == IMPORT_FROM_FILE ) { $t_column_array[$t_column_count++] = 'description'; } if ( $f_steps_to_reproducex == IMPORT_FROM_FILE ) { $t_column_array[$t_column_count++] = 'reproduce'; } if ( $f_additional_informationx == IMPORT_FROM_FILE ) { $t_column_array[$t_column_count++] = 'info'; } foreach( $t_related_custom_field_ids as $t_id ) { if ( gpc_get_int( "choice_custom_field_$t_id" ) == IMPORT_FROM_FILE ) { $t_column_array[$t_column_count++] = "custom_field_$t_id"; } } $t_column_list = "(" . implode ( "," , $t_column_array ) . ")"; echo '<p>' . lang_get( 'importing_columns' ) . $t_column_list . '</p>'; # drop import table if it remains from a previous import attempt # (may wind up with duplicate records otherwise). $t_mantis_import_issues_table = config_get( 'db_table_prefix' ) . '_import_issues' . config_get( 'db_table_suffix' ); $query = 'DROP TABLE IF EXISTS ' . $t_mantis_import_issues_table; db_query( $query ); # create temporary table for uploading data. $query = 'CREATE TABLE ' . $t_mantis_import_issues_table . '(' . 'reporter VARCHAR(32)' . ', handler VARCHAR(32)' . ', priority VARCHAR(32)' . ', severity VARCHAR(32)' . ', reproducibility VARCHAR(32)' . ', status VARCHAR(32)' . ', resolution VARCHAR(32)' . ', category VARCHAR(64)' . ', date_submitted DATETIME' . ', os VARCHAR(32)' . ', os_build VARCHAR(32)' . ', platform VARCHAR(32)' . ', version VARCHAR(64)' . ', fixed_in_version VARCHAR(64)' . ', build VARCHAR(32)' . ', view_state VARCHAR(64)' . ', summary VARCHAR(128)' . ', description TEXT' . ', reproduce TEXT' . ', info TEXT' ; foreach( $t_related_custom_field_ids as $t_id ) { $query .= ", custom_field_$t_id VARCHAR(255)" ; } $query .= ' ) '; db_query( $query ); $c_import_file = db_prepare_string( $f_import_file['tmp_name'] ); $c_fieldlim = db_prepare_string( $f_fieldlim ); if ( $f_linelim == '\r' ) $c_linelim = '\r'; else if ( $f_linelim == '\n' ) $c_linelim = '\n'; else $c_linelim = '\r\n'; # upload data into temporary table. if ( $f_client ) { $query = 'LOAD DATA INFILE '; } else { $query = 'LOAD DATA LOCAL INFILE '; } $query .= '"'; $query .= $c_import_file ; $query .= '"'; $query .= ' REPLACE INTO TABLE ' . $t_mantis_import_issues_table . ' FIELDS TERMINATED BY ' ; $query .= '"'; $query .= $c_fieldlim ; $query .= '"'; $query .= ' LINES TERMINATED BY '; $query .= '"'; $query .= $c_linelim ; $query .= '" '; $query .= $t_column_list ; $query .= ";"; db_query( $query ); # do actual importing here: # for each row in temporary table, # - construct a BugData object # - use bug_create to create a new issue. $t_bug_count = 0; $t_success_count = 0; $t_error_count = 0; $query = 'SELECT * FROM ' . $t_mantis_import_issues_table; $result = db_query( $query ); $num_rows = db_num_rows($result); # @@@ mgf: inserted # print_r($num_rows); # @@@ mgf: inserted to test for ($i=0;$i<$num_rows;$i++) { # @@@ mgf: inserted # while ( $t_row = db_fetch_array( $result ) ) { # @@@ mgf: use $num_files instead of this line and fudge below # @@@ note: the following ugly fudge is present to catch the end of file - gtomlin # if ( in_array( chr( 26 ), $t_row ) ) # @@@ mgf: commented out # break; # @@@ mgf: commented out # echo($i); # @@@ mgf: inserted to test $t_row = db_fetch_array( $result ); # @@@ mgf: inserted # print_r($t_row); # @@@ mgf: inserted to test $t_bug_count++; /* # @@@ mgf: replaced all numerical indices into $t_row by actual keys # @@@ mgf: custom fields must then be treated differently also, see below $t_col = 0; $t_reporter = $t_row[$t_col++]; $t_handler = $t_row[$t_col++]; $t_priority = $t_row[$t_col++]; $t_severity = $t_row[$t_col++]; $t_reproducibility = $t_row[$t_col++]; $t_status = $t_row[$t_col++]; $t_resolution = $t_row[$t_col++]; $t_category = $t_row[$t_col++]; $t_date_submitted = $t_row[$t_col++]; $t_os = $t_row[$t_col++]; $t_os_build = $t_row[$t_col++]; $t_platform = $t_row[$t_col++]; $t_version = $t_row[$t_col++]; $t_fixed_in_version = $t_row[$t_col++]; $t_build = $t_row[$t_col++]; $t_view_state = $t_row[$t_col++]; $t_summary = $t_row[$t_col++]; $t_description = $t_row[$t_col++]; $t_steps_to_reproduce = $t_row[$t_col++]; $t_additional_information = $t_row[$t_col++]; */ $t_reporter = $t_row['reporter']; $t_handler = $t_row['handler']; $t_priority = $t_row['priority']; $t_severity = $t_row['severity']; $t_reproducibility = $t_row['reproducibility']; $t_status = $t_row['status']; $t_resolution = $t_row['resolution']; $t_category = $t_row['category']; $t_date_submitted = $t_row['date_submitted']; $t_os = $t_row['os']; $t_os_build = $t_row['os_build']; $t_platform = $t_row['platform']; $t_version = $t_row['version']; $t_fixed_in_version = $t_row['fixed_in_version']; $t_build = $t_row['build']; $t_view_state = $t_row['view_state']; $t_summary = $t_row['summary']; $t_description = $t_row['description']; $t_steps_to_reproduce = $t_row['reproduce']; $t_additional_information = $t_row['info']; # this number should reflect the number of standard columns, this is used later to calculate # @@@ mgf: no, key is now used # the index of the first custom field. # @@@ mgf: no, key is now used # $t_num_of_columns = $t_col; # @@@ mgf: no, this is not used anymore, see below if ( is_blank( $t_description ) ) { $t_description = $t_summary; } # Fill the fields for uploading # Set up reporter_id (if value is from file must translate from string to id) if ( $f_reporterx == IMPORT_FROM_FILE ) { $t_reporter_id = user_get_id_by_name( $t_reporter ); } else if ( $f_reporterx == IMPORT_USE_CONST_VALUE ) { $t_reporter_id = $f_const_reporter; } else { $t_reporter_id = 1 ; } # Set up handler_id (if value is from file must translate from string to id) if ( $f_handlerx == IMPORT_FROM_FILE ) { $t_handler_id = user_get_id_by_name( $t_handler ); } else if ( $f_handlerx == IMPORT_USE_CONST_VALUE ) { $t_handler_id = $f_const_handler; } else { $t_handler_id = 0 ; } # Set up duplicate_id (hard coded since it's the # ID of another bug, which could be in import stream so we will not know its ID). $t_duplicate_id = 0; # Set up priority (if value is from file must translate from string to id) if ( $f_priorityx == IMPORT_FROM_FILE ) { $t_priority = get_string_to_enum( 'priority', $t_priority ); } else if ( $f_priorityx == IMPORT_USE_CONST_VALUE ) { $t_priority = $f_const_priority; } else { $t_priority = config_get( 'default_bug_priority' ) ; } # Set up severity (if value is from file must translate from string to id) if ( $f_severityx == IMPORT_FROM_FILE ) { $t_severity = get_string_to_enum( 'severity', $t_severity ); } else if ( $f_severityx == IMPORT_USE_CONST_VALUE ) { $t_severity = $f_const_severity; } else { $t_severity = config_get( 'default_bug_severity' ) ; } # Set up reproducibility (if value is from file must translate from string to id) if ( $f_reproducibilityx == IMPORT_FROM_FILE ) { $t_reproducibility = get_string_to_enum( 'reproducibility', $t_reproducibility ); } else if ( $f_reproducibilityx == IMPORT_USE_CONST_VALUE ) { $t_reproducibility = $f_const_reproducibility; } else { $t_reproducibility = 10 ; } # Set up status (if value is from file must translate from string to id) if ( $f_statusx == IMPORT_FROM_FILE ) { $t_status = get_string_to_enum( 'status', $t_status ); } else if ( $f_statusx == IMPORT_USE_CONST_VALUE ) { $t_status = $f_const_status; } else { $t_status = config_get( 'bug_submit_status' ) ; } # Default resolution - bug_create will set value if ( $f_resolutionx == IMPORT_FROM_FILE ) { $t_resolution = get_string_to_enum( 'resolution', $t_resolution ); } else if ( $f_resolutionx == IMPORT_USE_CONST_VALUE ) { $t_resolution = $f_const_resolution; } else { $t_resolution = OPEN ; } # Default projection - bug_create will set value $t_projection = 10 ; # Set up category # @@@ should not really trust value from file here! (gtomlin) if ( $f_categoryx == IMPORT_FROM_FILE ) { # do nothing } else if ( $f_categoryx == IMPORT_USE_CONST_VALUE ) { $t_category = $f_const_category; } else { $t_category = '' ; } # Date fields. Last updated is set to now by bug_create if ( $f_date_submittedx == IMPORT_FROM_FILE ) { # do nothing } else if ( $f_date_submittedx == IMPORT_USE_CONST_VALUE ) { $t_date_submitted = $f_const_date_submitted; } else { $t_date_submitted = '' ; } $t_last_updated = ''; # Default eta - bug_create will set value $t_eta = 10 ; # Set up os if ( $f_osx == IMPORT_FROM_FILE ) { # do nothing } else if ( $f_osx == IMPORT_USE_CONST_VALUE ) { $t_os = $f_const_os; } else { $t_os = '' ; } # Set up os_build if ( $f_os_buildx == IMPORT_FROM_FILE ) { # do nothing } else if ( $f_os_buildx == IMPORT_USE_CONST_VALUE ) { $t_os_build = $f_const_os_build; } else { $t_os_build = ''; } # Set up platform if( $f_platformx == IMPORT_FROM_FILE ) { # do nothing } else if ( $f_platformx == IMPORT_USE_CONST_VALUE ) { $t_platform = $f_const_platform; } else { $t_platform = '' ; } # Set up version (should not really trust value from file here) if ( $f_versionx == IMPORT_FROM_FILE ) { # do nothing } else if ( $f_versionx == IMPORT_USE_CONST_VALUE ) { $t_version = $f_const_version; } else { $t_version = '' ; } # Set up fixed_in_version (should not really trust value from file here) if ( $f_fixed_in_versionx == IMPORT_FROM_FILE ) { # do nothing } else if ( $f_fixed_in_versionx == IMPORT_USE_CONST_VALUE ) { $t_fixed_in_version = $f_const_fixed_in_version; } else { $t_fixed_in_version = '' ; } # Set up build if( $f_buildx == IMPORT_FROM_FILE ) { # do nothing } else if ( $f_buildx == IMPORT_USE_CONST_VALUE ) { $t_build = $f_const_build; } else { $t_build = '' ; } # Set up view state if( $f_view_statex == IMPORT_FROM_FILE ) { $t_view_state = get_string_to_enum( 'view_state', $t_view_state ); } else if ( $f_buildx == IMPORT_USE_CONST_VALUE ) { $t_view_state = $f_const_view_state; } else { $t_view_state = config_get( 'default_bug_view_status' ) ; } # Defaulting sponsorship for now. $t_sponsorship_total = 0; # Set up description if( $f_descriptionx == IMPORT_FROM_FILE ) { # do nothing } else { $t_description = $f_const_description; } # Set up steps to reproduce if( $f_steps_to_reproducex == IMPORT_FROM_FILE ) { # do nothing } else if ( $f_steps_to_reproducex == IMPORT_USE_CONST_VALUE ) { $t_steps_to_reproduce = $f_const_steps_to_reproduce; } else { $t_steps_to_reproduce = ''; } # Set up additional information if( $f_additional_informationx == IMPORT_FROM_FILE ) { # do nothing } else if ( $f_additional_informationx == IMPORT_USE_CONST_VALUE ) { $t_additional_information = $f_const_additional_information; } else { $t_additional_information = '' ; } # Defaulting profile_id for now. $t_profile_id = 0; # Create the bug $t_bug_data = new BugData; $t_bug_data->project_id = $t_project_id; $t_bug_data->reporter_id = $t_reporter_id; $t_bug_data->handler_id = $t_handler_id; $t_bug_data->duplicate_id = $t_duplicate_id; $t_bug_data->priority = $t_priority; $t_bug_data->severity = $t_severity; $t_bug_data->reproducibility = $t_reproducibility; $t_bug_data->status = $t_status; $t_bug_data->resolution = $t_resolution; $t_bug_data->projection = $t_projection; $t_bug_data->category = $t_category; $t_bug_data->date_submitted = $t_date_submitted; $t_bug_data->last_updated = $t_last_updated; $t_bug_data->eta = $t_eta; $t_bug_data->os = $t_os; $t_bug_data->os_build = $t_os_build; $t_bug_data->platform = $t_platform; $t_bug_data->version = $t_version; $t_bug_data->fixed_in_version = $t_fixed_in_version; $t_bug_data->build = $t_build; $t_bug_data->view_state = $t_view_state; $t_bug_data->summary = $t_summary; $t_bug_data->description = $t_description; $t_bug_data->steps_to_reproduce = $t_steps_to_reproduce; $t_bug_data->additional_information = $t_additional_information; $t_bug_data->profile_id = $t_profile_id; $t_bug_data->sponsorship_total = $t_sponsorship_total; $t_bug_id = bug_create($t_bug_data); if ( $t_bug_id ) { $t_error = false; # Setting status if ( $t_bug_data->status != config_get( 'bug_submit_status' ) ) { bug_set_field( $t_bug_id, 'status', $t_bug_data->status ); } # Setting resolution if ( $t_bug_data->resolution != OPEN ) { bug_set_field( $t_bug_id, 'resolution', $t_bug_data->resolution ); } # Setting fixed_in_version if ( $t_bug_data->fixed_in_version != '' ) { bug_set_field( $t_bug_id, 'fixed_in_version', $t_bug_data->fixed_in_version ); } # Setting date fields if ( $t_bug_data->date_submitted != '' ) { bug_set_field( $t_bug_id, 'date_submitted', $t_bug_data->date_submitted ); } # Adding custom fields $t_custom_field_count = 0; foreach( $t_related_custom_field_ids as $t_id ) { $t_custom_field_count++; $t_def = custom_field_get_definition( $t_id ); if ( gpc_get_int( "choice_custom_field_$t_id" ) == IMPORT_FROM_FILE ) { # $t_custom_field_value = $t_row[ $t_num_of_columns - 1 + $t_custom_field_count ]; # @@@ mgf: commented out $t_custom_field_value = $t_row[ "custom_field_$t_id" ]; # @@@ mgf: inserted } else if ( gpc_get_int( "choice_custom_field_$t_id" ) == IMPORT_USE_CONST_VALUE ) { $t_custom_field_value = gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], $t_def['default_value'] ); } else { continue; } # August 2006 - mBernigaud : don't set empty date --> if ( $t_custom_field_value != '') { # August 2006 - mBernigaud : Convert string date to its internal value if ( $t_def['type'] == CUSTOM_FIELD_TYPE_DATE ) { $t_custom_field_value = strtotime( $t_custom_field_value ) ; } if( !custom_field_set_value( $t_id, $t_bug_id, $t_custom_field_value ) ) { echo '<p>' . lang_get( 'import_custom_field_failure' ) . $t_def['name'] . ' : ' . $t_summary . '</p >'; $t_error_count++; $t_error = true; } } } if ( !$t_error ) { echo '<p>' . lang_get( 'import_success' ) . $t_bug_id . ": " . $t_summary . '</p>'; $t_success_count++; } } else { echo '<p>' . lang_get( 'import_failure' ) . $t_summary . '</p>'; $t_error_count++; } } #echo '<p>' . lang_get( 'import_completed' ) . $t_error_count . '</p>'; echo '<p>' . lang_get( 'import_completed_1' ) . $t_success_count . lang_get( 'import_completed_2' ) . $t_error_count . '</p>'; # remove temporary import table $query = 'DROP TABLE IF EXISTS ' . $t_mantis_import_issues_table; db_query( $query ); html_page_bottom1( __FILE__ ); #----------------------- # get_string_to_enum: # arg: enum name, string value # return: enum value #----------------------- function get_string_to_enum( $p_enum_name, $p_value ) { $t_config_var_name = $p_enum_name.'_enum_string'; #$t_config_var_value = config_get( $t_config_var_name ); $t_config_var_value = lang_get( $t_config_var_name ); $t_arr = explode_enum_string( $t_config_var_value ); $t_enum_count = count( $t_arr ); for ( $i = 0; $i < $t_enum_count; $i++ ) { $t_elem = explode_enum_arr( $t_arr[$i] ); if ( $t_elem[1] == $p_value ) { return $t_elem[0]; } } # end for return 0; } ?> strings_german.txt (2,140 bytes)
<?php # Custom strings for german language $s_csv_import_title = "Mantis CSV Import Probleme" ; $s_csv_import_config = "Konfiguration" ; $s_csv_update_config = "Aktualisiere Konfiguration"; # Extensions by u.sommer $s_import_file_format_col_spacer = 'CSV Spalten Trennzeichen'; $s_import_skip_blank_lines = 'leere Zeilen auslassen'; $s_import_skip_blank_columns = 'alle Spalten, die einem leeren Eintrag folgen, auslassen'; # Import issues $s_manage_import_issues_link = 'CSV Datei imporierten'; $s_manage_import_issues = 'CSV Probleme importieren'; $s_import_issues_file = 'Importiere Probleme aus einer CSV Datei'; $s_import_issues_columns = 'Datei Spalten'; $s_import_skip_first_line = 'erste Zeile der Datei auslassen'; $s_import_file_button = 'Importiere Datei'; $s_import_column_number = 'Spalte #%d'; $s_import_result_failure_ct = 'Bei %d Problemen traten Fehler auf'; $s_import_result_import_success_ct = '%d Probleme erfolgreich importiert'; $s_import_result_update_success_ct = '%d Probleme erfolgreich aktualisiert'; $s_import_error_nolines = 'Es muss mindestens eine Zeile zu importieren sein'; $s_import_error_noseparator = 'Jede Zeile muss das Trennzeichen "%s" enthalten'; $s_import_error_manycols = 'Die Datei hat zu viele Spalten'; $s_import_error_col_count = 'Jede Zeile muss die Gleiche Anzahl des Trennzeichens "%s" enthalten'; $s_import_error_file_not_found = 'Datei konnte nicht gefunden werden'; $s_import_error_col_multiple = 'die gleiche Spalte wurde mehr als einmal definiert'; $s_import_error_bug_not_exist = 'Das Problem %d existiert nicht'; $s_import_error_bug_bad_project = 'Das Problem %d ist nicht im aktuellen Projekt enthalten'; $s_import_error = 'Bei der Verarbeitung des Problems "%s" trat ein Fehler auf'; $s_import_error_custom_field = 'Beim Import des benutzerdefinierten Feldes "%s" zu Problem "%s" trat ein Fehler auf'; # Errors $MANTIS_ERROR[ERROR_IMPORT_ALL_PROJECT] = 'Es muss ein Projekt bestimmt werden, um Probleme zu importieren'; $MANTIS_ERROR[ERROR_IMPORT_FILE_FORMAT] = 'Das Dateiformat ist nicht korrekt: %s'; $MANTIS_ERROR[ERROR_IMPORT_FILE_ERROR] = 'Die Datei ist fehlerhaft'; ?> 0001-Utf8-support-and-Real-names.patch (3,220 bytes)
From c5c80b4b9773ff800fbcf1a3603ce849ec650e1c Mon Sep 17 00:00:00 2001 From: Andreas Back <andreas.back@kapero.fi> Date: Sun, 19 Jun 2011 15:08:59 +0300 Subject: [PATCH] Utf8 support and Real names --- pages/import_issues_inc.php | 39 +++++++++++++++++++++++++++++++++++++-- 1 files changed, 37 insertions(+), 2 deletions(-) diff --git a/pages/import_issues_inc.php b/pages/import_issues_inc.php index 8e9640b..db3ef08 100644 --- a/pages/import_issues_inc.php +++ b/pages/import_issues_inc.php @@ -8,6 +8,8 @@ if( $g_project_id == ALL_PROJECTS ) # This identify a custom field $g_custom_field_identifier = 'custom_'; +#Normally we expect the file to be in Latin1 and the database to be in utf-8 +$g_files_is_ISO8859_1 = true; # All column names that can be used with this project $g_all_fields = array(); @@ -104,9 +106,22 @@ function csv_string_unescape( $p_string ) { # -------------------- function read_csv_file( $p_filename ) { + global $g_files_is_ISO8859_1; $t_regexp = '/\G((?:[^"\r\n]+|"[^"]*")+)[\r|\n]*/sm'; $t_file_content = file_get_contents( $p_filename ); + # Do it exist a UTF-8 byte order mark? + $bom = pack("CCC", 0xef, 0xbb, 0xbf); + if (0 == strncmp($t_file_content, $bom, 2)) { + $t_file_content = substr($t_file_content, 3); + $g_files_is_ISO8859_1 = false; + }else{ + $g_files_is_ISO8859_1 = true; + } + + # Need to add a non default module for this so we support both UTF and Latin1 + #$t_file_content = mb_convert_encoding($t_file_content 'UTF-8'); + preg_match_all($t_regexp, $t_file_content, $t_file_rows); return $t_file_rows[1]; } @@ -137,7 +152,13 @@ function category_get_id_by_name_ne( $p_category_name, $p_project_id ) { } function prepare_output( $t_string , $t_encode_only = false ) { - return string_html_specialchars( utf8_encode($t_string) ); + + global $g_files_is_ISO8859_1; + + if($g_files_is_ISO8859_1 == true){ + $t_string = utf8_encode($t_string); + } + return string_html_specialchars( $t_string ); } function get_csv_import_category_id( $t_project_id , $t_category_name ) { @@ -234,6 +255,10 @@ function get_user_column_value( $p_name, $p_row, $p_default ) { return $p_default; } + if( ($t_user_id = user_get_id_by_realname($t_username)) !== false ) { + return $t_user_id; + } + if( ($t_user_id = user_get_id_by_name($t_username)) !== false ) { return $t_user_id; } @@ -253,8 +278,18 @@ function get_user_column_value( $p_name, $p_row, $p_default ) { #----------------------- function get_column_value( $p_name, $p_row, $p_default = '' ) { global $f_columns; + global $g_files_is_ISO8859_1; + $t_column = array_isearch( $p_name, $f_columns ); - return ( ($t_column === false) || (!isset( $p_row[$t_column] )) ) ? $p_default : utf8_encode(trim( $p_row[$t_column] )); + $column_val; + if(( ($t_column === false) || (!isset( $p_row[$t_column] )) )){ + $column_val = $p_default; + } elseif ($g_files_is_ISO8859_1 == true){ + $column_val = utf8_encode(trim( $p_row[$t_column] )); + }else{ + $column_val = trim( $p_row[$t_column] ); + } + return $column_val; } #----------------------- -- 1.7.4.msysgit.0 | ||||
This is something that is an absolute prerequisite for me to migrate to Mantis. There's simply no way I can do so without keeping our existing bug history. I'm interested to see that this worked for 0.19.a2. I had to change it substantially to work with 0.19.0. Right now I'm playing with it to make it a little more flexible. I'll upload it when I'm done. Ultimately I will want to add the capability to import old text as bugnotes as well. |
|
Looks interesting, but it needs some work. It needs to adhere to coding standards and the logic needs to be moved to a core file. Perhaps this feature also needs to be expanded a bit (preview?). Anyone who wants to work on this? P.S. Did the author give permission to include this? |
|
I have almost completed a modified version of this program that will allow almost any field in an issue to be imported or defaulted or set to a constant value, and will submit it when I am done. I've sent a note to the author of the original program asking for his permission to submit it. This is the only issue in the database that I could find that mentions coding standards, so I have to ask: where are the standards documented? Or alternatively, I can submit what I've done and someone can add/change whatever is necessary for conformance. Edit: completed, waiting for original author's permission. |
|
Received a note from Cas Nuy (the original author): "Good news, ofcourse you can. Looking forward in checking it out. Kind regards, At this point, I can either attach the files I have or alter as required to comply with coding standards (which I would need access to). Which would the team prefer? |
|
The coding standards are here: http://www.mantisbt.org/guidelines.php There is also a link to the more general PHP Standards. This is great stuff gtomlin - keep it up! =) |
|
Please look at the coding standards first. Sounds good though! |
|
Note: the link to PHP coding standards on http://www.mantisbt.org/guidelines.php is obsolete. It points to http://utvikler.start.no/code/php_coding_standard.html, which in turn redirects you to http://alltasks.net/code/php_coding_standard.html. This last page says the domain alltasks.net is expired. |
|
Updated version uploaded as mantis_import_issues.zip; I've tested this on 0.19.0 and 0.19.1. Anyone is welcome to use/misuse/abuse or modify it as they see fit. Have fun. (thanks to Cas Nuy for the original idea!) |
|
I moved it from 0.20.0 to 0.19.3, but it's too late for 0.19.2. |
|
Great work on the patch. Had a question: Can this patch can handle importing into existing custom fields? I think that would be helpful if possible, especially when importing from another system. |
|
No it can't as it's presently written. To do this in a generalized fashion would require interrogating the custom field definitions in the database and then constructing the import page on the fly based on what custom fields are defined, and I just didn't have time to do that. For my own needs, if I put more work into this it would be to import external text as bugnotes. |
|
Thanks for the patch... However, I am having some difficulty getting it to work. Thank you, |
|
Try commenting the lines that delete the temporary import table, and use phpmyadmin (or equivalent) to have a look at the data in that table. This should help to narrow down the problem. |
|
Thanks for the info... Actually, I figured it out. I had previously commented out the summary and description while I was debugging and for got to put them back in... my bad. It works great! Thanks again, |
|
I tested gtomlin's contribution (mantis_import_issues.zip) under 0.19.2 it works fine. I have two small issues: Results of investigation for item 2: Set up buildif($f_buildx == IMPORT_FROM_FILE) { $t_build = $a_buildx[$i] ; (replace $a_buildx[$i] to $a_build[$i])
} else if ($f_buildx == IMPORT_USE_CONST_VALUE) { |
|
Sorry for the delay in getting back to this...bogged down with other work. Scipion's suggested fix corrected the problem for the "build" field. and the "fixed in version" field problem has been fixed by using bug_set_field() after bug_create(), since bug_create() does not set fixed_in_version. Before uploading the fixed files, I need some guidance from the team. In 1.0.0a(x), function print_manage_menu() in core/html_api.php tests authority for each menu item before printing a link to it. What authority do you think should be tested for importing issues? |
|
Uploaded new version (mantis_import_issues_v2.zip). Tested on 0.19.0 and 1.0.0a1. Made an "executive decision" that import should require ADMINISTRATOR access. |
|
This issue is marked as a child of 0.20.0, which is obviously never going to be a real release as we're at 1.0.0a[n] now. It's still in feedback status but it's not apparent what that feedback might be. What do we need to do to get this one back on track? |
|
gtomlin, I didn't run the script yet, but I like the idea of a configurable importer.
More to come later. I will need to set it up and do some testing. |
|
will like to confirm the data will be imported to the current project view? |
|
fredckp, issues will be imported into whatever project is the current project when you start the import. If you are not in the desired project, switch before starting the import. |
|
Thanks for the feedback Victor...I'll incorporate the bulk of your suggestions. A few comments:
|
|
There was a discussion about implementing this as an administrator task or as part of the application. I appreciate implementing as part of the application because I will need this feature frequently. We often get Excel Sheets from our customers; it would be nice to import these and this should be done by someone with manager rights. Just my humble opinion on that feature. |
|
There are a couple of issues with this functionality. First of all, it doesn't work on the Safari browser (MAC OSX 10.4). But that might be a Safari thing, it does work with Firefox. The more serious, showstopper bug though: it turns out that for recent versions of MySQL the LOAD DATA LOCAL INFILE was removed because of an apparent "security issue". After hours of searching I finally found the way to re-enable LOAD DATA LOCAL INFILE again. Edit the file core/adodb/drivers/adodb-mysql.inc.php. Now I was finally able to upload the file, but alas, MySQL did not find my uploadfile. So now I'm stuck. Error message: File 'bugs.txt' not found |
|
Hi joostbaaij, Were you able to find a solution to the file not being found? |
|
The only way it is going to work, is upload the file to the server (via ftp/scp etc). It doesn't matter if you choose client/server the importer always looks on the server. sadly enough. |
|
joostbaaij, where exactly the file needs to be uploaded on the server? Directory? |
|
I have put the file on the server, in the same directory as Mantis, but can't get it to recognize the file. I click 'Start Import' and nothing happens, the page doesn't reload or anything. If I switch the path to a local drive 'C:/..' then it responds with the 'Can't find file error'. If you have an example syntax for a server path that you've found works it would help a lot. My next step is to manually import the records into the Mantis_Import table the tool created (using PhpMyAdmin), then comment out the LOAD FILE part of the script, and retry running the tool from that point. Any other ideas? |
|
There's not enough info in these recent posts to enable anyone to help. What is the actual file location? How exactly are you typing it on the import issues page? What platform are you running? What MySQL version? What PHP version? What Mantis version? For LOAD DATA LOCAL security considerations, see: |
|
Hi gtomlin, thank you for offering to help. This is my setup: Local Client Import Error Message: I have never been able to import a file. Not from my local PC or from the server. When trying to load a file from the server the page stays as is after clicking 'start import'. It doesn't refresh or throw an error. Any help would be great, thank you! |
|
I tested both client and server imports successfully and only after doing so I noticed that you are specifying 'C:/Import_Columns_2.csv' but the import is attempting to access 'C:Import_Columns_2.txt'. It looks to me like your system is doing something strange. |
|
Thank you for taking the time to test it. I'll keep digging to see what the problem might be. |
|
Updated version uploaded: mantis_import_issues_v3.zip. Addresses the following items in Victor's note 10322:
As I mentioned in my note 10359, it makes sense for the importer to be a part of the distribution, since it may be necessary to run it after the admin directory has been removed. Accordingly, I haven't done anything to the way the custom_constants_inc.php and constant_strings_inc.php files are updated. BTW, is there a syntax to generate a link to a bugnote (analogous to # and an issue number to generate a link to an issue)? |
|
gtomlin, I've attached version 4 of the patch which includes the following:
I'd recommend the following:
Note: Without changing MySQL settings, I could only get it to import a file from the server that is located in the database directory. |
|
Error generated when importing a server based file on a MySQL 4.1.14-standard installed on Linux: Database query failed. Error received from database was 0001045: Access denied for user 'username'@'localhost' (using password: YES) for the query: LOAD DATA INFILE "./testissues.txt" REPLACE INTO TABLE mantis_import_issues_table FIELDS TERMINATED BY ";" LINES TERMINATED BY "\r\n" (summary,description); Importing the file from the browser machine worked fine. Is there a specific location on the server that the file should be placed? The current situation is:
|
|
I just tested the mantis_import_issues_v4 on Mantis 1.0.0rc3 and the import worked without issue. As a non-programmer I have 2 queries that would really help if anyone had an answer.
|
|
A couple of other comments:
|
|
Victor, when you say that '\' should not be changed to '/' on a Windows client, what platform was MySQL running on? According to the MySQL 5.0 Reference Manual (see http://dev.mysql.com/doc/refman/5.0/en/load-data.html), "Note that Windows pathnames are specified using forward slashes rather than backslashes. If you do use backslashes, you must double them." My tests were done with client and server both on Windows boxes, and my results were:
|
|
I read the / \ comment and I thought I would share my experience. I used mantis_import_issues_v4 on Mantis 1.0.0rc3 on a WinXP machine running MySQL 4.1.11. Importing a cvs file from c:\ and I found it necessary to change the \ to /. If someone could advise me how to import custom fields using this I would really appreciate it. |
|
AG, this is just using bug_create(), which creates an issue without custom fields. To make this importer support custom fields would be a substantial project. |
|
I've attached v5 which includes the following changes:
This will probably break the server-side files. Do we really need to support such case? |
|
I had a look at your v5 files, and the approach should be fine. The important thing is that the facility works for all users in all environments. The user just needs to know where the file needs to be located when he/she starts the process. |
|
Isn't this something that it would be more sensible to use mantisconnect to do? Importing Issues somewhat strikes me as something you'd do from a command line script, rather then a webpage - for example, I did start trying to use a c# client at work, to add issues to mantis based on the output of an xml file.... Personally, I'm thinking this sort of thing is something better done as a contributed script/addon, then as a 'core feature' In terms of a critical review of issues in v5:
|
|
While you were working on bug corrections, I developped the following features required at my work.
Because some fields are set to default by bug_create, function bug_set_field is used to import extra fields (status, resolution, date submitted). A consequence is that the bug history is updated each time such a field is imported. Custom fields API, specially custom_field_set_value, is used to import custom fields values. Unfortunatly, this is based on V3 version and all modifications till V5 have to be merged. Does anyone want to perform this merge? I will attach this version as Mantis_Import_Issue_v3.1. |
|
Sorry, the archive V3.1 is just a copy of V3 :-( Why a reporter can't delete its own attached file in this page? |
|
Thanks jblanchon for your contribution. I uploaded v6 which includes the following:
|
|
I'm trying to import the sample "testissues.txt" file as-is and I get: Somebody (apparently) fixed the script so that you no longer have to modify the path on Windows systems (as i remember in older versions having to switch the slashes). Therefore, if you follow the now-misleading directions and painstakingly change all the backslashes, you will experience app error #11. ...So I adjusted: "custom_strings_inc.php" at line 18: "$s_import_instructions_2 = "2. Specify the input file (Windows users change all \ to / in file name) and its characteristics."; ... replacing this line 18 with: I submit only the "custom_strings_inc.php" file since somebody should verify that the syntax above is not problematic on non-Windows systems (i'm not certain about the '\' and '/' part). Then it could be folded into the main distribution. |
|
First, thanks for the great work! I have applied a few changes to import_issues.php and hope that they are usefull. The reason was that I could not import data, receiving application error 11. Basically, in the section that creates the bug entries from the temporary table, columns are now referenced by key instead of by index number, and the loop has been changed to a for loop. The PHP Version used in my environment is 4.4.2, and Mantis is 0.19.3. I don't know if I should supply a new version or if you, gtomlin, will incorporate my changes. Also, I'm not sure whether my changes will work in other versions of PHP etc. My changes are based on mantis_import_issues_v6.zip. Please let me know how I can best submit my suggestions. |
|
mgfeller, Victor and others have changed this script substantially since I last touched it (which was _v3). I don't presently have any time to work on this, and I wouldn't want everyone else waiting for me because the last note mentioned my user name! |
|
Using version 6! When I try to import a file I get this error message: Does it has to be txt file? I used a csv file. I put my file on the server in the root of my Mantis directory and still I'm getting this error message. What am I doing wrong?? |
|
MPA, try mantis_import_issues_v6.1.zip which incorporates my changes as well as custom_strings_inc.zip submitted by atomoid. michael |
|
I am using 6.1 with mantis 1.0.1. Not sure if that is supposed to be supported or not, but I get the: APPLICATION ERROR 11 No matter what I try when using the import page. I tried importing only the 2 required fields, and setting all the rest to either default or expclitly setting, same error as above. Is there a way to turn on some sort of logging besides "a required field was empty?" Maybe print out the name of the field that was empty? Or maybe that error message is just a red herring. |
|
wade_albright, do you have a custom field that is required when submitting a new issue? |
|
vboctor, no, not that i know of. i'm just using 1.0.1 out of the box. |
|
Using Mantis version 1.0.1 with import v6.1 gives me the following error; With the import file on the server in the Mantis root folder; It seams that I don't have autorisation for de DB. This seems not correct. I'm sure that I'm using the correct name and password. But what about localhost? MySQL is running on the server at my provider. Maybe this has got something to do with it? And maybe someone can attach a demo import file which is working correctly, so I can check/test this out? EDIT: dregad 2011-11-01 break long lines to avoid horizontal scrolling |
|
I'm afraid I have tested mantis_import_issues_v6.1.zip only with Mantis 0.19.3. I hope to use Mantis 1.0.1. soon... and then maybe extend the error messages, if at all possible. The app err 11 usually meant (for me) that the parsing didn't work at all. Are field delimiter and end of line marker ok? Does your data make it into the temporary table (result of LOAD DATA INFILE ...)? |
|
Are field delimiter and end of line marker ok? Does your data make it into the temporary table (result of LOAD DATA INFILE ...)? Yes, It seems that all other variables are ok. And no, the temporary table is not filled. I'm getting very close! Is it possible that someone can sent me a import example file, where every column is used, including which columns i have to set on 'import', 'default' or 'Set all to'? |
|
I tried the 6.1 version on a system where the mysql server runs on a windows machine, and the apache/php runs on a FreeBSD machine. I placed the import file on the windows machine, and checked the 'server based' checkbox. Unchecking the 'server based' check box gave a lot of problems with MySQL rights. I could not figure out how to handle this. |
|
I'm trying to use the 6.1 version on a windows system with easyphp installed. Im having the following error message: Error 401: database query failed. I'm using a very simple file to test the import feature, i tried to manually launch the query "load data infile..." in the temporary table, it worked perfectly. Any idea where the problem comes from? By the way i would need to do the import manually for some reasons, could anyone tell me how to build the queries i will need to do it? |
|
I use the "issue import v6.1" with Mantis V1.0.3. On the mysql server the "local infile" option is enabled. Still I get an error: Database query failed. Error received from database was #1148: The used command is not allowed with this MySQL version for the query: LOAD DATA LOCAL INFILE "/tmp/php20HwUP" REPLACE INTO TABLE mantis_import_issues_table FIELDS TERMINATED BY ";" LINES TERMINATED BY "\r\n" (reporter,summary,description); How can I avoid this and import an issue? |
|
Sorry I don't saw before but 0004220:0010919 solved the problem. |
|
The custom field date type where imported as String. August 2006 - mBernigaud : don't set empty date -->if ( $t_custom_field_value != '') { August 2006 - mBernigaud : Convert string date to its internal value if ( $t_def['type'] == CUSTOM_FIELD_TYPE_DATE ) {$t_custom_field_value = strtotime( $t_custom_field_value ) ; ' . lang_get( 'import_custom_field_failure' ) . $t_def['name'] . ' : $t_error_count++; $t_error = true; } } The v6.1.1 includes this fix |
|
I'm currently (9/12/2006), unable to download the files. They download to a 0k file. Not sure if this has to do with the recent domain change. Also, I'm hoping there are some instructions within the file about the installation and use. If not I plan to write some and will post them if desired by others. |
|
carp3tshark , This probably ocurred when Mantis switched their nameserver or upgraded to 1.1a1 |
|
Hello Where are attached files ? |
|
Since this hasnt been fixed yet, i uploaded the most recent version i had, I titled it "mantis_import_issues_v6.1--reuploaded.zip" since it wouldnt let me upload a duplicate name, anyway there it is... in a pinch you can roll in the 6.1.1 fix noted in the post above: (0013188) mbernigaud |
|
Hello: |
|
I found a problem in the 'mantis_import_issues_v6.1--reuploaded.zip'. It was easy to fix. } else if ( $f_buildx == IMPORT_USE_CONST_VALUE ) { should be } else if ( $f_view_statex == IMPORT_USE_CONST_VALUE ) { |
|
Does anyone have a 1.1.0a2 patch for this feature? Also, will it eventually be easy to use the same php extension to export issues to a file as well? |
|
I've tried a multiplicity of different combinations trying to get the csv importer to work. It appears that it doesn't respect the order of the fields that I put in my csv file, based on what I can see from the error message. Here's my input file (containing 2 lines) which imports data for every single field in the 'import issues' page: "reporter";"handler";"priority";"severity";"reproducibility";"status";"resolution";"category";"date_submitted"; and here are the columns the importer says it's importing: but notice the error message: it's complaining about the last field in the input file, but the data that it says it received for that field is actually from a field in the middle of the line. Would anyone have a sample record that actually works? Please post it here for everyone to see or drop me a line at stewart 'at' midwinter 'dot' ca. thanks so much! EDIT: dregad 2011-11-01 break long lines to avoid horizontal scrolling |
|
BTW, I'm running Mantis 1.06 and mySQL 4.1.20. |
|
midtoad, what happens if you remove double quotation marks for each fields? |
|
removing the double quotations from all fields except those with commas in the text has no impact on the importer. It still appears to process the fields in the wrong order. This is a blocker issue for me. I can't use Mantis if I'm unable to import my existing issues. |
|
I have attached 'mantis_import_issues_v7.zip' which allows you to import 'target version' introduced in 1.1.0. Notes:
Tested on:
-- |
|
I use v6.1 import function and have fixed in it a bug relative to custom fields of type date : their values need to be converted to php internally format by See import_issue.php uploaded 2007-05-21 10:15 (sorry I forgot to suffix it |
|
Hi, I have written a plugin to import/export data from/to Mantis. Import supports only XML format at this time but other formats will be supported soon. |
|
I added a new importer inspired by the one posted by ave. This one allow to import CSV files, where columns are in any order you want. It also can update issues, instead of creating them if you have a bug id column. And finally, it does not use the MySQL load data functionality (which was not working in my firm), but only Mantis PHP functions, and therefore is compatible with any supported database. Hope this can help. |
|
There is an error in the script I uploaded in import_issues.php at line 117. This line should be: |
|
I just tested the Import but the import of custom fields dont work at all All other data is imported correctly. |
|
I found the problem... For my needs I simply added a line Look if this field is set$t_def = custom_field_get_definition( $t_id ); |
|
We should consider re-developing this patch as a plugin for Mantis 1.2.x. I will look into it when I get a chance unless someone else beats me to it. |
|
Is it possible to transform this tool that a note can be imported. Should have a note for this ID exist, a new note added. Greeting |
|
I wanted to write something about the new file csv_import-1.0.1.zip, That is why the note I wrote was posted so often. uso |
|
I have done some little work on the CSV Import plugin. I made changes to CSV Import 1.0 only for my company, I hope it will help somebody, too. But do not treat me if it does not. ;-) (I'm sorry to the developers, my coding style is not what it should be...) uso |
|
Dear Members, I am so confused in choosing the right version of mantis. I need import option in mantis 1.1.6, where the other plugins like myViewIssues,Hierarchy plugins are to be supported by this..... Please do let me know, how to use and which one to use with mantis 1.1.6 to have the option to import in to CSV or XML format. Is there anyway by means of customization, we could use the import/export plugin version 0.0.4 to use with mantis1.1.6 Regards, |
|
I'm also looking for an import excel feature and wondering if 1.1.6 has it.
|
|
Needed to import issues into 1.2 and adjusted this plugin to fit my needs. |
|
Cas will this CSV import work with mantis 1.2.0a3, please let me know. Already i have XML import contributed by you. Now please let me know how to use this CSV import with the XML import. Regards, |
|
The XML is not by me. |
|
Oh yes, Reminder is by you...... |
|
Dear All, I have an issue with XML import; It is working fine in WINDOWS machine, but it throws some error in LINUX machine; Any one faced this issue. Or it would be a file permission in LINUX. Error: Regards, |
|
Dear All, I am facing this issue while trying to import issues using CSV Import: Fatal error: Call to undefined function explode_enum_arr() in C:\Documents and Settings\prabhu_rangan\workspace\mylo\plugins\Csv_import\pages\import_issues.php on line 76 Please anyone let me know what is wrong with this. Also which are the required fields to import CSV issues, to create new issues; like the attribute 'ID' should be specified '0' Regards, |
|
Add the following code @ the end of import_issues_inc.php (before the closing tag): --------------------
Have updated my source also. |
|
I am facing this isssue, do i have to add a function same as to 'explode_enum_arr()' Fatal error: Call to undefined function explode_enum_string() in C:\Documents and Settings\prabhu_rangan\workspace\mylo\plugins\Csv_import\pages\import_issues.php on line 73 |
|
Sorry cas, its my mistake. No issue |
|
I have added a custom_field 'Deadline' and 'Est.' hours to my view issues and while importing issue to CSV, i need to import values to these two fields also, how shall i perform it. In the '$g_all_fields' array i have mentioned my default columns for import, but after importing i could not see the values imported for these two fields. Can you please share your ideas |
|
Custom fields will show up in the list of available fiedls automatically. |
|
it should bring up some error messages if type or content of columns do not match in some cases like invalid values for category you do not get HTML at all in that respect also two feature requests:
apart from that: a real good tool; it makes mantis a lot more usefull than it already is, great work, thanks BTW: does the CSV import has an own web page? maybe this plugin is enough of a project of its own so it should its own tracker |
|
feature request: match automagically columns with same name advantage: you could prepare the import in the application that generates the CSV without matching each column manually during the import even moving issues from one mantis system to another would be very easy that way |
|
Although I started this tool in the past, GTOMLIN took over. I then converted the latest code into a plugin sinci I was excercising plugin development and used 1.2. |
|
Is this patch scheduled to find its way into the next release (1.2.x)? Is it possible to import files via linux shell? I dont want to login as admin to import csv files but would upload it via ftp to mantis temp directory. This file should get imported by a cronjob/shellscribt. |
|
It is not a patch but a plugin and it is available for 1.2 |
|
In this csv import plugin, while importing issues a default category named 'csv_imported' is created and if the category field is given empty or if it is missed out, the default category created is assigned. Instead it would be nice to have a validation if the category field is left empty while importing issues. As for now it looks odd to have a category named 'csv_imported' in the category table as it does not mean anything. Please let me know your suggestions in this. |
|
at the time i've (re)written the plugin for version 1.2.x it was impossible to also it was too much to collect it by the time of the import and then give an error to the importer, because then he/she would have had to fix this by hand. so i've decided to write a fallback to make it possible to import issues without category and collect them under "csv_imported" so the users have a place were they can look for their bugs and assign them correct. best regards |
|
Ya i could understand. As 'Category' is a mandatory field in 1.2.x while creating issues. |
|
I have a big issue, in DueDate Reminder notification: It is working fine in windows; however if set it as a cron job in Liniux machine, it is not working. Also i am not receiving emails. When i checked it, we will be giving a syntax like "/1440 * lynx --dump http://mantis.homepage.com/plugin.php?page=Reminder/bug_reminder_mail.php" and in this "lynx" is a text based browser and I installed it in linux machine, even now i am not receiving any emails. If I execute the cron job, it shows me the "login_page.php" It shows the text content in that page. But the notifications is not coming. Please let me know your thoughts.... |
|
You should really post under the correct issue. This is not about the reminder plugin. |
|
great job for this plugin!!! |
|
Great plugin! But it doesnt work for me. I have a problem with importing a csv. Probably i used a wrong tabledefinition. does it exist a example-csv? |
|
configure your mantis as you want (custom fields, etc.), if you've done this, use native mantis EXport capabilities to then open the csv and see ... . best regards |
|
Uploaded csv_import-1.0a_mantis1.1.tgz. Tested against Mantis 1.1.7 Changes:
Changes were made to csv_import-1.0.tgz which I believe is the last version compatible with Mantis 1.1. |
|
I made a mistake in "csv_import-1.0a_mantis1.1.tgz" so do not download. If somebody can delete, please do so. "csv_import-1.0b_mantis1.1.tgz" is the replacement. |
|
using csv_import-1.0b_mantis1.1.tgz the column detection is case-sensitive, i.e. if you have "id" instead of "ID" no columns will be detected |
|
sorry.. but could someone provide an example csv? thanks.. |
|
I get Issue 0 not found when I try to import. I am using Mantis 1.2.0 on a fresh install. |
|
Hi all, i'm experiencing the same problem posted by Fyb3roptik : csv file correctlyt read and values displayed, however, starting rows importation in to the database, data importing stops immediately displaying following error message : |
|
It is rather confusing, but csv_import-1.0b_mantis1.1 is only for Mantis 1.1.x. You will have to read through all of the comments to determine which versions are compatible with 1.2.x. |
|
So which version is compatible with mantisbt 1.2.0 and which with 1.2.1? I'd like to import about 200 issues from a excel spread sheet. I tried the xml import with no success. Even a reimport (xml export -> xml import) does not work (bug 0010794) and does not support custom fields (bug 0011876). This plugin is my last hope. Or are there other ways (not manually) to import a bulk of issues? |
|
To get csv import to work under 1.2.x, what is the recommended way forward?
|
|
csv_import110.zip is for mantis 1.2.x |
|
Installed csv_import110.zip as plugin in fresh install on Mantis 1.2.0, schema 183 and I'm also getting the error "APPLICATION ERROR #1100 Issue 0 not found" whenever I try to import. My csv file is uploaded, the headers are automatically recognised and the drop-downs set to the corresponding columns but clicking import throws that error. Anyone got any ideas what causes this? |
|
Found that I had version 1.11 on the shelf. |
|
Found a couple of issues with this: The "APPLICATION ERROR #1100 Issue 0 not found" is being triggered on line 261 of import_issues.php - when $t_default->description is used, the BugData class attempts to get the description from the DB but it doesn't have an id, since you're just using it to store default values. Setting a default description around line 220 avoids this issue. However, after doing this I'm getting Fatal error: Call to undefined function bug_create() on line 316 I can also see a call to bug_update() which doesn't exist either. |
|
send me the csv (or attach here) you use and I will fix the issues |
|
attached version 1.1.2 which handles reported issues. |
|
Thanks for your cvs_import. |
|
I found the solution to update the existing issues. |
|
The solution to updating existing issues does not work for me. I export a CSV to one file, make a minor change to the Excel file, export a second CSV file. I import file 1 no problem. Import file 2 and they're all new issues. No changes to the 'id' numbers at all. I'm trying to mess around too see what's what, and running into stuff like the "$t_bug_exists" variable coming back as 0 (my 'id' column is column 0 in the array) which evaluates to false when simply doing a boolean check on the varialbe (it as it does 4 times in the import_issues.php file). So I replaced the "true" condition to be ($t_bug_exists >= 0). No go :( |
|
Unless anyone else has done it, I'm also trying to create a Mapping Save feature. I've created a separate table with 4 columns (map_id, map_prj, map_cvs, map_mantis) to store the field mappings (saved per project). I'm doing this by trying to add a few new methods in the bug_api.php -> BugData Class. I'm sure there's a better place to store these by extending the class in another file, but don't know enough about classes. The new methods I'm creating are; create_map_def(), update_map_def(), and get_map_def(). Hoping that on the mapping page, I can default in any previously selected fields from the dropdowns so that subsequent runs won't require selecting them all again. Any input appreciated :) |
|
Just as an FYI to anyone who didn't already know ('cause it took me awhile to figure it out), this plugin, or at least the latest version of this plugin (112), is not compatible with Mantis 1.0.8, which is the version we're using in our office. I'm not sure which version of Mantis = which version of this plugin, but I do know that much. Just wanted to clear that up for anyone new coming into this. UPDATE:Just came across (or noticed rather): |
|
The plugin system is only available as of version 1.2 so that also indicates the compatibility of the plugin. |
|
I tried this plug-in today, and after a few trials and errors, managed to successfully import a bunch of issues. Many thanks to all those who contributed to this ! If I may make a suggestion, it would be nice if the imported records, would be marked as such in the Issue History, i.e. the Change Column showing the name of the file as in the example below, or something similar. Date Modified Username Field Change |
|
I just noticed that when importing issues into a sub-project which is inheriting Categories from its parent, the plug-in seems unable to match the value in the CSV's column with the ID in mantis_category_table. In Mantis, assume the following categories exist for sub-project: In CSV, I tried the following values in the Category column, without success on import (i.e. always ending up with category = csv_imported) I would expect the plug-in to be able to find a match with a). Note: I have not tested with global categories as I do not use them currently This is on Mantis 1.2.1 by the way. |
|
I tried to import a csv file. Mapped the fields. At the end of the import i get the following error: Invalid e-mail address But there is no email address mapped. |
|
Do you have by chance a mandatory customfield defined that would hold an email address? |
|
Hi, If I have a string like : abcd"fzefz"feizjfz Shouldn't be like that : instead of ? |
|
I added a new version of the plugin (1.1.3). I made two minor changes on it:
Enjoy! |
|
@jojow |
|
1.1.5 version is my contribution. Changelog :
|
|
Wouldn't it be good to have this src in git or svn somewhere? in latest 1.1.5 the version number was 1.1.3 in Csv_import.php |
|
Sorry for the mistake ... Great idea ! |
|
1.2.0 version is my new contribution. Changelog :
|
|
open_basedir restriction in effect. File() is not within the allowed path(s) I am getting an open_basedir restriction. However can not figure out which path should be defined. I define the $HOME of mantis installation, the upload path for the project, the general upload path from the config_inc.php. But none of these are OK. Which path should be added? |
|
Do you have this statement in your config_inc.php: |
|
Hi Cas, not initially. ( Using 1.2.3 ). But even when I put the absolute path in, same error occurs. But l other default stuff of Mantis regarding uploading files is working. To which (sub)directory the functions tempnam() and move_uploaded_file() referring? SYSTEM WARNING: tempnam() [function.tempnam]: open_basedir restriction in effect. File() is not within the allowed path(s): (/home/proguide/:/home/proguide/domains/proguideweb.nl/public_html/abs-pad/upload:/var/www/ctstestdocs:/var/www/testtrackdocs:/var/www/testwiki:/var/www/devtrackdocs:/var/www/devwiki:/var/www/html/jpgraph-3.0.6:/usr/local/lib/php/:/tmp:/usr/share/fonts/) SYSTEM WARNING: move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect. File() is not within the allowed path(s): (/home/proguide/:/home/proguide/domains/proguideweb.nl/public_html/abs-pad/upload:/var/www/ctstestdocs:/var/www/testtrackdocs:/var/www/testwiki:/var/www/devtrackdocs:/var/www/devwiki:/var/www/html/jpgraph-3.0.6:/usr/local/lib/php/:/tmp:/usr/share/fonts/) |
|
Problem is in line 112 from Changed it into Function does not seem to like an empty directory a first parameter. Can someone perhaps comment on that? |
|
How can you import in such a way that the due date is empty? Default the due date is becoming the dat of today with time 00:00, this effectivly means that the item is after import overdue. Importing with column due date set to 1, will import it as due date set to 0, which lead to displaying it as 01/01/1970. The due dat should have the value 1, not 0 ( zero ) to display it as empty. But how can I import the value '1'? |
|
OK, about the due date, also figured that out. I changed the default. $t_default->due_date = date('Y-m-d');
Perhaps it would be nice to make this configurable. Otherise make the default = 1, in my opinion this is more logical than assign a due date which is already overdue. |
|
I created a github repository here : https://github.com/lionheart33806/Csv-import-4-MantisBT |
|
Thanks for that, lionheart33806! |
|
Sounds like a great idea ! This page is totally unmanageable. |
|
I'm agree to use issues section too. |
|
I've just release v1.3.0b on github (if you don't use git, just use "Downloads" button). |
|
Lionheart, could you please comment on my remarks: |
|
Ok, try this source : https://github.com/lionheart33806/Csv-import-4-MantisBT/commit/515e2a299f2a2f55a07b6617e35fd798f3b075c0 (via "Downloads") Please next time use "Issues" section of github |
|
lionheart33806, are you aware that you can have an own project for this plugin at this instance of MantisBT tracker? |
|
Sorry my english is bad, i don't understand you ... |
|
I think the repo is Ok, but a better place for this would be http://git.mantisforge.org I was talking about issue tracking for the plugin. Have a look at the project selection list, where you will find that there are projects for four plugins at the momement. |
|
I get it now, thanks ! I'll look it when I'll have more time ! |
|
THANK for moving you code to http://git.mantisforge.org ! Just discovered your plug-in, need to try it a little more however found one glitch The strings with "Csv" should be "csv" , mind the capital "C" $s_plugin_Csv_import_title = 'Mantis CSV Importer'; When I've added them to custom_strings_inc.php it worked. $s_plugin_csv_import_title = 'Mantis CSV Importer'; |
|
Where under http://git.mantisforge.org have you added this plugin, I tried looking for any plugin with cvs or import there but could not find any. |
|
We use this plugin to export/import issues beween ms project and I need to fix a couple of things from the version found 0004220:0027475 -When exporting CVS the files comes in UTF-8 but import expect e.g Latin1 So the question is these fixed alreday if yes in wich repos as I seams not be be able to find it under http://git.mantisforge.org and if no where should I commit the changes if I fix these? |
|
Nice plugin!
|
|
Get the latest version via Git https://github.com/lionheart33806/Csv-import-4-MantisBT Fork it, change the defects, and ask the maintainer, to do a Pull request to get all fixes into the mater original branch. You could then delete your fork |
|
I was not able to use this plugin. In the readme, the installation part says I suggest to describe the full procedure installation in the readme because it's not easy to find the procedure on the net (essentially found instructions for old mantis versions with pluginmanager that is not compatible with new mantis any more). thank you. |
|
@lionheart: |
|
Is the repos https://github.com/lionheart33806/Csv-import-4-MantisBT alive any more? Created a little patch for the mantis Csv plugin that also can take real names and not only user names and if the file contains a UTF-8 BOM characters it will expect the file to in utf-8 instead of Latin-1 I sent this patch file to lionheart33806 19.6.2011 but it seems to have gone out in space. However I have attached the patch here 0001-Utf8-support-and-Real-names.patch |
|
Hi Guys, I've found this plugin useful and I'm about to use it on our production environment. I have tested it on my local and it seems fine. However, it seems that it doesn't send emails for the uploaded entries. Do you think if it is possible that it can be tweaked to send emails for all the entries imported by this plugin? Just the same as submitting a single entry. |
|
Sending emails for each of the bugs imported through this plugin. Guys, I was able to fix what I need and I just want to share this piece of idea. Actually , this is based on the bug_report.php included in the mantis core package. If you want to have an automated email sent for each of the new bugs imported by this plugin, just add these lines from bug_report.php to import_issue.php included in this plugin just before the # Result comment: helper_call_custom_function( 'issue_create_notify', array( $t_bug_id ) ); Resultif($t_error) { Hope it helps! |
|
I'm (a little) back ! Sorry, I didn't have time to work on the plugin. Let me a bit of time to see your notes. |
|
@Rustan : Interesting idea ! I added it in github "issues". @andy778 : I can't find something (mail or github) about your patch :-/ @sveyret & Georges_ : It's on the way. @cor3huis : Is your plugin folder named "csv_import" ? Try "Csv_import". @AboeBakr : Can you be more "clear" about the 2nd problem ? |
|
@lionheart33806 the patch is also here as an attachment 0001-Utf8-support-and-Real-names.patch |
|
Guys, I encountered issue when trying to test in on our dev environment: SYSTEM WARNING: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/tmp/D9R8wM) is not within the allowed path(s): /data/otherlocation Would you know where can I tweak this location? I think it points by default to /tmp location and it is not where we upload temp files. Your help is very much appreciated. |
|
Look at sys_get_temp_dir() (import_issues_inc.php, import_issues_page_col_set.php and http://php.net/manual/en/function.sys-get-temp-dir.php) |
|
@lionheart33806 - it does not get inside the if condition: import_issues_inc.php: if ( !function_exists('sys_get_temp_dir')) { The output of this one is: $temp: Can i override the system temp directory to point to /data/otherlocation? |
|
regarding the second problem, the problem is: it inserts all the entries up to the row with the missing description. as it is now, you have too look up at which point in the csv it goes amiss, the line at which it is failing is not reported as well, making this even more inconvenient. If the csv would be scanned for these missing fields, you could either import all entries or none. And preferably report to the user at which row/column there is a problem. |
|
@Rustan To work around the problem, assuming you're using apache, you could try to
Maybe the plugin should be improved to check that the path returned by sys_get_temp_dir() is checked for accessibility prior to further processing. |
|
The repository moved to https://github.com/mantisbt-plugins/csv-import @Rustan : please try latest tarball |
|
@dregad - thanks for the info, actually, i understand that it uses the system-defined temp dir but, as i have said, we have a defined temp location to write on such as /data/otherlocation. your suggestion can be done on the server side. can i change the location, say define the /data/otherlocation because i know that where i have write privilege? @lionheart33806 - thanks, ill try that. |
|
My changes only try to prevent the warning message. |
|
@lionheart33806 - thanks, it works. now, when i implemented this into our production, im having problem when i clicked the upload file button, here is the error: APPLICATION ERROR #11 Please use the "Back" button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section. |
|
The CsvImport project is now created in Mantis BT (see the project drop down at top right of this window). If you have any more problems concerning this plug-in, please open a new issue in the corresponding project. |
|
I am trying to import a csv file using the [ Import CSV file ] plugin link in the manage screen. I installed Csv_import.120.tar.gz I get the same error like m.vanhamme above: "Invalid e-mail address". There is no e-mail address in the csv file, in fact there is not even an @ sign. The source is actually a converted xml file from a mantisbt export, only with default fields. Fields as defined in the first line of the csv: ID, Reporter, Assigned To, Priority, Severity, Reproducibility, Product Version, Category, Date Submitted, OS, OS Version, Platform, View Status, Updated, Summary, Status, Resolution, Fixed in Version. (no space after comma in csv, added here for clarity) Suspecting that the converter is choking on certain content I tried to convert only the first 10 records of a 480 record csv file. Same result. Then I tried to import records 10-20. Now I get this: "APPLICATION ERROR #11. A necessary field "Description" was empty. Please recheck your inputs." There is no Description field? I also tried to import the xml using the [ Import issues ] plugin link. This fails showing an empty screen with URL: https://example.com/mantisbt/plugin.php?page=XmlImportExport/import_action - an no data imported. Any help in how to import data from another mantisbt is greatly appreciated, thank you. |
|
Celebrity alert ! We've got the famous creator of TWiki in the house :-) Hi Peter, I can't really help you with your question, hopefully lionheart33806 who maintains the plugin will have an answer for you. Nevertheless, I would suggest to get the latest source for the plug-in from Github [1], instead of the tarballs attached to this issue. Damien |
|
Thank you Damien. I installed the latest Mantis CSV Importer 1.3.0b from github. Now I get this error: APPLICATION WARNING #300: String "plugin_Csv_import_result_nothing_success_ct" not found. When I omit the ID field I get again this error: APPLICATION ERROR 0001200: Invalid e-mail address. Hmm... |
|
Apparently the Description field is mandatory, so I added it. However, import still gave me the e-mail error. I did a brute force import: Wrote a script that uses curl to push the data record by record via http posts. Problem solved (with much more effort than it should be). Thanks for your help anyway! |
|
about 0004220:0030141 , if you try to import handler or reporter who doesn't exist in your mantisbt, then it will try to create it... but function user_create() in user_api.php do "email_ensure_valid(email)" even if email is '', that's an "Invalid e-mail address." so, don't import handler or reporter or write in plugins\csv_import\pages\import_issues_inc.php : Not good for security : password = username... |
|
teste |
|
VeMag is correct. If you are trying to assign an entry to a user with invalid email address, it would give you an error of invalid email address. to fix this, you can disable the checking of valid email addresses of users being assigned to an entry. |
|
hI, FUNNY PROBLEM! |
|
When I import a CSV file everything goes well. Except for the custom fields. Is there something I forgot? I've latest verion 1.3.0b, mantis 1.2.8. |
|
Resolving this issue in favor of the version of the extension hosted in github and has been getting the recent fixes. |
|