Exemplo n.º 1
0
        ?>
	</td>
	<td>
		<?php 
        echo get_enum_element('project_view_state', $t_project['view_state']);
        ?>
	</td>
	<td>
		<?php 
        echo string_display_links($t_project['description']);
        ?>
	</td>
</tr>
<?php 
    }
    $t_subprojects = project_hierarchy_get_subprojects($t_project_id, true);
    if (0 < count($t_projects) || 0 < count($t_subprojects)) {
        array_unshift($t_stack, $t_projects);
    }
    if (0 < count($t_subprojects)) {
        $t_full_projects = array();
        foreach ($t_subprojects as $t_project_id) {
            $t_full_projects[] = project_get_row($t_project_id);
        }
        $t_subprojects = multi_sort($t_full_projects, $f_sort, $t_direction);
        array_unshift($t_stack, $t_subprojects);
    }
}
?>
</table>
<br />
Exemplo n.º 2
0
function user_get_accessible_projects($p_user_id, $p_show_disabled = false)
{
    global $g_user_accessible_projects_cache;
    if (null !== $g_user_accessible_projects_cache && auth_get_current_user_id() == $p_user_id && false == $p_show_disabled) {
        return $g_user_accessible_projects_cache;
    }
    if (access_has_global_level(config_get('private_project_threshold'), $p_user_id)) {
        $t_projects = project_hierarchy_get_subprojects(ALL_PROJECTS, $p_show_disabled);
    } else {
        $c_user_id = db_prepare_int($p_user_id);
        $t_project_table = config_get('mantis_project_table');
        $t_project_user_list_table = config_get('mantis_project_user_list_table');
        $t_project_hierarchy_table = config_get('mantis_project_hierarchy_table');
        $t_public = VS_PUBLIC;
        $t_private = VS_PRIVATE;
        $t_enabled_clause = $p_show_disabled ? '' : 'p.enabled = 1 AND';
        $query = "SELECT p.id, p.name, ph.parent_id\n\t\t\t\t\t  FROM {$t_project_table} p\n\t\t\t\t\t  LEFT JOIN {$t_project_user_list_table} u\n\t\t\t\t\t    ON p.id=u.project_id AND u.user_id={$c_user_id}\n\t\t\t\t\t  LEFT JOIN {$t_project_hierarchy_table} ph\n\t\t\t\t\t    ON ph.child_id = p.id\n\t\t\t\t\t  WHERE {$t_enabled_clause}\n\t\t\t\t\t\t( p.view_state='{$t_public}'\n\t\t\t\t\t\t    OR (p.view_state='{$t_private}'\n\t\t\t\t\t\t\t    AND\n\t\t\t\t\t\t        u.user_id='{$c_user_id}' )\n\t\t\t\t\t\t)\n\t\t\t\t\t  ORDER BY p.name";
        $result = db_query($query);
        $row_count = db_num_rows($result);
        $t_projects = array();
        for ($i = 0; $i < $row_count; $i++) {
            $row = db_fetch_array($result);
            $t_projects[$row['id']] = $row['parent_id'] === NULL ? 0 : $row['parent_id'];
        }
        # prune out children where the parents are already listed. Make the list
        #  first, then prune to avoid pruning a parent before the child is found.
        $t_prune = array();
        foreach ($t_projects as $t_id => $t_parent) {
            if ($t_parent !== 0 && isset($t_projects[$t_parent])) {
                $t_prune[] = $t_id;
            }
        }
        foreach ($t_prune as $t_id) {
            unset($t_projects[$t_id]);
        }
        $t_projects = array_keys($t_projects);
    }
    if (auth_get_current_user_id() == $p_user_id) {
        $g_user_accessible_projects_cache = $t_projects;
    }
    return $t_projects;
}
Exemplo n.º 3
0
/**
 * retun an array of project IDs to which the user has access
 *
 * @param integer $p_user_id       A valid user identifier.
 * @param boolean $p_show_disabled Whether to include disabled projects in the result array.
 * @return array
 */
function user_get_accessible_projects($p_user_id, $p_show_disabled = false)
{
    global $g_user_accessible_projects_cache;
    if (null !== $g_user_accessible_projects_cache && auth_get_current_user_id() == $p_user_id && false == $p_show_disabled) {
        return $g_user_accessible_projects_cache;
    }
    if (access_has_global_level(config_get('private_project_threshold'), $p_user_id)) {
        $t_projects = project_hierarchy_get_subprojects(ALL_PROJECTS, $p_show_disabled);
    } else {
        $t_public = VS_PUBLIC;
        $t_private = VS_PRIVATE;
        $t_query = 'SELECT p.id, p.name, ph.parent_id
						  FROM {project} p
						  LEFT JOIN {project_user_list} u
						    ON p.id=u.project_id AND u.user_id=' . db_param() . '
						  LEFT JOIN {project_hierarchy} ph
						    ON ph.child_id = p.id
						  WHERE ' . ($p_show_disabled ? '' : 'p.enabled = ' . db_param() . ' AND ') . '
							( p.view_state=' . db_param() . '
							    OR (p.view_state=' . db_param() . '
								    AND
							        u.user_id=' . db_param() . ' )
							) ORDER BY p.name';
        $t_result = db_query($t_query, $p_show_disabled ? array($p_user_id, $t_public, $t_private, $p_user_id) : array($p_user_id, true, $t_public, $t_private, $p_user_id));
        $t_projects = array();
        while ($t_row = db_fetch_array($t_result)) {
            $t_projects[(int) $t_row['id']] = $t_row['parent_id'] === null ? 0 : (int) $t_row['parent_id'];
        }
        # prune out children where the parents are already listed. Make the list
        #  first, then prune to avoid pruning a parent before the child is found.
        $t_prune = array();
        foreach ($t_projects as $t_id => $t_parent) {
            if ($t_parent !== 0 && isset($t_projects[$t_parent])) {
                $t_prune[] = $t_id;
            }
        }
        foreach ($t_prune as $t_id) {
            unset($t_projects[$t_id]);
        }
        $t_projects = array_keys($t_projects);
    }
    if (auth_get_current_user_id() == $p_user_id) {
        $g_user_accessible_projects_cache = $t_projects;
    }
    return $t_projects;
}
Exemplo n.º 4
0
/**
 * print bug counts by project
 * @todo check p_cache - static?
 *
 * @param array   $p_projects Array of project id's.
 * @param integer $p_level    Indicates the depth of the project within the sub-project hierarchy.
 * @param array   $p_cache    Summary cache.
 * @return void
 */
