Пример #1
0
/**
 * Add project to project hierarchy
 * @param int $p_child_id Child project ID
 * @param int $p_parent_id Parent project ID
 * @param bool $p_inherit_parent Whether or not the child project inherits from the parent project
 * @return null
 */
function project_hierarchy_add($p_child_id, $p_parent_id, $p_inherit_parent = true)
{
    if (in_array($p_parent_id, project_hierarchy_get_all_subprojects($p_child_id))) {
        trigger_error(ERROR_PROJECT_RECURSIVE_HIERARCHY, ERROR);
    }
    $t_project_hierarchy_table = db_get_table('project_hierarchy');
    $query = "INSERT INTO {$t_project_hierarchy_table}\n\t\t                ( child_id, parent_id, inherit_parent )\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t( " . db_param() . ', ' . db_param() . ', ' . db_param() . ' )';
    db_query_bound($query, array($p_child_id, $p_parent_id, $p_inherit_parent));
}
Пример #2
0
/**
 * Add project to project hierarchy
 * @param integer $p_child_id       Child project identifier.
 * @param integer $p_parent_id      Parent project identifier.
 * @param boolean $p_inherit_parent Whether or not the child project inherits from the parent project.
 * @return void
 */
function project_hierarchy_add($p_child_id, $p_parent_id, $p_inherit_parent = true)
{
    if (in_array($p_parent_id, project_hierarchy_get_all_subprojects($p_child_id))) {
        trigger_error(ERROR_PROJECT_RECURSIVE_HIERARCHY, ERROR);
    }
    $t_query = 'INSERT INTO {project_hierarchy}
		                ( child_id, parent_id, inherit_parent )
						VALUES
						( ' . db_param() . ', ' . db_param() . ', ' . db_param() . ' )';
    db_query($t_query, array($p_child_id, $p_parent_id, $p_inherit_parent));
}
function project_hierarchy_add($p_child_id, $p_parent_id)
{
    if (in_array($p_parent_id, project_hierarchy_get_all_subprojects($p_child_id))) {
        trigger_error(ERROR_PROJECT_RECURSIVE_HIERARCHY, ERROR);
    }
    $t_project_hierarchy_table = config_get('mantis_project_hierarchy_table');
    $c_child_id = db_prepare_int($p_child_id);
    $c_parent_id = db_prepare_int($p_parent_id);
    $query = "INSERT INTO {$t_project_hierarchy_table}\n\t\t                ( child_id, parent_id )\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t( {$c_child_id}, {$c_parent_id} )";
    db_query($query);
}
Пример #4
0
/**
 * Add project to project hierarchy
 * @param int $p_child_id Child project ID
 * @param int $p_parent_id Parent project ID
 * @param bool $p_inherit_parent Whether or not the child project inherits from the parent project
 * @return null
 */
function project_hierarchy_add($p_child_id, $p_parent_id, $p_inherit_parent = true)
{
    if (in_array($p_parent_id, project_hierarchy_get_all_subprojects($p_child_id))) {
        trigger_error(ERROR_PROJECT_RECURSIVE_HIERARCHY, ERROR);
    }
    $t_project_hierarchy_table = db_get_table('mantis_project_hierarchy_table');
    $c_child_id = db_prepare_int($p_child_id);
    $c_parent_id = db_prepare_int($p_parent_id);
    # Workaround for #14385 - inherit_parent column is wrongly defined as int
    if (db_is_pgsql()) {
        $c_inherit_parent = db_prepare_int($p_inherit_parent);
    } else {
        $c_inherit_parent = db_prepare_bool($p_inherit_parent);
    }
    $query = "INSERT INTO {$t_project_hierarchy_table}\n\t\t                ( child_id, parent_id, inherit_parent )\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t( " . db_param() . ', ' . db_param() . ', ' . db_param() . ' )';
    db_query_bound($query, array($c_child_id, $c_parent_id, $c_inherit_parent));
}
/**
 * @param $type_id
 * @param $project_id
 * @return array
 */
