View Issue Details

IDProjectCategoryView StatusLast Update
0006407mantisbtfeaturepublic2012-01-04 07:36
Reporterzimbop Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status acknowledgedResolutionopen 
Product Versionnone 
Summary0006407: Project Templates
Description

We're using Mantis to track commissions and contributions to a monthly magazine. In effect every month we start a new project which represents a new issue of the magazine, and into that project we have to load the same custom fields and other things each time.

It would be far easier to have a "Copy another projects settings" button or option. That would enable us to set up one project (let's call it "MasterTemplate") in which we define all the settings. When a new project is created, during creation we could have it copy all the settings from the template, or after it's created we could "copy settings from another project".

As it is at present, Mantis seems to be set up for long term projects, this feature enhancement suggestion would greatly help those who want to use it for frequent new projects, or very similar projects that run concurrently. We often have 2 magazines on the go at once, and occasionally a "special issue" (maybe a summer special) as well. Either way we're always tracking similar stuff that requires the same custom fields etc.

Tagsproject_management

Relationships

has duplicate 0006878 closedvboctor Create a project template management 
child of 0004181 closed Features in Mantis 1.1 release 

Activities

ryandesign

ryandesign

2005-11-26 19:14

reporter   ~0011657

As a web design company, we also often create new projects and also want our complement of custom fields in each one.

zimbop

zimbop

2005-11-30 10:53

reporter   ~0011673

Just to refine this idea, I think the best way of doing it would be something that looks like this:

Copy these settings:

Categories [ ]
Versions [ ]
Users [ ]
Custom Fields [ ]

Copy from which project [Drop down list]

Ideally this option would appear in both CREATE NEW PROJECT and EDIT PROJECT.

2005-12-22 08:18

 

clone-project.diff (4,408 bytes)   
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 <dma@zuehlke.com>


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' ) );
  		}
  		?>
  	</td>
clone-project.diff (4,408 bytes)   

2005-12-22 08:21

 

manage_proj_clone.php.txt (1,233 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: manage_proj_clone.php   		   dma@zuehlke.com
	# --------------------------------------------------------
?>
<?php
	require_once( 'core.php' );

	$t_core_path = config_get( 'core_path' );

	require_once( $t_core_path.'project_hierarchy_api.php' );
?>
<?php
	access_ensure_global_level( config_get( 'create_project_threshold' ) );

	$f_name 		= gpc_get_string( 'name' );
	$f_other_project_id 	= gpc_get_string( 'other_project_id' );

	project_clone( $f_name, $f_other_project_id);

	$t_redirect_url = 'manage_proj_page.php';
	html_page_top1();
	html_meta_redirect( $t_redirect_url );
	html_page_top2();
?>

<br />
<div align="center">
<?php
	echo lang_get( 'operation_successful' ) . '<br />';

	print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
?>
</div>

<?php html_page_bottom1( __FILE__ ) ?>
manage_proj_clone.php.txt (1,233 bytes)   

2005-12-22 08:21

 

manage_proj_clone_page.php.txt (1,790 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: manage_proj_clone_page              dma@zuehlke.com
	# --------------------------------------------------------
?>
<?php require_once( 'core.php' ) ?>
<?php
	access_ensure_global_level( config_get( 'create_project_threshold' ) );
?>
<?php html_page_top1() ?>
<?php html_page_top2() ?>

<?php print_manage_menu( 'manage_proj_create_page.php' ) ?>

<?php
	$f_parent_id = gpc_get( 'parent_id', null );
?>

<br />
<div align="center">
<form method="get" action="manage_proj_clone.php">

<table class="width75" cellspacing="1">
<tr>
<td class="form-title" colspan="2">
		<?php
				echo lang_get( 'clone_project_title' );
		?>
	</td>
</tr>
<tr class="row-1">
	<td class="category" width="25%">
		<span class="required">*</span><?php echo lang_get( 'clone_project_new' )?>
	</td>
	<td width="75%">
		<input type="text" name="name" size="64" maxlength="128" />
	</td>
</tr>
<tr class="row-2">
	<td class="category">
		<?php echo lang_get( 'clone_project_old' ) ?>
	</td>
	<td class="left">
	    <select name="other_project_id">
	        <?php print_project_option_list( null, false, $f_project_id ); ?>
	    </select>
	</td>
</tr>
<tr>
	<td class="center" colspan="2">
		<input type="submit" class="button" value="<?php echo lang_get( 'clone_project_link' ) ?>" />
	</td>
</tr>
</table>
</form>
</div>

<?php html_page_bottom1( __FILE__ ) ?>
manage_proj_clone_page.php.txt (1,790 bytes)   
dma

dma

2005-12-22 08:28

reporter   ~0011831

Just uploaded the solution (see the 3 attached files):

  • two new web pages:
    manage_proj_clone.php
    manage_proj_clone_page.php

  • a patch that modifies 3 existing files:
    lang/strings_english.txt (adds 4 new string variables)
    core/project_api.php (adds function project_clone)
    manage_proj_page.php (adds a button "Clone Project")

tandler

tandler

2008-02-16 16:15

reporter   ~0017068

Has dup 0006878?

We also have these frequent projects and as we're using mantis heavily for our SW development, it would be nice to use mantis for these projects as well.

As these projects all have the same or similar structure, it would be important to be able to also copy all issues defined by the template.

In fact, in this case it would be sufficient to be able to deep-copy an issues together with all child issues.

And, deadlines (0008112) would also be important, of course. In this case, the deadlines need to be adapted when copying to the new start date of the project -- how ever this would be modeled in mantis.

vboctor

vboctor

2008-02-17 01:16

manager   ~0017087

@dma, your attachments seems to have been lost. Do you still have them? If so, please upload.

At the moment (as per Mantis 1.1.1), we support copy the following attributes from one project to another:

  1. Categories
  2. Versions
  3. Custom fields.
  4. Users

We don't support copying the following:

  1. Sub-projects.
  2. Issues.

I wonder if there is an added value for a "clone" function, compared to user creating a new project, then explicitly copying each of the above entities. This provides the flexibility where the user decides what to clone and what not to clone.

If we decide to copy issues, who should be the reporter of such issues? Is it the reporter of the original issue (who may or may not have access to the new project?) or is it the person who decided to clone the issues? I can see pros and cons for each.

Issue History

Date Modified Username Field Change
2005-11-15 23:34 zimbop New Issue
2005-11-15 23:42 zimbop Sponsorship Added zimbop: US$ 25
2005-11-15 23:42 zimbop Sponsorship Total 0 => 25
2005-11-26 19:14 ryandesign Note Added: 0011657
2005-11-30 10:53 zimbop Note Added: 0011673
2005-12-22 08:18 dma File Added: clone-project.diff
2005-12-22 08:21 dma File Added: manage_proj_clone.php.txt
2005-12-22 08:21 dma File Added: manage_proj_clone_page.php.txt
2005-12-22 08:28 dma Note Added: 0011831
2005-12-22 12:10 jlatour Status new => acknowledged
2005-12-22 12:15 jlatour Relationship added child of 0004181
2008-02-16 16:10 tandler Tag Attached: project_management
2008-02-16 16:15 tandler Note Added: 0017068
2008-02-16 18:55 vboctor Relationship added has duplicate 0006878
2008-02-17 01:16 vboctor Note Added: 0017087