Exemple #1
0
function print_assign_to_option_list($p_id = "")
{
    global $g_mantis_user_table, $g_mantis_project_table, $g_mantis_project_user_list_table, $g_project_cookie_val;
    $t_adm = ADMINISTRATOR;
    $t_dev = DEVELOPER;
    $t_pub = PUBLICPROJ;
    $t_prv = PRIVATEPROJ;
    $user_arr = array();
    # checking if it's per project or all projects
    # 0 is all projects
    if ('0000000' == $g_project_cookie_val) {
        $query = "SELECT DISTINCT u.id, u.username, u.email\n\t\t\t\t\tFROM \t{$g_mantis_user_table} u,\n\t\t\t\t\t\t\t{$g_mantis_project_user_list_table} l,\n\t\t\t\t\t\t\t{$g_mantis_project_table} p\n\t\t\t\t\tWHERE\t(p.view_state='{$t_pub}' AND\n\t\t\t\t\t\t\tu.access_level>='{$t_dev}') OR\n\t\t\t\t\t\t\t(l.access_level>='{$t_dev}' AND\n\t\t\t\t\t\t\tl.user_id=u.id) OR\n\t\t\t\t\t\t\tu.access_level>='{$t_adm}'\n\t\t\t\t\tORDER BY u.username";
        $result = db_query($query);
        $user_count = db_num_rows($result);
        for ($i = 0; $i < $user_count; $i++) {
            $row = db_fetch_array($result);
            extract($row, EXTR_PREFIX_ALL, "v");
            $user_arr[$v_username] = array($v_username, $v_id);
        }
    } else {
        $temp_arr = array();
        # grab the administrators
        $query = "SELECT id, username\n\t\t\t\t\tFROM {$g_mantis_user_table}\n\t\t\t\t\tORDER BY username";
        $result = db_query($query);
        $user_count = db_num_rows($result);
        for ($i = 0; $i < $user_count; $i++) {
            $row = db_fetch_array($result);
            extract($row, EXTR_PREFIX_ALL, "v");
            $temp_arr[$v_username] = array($v_username, $v_id);
        }
        foreach ($temp_arr as $key => $val) {
            $v_id = $val[1];
            $v_username = $val[0];
            # always add all administrators
            $t_access_level = get_user_field($v_id, "access_level");
            if (ADMINISTRATOR == $t_access_level) {
                $user_arr[$v_username] = array($v_username, $v_id);
                continue;
            }
            # see if users belong
            $t_project_view_state = get_project_field($g_project_cookie_val, "view_state");
            if (PUBLICPROJ == $t_project_view_state) {
                $query = "SELECT l.access_level\n\t\t\t\t\t\t\tFROM\t{$g_mantis_project_user_list_table} l,\n\t\t\t\t\t\t\t\t\t{$g_mantis_project_table} p\n\t\t\t\t\t\t\tWHERE\tl.project_id='{$g_project_cookie_val}' AND\n\t\t\t\t\t\t\t\t\tp.id=l.project_id AND\n\t\t\t\t\t\t\t\t\tl.user_id='{$v_id}'";
                $result = db_query($query);
                $count = db_num_rows($result);
                if ($count > 0) {
                    $t_access_level = db_result($result);
                }
                if ($t_access_level >= DEVELOPER) {
                    $user_arr[$v_username] = array($v_username, $v_id);
                }
            } else {
                $query = "SELECT COUNT(*)\n\t\t\t\t\t\t\tFROM\t{$g_mantis_project_user_list_table} l,\n\t\t\t\t\t\t\t\t\t{$g_mantis_project_table} p\n\t\t\t\t\t\t\tWHERE\tl.project_id='{$g_project_cookie_val}' AND\n\t\t\t\t\t\t\t\t\tp.id=l.project_id AND\n\t\t\t\t\t\t\t\t\tl.user_id='{$v_id}' AND\n\t\t\t\t\t\t\t\t\tl.access_level>='{$t_dev}'";
                $result = db_query($query);
                $count = db_result($result, 0, 0);
                if ($count > 0) {
                    $user_arr[$v_username] = array($v_username, $v_id);
                    continue;
                }
            }
        }
    }
    asort($user_arr);
    foreach ($user_arr as $key => $val) {
        $v_id = $val[1];
        $v_username = $val[0];
        if ($v_id == $p_user_id) {
            print "<option value=\"{$v_id}\" SELECTED>{$v_username}</option>";
        } else {
            print "<option value=\"{$v_id}\">{$v_username}</option>";
        }
    }
    # end foreach
}
$closed_count_arr = array();
foreach ($projection_arr as $t_projection) {
    # OPEN
    $query = "SELECT COUNT(*) as count\n\t\t\t\tFROM mantis_bug_table\n\t\t\t\tWHERE project_id='{$t_project_id}' AND\n\t\t\t\t\tprojection='{$t_projection}' AND\n\t\t\t\t\tstatus<80";
    $result = db_query($query);
    $open_count_arr[] = db_result($result, 0, 0);
    # RESOLVED
    $query = "SELECT COUNT(*) as count\n\t\t\t\tFROM mantis_bug_table\n\t\t\t\tWHERE project_id='{$t_project_id}' AND\n\t\t\t\t\tprojection='{$t_projection}' AND\n\t\t\t\t\tstatus=80";
    $result = db_query($query);
    $resolved_count_arr[] = db_result($result, 0, 0);
    # CLOSED
    $query = "SELECT COUNT(*) as count\n\t\t\t\tFROM mantis_bug_table\n\t\t\t\tWHERE project_id='{$t_project_id}' AND\n\t\t\t\t\tprojection='{$t_projection}' AND\n\t\t\t\t\tstatus=90";
    $result = db_query($query);
    $closed_count_arr[] = db_result($result, 0, 0);
}
$proj_name = get_project_field($t_project_id, 'name');
$graph = new Graph(800, 600, 'auto');
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->img->SetMargin(40, 30, 40, 80);
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 10);
$graph->xaxis->SetTickLabels($projection_arr);
$graph->xaxis->SetLabelAngle(45);
#$graph->xaxis->title->Set("Release Increments");
#$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->title->Set("{$proj_name} Release Delta Chart");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
# Create graph
$bplot1 = new BarPlot($open_count_arr);
$bplot2 = new BarPlot($resolved_count_arr);
$bplot3 = new BarPlot($closed_count_arr);
Exemple #3
0
function check_access_to_project($p_project_id)
{
    $t_project_view_state = get_project_field($p_project_id, 'view_state');
    # Administrators ALWAYS pass.
    if (get_current_user_field('access_level') >= ADMINISTRATOR) {
        return;
    }
    # public project accept all users
    if (PUBLICPROJ == $t_project_view_state) {
        return;
    } else {
        # private projects require users to be assigned
        $t_project_access_level = get_project_access_level($p_project_id);
        # -1 means not assigned, kick them out to the project selection screen
        if (-1 == $t_project_access_level) {
            print_header_redirect('login_select_proj_page.php');
        } else {
            # passed
            return;
        }
    }
}