function get_version_ids($type_id, $project_id)
{
    $specmanagement_database_api = new specmanagement_database_api();
    $version_id_array = array();
    $version_ids = $specmanagement_database_api->get_version_ids($type_id, $project_id);
    foreach ($version_ids as $version_id) {
        array_push($version_id_array, $version_id);
    }
    if ($project_id != 0) {
        $sub_project_ids = project_hierarchy_get_all_subprojects($project_id);
        foreach ($sub_project_ids as $sub_project_id) {
            $version_ids = $specmanagement_database_api->get_version_ids($type_id, $sub_project_id);
            foreach ($version_ids as $version_id) {
                array_push($version_id_array, $version_id);
            }
        }
    }
    return $version_id_array;
}
Пример #6
0
			<?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, 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>
Пример #7
0
/**
 * Remove a version from the project
 * @param int $p_version_id
 * @param string $p_new_version
 * @return true
 */
function version_remove($p_version_id, $p_new_version = '')
{
    $c_version_id = db_prepare_int($p_version_id);
    version_ensure_exists($p_version_id);
    $t_old_version = version_get_field($p_version_id, 'version');
    $t_project_id = version_get_field($p_version_id, 'project_id');
    $c_project_id = db_prepare_int($t_project_id);
    $t_project_version_table = db_get_table('project_version');
    $t_bug_table = db_get_table('bug');
    $query = "DELETE FROM {$t_project_version_table}\n\t\t\t\t  WHERE id=" . db_param();
    db_query_bound($query, array($c_version_id));
    $t_project_list = array($c_project_id);
    if (config_get('subprojects_inherit_versions')) {
        $t_project_list = array_merge($t_project_list, project_hierarchy_get_all_subprojects($c_project_id, true));
    }
    $t_project_list = implode(',', $t_project_list);
    $query = "UPDATE {$t_bug_table}\n\t\t\t\t  SET version=" . db_param() . "\n\t\t\t\t  WHERE project_id IN ( {$t_project_list} ) AND version=" . db_param();
    db_query_bound($query, array($p_new_version, $t_old_version));
    $query = "UPDATE {$t_bug_table}\n\t\t\t\t  SET fixed_in_version=" . db_param() . "\n\t\t\t\t  WHERE ( project_id IN ( {$t_project_list} ) ) AND ( fixed_in_version=" . db_param() . ')';
    db_query_bound($query, array($p_new_version, $t_old_version));
    $query = "UPDATE {$t_bug_table}\n\t\t\t\t  SET target_version=" . db_param() . "\n\t\t\t\t  WHERE ( project_id IN ( {$t_project_list} ) ) AND ( target_version=" . db_param() . ')';
    db_query_bound($query, array($p_new_version, $t_old_version));
    # db_query errors on failure so:
    return true;
}
Пример #8
0
/**
 * Remove a version from the project
 * @param integer $p_version_id  A valid version identifier.
 * @param string  $p_new_version A version string to update issues using the old version with.
 * @return void
 */
function version_remove( $p_version_id, $p_new_version = '' ) {
	version_ensure_exists( $p_version_id );

	$t_old_version = version_get_field( $p_version_id, 'version' );
	$t_project_id = version_get_field( $p_version_id, 'project_id' );

	$t_query = 'DELETE FROM {project_version} WHERE id=' . db_param();
	db_query( $t_query, array( (int)$p_version_id ) );

	$t_project_list = array( $t_project_id );
	if( config_get( 'subprojects_inherit_versions' ) ) {
		$t_project_list = array_merge( $t_project_list, project_hierarchy_get_all_subprojects( $t_project_id, true ) );
	}
	$t_project_list = implode( ',', $t_project_list );

	$t_query = 'UPDATE {bug} SET version=' . db_param() . '
				  WHERE project_id IN ( ' . $t_project_list . ' ) AND version=' . db_param();
	db_query( $t_query, array( $p_new_version, $t_old_version ) );

	$t_query = 'UPDATE {bug} SET fixed_in_version=' . db_param() . '
				  WHERE ( project_id IN ( ' . $t_project_list . ' ) ) AND ( fixed_in_version=' . db_param() . ')';
	db_query( $t_query, array( $p_new_version, $t_old_version ) );

	$t_query = 'UPDATE {bug} SET target_version=' . db_param() . '
				  WHERE ( project_id IN ( ' . $t_project_list . ' ) ) AND ( target_version=' . db_param() . ')';
	db_query( $t_query, array( $p_new_version, $t_old_version ) );
}
/**
 * @return array
 */
function prepare_relevant_projects()
{
    $project_ids = array();
    $project_id = helper_get_current_project();
    $sub_project_ids = project_hierarchy_get_all_subprojects($project_id);
    array_push($project_ids, $project_id);
    foreach ($sub_project_ids as $sub_project_id) {
        array_push($project_ids, $sub_project_id);
    }
    return $project_ids;
}
/**
 * Print the option panel where the user manage user->project-assignments and the overall amount of issues
 * for each status under the user table
 *
 * @param $stat_issue_count
 */
function print_option_panel($stat_issue_count)
{
    global $print;
    $user_has_level = false;
    $project_ids = array();
    $current_project_id = helper_get_current_project();
    array_push($project_ids, $current_project_id);
    $sub_project_ids = project_hierarchy_get_all_subprojects($current_project_id);
    foreach ($sub_project_ids as $sub_project_id) {
        array_push($project_ids, $sub_project_id);
    }
    foreach ($project_ids as $project_id) {
        $access_level = user_get_access_level(auth_get_current_user_id(), $project_id);
        if ($access_level >= plugin_config_get('UserProjectAccessLevel')) {
            $user_has_level = true;
        }
    }
    echo '<tr>' . PHP_EOL;
    echo '<td colspan="' . userprojectapi::get_project_hierarchy_spec_colspan(6, true) . '">';
    if (!$print) {
        if ($user_has_level) {
            echo '<label for="option"></label>';
            echo '<select id="option" name="option">';
            echo '<option value="removeSingle">' . plugin_lang_get('remove_selectSingle') . '</option>';
            echo '<option value="removeAll">' . plugin_lang_get('remove_selectAll') . '</option>';
            echo '</select>';
            echo '&nbsp;<input type="submit" name="formSubmit" class="button" value="' . lang_get('ok') . '"/>';
        }
    }
    echo '</td>' . PHP_EOL;
    for ($stat_index = 1; $stat_index <= userprojectapi::get_stat_count(); $stat_index++) {
        echo '<td>' . $stat_issue_count[$stat_index] . '</td>' . PHP_EOL;
    }
    echo '<td></td>' . PHP_EOL;
    echo '</tr>' . PHP_EOL;
}
	 max-width: 500px
	}
</style>';
html_page_top2();
print_manage_menu();
$t_current_project = helper_get_current_project();
if (ALL_PROJECTS == $t_current_project) {
    # All Projects selected
    $t_projects = project_get_all_rows();
    $t_all_projects = array();
    foreach ($t_projects as $t_project) {
        $t_all_projects[] = $t_project['id'];
    }
} else {
    # Use Current Project plus any Subprojects
    $t_all_projects = project_hierarchy_get_all_subprojects($t_current_project);
    array_unshift($t_all_projects, $t_current_project);
}
$t_bug_table = db_get_table('mantis_bug_table');
$t_estimate_table = plugin_table('estimate');
$t_time_total = 0;
$t_projects = join(',', $t_all_projects);
$t_query = "SELECT sum(est.estimate) AS total FROM {$t_bug_table} AS bug\n\t\t\t\tJOIN {$t_estimate_table} AS est ON est.bug_id=bug.id\n\t\t\t\tWHERE bug.project_id IN (" . $t_projects . ')
				AND est.estimate > 0';
$t_result = db_query_bound($t_query);
$t_row = db_fetch_array($t_result);
$t_time_total = $t_row['total'];
echo '<table class="width100">
		<tr class="bold"><td class="center">' . plugin_lang_get('total_remaining') . ': ' . $t_time_total . '</td></tr>
	  </table><br/>';
echo '<table class="width100" cellspacing="1">';
Пример #12
0
		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>
		</form>
	<?php

	$t_subproject_ids = current_user_get_accessible_subprojects( $f_project_id, /* show_disabled */ true );
	if ( Array() != $t_subproject_ids ) { ?>
	<form id="manage-project-update-subprojects-form" action="manage_proj_update_children.php" method="post">
		<fieldset>
function print_tbody()
{
    $databaseapi = new databaseapi();
    $selected_values = null;
    if (isset($_POST['dataRow'])) {
        $selected_values = $_POST['dataRow'];
    }
    $select = strtolower($_POST['option']);
    /** prepare user groups */
    $user_group = userprojectapi::prepare_user_project_remove_group($selected_values);
    echo '<tbody><form action="' . plugin_page('UserProject_RemoveSubmit') . '" method="post">';
    foreach ($user_group as $user) {
        $user_id = $user[0];
        $project_ids = explode(',', $user[1]);
        print_option_user_row($user_id);
        for ($project_index = 0; $project_index < count($project_ids); $project_index++) {
            $project_id = $project_ids[$project_index];
            if ($project_index > 0) {
                $project_id_spec_sub_projects = project_hierarchy_get_all_subprojects($project_id);
                $old_project_id = $project_ids[$project_index - 1];
                $old_project_id_spec_sub_projects = project_hierarchy_get_all_subprojects($old_project_id);
                if (in_array($old_project_id, $project_id_spec_sub_projects)) {
                    /** alte löschen */
                    $project_ids[$project_index - 1] = null;
                } elseif (in_array($project_id, $old_project_id_spec_sub_projects)) {
                    continue;
                }
            }
            switch ($select) {
                case 'removesingle':
                    $user_is_assigned_to_project = $databaseapi->check_user_project_assignment($user_id, $project_id);
                    if (!is_null($user_is_assigned_to_project)) {
                        print_option_project_row($user_id, $project_id);
                    } else {
                        echo '<tr class="info" data-level="1" data-status="0">';
                        echo '<td width="20px"></td>';
                        echo '<td class="user_row_bg" style="text-align: left">' . project_get_name($project_id) . '</td>';
                        echo '<td class="user_row_bg" style="text-align: left" colspan="2">';
                        if (user_is_administrator($user_id)) {
                            echo plugin_lang_get('remove_administrator');
                        } else {
                            echo plugin_lang_get('remove_noassignment');
                        }
                        echo '</td>';
                        echo '</tr>';
                    }
                    break;
                case 'removeall':
                    $sub_project_ids = array();
                    array_push($sub_project_ids, $project_id);
                    $t_sub_project_ids = project_hierarchy_get_all_subprojects($project_id);
                    foreach ($t_sub_project_ids as $t_sub_project_id) {
                        if (!in_array($t_sub_project_id, $sub_project_ids, true)) {
                            array_push($sub_project_ids, $t_sub_project_id);
                        }
                    }
                    foreach ($sub_project_ids as $sub_project_id) {
                        $user_is_assigned_to_project = $databaseapi->check_user_project_assignment($user_id, $sub_project_id);
                        if (!is_null($user_is_assigned_to_project)) {
                            print_option_project_row($user_id, $sub_project_id);
                        } else {
                            echo '<tr class="info" data-level="1" data-status="0">';
                            echo '<td width="20px"></td>';
                            echo '<td class="user_row_bg" style="text-align: left">' . project_get_name($sub_project_id) . '</td>';
                            echo '<td class="user_row_bg" style="text-align: left" colspan="2">';
                            if (user_is_administrator($user_id)) {
                                echo plugin_lang_get('remove_administrator');
                            } else {
                                echo plugin_lang_get('remove_noassignment');
                            }
                            echo '</td>';
                            echo '</tr>';
                        }
                    }
                    break;
            }
        }
    }
    print_option_submit_button();
    echo '</form></tbody>';
}