Beispiel #1
0
/**
 * Parse a workflow into a graph-like array of workflow transitions.
 * @param array The workflow enumeration to parse.
 * @return array The parsed workflow graph.
 */
function workflow_parse($p_enum_workflow)
{
    $t_status_arr = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
    if (count($p_enum_workflow) == 0) {
        # workflow is not set, default it to all transitions
        foreach ($t_status_arr as $t_status => $t_label) {
            $t_temp_workflow = array();
            foreach ($t_status_arr as $t_next => $t_next_label) {
                if ($t_status != $t_next) {
                    $t_temp_workflow[] = $t_next . ':' . $t_next_label;
                }
            }
            $p_enum_workflow[$t_status] = implode(',', $t_temp_workflow);
        }
    }
    $t_entry = array();
    $t_exit = array();
    # prepopulate new bug state (bugs go from nothing to here)
    $t_submit_status_array = config_get('bug_submit_status');
    $t_new_label = MantisEnum::getLabel(lang_get('status_enum_string'), config_get('bug_submit_status'));
    if (is_array($t_submit_status_array)) {
        # @@@ (thraxisp) this is not implemented in bug_api.php
        foreach ($t_submit_status_array as $t_access => $t_status) {
            $t_entry[$t_status][0] = $t_new_label;
            $t_exit[0][$t_status] = $t_new_label;
        }
    } else {
        $t_status = $t_submit_status_array;
        $t_entry[$t_status][0] = $t_new_label;
        $t_exit[0][$t_status] = $t_new_label;
    }
    # add user defined arcs and implicit reopen arcs
    $t_reopen = config_get('bug_reopen_status');
    $t_reopen_label = MantisEnum::getLabel(lang_get('resolution_enum_string'), config_get('bug_reopen_resolution'));
    $t_resolved_status = config_get('bug_resolved_status_threshold');
    $t_default = array();
    foreach ($t_status_arr as $t_status => $t_status_label) {
        if (isset($p_enum_workflow[$t_status])) {
            $t_next_arr = MantisEnum::getAssocArrayIndexedByValues($p_enum_workflow[$t_status]);
            foreach ($t_next_arr as $t_next => $t_next_label) {
                if (!isset($t_default[$t_status])) {
                    $t_default[$t_status] = $t_next;
                }
                $t_exit[$t_status][$t_next] = '';
                $t_entry[$t_next][$t_status] = '';
            }
        } else {
            $t_exit[$t_status] = array();
        }
        if ($t_status >= $t_resolved_status) {
            $t_exit[$t_status][$t_reopen] = $t_reopen_label;
            $t_entry[$t_reopen][$t_status] = $t_reopen_label;
        }
        if (!isset($t_entry[$t_status])) {
            $t_entry[$t_status] = array();
        }
    }
    return array('entry' => $t_entry, 'exit' => $t_exit, 'default' => $t_default);
}
Beispiel #2
0
 /**
  * Tests getAssocArrayIndexedByValues() method.
  */
 public function testGetAssocArrayIndexedByValues()
 {
     $this->assertEquals(array(), MantisEnum::getAssocArrayIndexedByValues(MantisEnumTest::EMPTY_ENUM));
     $this->assertEquals(array(10 => 'viewer'), MantisEnum::getAssocArrayIndexedByValues(MantisEnumTest::SINGLE_VALUE_ENUM));
     $this->assertEquals(array(10 => 'viewer1'), MantisEnum::getAssocArrayIndexedByValues(MantisEnumTest::DUPLICATE_VALUES_ENUM));
     $this->assertEquals(array(10 => 'viewer', 20 => 'viewer'), MantisEnum::getAssocArrayIndexedByValues(MantisEnumTest::DUPLICATE_LABELS_ENUM));
     $this->assertEquals(array(10 => 'first label', 20 => 'second label'), MantisEnum::getAssocArrayIndexedByValues(MantisEnumTest::NAME_WITH_SPACES_ENUM));
 }
/**
 * Print table head
 * @param $status_cols
 */
function print_thead($status_cols)
{
    echo '<thead>';
    echo '<tr>';
    echo '<th></th>';
    foreach ($status_cols as $status_col) {
        echo '<th bgcolor="' . get_status_color($status_col, null, null) . '" class="center">';
        $assocArray = MantisEnum::getAssocArrayIndexedByValues(lang_get('status_enum_string'));
        echo $assocArray[$status_col];
        echo '</th>';
    }
    echo '</tr>';
    echo '</thead>';
}
function set_capability_row( $p_threshold, $p_all_projects_only=false ) {
	global $t_access, $t_project;

	if ( ( $t_access >= config_get_access( $p_threshold ) )
			  && ( ( ALL_PROJECTS == $t_project ) || !$p_all_projects_only ) ) {
		$f_threshold = gpc_get_int_array( 'flag_thres_' . $p_threshold, array() );
		$f_access = gpc_get_int( 'access_' . $p_threshold );
		# @@debug @@ echo "<br />for $p_threshold "; var_dump($f_threshold, $f_access); echo '<br />';
		$t_access_levels = MantisEnum::getAssocArrayIndexedByValues( config_get( 'access_levels_enum_string' ) );
		ksort( $t_access_levels );
		reset( $t_access_levels );

		$t_lower_threshold = NOBODY;
		$t_array_threshold = array();

		foreach( $t_access_levels as $t_access_level => $t_level_name ) {
			if ( in_array( $t_access_level, $f_threshold ) ) {
				if ( NOBODY == $t_lower_threshold ) {
					$t_lower_threshold = $t_access_level;
				}
				$t_array_threshold[] = $t_access_level;
			} else {
				if ( NOBODY <> $t_lower_threshold ) {
					$t_lower_threshold = -1;
				}
			}
		# @@debug @@ var_dump($$t_access_level, $t_lower_threshold, $t_array_threshold); echo '<br />';
		}
		$t_existing_threshold = config_get( $p_threshold );
		$t_existing_access = config_get_access( $p_threshold );
		if ( -1 == $t_lower_threshold ) {
			if ( ( $t_existing_threshold != $t_array_threshold )
					|| ( $t_existing_access != $f_access ) ) {
				config_set( $p_threshold, $t_array_threshold, NO_USER, $t_project, $f_access );
			}
		} else {
			if ( ( $t_existing_threshold != $t_lower_threshold )
					|| ( $t_existing_access != $f_access ) ) {
				config_set( $p_threshold, $t_lower_threshold, NO_USER, $t_project, $f_access );
			}
		}
	}
}
 function renderLists()
 {
     $content = '';
     $status_codes = config_get('status_enum_string');
     $t_status_array = MantisEnum::getAssocArrayIndexedByValues($status_codes);
     foreach ($t_status_array as $status => $statusCode) {
         if ($statusCode != "backlog" && $statusCode != "closed") {
             $issues = $this->renderIssues($status);
             $statusName = string_display_line(get_enum_element('status', $status));
             $content .= '<div class="column">
                                 <div class="inside"
                                 style="background-color: ' . get_status_color($status) . '"
                                 id="' . $status . '">
                                 <h5 title="' . $status . '">' . $statusName . ' (' . sizeof($issues) . ')</h5>';
             $content .= implode("\n", $issues);
             $content .= '</div>';
             // inside
             $content .= '</div>';
             // column
         }
     }
     return $content;
 }
function getBugsInfoJSONPResponse($bugsString)
{
    $t_bug_table = db_get_table('mantis_bug_table');
    $t_statuses = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
    $statuses = '';
    foreach ($t_statuses as $t_state => $t_label) {
        $statuses .= '"' . $t_label . '": "' . get_status_color($t_state) . '", ';
    }
    $bugs_list = array_unique(str_split($bugsString, 7));
    $bugs_list = "'" . implode("', '", $bugs_list) . "'";
    $query = "SELECT id, status, summary\r\n\t\t\t  FROM `" . $t_bug_table . "`\r\n\t\t\t  WHERE id IN (" . $bugs_list . ")\r\n\t\t\t  ORDER BY FIELD(id, " . $bugs_list . ")";
    $results = db_query_bound($query);
    if ($results) {
        $json = '';
        while ($row = db_fetch_array($results)) {
            $id = $row['id'];
            $statusId = $row['status'];
            $summary = $row['summary'];
            $json .= '"' . $id . '": { "status": "' . $t_statuses[$statusId] . '", "summary": "' . htmlspecialchars($summary) . '" }, ';
        }
    }
    header("Content-Type: application/javascript; charset=utf-8");
    echo 'bugtrackerConnection_callback( { "offset": "' . $_REQUEST['offset'] . '", "length": "' . $_REQUEST['length'] . '", "statuses": { ' . substr($statuses, 0, -2) . ' }, "bugsInfo" : { ' . substr($json, 0, -2) . ' } } );';
}
Beispiel #7
0
 * status of task, see lang/strings_german.txt ($s_status_enum_string) and
 * MantisKanban/lang/strings_german.txt:
 * Sets your kanban board columns - format is
 *
 * $columns = array(
 *	COLUM_NAME => array('status' => ARRAY_OF_MANTIS_STATI, WORK_IN_PROGRESS_LIMIT),
 *      ...
 * example:
 * $columns = array(
 *	lang_get('header_column_1') => array('status' => array(10), 'wip_limit' => 0),
 * means: Column 1 of your board has the name of the key "header_column_1" (e.g. "New"),
 * shows all tickets with status = 10 and has a "work in progress" limit of 0 (unlimited).
*/
$columns = array(lang_get('header_column_1') => array('status' => array(10), 'wip_limit' => 0), lang_get('header_column_2') => array('status' => array(30), 'wip_limit' => 0), lang_get('header_column_3') => array('status' => array(40), 'wip_limit' => 8), lang_get('header_column_4') => array('status' => 20, 'wip_limit' => 0), lang_get('header_column_5') => array('status' => 50, 'wip_limit' => 8));
if (ON == plugin_config_get('kanban_simple_columns')) {
    $defaults = MantisEnum::getAssocArrayIndexedByValues($g_status_enum_string);
    $columns = null;
    $hideUntilThisStatus = config_get('bug_resolved_status_threshold');
    foreach ($defaults as $num => $status) {
        if ($num < $hideUntilThisStatus) {
            $wip_limit = 12;
            //no limit for "new"
            if (10 == $num) {
                $wip_limit = 0;
            }
            $columns[kanban_get_status_text($num)] = array('status' => array($num), 'wip_limit' => $wip_limit, 'color' => get_status_color($num));
        }
    }
}
// default sorting of the tickets in the columns
// either 'last_updated' or 'priority'
require_api('helper_api.php');
require_api('html_api.php');
require_api('lang_api.php');
require_api('print_api.php');
require_api('project_api.php');
require_api('string_api.php');
require_api('user_api.php');
auth_reauthenticate();
html_page_top(lang_get('manage_threshold_config'));
print_manage_menu('adm_permissions_report.php');
print_manage_config_menu('manage_config_work_threshold_page.php');
$t_user = auth_get_current_user_id();
$t_project_id = helper_get_current_project();
$t_access = user_get_access_level($t_user, $t_project_id);
$t_show_submit = false;
$t_access_levels = MantisEnum::getAssocArrayIndexedByValues(config_get('access_levels_enum_string'));
$t_overrides = array();
function set_overrides($p_config)
{
    global $t_overrides;
    if (!in_array($p_config, $t_overrides)) {
        $t_overrides[] = $p_config;
    }
}
function get_section_begin_mcwt($p_section_name)
{
    global $t_access_levels;
    echo '<table class="width100">';
    echo '<tr><td class="form-title" colspan="' . (count($t_access_levels) + 2) . '">' . $p_section_name . '</td></tr>' . "\n";
    echo '<tr><td class="form-title" width="40%" rowspan="2">' . lang_get('perm_rpt_capability') . '</td>';
    echo '<td class="form-title"style="text-align:center"  width="40%" colspan="' . count($t_access_levels) . '">' . lang_get('access_levels') . '</td>';
/**
 * access row
 * @return void
 */
function access_row()
{
    global $g_access, $g_can_change_flags;
    $t_enum_status = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
    $t_file_new = config_get_global('report_bug_threshold');
    $t_global_new = config_get('report_bug_threshold', null, ALL_USERS, ALL_PROJECTS);
    $t_project_new = config_get('report_bug_threshold');
    $t_file_set = config_get_global('set_status_threshold');
    $t_global_set = config_get('set_status_threshold', null, ALL_USERS, ALL_PROJECTS);
    $t_project_set = config_get('set_status_threshold');
    $t_submit_status = config_get('bug_submit_status');
    # Print the table rows
    foreach ($t_enum_status as $t_status => $t_status_label) {
        echo "\t\t" . '<tr><td class="width30">' . string_no_break(MantisEnum::getLabel(lang_get('status_enum_string'), $t_status)) . '</td>' . "\n";
        if ($t_status == $t_submit_status) {
            # 'NEW' status
            $t_level_project = $t_project_new;
            $t_can_change = $g_access >= config_get_access('report_bug_threshold');
            $t_color = set_color_override($t_file_new, $t_global_new, $t_project_new);
            set_overrides('report_bug_threshold', $t_can_change, $t_color);
        } else {
            # Other statuses
            # File level: fallback if set_status_threshold is not defined
            if (isset($t_file_set[$t_status])) {
                $t_level_file = $t_file_set[$t_status];
            } else {
                $t_level_file = config_get_global('update_bug_status_threshold');
            }
            $t_level_global = isset($t_global_set[$t_status]) ? $t_global_set[$t_status] : $t_level_file;
            $t_level_project = isset($t_project_set[$t_status]) ? $t_project_set[$t_status] : $t_level_global;
            $t_can_change = $g_access >= config_get_access('set_status_threshold');
            $t_color = set_color_override($t_level_file, $t_level_global, $t_level_project);
            set_overrides('set_status_threshold', $t_can_change, $t_color);
        }
        if ($t_can_change) {
            echo '<td class="center ' . $t_color . '"><select name="access_change_' . $t_status . '">' . "\n";
            print_enum_string_option_list('access_levels', $t_level_project);
            echo '</select> </td>' . "\n";
            $g_can_change_flags = true;
        } else {
            echo '<td class="center ' . $t_color . '">' . MantisEnum::getLabel(lang_get('access_levels_enum_string'), $t_level_project) . '</td>' . "\n";
        }
        echo '</tr>' . "\n";
    }
}
Beispiel #10
0
 /**
  * Checks if the specified enum string contains the specified value.
  *
  * @param string $enumString  The enumeration string.
  * @param integer $value      The value to chec,
  * @return bool true if found, false otherwise.
  */
 public static function hasValue($enumString, $value)
 {
     $assocArray = MantisEnum::getAssocArrayIndexedByValues($enumString);
     $valueAsInteger = (int) $value;
     return isset($assocArray[$valueAsInteger]);
 }
Beispiel #11
0
/**
 * Print the color legend for the status colors
 * @param string
 * @return null
 */
function html_status_legend()
{
    echo '<br />';
    echo '<table class="width100" cellspacing="1">';
    echo '<tr>';
    $t_status_array = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
    $t_status_names = MantisEnum::getAssocArrayIndexedByValues(lang_get('status_enum_string'));
    $enum_count = count($t_status_array);
    # read through the list and eliminate unused ones for the selected project
    # assumes that all status are are in the enum array
    $t_workflow = config_get('status_enum_workflow');
    if (!empty($t_workflow)) {
        foreach ($t_status_array as $t_status => $t_name) {
            if (!isset($t_workflow[$t_status])) {
                # drop elements that are not in the workflow
                unset($t_status_array[$t_status]);
            }
        }
    }
    # draw the status bar
    $width = (int) (100 / count($t_status_array));
    foreach ($t_status_array as $t_status => $t_name) {
        $t_val = isset($t_status_names[$t_status]) ? $t_status_names[$t_status] : $t_status_array[$t_status];
        $t_color = get_status_color($t_status);
        echo "<td class=\"small-caption\" width=\"{$width}%\" bgcolor=\"{$t_color}\">{$t_val}</td>";
    }
    echo '</tr>';
    echo '</table>';
    if (ON == config_get('status_percentage_legend')) {
        html_status_percentage_legend();
    }
}
Beispiel #12
0
/**
 * Print the color legend for the status colors at the requested position
 * @param int  $p_display_position   STATUS_LEGEND_POSITION_TOP or STATUS_LEGEND_POSITION_BOTTOM
 * @param bool $p_restrict_by_filter If true, only display status visible in current filter
 * @return void
 */
function html_status_legend($p_display_position, $p_restrict_by_filter = false)
{
    if ($p_restrict_by_filter) {
        # Don't show the legend if only one status is selected by the current filter
        $t_current_filter = current_user_get_bug_filter();
        if ($t_current_filter === false) {
            $t_current_filter = filter_get_default();
        }
        $t_simple_filter = $t_current_filter['_view_type'] == 'simple';
        if ($t_simple_filter) {
            if (!filter_field_is_any($t_current_filter[FILTER_PROPERTY_STATUS][0])) {
                return;
            }
        }
    }
    $t_status_array = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
    $t_status_names = MantisEnum::getAssocArrayIndexedByValues(lang_get('status_enum_string'));
    # read through the list and eliminate unused ones for the selected project
    # assumes that all status are are in the enum array
    $t_workflow = config_get('status_enum_workflow');
    if (!empty($t_workflow)) {
        foreach ($t_status_array as $t_status => $t_name) {
            if (!isset($t_workflow[$t_status])) {
                # drop elements that are not in the workflow
                unset($t_status_array[$t_status]);
            }
        }
    }
    if ($p_restrict_by_filter) {
        # Remove status values that won't appear as a result of the current filter
        foreach ($t_status_array as $t_status => $t_name) {
            if ($t_simple_filter) {
                if (!filter_field_is_none($t_current_filter[FILTER_PROPERTY_HIDE_STATUS][0]) && $t_status >= $t_current_filter[FILTER_PROPERTY_HIDE_STATUS][0]) {
                    unset($t_status_array[$t_status]);
                }
            } else {
                if (!in_array(META_FILTER_ANY, $t_current_filter[FILTER_PROPERTY_STATUS]) && !in_array($t_status, $t_current_filter[FILTER_PROPERTY_STATUS])) {
                    unset($t_status_array[$t_status]);
                }
            }
        }
        # If there aren't at least two statuses showable by the current filter,
        # don't draw the status bar
        if (count($t_status_array) <= 1) {
            return;
        }
    }
    # Display the legend
    $t_legend_position = config_get('status_legend_position') & $p_display_position;
    if (STATUS_LEGEND_POSITION_NONE != $t_legend_position) {
        echo '<br />';
        echo '<table class="status-legend width100" cellspacing="1">';
        echo '<tr>';
        # draw the status bar
        foreach ($t_status_array as $t_status => $t_name) {
            $t_val = isset($t_status_names[$t_status]) ? $t_status_names[$t_status] : $t_status_array[$t_status];
            echo '<td class="small-caption status-legend-width ' . html_get_status_css_class($t_status) . '">' . $t_val . '</td>';
        }
        echo '</tr>';
        echo '</table>';
        if (ON == config_get('status_percentage_legend')) {
            html_status_percentage_legend();
        }
    }
    if (STATUS_LEGEND_POSITION_TOP == $t_legend_position) {
        echo '<br />';
    }
}
Beispiel #13
0
 /**
  * Checks if the specified enum string contains the specified value.
  *
  * @param string  $p_enum_string The enumeration string.
  * @param integer $p_value       The value to check.
  * @return boolean true if found, false otherwise.
  */
 public static function hasValue($p_enum_string, $p_value)
 {
     $t_assoc_array = MantisEnum::getAssocArrayIndexedByValues($p_enum_string);
     $t_value_as_integer = (int) $p_value;
     return isset($t_assoc_array[$t_value_as_integer]);
 }
Beispiel #14
0
/**
 * Parse a workflow into a graph-like array of workflow transitions.
 * @param array $p_enum_workflow The workflow enumeration to parse.
 * @return array The parsed workflow graph.
 */
function workflow_parse(array $p_enum_workflow)
{
    $t_status_arr = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
    # If workflow is not set, defaults to array(), which means that all transitions are valid
    if (!is_array($p_enum_workflow)) {
        $p_enum_workflow = array();
    }
    # If any status row is missing, it defaults to all transitions
    foreach ($t_status_arr as $t_status => $t_label) {
        if (!isset($p_enum_workflow[$t_status])) {
            $t_temp_workflow = array();
            foreach ($t_status_arr as $t_next => $t_next_label) {
                if ($t_status != $t_next) {
                    $t_temp_workflow[] = $t_next . ':' . $t_next_label;
                }
            }
            $p_enum_workflow[$t_status] = implode(',', $t_temp_workflow);
        }
    }
    $t_entry = array();
    $t_exit = array();
    # prepopulate new bug state (bugs go from nothing to here)
    $t_submit_status_array = config_get('bug_submit_status');
    $t_new_label = MantisEnum::getLabel(lang_get('status_enum_string'), config_get('bug_submit_status'));
    if (is_array($t_submit_status_array)) {
        # @@@ (thraxisp) this is not implemented in bug_api.php
        foreach ($t_submit_status_array as $t_access => $t_status) {
            $t_entry[$t_status][0] = $t_new_label;
            $t_exit[0][$t_status] = $t_new_label;
        }
    } else {
        $t_status = $t_submit_status_array;
        $t_entry[$t_status][0] = $t_new_label;
        $t_exit[0][$t_status] = $t_new_label;
    }
    # add user defined arcs
    $t_default = array();
    foreach ($t_status_arr as $t_status => $t_status_label) {
        $t_exit[$t_status] = array();
        if (isset($p_enum_workflow[$t_status])) {
            $t_next_arr = MantisEnum::getAssocArrayIndexedByValues($p_enum_workflow[$t_status]);
            foreach ($t_next_arr as $t_next => $t_next_label) {
                if (!isset($t_default[$t_status])) {
                    $t_default[$t_status] = $t_next;
                }
                $t_exit[$t_status][$t_next] = '';
                $t_entry[$t_next][$t_status] = '';
            }
        }
        if (!isset($t_entry[$t_status])) {
            $t_entry[$t_status] = array();
        }
    }
    return array('entry' => $t_entry, 'exit' => $t_exit, 'default' => $t_default);
}
Beispiel #15
0
/**
 * Function which gives the absolute values according to the status (opened/closed/resolved)
 *
 * @param string $p_enum_string Enumeration string.
 * @param string $p_enum        Enumeration field.
 * @return array
 */
function enum_bug_group($p_enum_string, $p_enum)
{
    $t_project_id = helper_get_current_project();
    $t_user_id = auth_get_current_user_id();
    $t_res_val = config_get('bug_resolved_status_threshold');
    $t_clo_val = config_get('bug_closed_status_threshold');
    $t_specific_where = ' AND ' . helper_project_specific_where($t_project_id, $t_user_id);
    if (!db_field_exists($p_enum, db_get_table('bug'))) {
        trigger_error(ERROR_DB_FIELD_NOT_FOUND, ERROR);
    }
    $t_array_indexed_by_enum_values = MantisEnum::getAssocArrayIndexedByValues($p_enum_string);
    foreach ($t_array_indexed_by_enum_values as $t_value => $t_label) {
        # Calculates the number of bugs opened and puts the results in a table
        $t_query = 'SELECT COUNT(*) FROM {bug}
					WHERE ' . $p_enum . '=' . db_param() . ' AND
						status<' . db_param() . ' ' . $t_specific_where;
        $t_result2 = db_query($t_query, array($t_value, $t_res_val));
        $t_metrics['open'][$t_label] = db_result($t_result2, 0, 0);
        # Calculates the number of bugs closed and puts the results in a table
        $t_query = 'SELECT COUNT(*) FROM {bug}
					WHERE ' . $p_enum . '=' . db_param() . ' AND
						status>=' . db_param() . ' ' . $t_specific_where;
        $t_result2 = db_query($t_query, array($t_value, $t_clo_val));
        $t_metrics['closed'][$t_label] = db_result($t_result2, 0, 0);
        # Calculates the number of bugs resolved and puts the results in a table
        $t_query = 'SELECT COUNT(*) FROM {bug}
					WHERE ' . $p_enum . '=' . db_param() . ' AND
						status>=' . db_param() . ' AND
						status<' . db_param() . ' ' . $t_specific_where;
        $t_result2 = db_query($t_query, array($t_value, $t_res_val, $t_clo_val));
        $t_metrics['resolved'][$t_label] = db_result($t_result2, 0, 0);
    }
    return $t_metrics;
}
Beispiel #16
0
 * should only be known internally to the server.
 */
/**
 *	@todo Modify to run sections only on certain pages.
 *	eg. status colors are only necessary on a few pages.(my view, view all bugs, bug view, etc. )
 *	other pages may need to include dynamic css styles as well
 */
$t_referer_page = basename(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_PATH));
switch ($t_referer_page) {
    case 'login_page.php':
    case 'signup_page.php':
    case 'lost_pwd_page.php':
    case 'account_update.php':
        # We don't need custom status colors on login page, and this is
        # actually causing an error since we're not authenticated yet.
        exit;
}
$t_status_string = config_get('status_enum_string');
$t_statuses = MantisEnum::getAssocArrayIndexedByValues($t_status_string);
$t_colors = config_get('status_colors');
$t_color_count = count($t_colors);
$t_color_width = $t_color_count > 0 ? round(100 / $t_color_count) : 0;
$t_status_percents = get_percentage_by_status();
foreach ($t_statuses as $t_id => $t_label) {
    if (array_key_exists($t_label, $t_colors)) {
        echo ".{$t_label}-color { background-color: {$t_colors[$t_label]}; width: {$t_color_width}%; }\n";
    }
    if (array_key_exists($t_id, $t_status_percents)) {
        echo ".{$t_label}-percentage { width: {$t_status_percents[$t_id]}%; }\n";
    }
}
/**
 * remark about issues, where last update is older than configured threshold
 *
 * @param $data_row
 * @param $print
 * @param $group_index
 */
function remark_old_issues($data_row, $print, $group_index)
{
    $user_id = $data_row['user_id'];
    $assigned_project_id = $data_row['assigned_project_id'];
    $target_version_id = $data_row['target_version_id'];
    $target_version = '';
    if (strlen($target_version_id) > 0) {
        $target_version = version_get_field($target_version_id, 'version');
    }
    for ($stat_index = 1; $stat_index <= userprojectapi::get_stat_count(); $stat_index++) {
        $stat_issue_age_threshold = plugin_config_get('IAGThreshold' . $stat_index);
        if ($assigned_project_id == null) {
            continue;
        }
        $stat_ignore_status = plugin_config_get('CStatIgn' . $stat_index);
        $stat_status_id = plugin_config_get('CStatSelect' . $stat_index);
        $databaseapi = new databaseapi();
        $stat_issue_ids = $databaseapi->get_issues_by_user_project_version_status($user_id, $assigned_project_id, $target_version, $stat_status_id, $stat_ignore_status, $group_index);
        if (!empty($stat_issue_ids)) {
            $stat_time_difference = userprojectapi::calculate_time_difference($stat_issue_ids)[0];
            $stat_oldest_issue_id = userprojectapi::calculate_time_difference($stat_issue_ids)[1];
            if ($stat_time_difference > $stat_issue_age_threshold && !$print) {
                if ($stat_ignore_status == OFF || $group_index == 3) {
                    $stat_enum = MantisEnum::getAssocArrayIndexedByValues(lang_get('status_enum_string'));
                    $filter_string = '<a href="search.php?project_id=' . $assigned_project_id . '&amp;search=' . $stat_oldest_issue_id . '&amp;status_id=' . $stat_status_id;
                    if ($group_index != 3) {
                        $filter_string .= '&amp;handler_id=' . userprojectapi::get_link_user_id($user_id);
                    }
                    $filter_string .= '&amp;sticky_issues=on' . '&amp;target_version=' . $target_version . '&amp;sortby=last_updated' . '&amp;dir=DESC' . '&amp;hide_status_id=-2' . '&amp;match_type=0">';
                    echo $filter_string;
                    echo '"' . $stat_enum[$stat_status_id] . '"' . ' ' . plugin_lang_get('remark_since') . ' ' . $stat_time_difference . ' ' . plugin_lang_get('remark_day');
                    echo '<br/>' . PHP_EOL;
                    echo '</a>';
                }
            }
        }
    }
}
Beispiel #18
0
/**
 * Print the color legend for the status colors
 * @param string
 * @return null
 */
function html_status_legend()
{
    # Don't show the legend if only one status is selected by the current filter
    $t_current_filter = current_user_get_bug_filter();
    if ($t_current_filter === false) {
        $t_current_filter = filter_get_default();
    }
    $t_simple_filter = $t_current_filter['_view_type'] == 'simple';
    if ($t_simple_filter) {
        if (!filter_field_is_any($t_current_filter[FILTER_PROPERTY_STATUS][0])) {
            return null;
        }
    }
    $t_status_array = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
    $t_status_names = MantisEnum::getAssocArrayIndexedByValues(lang_get('status_enum_string'));
    $enum_count = count($t_status_array);
    # read through the list and eliminate unused ones for the selected project
    # assumes that all status are are in the enum array
    $t_workflow = config_get('status_enum_workflow');
    if (!empty($t_workflow)) {
        foreach ($t_status_array as $t_status => $t_name) {
            if (!isset($t_workflow[$t_status])) {
                # drop elements that are not in the workflow
                unset($t_status_array[$t_status]);
            }
        }
    }
    # Remove status values that won't appear as a result of the current filter
    foreach ($t_status_array as $t_status => $t_name) {
        if ($t_simple_filter) {
            if (!filter_field_is_none($t_current_filter[FILTER_PROPERTY_HIDE_STATUS][0]) && $t_status >= $t_current_filter[FILTER_PROPERTY_HIDE_STATUS][0]) {
                unset($t_status_array[$t_status]);
            }
        } else {
            if (!in_array(META_FILTER_ANY, $t_current_filter[FILTER_PROPERTY_STATUS]) && !in_array($t_status, $t_current_filter[FILTER_PROPERTY_STATUS])) {
                unset($t_status_array[$t_status]);
            }
        }
    }
    # If there aren't at least two statuses showable by the current filter,
    # don't draw the status bar
    if (count($t_status_array) <= 1) {
        return null;
    }
    echo '<br />';
    echo '<table class="status-legend width100" cellspacing="1">';
    echo '<tr>';
    # draw the status bar
    $width = (int) (100 / count($t_status_array));
    $t_status_enum_string = config_get('status_enum_string');
    foreach ($t_status_array as $t_status => $t_name) {
        $t_val = $t_status_names[$t_status];
        $t_status_label = MantisEnum::getLabel($t_status_enum_string, $t_status);
        echo "<td class=\"small-caption {$t_status_label}-color\">{$t_val}</td>";
    }
    echo '</tr>';
    echo '</table>';
    if (ON == config_get('status_percentage_legend')) {
        html_status_percentage_legend();
    }
}
Beispiel #19
0
/**
 * Get the list of supported email actions.
 *
 * @return array List of actions
 */
function email_get_actions()
{
    $t_actions = array('updated', 'owner', 'reopened', 'deleted', 'bugnote', 'relation');
    if (config_get('enable_sponsorship') == ON) {
        $t_actions[] = 'sponsor';
    }
    $t_statuses = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
    ksort($t_statuses);
    reset($t_statuses);
    foreach ($t_statuses as $t_label) {
        $t_actions[] = $t_label;
    }
    return $t_actions;
}
Beispiel #20
0
function enum_bug_group($p_enum_string, $p_enum)
{
    $t_bug_table = db_get_table('bug');
    $t_project_id = helper_get_current_project();
    $t_bug_table = db_get_table('bug');
    $t_user_id = auth_get_current_user_id();
    $t_res_val = config_get('bug_resolved_status_threshold');
    $t_clo_val = config_get('bug_closed_status_threshold');
    $specific_where = " AND " . helper_project_specific_where($t_project_id, $t_user_id);
    $t_array_indexed_by_enum_values = MantisEnum::getAssocArrayIndexedByValues($p_enum_string);
    $enum_count = count($t_array_indexed_by_enum_values);
    foreach ($t_array_indexed_by_enum_values as $t_value => $t_label) {
        # Calculates the number of bugs opened and puts the results in a table
        $query = "SELECT COUNT(*)\n\t\t\t\t\tFROM {$t_bug_table}\n\t\t\t\t\tWHERE {$p_enum}='{$t_value}' AND\n\t\t\t\t\t\tstatus<'{$t_res_val}' {$specific_where}";
        $result2 = db_query($query);
        $t_metrics['open'][$t_label] = db_result($result2, 0, 0);
        # Calculates the number of bugs closed and puts the results in a table
        $query = "SELECT COUNT(*)\n\t\t\t\t\tFROM {$t_bug_table}\n\t\t\t\t\tWHERE {$p_enum}='{$t_value}' AND\n\t\t\t\t\t\tstatus='{$t_clo_val}' {$specific_where}";
        $result2 = db_query($query);
        $t_metrics['closed'][$t_label] = db_result($result2, 0, 0);
        # Calculates the number of bugs resolved and puts the results in a table
        $query = "SELECT COUNT(*)\n\t\t\t\t\tFROM {$t_bug_table}\n\t\t\t\t\tWHERE {$p_enum}='{$t_value}' AND\n\t\t\t\t\t\tstatus>='{$t_res_val}'  AND\n\t\t\t\t\t\tstatus<'{$t_clo_val}' {$specific_where}";
        $result2 = db_query($query);
        $t_metrics['resolved'][$t_label] = db_result($result2, 0, 0);
    }
    # ## end for
    return $t_metrics;
}
Beispiel #21
0
function enum_bug_group($p_enum_string, $p_enum)
{
    $t_bug_table = db_get_table('mantis_bug_table');
    $t_project_id = helper_get_current_project();
    $t_bug_table = db_get_table('mantis_bug_table');
    $t_user_id = auth_get_current_user_id();
    $t_res_val = config_get('bug_resolved_status_threshold');
    $t_clo_val = config_get('bug_closed_status_threshold');
    $specific_where = " AND " . helper_project_specific_where($t_project_id, $t_user_id);
    if (!db_field_exists($p_enum, $t_bug_table)) {
        trigger_error(ERROR_DB_FIELD_NOT_FOUND, ERROR);
    }
    $t_array_indexed_by_enum_values = MantisEnum::getAssocArrayIndexedByValues($p_enum_string);
    $enum_count = count($t_array_indexed_by_enum_values);
    foreach ($t_array_indexed_by_enum_values as $t_value => $t_label) {
        # Calculates the number of bugs opened and puts the results in a table
        $query = "SELECT COUNT(*)\n\t\t\t\t\tFROM {$t_bug_table}\n\t\t\t\t\tWHERE {$p_enum}=" . db_param() . " AND\n\t\t\t\t\t\tstatus<" . db_param() . " {$specific_where}";
        $result2 = db_query_bound($query, array($t_value, $t_res_val));
        $t_metrics['open'][$t_label] = db_result($result2, 0, 0);
        # Calculates the number of bugs closed and puts the results in a table
        $query = "SELECT COUNT(*)\n\t\t\t\t\tFROM {$t_bug_table}\n\t\t\t\t\tWHERE {$p_enum}=" . db_param() . " AND\n\t\t\t\t\t\tstatus>=" . db_param() . " {$specific_where}";
        $result2 = db_query_bound($query, array($t_value, $t_clo_val));
        $t_metrics['closed'][$t_label] = db_result($result2, 0, 0);
        # Calculates the number of bugs resolved and puts the results in a table
        $query = "SELECT COUNT(*)\n\t\t\t\t\tFROM {$t_bug_table}\n\t\t\t\t\tWHERE {$p_enum}=" . db_param() . " AND\n\t\t\t\t\t\tstatus>=" . db_param() . " AND\n\t\t\t\t\t\tstatus<" . db_param() . " {$specific_where}";
        $result2 = db_query_bound($query, array($t_value, $t_res_val, $t_clo_val));
        $t_metrics['resolved'][$t_label] = db_result($result2, 0, 0);
    }
    # ## end for
    return $t_metrics;
}
 if (ALL_PROJECTS != $t_project) {
     echo '<span class="color-project">' . lang_get('colour_project') . '</span><br />';
 }
 echo '<span class="color-global">' . lang_get('colour_global') . '</span></p>';
 get_section_begin_for_email(lang_get('email_notification'));
 #		get_capability_row_for_email( lang_get( 'email_on_new' ), 'new' );  # duplicate of status change to 'new'
 get_capability_row_for_email(lang_get('email_on_updated'), 'updated');
 get_capability_row_for_email(lang_get('email_on_assigned'), 'owner');
 get_capability_row_for_email(lang_get('email_on_reopened'), 'reopened');
 get_capability_row_for_email(lang_get('email_on_deleted'), 'deleted');
 get_capability_row_for_email(lang_get('email_on_bugnote_added'), 'bugnote');
 if (config_get('enable_sponsorship') == ON) {
     get_capability_row_for_email(lang_get('email_on_sponsorship_changed'), 'sponsor');
 }
 get_capability_row_for_email(lang_get('email_on_relationship_changed'), 'relation');
 $t_statuses = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
 foreach ($t_statuses as $t_status => $t_label) {
     get_capability_row_for_email(lang_get('status_changed_to') . ' \'' . get_enum_element('status', $t_status) . '\'', $t_label);
 }
 get_section_end_for_email();
 if ($g_can_change_flags || $g_can_change_defaults) {
     echo '<p>' . lang_get('notify_actions_change_access') . "\n";
     echo '<select name="notify_actions_access">' . "\n";
     print_enum_string_option_list('access_levels', config_get_access('notify_flags'));
     echo "\n</select></p>";
     echo '<input type="submit" class="button" value="' . lang_get('change_configuration') . '" />' . "\n";
     echo "</form>\n";
     echo '<div class="right">' . "\n";
     echo '<form id="mail_config_action" method="post" action="manage_config_revert.php">' . "\n";
     echo form_security_field('manage_config_revert') . "\n";
     echo '<input name="revert" type="hidden" value="notify_flags,default_notify_flags" />' . "\n";
function access_row()
{
    global $t_access, $t_can_change_flags, $t_colour_project, $t_colour_global;
    $t_enum_status = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
    $t_file_new = config_get_global('report_bug_threshold');
    $t_global_new = config_get('report_bug_threshold', null, null, ALL_PROJECTS);
    $t_project_new = config_get('report_bug_threshold');
    $t_file_set = config_get_global('set_status_threshold');
    foreach ($t_enum_status as $t_status => $t_status_label) {
        if (!isset($t_file_set[$t_status])) {
            $t_file_set[$t_status] = config_get_global('update_bug_status_threshold');
        }
    }
    $t_global_set = config_get('set_status_threshold', null, null, ALL_PROJECTS);
    foreach ($t_enum_status as $t_status => $t_status_label) {
        if (!isset($t_file_set[$t_status])) {
            $t_file_set[$t_status] = config_get('update_bug_status_threshold', null, null, ALL_PROJECTS);
        }
    }
    $t_project_set = config_get('set_status_threshold');
    foreach ($t_enum_status as $t_status => $t_status_label) {
        if (!isset($t_file_set[$t_status])) {
            $t_file_set[$t_status] = config_get('update_bug_status_threshold');
        }
    }
    foreach ($t_enum_status as $t_status => $t_status_label) {
        echo '<tr ' . helper_alternate_class() . '><td width="30%">' . string_no_break(MantisEnum::getLabel(lang_get('status_enum_string'), $t_status)) . '</td>';
        if (config_get('bug_submit_status') == $t_status) {
            $t_level = $t_project_new;
            $t_can_change = $t_access >= config_get_access('report_bug_threshold');
            $t_colour = '';
            if ($t_global_new != $t_file_new) {
                $t_colour = ' bgcolor="' . $t_colour_global . '" ';
                # all projects override
                if ($t_can_change) {
                    set_overrides('report_bug_threshold');
                }
            }
            if ($t_project_new != $t_global_new) {
                $t_colour = ' bgcolor="' . $t_colour_project . '" ';
                # project overrides
                if ($t_can_change) {
                    set_overrides('report_bug_threshold');
                }
            }
        } else {
            $t_level = isset($t_project_set[$t_status]) ? $t_project_set[$t_status] : 0;
            $t_level_global = isset($t_global_set[$t_status]) ? $t_global_set[$t_status] : 0;
            $t_level_file = isset($t_file_set[$t_status]) ? $t_file_set[$t_status] : 0;
            $t_can_change = $t_access >= config_get_access('set_status_threshold');
            $t_colour = '';
            if ($t_level_global != $t_level_file) {
                $t_colour = ' bgcolor="' . $t_colour_global . '" ';
                # all projects override
                if ($t_can_change) {
                    set_overrides('set_status_threshold');
                }
            }
            if ($t_level != $t_level_global) {
                $t_colour = ' bgcolor="' . $t_colour_project . '" ';
                # project overrides
                if ($t_can_change) {
                    set_overrides('set_status_threshold');
                }
            }
        }
        if ($t_can_change) {
            echo '<td' . $t_colour . '><select name="access_change_' . $t_status . '">';
            print_enum_string_option_list('access_levels', $t_level);
            echo '</select> </td>';
            $t_can_change_flags = true;
        } else {
            echo '<td class="center"' . $t_colour . '>' . MantisEnum::getLabel(lang_get('access_levels_enum_string'), $t_level) . '</td>';
        }
        echo '</tr>' . "\n";
    }
}
Beispiel #24
0
    // no data to graph
    exit;
}
$t_bug_table = db_get_table('mantis_bug_table');
$t_bug_hist_table = db_get_table('mantis_bug_history_table');
$t_marker = array();
$t_data = array();
$t_ptr = 0;
$t_end = $t_interval->get_end_timestamp();
$t_start = $t_interval->get_start_timestamp();
if ($t_end == false || $t_start == false) {
    return;
}
// grab all status levels
$t_status_arr = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
$t_status_labels = MantisEnum::getAssocArrayIndexedByValues(lang_get('status_enum_string'));
$t_default_bug_status = config_get('bug_submit_status');
$t_bug = array();
$t_view_status = array();
// walk through all issues and grab their status for 'now'
$t_marker[$t_ptr] = time();
foreach ($rows as $t_row) {
    if (isset($t_data[$t_ptr][$t_row->status])) {
        $t_data[$t_ptr][$t_row->status]++;
    } else {
        $t_data[$t_ptr][$t_row->status] = 1;
        $t_view_status[$t_row->status] = isset($t_status_arr[$t_row->status]) ? $t_status_arr[$t_row->status] : '@' . $t_row->status . '@';
    }
    $t_bug[] = $t_row->id;
}
// get the history for these bugs over the interval required to offset the data
Beispiel #25
0
/**
 * Print the color legend for the status colors
 * @param string
 * @return null
 */
function gantt_chart_legend($p_show = true)
{
    $graph = new Graph(800, 40, 'auto');
    $graph->SetScale('textlin');
    $graph->SetMarginColor('white');
    $graph->SetBox(false);
    $graph->ygrid->SetFill(false);
    $graph->yaxis->Hide(true);
    $graph->xaxis->Hide(true);
    $graph->yaxis->HideLine(true);
    $graph->yaxis->HideTicks(true, true);
    $t_bplot_array = array();
    $t_status_array = MantisEnum::getAssocArrayIndexedByValues(config_get('status_enum_string'));
    $t_status_names = MantisEnum::getAssocArrayIndexedByValues(lang_get('status_enum_string'));
    $enum_count = count($t_status_array);
    # read through the list and eliminate unused ones for the selected project
    # assumes that all status are are in the enum array
    $t_workflow = config_get('status_enum_workflow');
    if (!empty($t_workflow)) {
        foreach ($t_status_array as $t_status => $t_name) {
            if (!isset($t_workflow[$t_status])) {
                # drop elements that are not in the workflow
                unset($t_status_array[$t_status]);
            }
        }
    }
    # draw the status bar
    $width = (int) (100 / count($t_status_array));
    foreach ($t_status_array as $t_status => $t_name) {
        $t_val = $t_status_names[$t_status];
        $t_color = get_status_color($t_status);
        // Create the bars
        $lplot = new LinePlot(array(0));
        $lplot->SetFillColor($t_color);
        //Legend
        $lplot->SetLegend($t_val);
        $graph->Add($lplot);
    }
    $graph->legend->SetFrameWeight(0);
    $graph->legend->SetColumns($enum_count);
    $graph->legend->SetColor('#4E4E4E', '#000000');
    $graph->legend->SetAbsPos(2, 2, 'left', 'top');
    $graph->legend->SetFont(graph_get_font(), FS_NORMAL, 8);
    $graph->legend->SetHColMargin(2);
    //    $graph->title->Set("Legend");
    if ($p_show) {
        // Display the graph
        $graph->Stroke();
    } else {
        // Return the graph
        return $graph;
    }
}