Пример #1
0
require_api('config_api.php');
require_api('constant_inc.php');
require_api('current_user_api.php');
require_api('custom_field_api.php');
require_api('error_api.php');
require_api('filter_api.php');
require_api('filter_constants_inc.php');
require_api('gpc_api.php');
require_api('helper_api.php');
auth_ensure_user_authenticated();
compress_enable();
global $t_filter;
global $t_select_modifier;
$t_filter = current_user_get_bug_filter();
if ($t_filter === false) {
    $t_filter = filter_get_default();
}
$t_project_id = helper_get_current_project();
$t_current_user_access_level = current_user_get_access_level();
$t_accessible_custom_fields_ids = array();
$t_accessible_custom_fields_names = array();
$t_accessible_custom_fields_types = array();
$t_accessible_custom_fields_values = array();
$t_filter_cols = 7;
$t_custom_cols = 1;
$t_custom_rows = 0;
if (ON == config_get('filter_by_custom_fields')) {
    $t_custom_cols = config_get('filter_custom_fields_per_row');
    $t_custom_fields = custom_field_get_linked_ids($t_project_id);
    foreach ($t_custom_fields as $t_cfid) {
        $t_field_info = custom_field_cache_row($t_cfid, true);
Пример #2
0
/**
 * Create a filter for getting issues monitored by the specified project and user.
 * @param integer $p_project_id The project id or ALL_PROJECTS.
 * @param integer $p_user_id    The user id.
 * @return array a valid filter.
 */
function filter_create_monitored_by($p_project_id, $p_user_id)
{
    $t_filter = filter_get_default();
    if ($p_user_id == 0) {
        $t_filter[FILTER_PROPERTY_MONITOR_USER_ID] = array('0' => META_FILTER_NONE);
    } else {
        $t_filter[FILTER_PROPERTY_MONITOR_USER_ID] = array('0' => $p_user_id);
    }
    if ($p_project_id != ALL_PROJECTS) {
        $t_filter[FILTER_PROPERTY_PROJECT_ID] = array('0' => $p_project_id);
    }
    return filter_ensure_valid_filter($t_filter);
}
Пример #3
0
/**
 * return the bug filter parameters for the specified user
 *
 * @param integer $p_user_id    A valid user identifier.
 * @param integer $p_project_id A valid project identifier.
 * @return array The user filter, or default filter if not valid.
 */
function user_get_bug_filter($p_user_id, $p_project_id = null)
{
    if (null === $p_project_id) {
        $t_project_id = helper_get_current_project();
    } else {
        $t_project_id = $p_project_id;
    }
    $t_view_all_cookie_id = filter_db_get_project_current($t_project_id, $p_user_id);
    $t_view_all_cookie = filter_db_get_filter($t_view_all_cookie_id, $p_user_id);
    $t_cookie_detail = explode('#', $t_view_all_cookie, 2);
    if (!isset($t_cookie_detail[1])) {
        return filter_get_default();
    }
    $t_filter = json_decode($t_cookie_detail[1], true);
    $t_filter = filter_ensure_valid_filter($t_filter);
    return $t_filter;
}
Пример #4
0
# // 2002-10-02T10:00:00-0500 -> // 2002-10-02T10:00:00-05:00
$base = utf8_substr($base, 0, 22) . ':' . utf8_substr($base, -2);
$rssfile->addSYdata($period, $frequency, $base);
$t_page_number = 1;
$t_issues_per_page = 25;
$t_page_count = 0;
$t_issues_count = 0;
$t_project_id = $f_project_id;
if ($f_username !== null) {
    $t_user_id = user_get_id_by_name($f_username);
} else {
    $t_user_id = user_get_id_by_name(config_get('anonymous_account'));
}
$t_show_sticky = null;
if ($f_filter_id == 0) {
    $t_custom_filter = filter_get_default();
    $t_custom_filter['sort'] = $c_sort_field;
} else {
    # null will be returned if the user doesn't have access right to access the filter.
    $t_custom_filter = filter_db_get_filter($f_filter_id, $t_user_id);
    if (null === $t_custom_filter) {
        access_denied();
    }
    $t_custom_filter = filter_deserialize($t_custom_filter);
}
$t_issues = filter_get_bug_rows($t_page_number, $t_issues_per_page, $t_page_count, $t_issues_count, $t_custom_filter, $t_project_id, $t_user_id, $t_show_sticky);
$t_issues_count = count($t_issues);
# Loop through results
for ($i = 0; $i < $t_issues_count; $i++) {
    $t_bug = $t_issues[$i];
    $about = $link = $t_path . "view.php?id=" . $t_bug->id;
Пример #5
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();
    }
}
Пример #6
0
/**
* Returns the issue filter parameters for the current user
*
* @param integer $p_project_id Project id. This argument is only used if a 'filter' string is not passed via the web request.
*                              The default value is null meaning return the current filter for user's current project
                               if a filter string is not supplied.
* @return array User filter, if not set, then default filter.
* @access public
*/
function current_user_get_bug_filter($p_project_id = null)
{
    $f_filter_string = gpc_get_string('filter', '');
    $t_filter = '';
    if (!is_blank($f_filter_string)) {
        if (is_numeric($f_filter_string)) {
            $t_token = token_get_value(TOKEN_FILTER);
            if (null != $t_token) {
                $t_filter = json_decode($t_token, true);
            }
        } else {
            $t_filter = json_decode($f_filter_string, true);
        }
        $t_filter = filter_ensure_valid_filter($t_filter);
    } else {
        if (!filter_is_cookie_valid()) {
            $t_filter = filter_get_default();
        } else {
            $t_user_id = auth_get_current_user_id();
            $t_filter = user_get_bug_filter($t_user_id, $p_project_id);
        }
    }
    return $t_filter;
}
Пример #7
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 />';
    }
}