View Issue Details

IDProjectCategoryView StatusLast Update
0009586mantisbtsub-projectspublic2019-03-23 14:12
Reporterchiky Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
Status newResolutionopen 
Summary0009586: Impossible to differentiate between two sub projects of different project
Description

When you add an user, you had to select the project he would work with, but in the case you got to big projects that had subprojects that share names.. in the section: Add user to project in the list Unassigned Projects, there is no way to know witch one is the one you need.

It is possible to show this list in the same way of the selection combo? so you can differentiate the projects and their subprojects?

TagsNo tags attached.

Relationships

has duplicate 0025525 closedcproensa Creating a User and Assign to Projects with Subprojets is very difficult 
has duplicate 0012724 closedcproensa The sub-subprojects are listed out of the tree on the top select list. Hard to see. 

Activities

kivio.wanderley

kivio.wanderley

2011-01-26 13:39

reporter   ~0028097

I created this function on "print_api.php":

--------------------

# return "TRUE" instead of "selected"
# used by the function "print_project_option_list2()" and "print_subproject_option_list2()"
function check_selected2( $p_var, $p_val=true ) {
    if ( is_array( $p_var ) ) {
        foreach( $p_var as $p_this_var ) {
            if ( $p_this_var == $p_val ) {
                return true;
            }
        }
    } else {
        if ( $p_var == $p_val ) {
            return true;
        }
    }
}

# --------------------
# modified function "print_project_option_list()"
function print_project_option_list2( $p_project_id = null, $p_filter_project_id = null ) {
    project_cache_all();
    $t_project_ids = current_user_get_accessible_projects();
    $t_project_count = count( $t_project_ids );
    for ($i=0;$i<$t_project_count;$i++) {
        $t_id = $t_project_ids[$i];
        if ( $t_id != $p_filter_project_id ) {
            if( check_selected2( $p_project_id, $t_id ) ) {
                PRINT "<option value=\"$t_id\"";
                PRINT '>' . string_display( project_get_field( $t_id, 'name' ) ) . '</option>' . "\n";
            }
            else { # (kivio 29.10.10) Projects that user is assigned shown in color gray
                //PRINT "<option value=\"$t_id\" style='color:gray'";//" disabled='disabled'"
                //PRINT '>' . string_display( project_get_field( $t_id, 'name' ) ) . '</option>' . "\n";
            }// End else
            print_subproject_option_list2( $t_id, $p_project_id, $p_filter_project_id );
        }
    }// End for 
}

# --------------------
# modified function "print_subproject_option_list()"
function print_subproject_option_list2( $p_parent_id, $p_project_id = null, $p_filter_project_id = null, $p_parents = Array() ) {
    array_push( $p_parents, $p_parent_id );
    $t_subproject_ids = current_user_get_accessible_subprojects( $p_parent_id );
    $t_subproject_count = count( $t_subproject_ids );
    for ($j=0;$j<$t_subproject_count;$j++) {
        $t_full_id = $t_id = $t_subproject_ids[$j];
        if ( $t_id != $p_filter_project_id ) {
            if( check_selected2( $p_project_id, $t_full_id ) ) {
                PRINT "<option value=\"";
                PRINT "$t_full_id\"";
                PRINT '>' . str_repeat( "» ", count( $p_parents ) ) . string_display( project_get_field( $t_id, 'name' ) ) . '</option>' . "\n";
            } 
            else { # (kivio 29.10.10) Subprojects that user is assigned shown in color gray
                //PRINT "<option value=\"";
                //PRINT "$t_full_id\" style='color:gray'";//disabled='disabled'";
                //PRINT '>' . str_repeat( "» ", count( $p_parents ) ) . string_display( project_get_field( $t_id, 'name' ) ) . '</option>' . "\n";
            }
            print_subproject_option_list2( $t_id, $p_project_id, $p_filter_project_id, $p_parents );
        }
    }// End for
}

# --------------------
# list of projects that a user is NOT in
function print_project_user_list_option_list2( $p_user_id ) {

    $t_mantis_project_user_list_table = config_get( 'mantis_project_user_list_table' );
    $t_mantis_project_table = config_get( 'mantis_project_table' );

    $c_user_id = db_prepare_int( $p_user_id );

    $query = "SELECT DISTINCT p.id, p.name
            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='$c_user_id'
            WHERE p.enabled=1 AND
                u.user_id IS NULL
            ORDER BY p.name";    

    $result = db_query( $query );
    $category_count = db_num_rows( $result );
    $t_project_id = array();

    for ($i=0;$i<$category_count;$i++) {
        $row = db_fetch_array( $result );
        $t_project_name = string_attribute( $row['name'] );
        $t_project_id[$i] = $row['id'];

    }

    print_project_option_list2( $t_project_id, null );

}

Then i call function print_project_user_list_option_list2 on "manage_user_edit_page". Hope it helps.