View Issue Details

IDProjectCategoryView StatusLast Update
0011055mantisbtemailpublic2009-10-19 13:20
Reporterwatergad Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status newResolutionopen 
Product Version1.2.0rc2 
Summary0011055: Main parent project output
Description

When Mantis has many different similar projects users can't determine by email what main project is described.
E.g. you have

  • Big bank Inc ` Main account department
  • SlowFood cafe
    ` Account department

User has email with "Project: Account department" and cant understand is it "Big bank Inc" or "SlowFood cafe" because he doesn't remember exactly how are they named.

Steps To Reproduce

Continuing multiproject idea
0011002
and
0011009

TagsNo tags attached.

Activities

watergad

watergad

2009-10-19 06:27

reporter   ~0023235

Sorry, filled "Steps To Reproduce" instead of "Additional Information"

watergad

watergad

2009-10-19 13:20

reporter   ~0023246

Last edited: 2009-10-19 13:21

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 (: