View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0011002 | mantisbt | administration | public | 2009-10-05 13:13 | 2009-10-05 15:55 |
| Reporter | watergad | Assigned To | |||
| Priority | normal | Severity | feature | Reproducibility | N/A |
| Status | new | Resolution | open | ||
| Summary | 0011002: Project hierarchy support in the user administration page | ||||
| Description | If you manage many projects within one mantis instance, assigning projects to users will become quite difficult. Especially with similar subproject names. Definitely usefull feature is to support project hierarchy here. | ||||
| Tags | No tags attached. | ||||
| Attached Files | print_project_user_list_option_list2.txt (1,658 bytes)
function print_project_user_list_option_list2( $p_user_id ) {
$t_mantis_project_user_list_table = db_get_table( 'mantis_project_user_list_table' );
$t_mantis_project_table = db_get_table( 'mantis_project_table' );
$t_mantis_project_hierarchy_table = db_get_table( 'mantis_project_hierarchy_table' );
$c_user_id = db_prepare_int( $p_user_id );
$res_p = Array();
$query = "SELECT DISTINCT p.id, p.name, IF(h.parent_id IS NULL, 0,h.parent_id) as parent_id, u.user_id
FROM $t_mantis_project_table p
LEFT JOIN $t_mantis_project_user_list_table u
ON p.id=u.project_id AND u.user_id=" . db_param() . "
LEFT JOIN $t_mantis_project_hierarchy_table h
ON p.id=h.child_id
WHERE p.enabled = " . db_param() . "
ORDER BY p.name";
// AND u.user_id IS NULL
$result = db_query_bound( $query, Array( $c_user_id, true ) );
$category_count = db_num_rows( $result );
for( $i = 0;$i < $category_count;$i++ ) {
$row = db_fetch_array( $result );
$t_project_name = string_attribute( $row['name'] );
$t_user_id = $row['id'];
$t_tmp = string_attribute( $row['parent_id']);
$res_p[$i] = Array( 'id' => $t_user_id, 'name' => $t_project_name, 'parent_id' => $t_tmp, 'user_id' => string_attribute( $row['user_id']) );
}
recprj( $res_p, 0, 0 );
}
function recprj( $prj, $id, $lev = 0 )
{
foreach($prj as $pr)
{
if( $pr['parent_id'] == $id ){
if (strlen($pr['user_id'])==0) $dis = ''; else $dis = ' disabled';
echo "<option".$dis." value=\"".$pr['id']."\">".str_repeat(" ",$lev).str_repeat("»",$lev).$pr['name']."</option>";
recprj( $prj, $pr['id'], $lev+1 );
}
}
} print_project_user_list.txt (3,290 bytes)
function print_project_user_list( $p_user_id, $p_include_remove_link = true ) {
$t_mantis_project_user_list_table = db_get_table( 'mantis_project_user_list_table' );
$t_mantis_project_table = db_get_table( 'mantis_project_table' );
$t_mantis_project_hierarchy_table = db_get_table( 'mantis_project_hierarchy_table' );
$res_p = Array();
$c_user_id = db_prepare_int( $p_user_id );
/*
$query = "SELECT DISTINCT p.id, p.name, p.view_state, u.access_level
FROM $t_mantis_project_table p
LEFT JOIN $t_mantis_project_user_list_table u
ON p.id=u.project_id
WHERE p.enabled = '1' AND
u.user_id=" . db_param() . "
ORDER BY p.name";
*/
$query = "SELECT DISTINCT p.id, p.name, p.view_state, u.access_level,
IF(h.parent_id IS NULL, 0,h.parent_id) as parent_id, u.user_id
FROM $t_mantis_project_table p
LEFT JOIN $t_mantis_project_user_list_table u
ON p.id=u.project_id AND u.user_id=" . db_param() . "
LEFT JOIN $t_mantis_project_hierarchy_table h
ON p.id=h.child_id
WHERE p.enabled = '1'
ORDER BY p.name";
// $result = db_query_bound( $query, Array( $c_user_id ) );
$result = db_query_bound( $query, Array( $c_user_id,$c_user_id ) );
$category_count = db_num_rows( $result );
for( $i = 0;$i < $category_count;$i++ ) {
$row = db_fetch_array( $result );
$t_project_id = $row['id'];
$t_project_name = $row['name'];
$t_view_state = $row['view_state'];
$t_access_level = $row['access_level'];
if(is_null($t_access_level))
$t_access_level = '-';
else
$t_access_level = get_enum_element( 'access_levels', $t_access_level );
// $t_access_level = get_enum_element( 'access_levels', $t_access_level );
$t_view_state = get_enum_element( 'project_view_state', $t_view_state );
$t_hierarchy = $row['parent_id'];
$t_userid = $row['user_id'];
$res_p[$i] = Array('id'=>$t_project_id,'name'=>$t_project_name,'view_state'=>$t_view_state,
'access_level'=>$t_access_level,'project_view_state'=>$t_view_state,'parent_id'=>$t_hierarchy,'user_id'=>$t_userid);
/*
echo $t_project_name . ' [' . $t_access_level . '] (' . $t_view_state . ')';
if( $p_include_remove_link && access_has_project_level( config_get( 'project_user_threshold' ), $t_project_id ) ) {
html_button( 'manage_user_proj_delete.php', lang_get( 'remove_link' ), array( 'project_id' => $t_project_id, 'user_id' => $p_user_id ) );
}
echo '<br />';
*/
}
recprj2( $res_p, 0, 0, $p_user_id, $p_include_remove_link );
}
function recprj2( $prj, $id, $lev = 0, $user, $p_include_remove_link )
{
foreach($prj as $pr)
{
if( $pr['parent_id'] == $id ){
if( $lev == 0 ) echo "<strong><u>";
echo str_repeat(" ",$lev).str_repeat("»",$lev).$pr['name']. ' [' . $pr['access_level'] . '] (' . $pr['view_state'] . ')';
if( !is_null($pr['user_id']) && $p_include_remove_link && access_has_project_level( config_get( 'project_user_threshold' ), $pr['id'] ) ) {
html_button( 'manage_user_proj_delete.php', lang_get( 'remove_link' ), array( 'project_id' => $pr['id'], 'user_id' => $user ) );
}
if( $lev == 0 ) echo "</u></strong>";
echo '<br />';
recprj2( $prj, $pr['id'], $lev+1, $user, $p_include_remove_link );
}
}
}
| ||||
|
I forgot to say: I'm talking about manage_user_edit_page.php page. PNG attachment: I suppose something like that is acceptable The same will be useful for the "Assigned projects" enumeration (the previous block). |
|
|
Because I'm stained with this code anyway, attaching the same "temporary solution" for the print_project_user_list function of the print_api.php (assigned projects output) - also some horrible recursive code (: Of course, both function edits got security hits (whole projects list is visible when assigning to user). P.S. And print_project_user_list() modified this way misleading when just viewing user's projects. |
|