|
|
We may try to use this solution:
[code]
function project_get_main_parent_project( $p_project_id )
{
$c_project_id = (int) $p_project_id;
$t_project_table = db_get_table( 'mantis_project_table' );
$t_hierarchy_table = db_get_table( 'mantis_project_hierarchy_table' );
for($i=0;$i<100;$i++){ // there must be while(1) but prevent infinite loops. Lets say 100 is the smth like MAX_LEV_LIMIT here.
$query = "SELECT parent_id
FROM $t_hierarchy_table
WHERE child_id=" . db_param();
// we will go up till we find the root
$result = db_query_bound( $query, Array( $c_project_id ) );
$row = db_fetch_array( $result );
if( 0 == db_num_rows( $result ) ) { // Its the root project so lets get it
$query = "SELECT
FROM $t_project_table
WHERE id=" . db_param();
$result = db_query_bound( $query, Array( $c_project_id ) );
$row = db_fetch_array( $result );
// we have done so END LOOP;
break;
} else {
$c_project_id = (int) $row['parent_id']; // not the root project, lets try to get upper level
}
}
return $row; // returning from projects table for the root project
}
[/code]
The drawback is the queries count - one query for one project level + one final query.
Then, you may use the code above in email_api:
add to email_build_visible_bug_data():
[code]
$t_main_project_name = project_get_main_parent_project( $t_project_id );
$t_main_project_name = $t_main_project_name['name'];
$t_bug_data['main_project_name'] = $t_main_project_name;
[/code]
add to email_format_bug_message() somewhere:
[code]
$t_message .= $p_visible_bug_data['main_project_name'] . " \n" ;
[/code]
and/or change in email_format_bug_message():
instead of
[code]
$t_message .= email_format_attribute( $p_visible_bug_data, 'email_project' );
[/code]
do this:
[code]
$t_message .= email_format_attribute( Array('email_project' => $p_visible_bug_data['main_project_name'] . ' / ' . $p_visible_bug_data['email_project'],'email_project'), 'email_project' );
// stupid tweak but no need to edit langs
[/code]
DO NOTE that this solution has the possible lack of security: if we don't give access to parent projects to user he'll see their names anyway.
But I don't assign users to projects that way so I don't care (: |