View Issue Details

IDProjectCategoryView StatusLast Update
0012164mantisbtadministrationpublic2010-07-13 07:18
Reporterwatergad Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status newResolutionopen 
Summary0012164: List all projects in the NOT ASSIGNED option list
Description

There is "NOT Assigned" project list on the manage_user_edit_page.php page.
If you assign any project to user, it will disappear from list.
So it becames a really mess of projects.

Why not to show all the projects with "disabled" attribute of already assigned projects?

Additional Information

I tweaked it such way ( print_api, print_project_user_list_option_list2 function):


$t_mantis_project_user_list_table = db_get_table( 'project_user_list' );
$t_mantis_project_table = db_get_table( 'project' );
// Watergad: project tree instead of just list
$t_mantis_project_hierarchy_table = db_get_table( 'project_hierarchy' );

$c_user_id = db_prepare_int( $p_user_id );

$res_p = Array();

// get all projects joined with user access, if not assigned - it would be NULL
$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";

$result = db_query_bound( $query, Array( $c_user_id, true ) );
$p_count = db_num_rows( $result );

for( $i = 0;$i < $p_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']) );
}

// silly recursion

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("&nbsp;",$lev).str_repeat("&raquo;",$lev).$pr['name']."</option>";
        recprj( $prj, $pr['id'], $lev+1 );
    }       
}

}

TagsNo tags attached.

Activities

There are no notes attached to this issue.