View Issue Details

IDProjectCategoryView StatusLast Update
0011009mantisbtsub-projectspublic2009-11-02 13:49
Reporterwatergad Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status newResolutionopen 
Product Version1.2.0rc1 
Summary0011009: Different subproject isolation
Description

Continuing talks about hierarchy support ( http://www.mantisbt.org/bugs/view.php?id=11002 ).

If we have different projects with subprojects, why must they have different names?
It's rather normal situation:

  • Project 1
    .|- Development
    .|- Subpr blablabla
    .
  • Project 2
    .|- Development
    .|- Subpr asdasdasd

Two isolated Development subprojects, why not? It's not the solution - to invent some kind of prefixes-postfixes for similar subprojects. And the whole idea of making UNIQUE index of just a Display name looks not good at all.

Of course we'll have name duplicates when we break links between subprojects and the parent project (if we have zero-level project with the same name). But why not to warn at this stage?
You can't break this link because of the existing same name zero-level project "Development", blablabla. - something like that.

I believe its definitely necessary feature when running multiple independence similar projects in one Mantis instance.

TagsNo tags attached.
Attached Files
mantis_multiproject_project_api.txt (2,673 bytes)   
// Watergad: multiproject instance addition

# check to see if project exists by name
function project_is_name_unique_h( $p_name, $parent_id ) {
	$t_project_table = db_get_table( 'mantis_project_table' );
	$t_mantis_project_hierarchy_table = db_get_table( 'mantis_project_hierarchy_table' );

	$query = "SELECT COUNT(*)
				 FROM $t_project_table p
				LEFT JOIN $t_mantis_project_hierarchy_table h
				ON p.id=h.child_id
				 WHERE name=" . db_param() . "
				 AND (h.parent_id = " . db_param() . " OR
					(h.parent_id IS NULL AND null IS NULL))";
//	$result = db_query_bound( $query, Array( $p_name ) );
	$result = db_query_bound( $query, Array( $p_name, $parent_id ) );

	if( 0 == db_result( $result ) ) {
		return true;
	} else {
		return false;
	}
}

// Watergad: multiproject instance addition

# check to see if project exists by id
# if it doesn't exist then error
#  otherwise let execution continue undisturbed
function project_ensure_name_unique_h( $p_name, $parent_id ) {
	if( !project_is_name_unique_h( $p_name, $parent_id ) ) {
		trigger_error( ERROR_PROJECT_NAME_NOT_UNIQUE, ERROR );
	}
}

// Watergad: multiproject instance addition
# Create a new project
function project_create_h( $p_name, $parent_id, $p_description, $p_status, $p_view_state = VS_PUBLIC, $p_file_path = '', $p_enabled = true, $p_inherit_global = true ) {

// Watergad: parent_id set with nvl of '0' so returning it to the null value if necessary. Stupid hard-coded tweak.
	if( $parent_id == 0 ) $parent_id = null;

	$c_enabled = db_prepare_bool( $p_enabled );
	$c_inherit_global = db_prepare_bool( $p_inherit_global );

	if( is_blank( $p_name ) ) {
		trigger_error( ERROR_PROJECT_NAME_INVALID, ERROR );
	}

//	project_ensure_name_unique( $p_name );
// Watergad: we use our multiproject analog here
	project_ensure_name_unique_h( $p_name, $parent_id );

	if( !is_blank( $p_file_path ) ) {
		# Make sure file path has trailing slash
		$p_file_path = terminate_directory_path( $p_file_path );
		file_ensure_valid_upload_path( $p_file_path );
	}

	$t_project_table = db_get_table( 'mantis_project_table' );

	$query = "INSERT INTO $t_project_table
					( name, status, enabled, view_state, file_path, description, inherit_global )
				  VALUES
					( " . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ')';

	db_query_bound( $query, Array( $p_name, (int) $p_status, $c_enabled, (int) $p_view_state, $p_file_path, $p_description, $c_inherit_global ) );

	# return the id of the new project
	return db_insert_id( $t_project_table );
}

Activities

watergad

watergad

2009-10-06 16:15

reporter   ~0023087

Last edited: 2009-10-06 16:22

I've added tweaked functions from project_api to create same name projects.
Replacements of the project creation, and project duplicate name checks. Tweaked function checks if there are same name project ONLY within the same level (no name duplicates for one parent_id).

Have to change mantis_project_table index for name from UNIQUE to INDEX.
Then change manage_proj_create.php:
// $t_project_id = project_create( strip_tags( $f_name ), $f_description, $f_status, $f_view_state, $f_file_path, true, $f_inherit_global );
// Watergad: we use multiproject analog here
$t_project_id = project_create_h( strip_tags( $f_name ), $f_parent_id, $f_description, $f_status, $f_view_state, $f_file_path, true, $f_inherit_global );

Please let us know if it's too bad idea and many problems will appear because of non-UNIQUE index.

But the solution of some kind is urgent for scalability. I'm quite confused how to make a good multiproject Mantis now. Can I go the described way?

watergad

watergad

2009-11-02 13:49

reporter   ~0023546

Seems to be related to 0008709 0006227 0008848