This patch adds the feature "Clone Project". It consists of: - two new web pages: - manage_proj_clone_page.php : page where name of new project and project to be cloned is entered - manage_proj_clone.php : page that executes the cloning and redirects to manage_proj_page.php - the modification of 3 files - manage_project_page.php : added button "Clone Project" - core/project_api.php : added new API function project_clone - lang/strings_english.txt : added 4 new string variables The patch below applies to mantis 1.0.0rc4, but should be applicable to 1.0.0rc5 or cvs head as well. -Mark Dettinger diff -r -c mantis-1.0.0rc4/core/project_api.php mantis-1.0.0dma/core/project_api.php *** mantis-1.0.0rc4/core/project_api.php Tue Jun 28 22:22:54 2005 --- mantis-1.0.0dma/core/project_api.php Thu Dec 22 13:26:38 2005 *************** *** 234,239 **** --- 234,296 ---- } # -------------------- + # Clone a project + # Parameters: name of new project, id of the project to be cloned + # + function project_clone( $p_name, $p_project_id) { + if ( is_blank( $p_name ) ) { + trigger_error( ERROR_PROJECT_NAME_INVALID, ERROR ); + } + project_ensure_name_unique( $p_name ); + + $t_project = project_get_row( $p_project_id ); + $t_project_table = config_get( 'mantis_project_table' ); + $c_name = db_prepare_string( $p_name ); + $c_status = $t_project['status']; + $c_enabled = $t_project['enabled']; + $c_view_state = $t_project['view_state']; + $c_file_path = $t_project['file_path']; + $c_description = $t_project['description']; + + $query = "INSERT INTO $t_project_table + ( name, status, enabled, view_state, file_path, description ) + VALUES + ('$c_name', '$c_status', '$c_enabled', + '$c_view_state', '$c_file_path', '$c_description')"; + db_query( $query ); + + $t_new_project_id = db_insert_id($t_project_table); + + # copy users + project_copy_users( $t_new_project_id, $p_project_id ); + + # add categories + $rows = category_get_all_rows( $p_project_id ); + foreach ( $rows as $row ) { + $t_category = $row['category']; + category_add( $t_new_project_id, $t_category ); + } + + # add versions + $rows = version_get_all_rows( $p_project_id); + foreach ( $rows as $row ) { + $t_version = $row['version']; + version_add( $t_new_project_id, $t_version); + } + + # link custom fields + $t_custom_field_ids = custom_field_get_linked_ids( $p_project_id); + foreach ( $t_custom_field_ids as $t_custom_field_id ) { + custom_field_link( $t_custom_field_id, $t_new_project_id); + $t_sequence = custom_field_get_sequence( $t_custom_field_id, $p_project_id ); + custom_field_set_sequence( $t_custom_field_id, $t_new_project_id, $t_sequence); + } + + # return the id of the new project + return $t_new_project_id; + } + + # -------------------- # Delete a project function project_delete( $p_project_id ) { $t_email_notifications = config_get( 'enable_email_notification' ); diff -r -c mantis-1.0.0rc4/lang/strings_english.txt mantis-1.0.0dma/lang/strings_english.txt *** mantis-1.0.0rc4/lang/strings_english.txt Sun Aug 7 16:42:04 2005 --- mantis-1.0.0dma/lang/strings_english.txt Wed Dec 21 16:52:03 2005 *************** *** 98,103 **** --- 98,107 ---- $s_make_public = 'Make Public'; $s_create_new_project_link = 'Create New Project'; + $s_clone_project_link = 'Clone Project'; + $s_clone_project_title = 'Clone Project'; + $s_clone_project_new = 'New Project'; + $s_clone_project_old = 'Clone of'; $s_login_link = 'Login'; Only in mantis-1.0.0dma: manage_proj_clone.php Only in mantis-1.0.0dma: manage_proj_clone_page.php diff -r -c mantis-1.0.0rc4/manage_proj_page.php mantis-1.0.0dma/manage_proj_page.php *** mantis-1.0.0rc4/manage_proj_page.php Mon May 16 15:56:06 2005 --- mantis-1.0.0dma/manage_proj_page.php Wed Dec 21 16:55:01 2005 *************** *** 43,48 **** --- 43,49 ---- # Check the user's global access level before allowing project creation if ( access_has_global_level ( config_get( 'create_project_threshold' ) ) ) { print_button( 'manage_proj_create_page.php', lang_get( 'create_new_project_link' ) ); + print_button( 'manage_proj_clone_page.php', lang_get( 'clone_project_link' ) ); } ?>