function summary_print_by_project(array $p_projects = array(), $p_level = 0, array $p_cache = null)
{
    $t_project_id = helper_get_current_project();
    if (empty($p_projects)) {
        if (ALL_PROJECTS == $t_project_id) {
            $p_projects = current_user_get_accessible_projects();
        } else {
            $p_projects = array($t_project_id);
        }
    }
    # Retrieve statistics one time to improve performance.
    if (null === $p_cache) {
        $t_query = 'SELECT project_id, status, COUNT( status ) AS bugcount
					FROM {bug}
					GROUP BY project_id, status';
        $t_result = db_query($t_query);
        $p_cache = array();
        $t_resolved_val = config_get('bug_resolved_status_threshold');
        $t_closed_val = config_get('bug_closed_status_threshold');
        while ($t_row = db_fetch_array($t_result)) {
            $t_project_id = $t_row['project_id'];
            $t_status = $t_row['status'];
            $t_bugcount = $t_row['bugcount'];
            if ($t_closed_val <= $t_status) {
                if (isset($p_cache[$t_project_id]['closed'])) {
                    $p_cache[$t_project_id]['closed'] += $t_bugcount;
                } else {
                    $p_cache[$t_project_id]['closed'] = $t_bugcount;
                }
            } else {
                if ($t_resolved_val <= $t_status) {
                    if (isset($p_cache[$t_project_id]['resolved'])) {
                        $p_cache[$t_project_id]['resolved'] += $t_bugcount;
                    } else {
                        $p_cache[$t_project_id]['resolved'] = $t_bugcount;
                    }
                } else {
                    if (isset($p_cache[$t_project_id]['open'])) {
                        $p_cache[$t_project_id]['open'] += $t_bugcount;
                    } else {
                        $p_cache[$t_project_id]['open'] = $t_bugcount;
                    }
                }
            }
        }
    }
    foreach ($p_projects as $t_project) {
        $t_name = str_repeat('&raquo; ', $p_level) . project_get_name($t_project);
        $t_pdata = isset($p_cache[$t_project]) ? $p_cache[$t_project] : array('open' => 0, 'resolved' => 0, 'closed' => 0);
        $t_bugs_open = isset($t_pdata['open']) ? $t_pdata['open'] : 0;
        $t_bugs_resolved = isset($t_pdata['resolved']) ? $t_pdata['resolved'] : 0;
        $t_bugs_closed = isset($t_pdata['closed']) ? $t_pdata['closed'] : 0;
        $t_bugs_total = $t_bugs_open + $t_bugs_resolved + $t_bugs_closed;
        summary_helper_print_row(string_display_line($t_name), $t_bugs_open, $t_bugs_resolved, $t_bugs_closed, $t_bugs_total);
        if (count(project_hierarchy_get_subprojects($t_project)) > 0) {
            $t_subprojects = current_user_get_accessible_subprojects($t_project);
            if (count($t_subprojects) > 0) {
                summary_print_by_project($t_subprojects, $p_level + 1, $p_cache);
            }
        }
    }
}
Exemplo n.º 5
0
/**
 * Get complete subproject hierarchy for a project
 * @param integer $p_project_id    Project identifier.
 * @param boolean $p_show_disabled Whether or not to consider projects which are disabled.
 * @return array
 */
function project_hierarchy_get_all_subprojects($p_project_id, $p_show_disabled = false)
{
    $t_todo = project_hierarchy_get_subprojects($p_project_id, $p_show_disabled);
    $t_subprojects = array();
    while ($t_todo) {
        $t_elem = array_shift($t_todo);
        if (!in_array($t_elem, $t_subprojects)) {
            array_push($t_subprojects, $t_elem);
            $t_todo = array_merge($t_todo, project_hierarchy_get_subprojects($t_elem, $p_show_disabled));
        }
    }
    return $t_subprojects;
}
Exemplo n.º 6
0
$minimum_level = access_get_global_level();
$t_where_clausole = "view_access <= {$minimum_level}";
if (!isset($_POST['f_all_user']) || !isset($_GET['f_all_user'])) {
    //allow show all youser
    $t_where_clausole .= " and poster_id = " . current_user_get_field("id");
} else {
    if (!isset($_POST['f_user_id'])) {
        //show by userId
        $t_where_clausole .= " and poster_id = " . gpc_get_int("poster_id");
    }
}
$p_project_id = helper_get_current_project();
if ($p_project_id != 0) {
    //pk remove filter by project
    $t_where_clausole .= " and ((project_id='" . $p_project_id . "' OR project_id=0)";
    $t_project_ids = project_hierarchy_get_subprojects($p_project_id);
    foreach ($t_project_ids as $value) {
        $t_where_clausole .= " or project_id='" . $value . "'";
    }
    $t_where_clausole .= ")";
}
$f_search = $_POST["f_search"];
if (!isset($f_search)) {
    $f_search = "";
    $f_search3 = "";
    $f_search2 = "";
} else {
    $f_search3 = "";
    $f_search2 = "";
    if ($t_where_clausole != "") {
        $t_where_clausole = $t_where_clausole . " AND ";
Exemplo n.º 7
0
?>

<!-- SUBPROJECTS -->
<div id="manage-project-update-subprojects-div" class="form-container">
	<h2><?php echo lang_get( 'subprojects' ); ?></h2>
	<?php
		# Check the user's global access level before allowing project creation
		if ( access_has_global_level ( config_get( 'create_project_threshold' ) ) ) {
			print_button( 'manage_proj_create_page.php?parent_id=' . $f_project_id, lang_get( 'create_new_subproject_link' ) );
		} ?>
		<form id="manage-project-subproject-add-form" method="post" action="manage_proj_subproj_add.php">
			<fieldset>
				<?php echo form_security_field( 'manage_proj_subproj_add' ) ?>
				<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
				<select name="subproject_id"><?php
				$t_all_subprojects = project_hierarchy_get_subprojects( $f_project_id, /* $p_show_disabled */ true );
				$t_all_subprojects[] = $f_project_id;
				$t_manage_access = config_get( 'manage_project_threshold' );
				$t_projects = project_get_all_rows();
				$t_projects = multi_sort( $t_projects, 'name', ASCENDING );
				foreach ( $t_projects as $t_project ) {
					if ( in_array( $t_project['id'], $t_all_subprojects ) ||
						in_array( $f_project_id, project_hierarchy_get_all_subprojects( $t_project['id'] ) ) ||
						!access_has_project_level( $t_manage_access, $t_project['id'] ) ) {
						continue;
					} ?>
					<option value="<?php echo $t_project['id'] ?>"><?php echo string_attribute( $t_project['name'] ) ?></option><?php
				} # End looping over projects ?>
				</select>
				<input type="submit" value="<?php echo lang_get('add_subproject'); ?>" />
			</fieldset>
Exemplo n.º 8
0
function user_get_accessible_projects( $p_user_id, $p_show_disabled = false ) {
	global $g_user_accessible_projects_cache;

	if( null !== $g_user_accessible_projects_cache && auth_get_current_user_id() == $p_user_id && false == $p_show_disabled ) {
		return $g_user_accessible_projects_cache;
	}

	if( access_has_global_level( config_get( 'private_project_threshold' ), $p_user_id ) ) {
		$t_projects = project_hierarchy_get_subprojects( ALL_PROJECTS, $p_show_disabled );
	} else {
		$t_project_table = db_get_table( 'project' );
		$t_project_user_list_table = db_get_table( 'project_user_list' );
		$t_project_hierarchy_table = db_get_table( 'project_hierarchy' );

		$t_public = VS_PUBLIC;
		$t_private = VS_PRIVATE;

		$result = null;

		$query = "SELECT p.id, p.name, ph.parent_id
						  FROM $t_project_table p
						  LEFT JOIN $t_project_user_list_table u
						    ON p.id=u.project_id AND u.user_id=" . db_param() . "
						  LEFT JOIN $t_project_hierarchy_table ph
						    ON ph.child_id = p.id
						  WHERE " . ( $p_show_disabled ? '' : ( 'p.enabled = ' . db_param() . ' AND ' ) ) . "
							( p.view_state=" . db_param() . "
							    OR (p.view_state=" . db_param() . "
								    AND
							        u.user_id=" . db_param() . " )
							)
			  ORDER BY p.name";
		$result = db_query_bound( $query, ( $p_show_disabled ? Array( $p_user_id, $t_public, $t_private, $p_user_id ) : Array( $p_user_id, true, $t_public, $t_private, $p_user_id ) ) );

		$row_count = db_num_rows( $result );

		$t_projects = array();

		for( $i = 0;$i < $row_count;$i++ ) {
			$row = db_fetch_array( $result );

			$t_projects[(int)$row['id']] = ( $row['parent_id'] === NULL ) ? 0 : (int)$row['parent_id'];
		}

		# prune out children where the parents are already listed. Make the list
		#  first, then prune to avoid pruning a parent before the child is found.
		$t_prune = array();
		foreach( $t_projects as $t_id => $t_parent ) {
			if(( $t_parent !== 0 ) && isset( $t_projects[$t_parent] ) ) {
				$t_prune[] = $t_id;
			}
		}
		foreach( $t_prune as $t_id ) {
			unset( $t_projects[$t_id] );
		}
		$t_projects = array_keys( $t_projects );
	}

	if( auth_get_current_user_id() == $p_user_id ) {
		$g_user_accessible_projects_cache = $t_projects;
	}

	return $t_projects;
}