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