Example #1
0
/**
 * Make sure that our filters are entirely correct and complete (it is possible that they are not).
 * We need to do this to cover cases where we don't have complete control over the filters given.
 * @param array $p_filter_arr A Filter definition.
 * @return array
 * @todo function needs to be abstracted
 */
function filter_ensure_valid_filter(array $p_filter_arr)
{
    # extend current filter to add information passed via POST
    if (!isset($p_filter_arr['_version'])) {
        $p_filter_arr['_version'] = FILTER_VERSION;
    }
    $t_cookie_vers = (int) substr($p_filter_arr['_version'], 1);
    if (substr(FILTER_VERSION, 1) > $t_cookie_vers) {
        # if the version is old, update it
        $p_filter_arr['_version'] = FILTER_VERSION;
    }
    if (!isset($p_filter_arr['_view_type'])) {
        $p_filter_arr['_view_type'] = gpc_get_string('view_type', 'simple');
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_ISSUES_PER_PAGE])) {
        $p_filter_arr[FILTER_PROPERTY_ISSUES_PER_PAGE] = gpc_get_int(FILTER_PROPERTY_ISSUES_PER_PAGE, config_get('default_limit_view'));
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_HIGHLIGHT_CHANGED])) {
        $p_filter_arr[FILTER_PROPERTY_HIGHLIGHT_CHANGED] = config_get('default_show_changed');
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_STICKY])) {
        $p_filter_arr[FILTER_PROPERTY_STICKY] = gpc_string_to_bool(config_get('show_sticky_issues'));
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_SORT_FIELD_NAME])) {
        $p_filter_arr[FILTER_PROPERTY_SORT_FIELD_NAME] = 'last_updated';
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_SORT_DIRECTION])) {
        $p_filter_arr[FILTER_PROPERTY_SORT_DIRECTION] = 'DESC';
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_PLATFORM])) {
        $p_filter_arr[FILTER_PROPERTY_PLATFORM] = array(0 => (string) META_FILTER_ANY);
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_OS])) {
        $p_filter_arr[FILTER_PROPERTY_OS] = array(0 => (string) META_FILTER_ANY);
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_OS_BUILD])) {
        $p_filter_arr[FILTER_PROPERTY_OS_BUILD] = array(0 => (string) META_FILTER_ANY);
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_PROJECT_ID])) {
        $p_filter_arr[FILTER_PROPERTY_PROJECT_ID] = array(0 => META_FILTER_CURRENT);
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_START_MONTH])) {
        $p_filter_arr[FILTER_PROPERTY_START_MONTH] = gpc_get_string(FILTER_PROPERTY_START_MONTH, date('m'));
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_START_DAY])) {
        $p_filter_arr[FILTER_PROPERTY_START_DAY] = gpc_get_string(FILTER_PROPERTY_START_DAY, 1);
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_START_YEAR])) {
        $p_filter_arr[FILTER_PROPERTY_START_YEAR] = gpc_get_string(FILTER_PROPERTY_START_YEAR, date('Y'));
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_END_MONTH])) {
        $p_filter_arr[FILTER_PROPERTY_END_MONTH] = gpc_get_string(FILTER_PROPERTY_END_MONTH, date('m'));
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_END_DAY])) {
        $p_filter_arr[FILTER_PROPERTY_END_DAY] = gpc_get_string(FILTER_PROPERTY_END_DAY, date('d'));
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_END_YEAR])) {
        $p_filter_arr[FILTER_PROPERTY_END_YEAR] = gpc_get_string(FILTER_PROPERTY_END_YEAR, date('Y'));
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_SEARCH])) {
        $p_filter_arr[FILTER_PROPERTY_SEARCH] = '';
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_FILTER_BY_DATE])) {
        $p_filter_arr[FILTER_PROPERTY_FILTER_BY_DATE] = gpc_get_bool(FILTER_PROPERTY_FILTER_BY_DATE, false);
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_VIEW_STATE])) {
        $p_filter_arr[FILTER_PROPERTY_VIEW_STATE] = gpc_get(FILTER_PROPERTY_VIEW_STATE, META_FILTER_ANY);
    } else {
        if (filter_field_is_any($p_filter_arr[FILTER_PROPERTY_VIEW_STATE])) {
            $p_filter_arr[FILTER_PROPERTY_VIEW_STATE] = META_FILTER_ANY;
        }
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_RELATIONSHIP_TYPE])) {
        $p_filter_arr[FILTER_PROPERTY_RELATIONSHIP_TYPE] = gpc_get_int(FILTER_PROPERTY_RELATIONSHIP_TYPE, -1);
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_RELATIONSHIP_BUG])) {
        $p_filter_arr[FILTER_PROPERTY_RELATIONSHIP_BUG] = gpc_get_int(FILTER_PROPERTY_RELATIONSHIP_BUG, 0);
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_TARGET_VERSION])) {
        $p_filter_arr[FILTER_PROPERTY_TARGET_VERSION] = (string) META_FILTER_ANY;
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_TAG_STRING])) {
        $p_filter_arr[FILTER_PROPERTY_TAG_STRING] = gpc_get_string(FILTER_PROPERTY_TAG_STRING, '');
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_TAG_SELECT])) {
        $p_filter_arr[FILTER_PROPERTY_TAG_SELECT] = gpc_get_string(FILTER_PROPERTY_TAG_SELECT, '');
    }
    if (!isset($p_filter_arr[FILTER_PROPERTY_MATCH_TYPE])) {
        $p_filter_arr[FILTER_PROPERTY_MATCH_TYPE] = gpc_get_int(FILTER_PROPERTY_MATCH_TYPE, FILTER_MATCH_ALL);
    }
    # initialize plugin filters
    $t_plugin_filters = filter_get_plugin_filters();
    foreach ($t_plugin_filters as $t_field_name => $t_filter_object) {
        if (!isset($p_filter_arr[$t_field_name])) {
            switch ($t_filter_object->type) {
                case FILTER_TYPE_STRING:
                    $p_filter_arr[$t_field_name] = gpc_get_string($t_field_name, $t_filter_object->default);
                    break;
                case FILTER_TYPE_INT:
                    $p_filter_arr[$t_field_name] = gpc_get_int($t_field_name, (int) $t_filter_object->default);
                    break;
                case FILTER_TYPE_BOOLEAN:
                    $p_filter_arr[$t_field_name] = gpc_get_bool($t_field_name, (bool) $t_filter_object->default);
                    break;
                case FILTER_TYPE_MULTI_STRING:
                    $p_filter_arr[$t_field_name] = gpc_get_string_array($t_field_name, array(0 => (string) META_FILTER_ANY));
                    break;
                case FILTER_TYPE_MULTI_INT:
                    $p_filter_arr[$t_field_name] = gpc_get_int_array($t_field_name, array(0 => META_FILTER_ANY));
                    break;
                default:
                    $p_filter_arr[$t_field_name] = (string) META_FILTER_ANY;
            }
        }
        if (!$t_filter_object->validate($p_filter_arr[$t_field_name])) {
            $p_filter_arr[$t_field_name] = $t_filter_object->default;
        }
    }
    $t_custom_fields = custom_field_get_ids();
    # @@@ (thraxisp) This should really be the linked ids, but we don't know the project
    $f_custom_fields_data = array();
    if (is_array($t_custom_fields) && count($t_custom_fields) > 0) {
        foreach ($t_custom_fields as $t_cfid) {
            if (is_array(gpc_get('custom_field_' . $t_cfid, null))) {
                $f_custom_fields_data[$t_cfid] = gpc_get_string_array('custom_field_' . $t_cfid, array(META_FILTER_ANY));
            } else {
                $f_custom_fields_data[$t_cfid] = gpc_get_string('custom_field_' . $t_cfid, (string) META_FILTER_ANY);
                $f_custom_fields_data[$t_cfid] = array($f_custom_fields_data[$t_cfid]);
            }
        }
    }
    # validate sorting
    $t_fields = helper_get_columns_to_view();
    $t_n_fields = count($t_fields);
    for ($i = 0; $i < $t_n_fields; $i++) {
        if (isset($t_fields[$i]) && in_array($t_fields[$i], array('selection', 'edit', 'bugnotes_count', 'attachment_count'))) {
            unset($t_fields[$i]);
        }
    }
    # Make sure array is no longer than 2 elements
    $t_sort_fields = explode(',', $p_filter_arr['sort']);
    if (count($t_sort_fields) > 2) {
        $t_sort_fields = array_slice($t_sort_fields, 0, 2);
    }
    # Make sure array is no longer than 2 elements
    $t_dir_fields = explode(',', $p_filter_arr['dir']);
    if (count($t_dir_fields) > 2) {
        $t_dir_fields = array_slice($t_dir_fields, 0, 2);
    }
    # Validate the max of two segments for $t_sort_fields and $t_dir_fields
    for ($i = 0; $i < 2; $i++) {
        if (isset($t_sort_fields[$i])) {
            $t_drop = false;
            $t_sort = $t_sort_fields[$i];
            if (strpos($t_sort, 'custom_') === 0) {
                if (false === custom_field_get_id_from_name(utf8_substr($t_sort, utf8_strlen('custom_')))) {
                    $t_drop = true;
                }
            } else {
                if (!in_array($t_sort, $t_fields)) {
                    $t_drop = true;
                }
            }
            if (!in_array($t_dir_fields[$i], array('ASC', 'DESC'))) {
                $t_drop = true;
            }
            if ($t_drop) {
                unset($t_sort_fields[$i]);
                unset($t_dir_fields[$i]);
            }
        }
    }
    if (count($t_sort_fields) > 0) {
        $p_filter_arr['sort'] = implode(',', $t_sort_fields);
        $p_filter_arr['dir'] = implode(',', $t_dir_fields);
    } else {
        $p_filter_arr['sort'] = 'last_updated';
        $p_filter_arr['dir'] = 'DESC';
    }
    # validate or filter junk from other fields
    $t_multi_select_list = array(FILTER_PROPERTY_CATEGORY_ID => 'string', FILTER_PROPERTY_SEVERITY => 'int', FILTER_PROPERTY_STATUS => 'int', FILTER_PROPERTY_REPORTER_ID => 'int', FILTER_PROPERTY_HANDLER_ID => 'int', FILTER_PROPERTY_NOTE_USER_ID => 'int', FILTER_PROPERTY_RESOLUTION => 'int', FILTER_PROPERTY_PRIORITY => 'int', FILTER_PROPERTY_BUILD => 'string', FILTER_PROPERTY_VERSION => 'string', FILTER_PROPERTY_HIDE_STATUS => 'int', FILTER_PROPERTY_FIXED_IN_VERSION => 'string', FILTER_PROPERTY_TARGET_VERSION => 'string', FILTER_PROPERTY_MONITOR_USER_ID => 'int', FILTER_PROPERTY_PROFILE_ID => 'int');
    foreach ($t_multi_select_list as $t_multi_field_name => $t_multi_field_type) {
        if (!isset($p_filter_arr[$t_multi_field_name])) {
            if (FILTER_PROPERTY_HIDE_STATUS == $t_multi_field_name) {
                $p_filter_arr[$t_multi_field_name] = array(config_get('hide_status_default'));
            } else {
                if ('custom_fields' == $t_multi_field_name) {
                    $p_filter_arr[$t_multi_field_name] = array($f_custom_fields_data);
                } else {
                    $p_filter_arr[$t_multi_field_name] = array(META_FILTER_ANY);
                }
            }
        } else {
            if (!is_array($p_filter_arr[$t_multi_field_name])) {
                $p_filter_arr[$t_multi_field_name] = array($p_filter_arr[$t_multi_field_name]);
            }
            $t_checked_array = array();
            foreach ($p_filter_arr[$t_multi_field_name] as $t_filter_value) {
                $t_filter_value = stripslashes($t_filter_value);
                if ($t_filter_value === 'any' || $t_filter_value === '[any]') {
                    $t_filter_value = META_FILTER_ANY;
                }
                if ($t_filter_value === 'none' || $t_filter_value === '[none]') {
                    $t_filter_value = META_FILTER_NONE;
                }
                if ('string' == $t_multi_field_type) {
                    $t_checked_array[] = $t_filter_value;
                } else {
                    if ('int' == $t_multi_field_type) {
                        $t_checked_array[] = (int) $t_filter_value;
                    } else {
                        if ('array' == $t_multi_field_type) {
                            $t_checked_array[] = $t_filter_value;
                        }
                    }
                }
            }
            $p_filter_arr[$t_multi_field_name] = $t_checked_array;
        }
    }
    if (is_array($t_custom_fields) && count($t_custom_fields) > 0) {
        foreach ($t_custom_fields as $t_cfid) {
            if (!isset($p_filter_arr['custom_fields'][$t_cfid])) {
                $p_filter_arr['custom_fields'][$t_cfid] = array(META_FILTER_ANY);
            } else {
                if (!is_array($p_filter_arr['custom_fields'][$t_cfid])) {
                    $p_filter_arr['custom_fields'][$t_cfid] = array($p_filter_arr['custom_fields'][$t_cfid]);
                }
                $t_checked_array = array();
                foreach ($p_filter_arr['custom_fields'][$t_cfid] as $t_filter_value) {
                    $t_filter_value = stripslashes($t_filter_value);
                    if ($t_filter_value === 'any' || $t_filter_value === '[any]') {
                        $t_filter_value = META_FILTER_ANY;
                    }
                    $t_checked_array[] = $t_filter_value;
                }
                $p_filter_arr['custom_fields'][$t_cfid] = $t_checked_array;
            }
        }
    }
    # all of our filter values are now guaranteed to be there, and correct.
    return $p_filter_arr;
}
Example #2
0
function gpc_get_custom_field($p_var_name, $p_custom_field_type, $p_default = null)
{
    switch ($p_custom_field_type) {
        case CUSTOM_FIELD_TYPE_MULTILIST:
        case CUSTOM_FIELD_TYPE_CHECKBOX:
            $t_values = gpc_get_string_array($p_var_name, $p_default);
            if (null !== $t_values && '' != $t_values) {
                return implode('|', $t_values);
            } else {
                return '';
            }
            break;
        case CUSTOM_FIELD_TYPE_DATE:
            $t_day = gpc_get_int($p_var_name . "_day", 0);
            $t_month = gpc_get_int($p_var_name . "_month", 0);
            $t_year = gpc_get_int($p_var_name . "_year", 0);
            if ($t_year == 0 || $t_month == 0 || $t_day == 0) {
                if ($p_default == null) {
                    return '';
                } else {
                    return $p_default;
                }
            } else {
                return strtotime($t_year . "-" . $t_month . "-" . $t_day);
            }
            break;
        default:
            return gpc_get_string($p_var_name, $p_default);
    }
}
                case CUSTOM_FIELD_DATE_AFTER:
                    $t_start = $t_start_date + $t_one_day - 1;
                    $t_end = 2147483647;
                    // Some time in 2038, max value of a signed int.
                    break;
                case CUSTOM_FIELD_DATE_ONORAFTER:
                    $t_start = $t_start_date;
                    $t_end = 2147483647;
                    // Some time in 2038, max value of a signed int.
                    break;
            }
            $f_custom_fields_data[$t_cfid][1] = $t_start;
            $f_custom_fields_data[$t_cfid][2] = $t_end;
        } else {
            if (is_array(gpc_get('custom_field_' . $t_cfid, null))) {
                $f_custom_fields_data[$t_cfid] = gpc_get_string_array('custom_field_' . $t_cfid, META_FILTER_ANY);
            } else {
                $f_custom_fields_data[$t_cfid] = gpc_get_string('custom_field_' . $t_cfid, META_FILTER_ANY);
                $f_custom_fields_data[$t_cfid] = array($f_custom_fields_data[$t_cfid]);
            }
        }
    }
}
$f_relationship_type = gpc_get_int(FILTER_PROPERTY_RELATIONSHIP_TYPE, -1);
$f_relationship_bug = gpc_get_int(FILTER_PROPERTY_RELATIONSHIP_BUG, 0);
if ($f_temp_filter) {
    $f_type = 1;
}
if ($f_and_not_assigned) {
    $f_and_not_assigned = 'on';
}
Example #4
0
$my_filter[FILTER_PROPERTY_HANDLER_ID] = gpc_get_string_array(FILTER_SEARCH_HANDLER_ID, META_FILTER_ANY);
$my_filter[FILTER_PROPERTY_SEVERITY_ID] = gpc_get_string_array(FILTER_SEARCH_SEVERITY_ID, META_FILTER_ANY);
$my_filter[FILTER_PROPERTY_STATUS_ID] = gpc_get_string_array(FILTER_SEARCH_STATUS_ID, META_FILTER_ANY);
$my_filter[FILTER_PROPERTY_PROJECT_ID] = gpc_get_string_array(FILTER_SEARCH_PROJECT_ID, META_FILTER_ANY);
$my_filter[FILTER_PROPERTY_RESOLUTION_ID] = gpc_get_string_array(FILTER_SEARCH_RESOLUTION_ID, META_FILTER_ANY);
$my_filter[FILTER_PROPERTY_PRODUCT_BUILD] = gpc_get_string_array(FILTER_SEARCH_PRODUCT_BUILD, META_FILTER_ANY);
$my_filter[FILTER_PROPERTY_FIXED_IN_VERSION] = gpc_get_string_array(FILTER_SEARCH_FIXED_IN_VERSION, META_FILTER_ANY);
$my_filter[FILTER_PROPERTY_TARGET_VERSION] = gpc_get_string_array(FILTER_SEARCH_TARGET_VERSION, META_FILTER_ANY);
$my_filter[FILTER_PROPERTY_PRIORITY_ID] = gpc_get_string_array(FILTER_SEARCH_PRIORITY_ID, META_FILTER_ANY);
$my_filter[FILTER_PROPERTY_MONITOR_USER_ID] = gpc_get_string_array(FILTER_SEARCH_MONITOR_USER_ID, META_FILTER_ANY);
$my_filter[FILTER_PROPERTY_PROFILE] = gpc_get_string_array(FILTER_SEARCH_PROFILE, META_FILTER_ANY);
$my_filter[FILTER_PROPERTY_PLATFORM] = gpc_get_string_array(FILTER_SEARCH_PLATFORM, META_FILTER_ANY);
$my_filter[FILTER_PROPERTY_OS] = gpc_get_string_array(FILTER_SEARCH_OS, META_FILTER_ANY);
$my_filter[FILTER_PROPERTY_OS_BUILD] = gpc_get_string_array(FILTER_SEARCH_OS_BUILD, META_FILTER_ANY);
$my_filter[FILTER_PROPERTY_VIEW_STATE_ID] = gpc_get_string_array(FILTER_SEARCH_VIEW_STATE_ID, META_FILTER_ANY);
$my_filter[FILTER_PROPERTY_PRODUCT_VERSION] = gpc_get_string_array(FILTER_SEARCH_PRODUCT_VERSION, META_FILTER_ANY);
$my_filter[FILTER_PROPERTY_MATCH_TYPE] = gpc_get_int(FILTER_SEARCH_MATCH_TYPE, FILTER_MATCH_ALL);
// Filtering by Date
$my_filter[FILTER_PROPERTY_FILTER_BY_DATE] = gpc_get_bool(FILTER_SEARCH_FILTER_BY_DATE);
$my_filter[FILTER_PROPERTY_START_MONTH] = gpc_get_int(FILTER_SEARCH_START_MONTH, META_FILTER_ANY);
$my_filter[FILTER_PROPERTY_START_DAY] = gpc_get_int(FILTER_SEARCH_START_DAY, META_FILTER_ANY);
$my_filter[FILTER_PROPERTY_START_YEAR] = gpc_get_int(FILTER_SEARCH_START_YEAR, META_FILTER_ANY);
$my_filter[FILTER_PROPERTY_END_MONTH] = gpc_get_int(FILTER_SEARCH_END_MONTH, META_FILTER_ANY);
$my_filter[FILTER_PROPERTY_END_DAY] = gpc_get_int(FILTER_SEARCH_END_DAY, META_FILTER_ANY);
$my_filter[FILTER_PROPERTY_END_YEAR] = gpc_get_int(FILTER_SEARCH_END_YEAR, META_FILTER_ANY);
$my_filter[FILTER_PROPERTY_NOT_ASSIGNED] = gpc_get_bool(FILTER_SEARCH_NOT_ASSIGNED);
$my_filter[FILTER_PROPERTY_RELATIONSHIP_TYPE] = gpc_get_int(FILTER_SEARCH_RELATIONSHIP_TYPE, -1);
$my_filter[FILTER_PROPERTY_RELATIONSHIP_BUG] = gpc_get_int(FILTER_SEARCH_RELATIONSHIP_BUG, 0);
$my_filter[FILTER_PROPERTY_HIDE_STATUS_ID] = gpc_get_int(FILTER_SEARCH_HIDE_STATUS_ID, config_get('hide_status_default'));
$my_filter[FILTER_PROPERTY_SHOW_STICKY_ISSUES] = gpc_get_bool(FILTER_SEARCH_SHOW_STICKY_ISSUES, config_get('show_sticky_issues'));
$my_filter[FILTER_PROPERTY_SORT_FIELD_NAME] = gpc_get_string(FILTER_SEARCH_SORT_FIELD_NAME, '');
Example #5
0
function filter_ensure_valid_filter($p_filter_arr)
{
    # extend current filter to add information passed via POST
    if (!isset($p_filter_arr['_version'])) {
        $p_filter_arr['_version'] = config_get('cookie_version');
    }
    $t_cookie_vers = (int) substr($p_filter_arr['_version'], 1);
    if (substr(config_get('cookie_version'), 1) > $t_cookie_vers) {
        # if the version is old, update it
        $p_filter_arr['_version'] = config_get('cookie_version');
    }
    if (!isset($p_filter_arr['_view_type'])) {
        $p_filter_arr['_view_type'] = gpc_get_string('view_type', 'simple');
    }
    if (!isset($p_filter_arr['per_page'])) {
        $p_filter_arr['per_page'] = gpc_get_int('per_page', config_get('default_limit_view'));
    }
    if (!isset($p_filter_arr['highlight_changed'])) {
        $p_filter_arr['highlight_changed'] = config_get('default_show_changed');
    }
    if (!isset($p_filter_arr['sticky_issues'])) {
        $p_filter_arr['sticky_issues'] = config_get('show_sticky_issues');
    }
    if (!isset($p_filter_arr['sort'])) {
        $p_filter_arr['sort'] = "last_updated";
    }
    if (!isset($p_filter_arr['dir'])) {
        $p_filter_arr['dir'] = "DESC";
    }
    if (!isset($p_filter_arr['platform'])) {
        $p_filter_arr['platform'] = array(0 => META_FILTER_ANY);
    }
    if (!isset($p_filter_arr['os'])) {
        $p_filter_arr['os'] = array(0 => META_FILTER_ANY);
    }
    if (!isset($p_filter_arr['os_build'])) {
        $p_filter_arr['os_build'] = array(0 => META_FILTER_ANY);
    }
    if (!isset($p_filter_arr['project_id'])) {
        $p_filter_arr['project_id'] = array(0 => META_FILTER_CURRENT);
    }
    if (!isset($p_filter_arr['start_month'])) {
        $p_filter_arr['start_month'] = gpc_get_string('start_month', date('m'));
    }
    if (!isset($p_filter_arr['start_day'])) {
        $p_filter_arr['start_day'] = gpc_get_string('start_day', 1);
    }
    if (!isset($p_filter_arr['start_year'])) {
        $p_filter_arr['start_year'] = gpc_get_string('start_year', date('Y'));
    }
    if (!isset($p_filter_arr['end_month'])) {
        $p_filter_arr['end_month'] = gpc_get_string('end_month', date('m'));
    }
    if (!isset($p_filter_arr['end_day'])) {
        $p_filter_arr['end_day'] = gpc_get_string('end_day', date('d'));
    }
    if (!isset($p_filter_arr['end_year'])) {
        $p_filter_arr['end_year'] = gpc_get_string('end_year', date('Y'));
    }
    if (!isset($p_filter_arr['search'])) {
        $p_filter_arr['search'] = '';
    }
    if (!isset($p_filter_arr['and_not_assigned'])) {
        $p_filter_arr['and_not_assigned'] = gpc_get_bool('and_not_assigned', false);
    }
    if (!isset($p_filter_arr['do_filter_by_date'])) {
        $p_filter_arr['do_filter_by_date'] = gpc_get_bool('do_filter_by_date', false);
    }
    if (!isset($p_filter_arr['view_state'])) {
        $p_filter_arr['view_state'] = gpc_get('view_state', '');
    } else {
        if ($p_filter_arr['view_state'] == 'any' || $p_filter_arr['view_state'] == 0) {
            $p_filter_arr['view_state'] = META_FILTER_ANY;
        }
    }
    if (!isset($p_filter_arr['relationship_type'])) {
        $p_filter_arr['relationship_type'] = gpc_get_int('relationship_type', -1);
    }
    if (!isset($p_filter_arr['relationship_bug'])) {
        $p_filter_arr['relationship_bug'] = gpc_get_int('relationship_bug', 0);
    }
    if (!isset($p_filter_arr['target_version'])) {
        $p_filter_arr['target_version'] = META_FILTER_ANY;
    }
    if (!isset($p_filter_arr['tag_string'])) {
        $p_filter_arr['tag_string'] = gpc_get_string('tag_string', '');
    }
    if (!isset($p_filter_arr['tag_select'])) {
        $p_filter_arr['tag_select'] = gpc_get_string('tag_select', '');
    }
    $t_custom_fields = custom_field_get_ids();
    # @@@ (thraxisp) This should really be the linked ids, but we don't know the project
    $f_custom_fields_data = array();
    if (is_array($t_custom_fields) && sizeof($t_custom_fields) > 0) {
        foreach ($t_custom_fields as $t_cfid) {
            if (is_array(gpc_get('custom_field_' . $t_cfid, null))) {
                $f_custom_fields_data[$t_cfid] = gpc_get_string_array('custom_field_' . $t_cfid, META_FILTER_ANY);
            } else {
                $f_custom_fields_data[$t_cfid] = gpc_get_string('custom_field_' . $t_cfid, META_FILTER_ANY);
                $f_custom_fields_data[$t_cfid] = array($f_custom_fields_data[$t_cfid]);
            }
        }
    }
    #validate sorting
    $t_fields = helper_get_columns_to_view();
    $t_n_fields = count($t_fields);
    for ($i = 0; $i < $t_n_fields; $i++) {
        if (isset($t_fields[$i]) && in_array($t_fields[$i], array('selection', 'edit', 'bugnotes_count', 'attachment'))) {
            unset($t_fields[$i]);
        }
    }
    $t_sort_fields = split(',', $p_filter_arr['sort']);
    $t_dir_fields = split(',', $p_filter_arr['dir']);
    for ($i = 0; $i < 2; $i++) {
        if (isset($t_sort_fields[$i])) {
            $t_drop = false;
            $t_sort = $t_sort_fields[$i];
            if (strpos($t_sort, 'custom_') === 0) {
                if (false === custom_field_get_id_from_name(substr($t_sort, strlen('custom_')))) {
                    $t_drop = true;
                }
            } else {
                if (!in_array($t_sort, $t_fields)) {
                    $t_drop = true;
                }
            }
            if (!in_array($t_dir_fields[$i], array("ASC", "DESC"))) {
                $t_drop = true;
            }
            if ($t_drop) {
                unset($t_sort_fields[$i]);
                unset($t_dir_fields[$i]);
            }
        }
    }
    if (count($t_sort_fields) > 0) {
        $p_filter_arr['sort'] = implode(',', $t_sort_fields);
        $p_filter_arr['dir'] = implode(',', $t_dir_fields);
    } else {
        $p_filter_arr['sort'] = "last_updated";
        $p_filter_arr['dir'] = "DESC";
    }
    # validate or filter junk from other fields
    $t_multi_select_list = array('show_category' => 'string', 'show_severity' => 'int', 'show_status' => 'int', 'reporter_id' => 'int', 'handler_id' => 'int', 'show_resolution' => 'int', 'show_priority' => 'int', 'show_build' => 'string', 'show_version' => 'string', 'hide_status' => 'int', 'fixed_in_version' => 'string', 'target_version' => 'string', 'user_monitor' => 'int', 'show_profile' => 'int');
    foreach ($t_multi_select_list as $t_multi_field_name => $t_multi_field_type) {
        if (!isset($p_filter_arr[$t_multi_field_name])) {
            if ('hide_status' == $t_multi_field_name) {
                $p_filter_arr[$t_multi_field_name] = array(config_get('hide_status_default'));
            } else {
                if ('custom_fields' == $t_multi_field_name) {
                    $p_filter_arr[$t_multi_field_name] = array($f_custom_fields_data);
                } else {
                    $p_filter_arr[$t_multi_field_name] = array(META_FILTER_ANY);
                }
            }
        } else {
            if (!is_array($p_filter_arr[$t_multi_field_name])) {
                $p_filter_arr[$t_multi_field_name] = array($p_filter_arr[$t_multi_field_name]);
            }
            $t_checked_array = array();
            foreach ($p_filter_arr[$t_multi_field_name] as $t_filter_value) {
                $t_filter_value = stripslashes($t_filter_value);
                if ($t_filter_value === 'any' || $t_filter_value === '[any]') {
                    $t_filter_value = META_FILTER_ANY;
                }
                if ($t_filter_value === 'none' || $t_filter_value === '[none]') {
                    $t_filter_value = META_FILTER_NONE;
                }
                if ('string' == $t_multi_field_type) {
                    $t_checked_array[] = db_prepare_string($t_filter_value);
                } else {
                    if ('int' == $t_multi_field_type) {
                        $t_checked_array[] = db_prepare_int($t_filter_value);
                    } else {
                        if ('array' == $t_multi_field_type) {
                            $t_checked_array[] = $t_filter_value;
                        }
                    }
                }
            }
            $p_filter_arr[$t_multi_field_name] = $t_checked_array;
        }
    }
    if (is_array($t_custom_fields) && sizeof($t_custom_fields) > 0) {
        foreach ($t_custom_fields as $t_cfid) {
            if (!isset($p_filter_arr['custom_fields'][$t_cfid])) {
                $p_filter_arr['custom_fields'][$t_cfid] = array(META_FILTER_ANY);
            } else {
                if (!is_array($p_filter_arr['custom_fields'][$t_cfid])) {
                    $p_filter_arr['custom_fields'][$t_cfid] = array($p_filter_arr['custom_fields'][$t_cfid]);
                }
                $t_checked_array = array();
                foreach ($p_filter_arr['custom_fields'][$t_cfid] as $t_filter_value) {
                    $t_filter_value = stripslashes($t_filter_value);
                    if ($t_filter_value === 'any' || $t_filter_value === '[any]') {
                        $t_filter_value = META_FILTER_ANY;
                    }
                    $t_checked_array[] = db_prepare_string($t_filter_value);
                }
                $p_filter_arr['custom_fields'][$t_cfid] = $t_checked_array;
            }
        }
    }
    # all of our filter values are now guaranteed to be there, and correct.
    return $p_filter_arr;
}
Example #6
0
/**
 * Retrieve a custom field variable.  Uses gpc_get().
 * If you pass in *no* default, an error will be triggered if
 * the variable does not exist
 * @param string  $p_var_name          Variable name.
 * @param integer $p_custom_field_type Custom Field Type.
 * @param mixed   $p_default           Default value.
 * @return string
 */
function gpc_get_custom_field($p_var_name, $p_custom_field_type, $p_default = null)
{
    switch ($p_custom_field_type) {
        case CUSTOM_FIELD_TYPE_MULTILIST:
        case CUSTOM_FIELD_TYPE_CHECKBOX:
            # ensure that the default is an array, if set
            if ($p_default !== null && !is_array($p_default)) {
                $p_default = array($p_default);
            }
            $t_values = gpc_get_string_array($p_var_name, $p_default);
            if (is_array($t_values)) {
                return implode('|', $t_values);
            } else {
                return '';
            }
            break;
        case CUSTOM_FIELD_TYPE_DATE:
            $t_day = gpc_get_int($p_var_name . '_day', 0);
            $t_month = gpc_get_int($p_var_name . '_month', 0);
            $t_year = gpc_get_int($p_var_name . '_year', 0);
            if ($t_year == 0 || $t_month == 0 || $t_day == 0) {
                if ($p_default == null) {
                    return '';
                } else {
                    return $p_default;
                }
            } else {
                return strtotime($t_year . '-' . $t_month . '-' . $t_day);
            }
            break;
        default:
            return gpc_get_string($p_var_name, $p_default);
    }
}
Example #7
0
 function process_post_data($p_advanced = false)
 {
     $f_execute_all = gpc_get_bool($this->upgrade_file . '_execute_all');
     $f_execute_selected = gpc_get_bool($this->upgrade_file . '_execute_selected');
     $f_print_all = gpc_get_bool($this->upgrade_file . '_print_all');
     $f_print_selected = gpc_get_bool($this->upgrade_file . '_print_selected');
     $f_execute_list = gpc_get_string_array($this->upgrade_file . '_execute_list', array());
     if ($f_execute_all) {
         $this->run(true, null, $p_advanced);
     } else {
         if ($f_execute_selected && $p_advanced) {
             $this->run(true, $f_execute_list, $p_advanced);
         } else {
             if ($f_print_all) {
                 $this->output();
             } else {
                 if ($f_print_selected && $p_advanced) {
                     $this->output($f_execute_list);
                 } else {
                     $this->run(false, null, $p_advanced);
                 }
             }
         }
     }
 }
<?php

auth_reauthenticate();
access_ensure_global_level(config_get('manage_plugin_threshold'));
plugin_require_api('core/config_api.php');
$f_mailbox_action = gpc_get_string('mailbox_action');
$f_select_mailbox = gpc_get_int('select_mailbox');
$t_mailboxes = plugin_config_get('mailboxes');
if ($f_mailbox_action === 'add' || $f_mailbox_action === 'copy' || ($f_mailbox_action === 'edit' || $f_mailbox_action === 'test' || $f_mailbox_action === 'complete_test') && $f_select_mailbox >= 0) {
    $t_mailbox = array('enabled' => gpc_get_int('enabled', ON), 'description' => gpc_get_string('description', ''), 'mailbox_type' => gpc_get_string('mailbox_type'), 'hostname' => gpc_get_string('hostname', ''), 'port' => gpc_get_string('port', ''), 'encryption' => gpc_get_string('encryption'), 'ssl_cert_verify' => gpc_get_int('ssl_cert_verify', ON), 'erp_username' => gpc_get_string('erp_username', ''), 'erp_password' => base64_encode(gpc_get_string('erp_password', '')), 'auth_method' => gpc_get_string('auth_method'), 'project_id' => gpc_get_int('project_id'), 'global_category_id' => gpc_get_int('global_category_id'));
    if ($t_mailbox['mailbox_type'] === 'IMAP') {
        $t_mailbox_imap = array('imap_basefolder' => ERP_prepare_directory_string(gpc_get_string('imap_basefolder', ''), TRUE), 'imap_createfolderstructure' => gpc_get_int('imap_createfolderstructure'));
        $t_mailbox += $t_mailbox_imap;
    }
    $t_plugin_content = gpc_get_string_array('plugin_content', NULL);
    if (is_array($t_plugin_content)) {
        $t_mailbox += array('plugin_content' => $t_plugin_content);
    }
}
if ($f_mailbox_action === 'add' || $f_mailbox_action === 'copy') {
    $t_mailboxes[] = $t_mailbox;
} elseif ($f_mailbox_action === 'edit' && $f_select_mailbox >= 0) {
    $t_mailboxes[$f_select_mailbox] = $t_mailbox;
} elseif ($f_mailbox_action === 'delete' && $f_select_mailbox >= 0) {
    unset($t_mailboxes[$f_select_mailbox]);
} elseif (($f_mailbox_action === 'test' || $f_mailbox_action === 'complete_test') && $f_select_mailbox >= 0) {
    # Verify mailbox - from Recmail by Cas Nuy
    plugin_require_api('core/mail_api.php');
    echo '<pre>';
    $t_mailbox_api = new ERP_mailbox_api($f_mailbox_action === 'complete_test' ? FALSE : TRUE);
    $t_result = $t_mailbox_api->process_mailbox($t_mailbox);
function Source_FilterOption_Permalink($p_string = null, $p_array = false)
{
    static $s_permalink = '';
    if (is_null($p_string)) {
        $t_string = $s_permalink;
        $s_permalink = '';
        return $t_string;
    }
    if ($p_array) {
        $t_input = gpc_get_string_array($p_string, null);
        $t_input_clean = array();
        if (is_array($t_input) && count($t_input) > 0) {
            foreach ($t_input as $t_value) {
                if (!is_blank($t_value)) {
                    $t_input_clean[] = $t_value;
                    $s_permalink .= "&{$p_string}[]={$t_value}";
                }
            }
        }
    } else {
        $t_input_clean = gpc_get_string($p_string, null);
        if ($p_string == 'date_start' || $p_string == 'date_end') {
            $t_input_clean = Source_Date_Validate($p_string, $p_string == 'date_end');
        }
        if (!is_blank($t_input_clean)) {
            $s_permalink .= "&{$p_string}={$t_input_clean}";
        }
    }
    return $t_input_clean;
}
Example #10
0
                case CUSTOM_FIELD_DATE_AFTER:
                    $t_start = $t_start_date + $t_one_day - 1;
                    $t_end = 2147483647;
                    # Some time in 2038, max value of a signed int.
                    break;
                case CUSTOM_FIELD_DATE_ONORAFTER:
                    $t_start = $t_start_date;
                    $t_end = 2147483647;
                    # Some time in 2038, max value of a signed int.
                    break;
            }
            $f_custom_fields_data[$t_cfid][1] = $t_start;
            $f_custom_fields_data[$t_cfid][2] = $t_end;
        } else {
            if (is_array(gpc_get('custom_field_' . $t_cfid, null))) {
                $f_custom_fields_data[$t_cfid] = gpc_get_string_array('custom_field_' . $t_cfid, $t_meta_filter_any_array);
            } else {
                $f_custom_fields_data[$t_cfid] = gpc_get_string('custom_field_' . $t_cfid, META_FILTER_ANY);
                $f_custom_fields_data[$t_cfid] = array($f_custom_fields_data[$t_cfid]);
            }
        }
    }
}
$f_relationship_type = gpc_get_int(FILTER_PROPERTY_RELATIONSHIP_TYPE, -1);
$f_relationship_bug = gpc_get_int(FILTER_PROPERTY_RELATIONSHIP_BUG, 0);
if ($f_temp_filter) {
    $f_type = 1;
}
if ($f_type < 0) {
    print_header_redirect('view_all_bug_page.php');
}
Example #11
0
$t_my_filter[FILTER_PROPERTY_HANDLER_ID] = gpc_get_string_array(FILTER_PROPERTY_HANDLER_ID, $t_meta_filter_any_array);
$t_my_filter[FILTER_PROPERTY_SEVERITY] = gpc_get_string_array(FILTER_PROPERTY_SEVERITY, $t_meta_filter_any_array);
$t_my_filter[FILTER_PROPERTY_STATUS] = gpc_get_string_array(FILTER_PROPERTY_STATUS, $t_meta_filter_any_array);
$t_my_filter[FILTER_PROPERTY_PROJECT_ID] = gpc_get_string_array(FILTER_PROPERTY_PROJECT_ID, $t_meta_filter_any_array);
$t_my_filter[FILTER_PROPERTY_RESOLUTION] = gpc_get_string_array(FILTER_PROPERTY_RESOLUTION, $t_meta_filter_any_array);
$t_my_filter[FILTER_PROPERTY_BUILD] = gpc_get_string_array(FILTER_PROPERTY_BUILD, $t_meta_filter_any_array);
$t_my_filter[FILTER_PROPERTY_FIXED_IN_VERSION] = gpc_get_string_array(FILTER_PROPERTY_FIXED_IN_VERSION, $t_meta_filter_any_array);
$t_my_filter[FILTER_PROPERTY_TARGET_VERSION] = gpc_get_string_array(FILTER_PROPERTY_TARGET_VERSION, $t_meta_filter_any_array);
$t_my_filter[FILTER_PROPERTY_PRIORITY] = gpc_get_string_array(FILTER_PROPERTY_PRIORITY, $t_meta_filter_any_array);
$t_my_filter[FILTER_PROPERTY_MONITOR_USER_ID] = gpc_get_string_array(FILTER_PROPERTY_MONITOR_USER_ID, $t_meta_filter_any_array);
$t_my_filter[FILTER_PROPERTY_PROFILE_ID] = gpc_get_string_array(FILTER_PROPERTY_PROFILE_ID, $t_meta_filter_any_array);
$t_my_filter[FILTER_PROPERTY_PLATFORM] = gpc_get_string_array(FILTER_PROPERTY_PLATFORM, $t_meta_filter_any_array);
$t_my_filter[FILTER_PROPERTY_OS] = gpc_get_string_array(FILTER_PROPERTY_OS, $t_meta_filter_any_array);
$t_my_filter[FILTER_PROPERTY_OS_BUILD] = gpc_get_string_array(FILTER_PROPERTY_OS_BUILD, $t_meta_filter_any_array);
$t_my_filter[FILTER_PROPERTY_VIEW_STATE] = gpc_get_string_array(FILTER_PROPERTY_VIEW_STATE, $t_meta_filter_any_array);
$t_my_filter[FILTER_PROPERTY_VERSION] = gpc_get_string_array(FILTER_PROPERTY_VERSION, $t_meta_filter_any_array);
$t_my_filter[FILTER_PROPERTY_MATCH_TYPE] = gpc_get_int(FILTER_PROPERTY_MATCH_TYPE, FILTER_MATCH_ALL);
# Filtering by Date
$t_my_filter[FILTER_PROPERTY_FILTER_BY_DATE] = gpc_get_bool(FILTER_PROPERTY_FILTER_BY_DATE);
$t_my_filter[FILTER_PROPERTY_START_MONTH] = gpc_get_int(FILTER_PROPERTY_START_MONTH, META_FILTER_ANY);
$t_my_filter[FILTER_PROPERTY_START_DAY] = gpc_get_int(FILTER_PROPERTY_START_DAY, META_FILTER_ANY);
$t_my_filter[FILTER_PROPERTY_START_YEAR] = gpc_get_int(FILTER_PROPERTY_START_YEAR, META_FILTER_ANY);
$t_my_filter[FILTER_PROPERTY_END_MONTH] = gpc_get_int(FILTER_PROPERTY_END_MONTH, META_FILTER_ANY);
$t_my_filter[FILTER_PROPERTY_END_DAY] = gpc_get_int(FILTER_PROPERTY_END_DAY, META_FILTER_ANY);
$t_my_filter[FILTER_PROPERTY_END_YEAR] = gpc_get_int(FILTER_PROPERTY_END_YEAR, META_FILTER_ANY);
$t_my_filter[FILTER_PROPERTY_RELATIONSHIP_TYPE] = gpc_get_int(FILTER_PROPERTY_RELATIONSHIP_TYPE, -1);
$t_my_filter[FILTER_PROPERTY_RELATIONSHIP_BUG] = gpc_get_int(FILTER_PROPERTY_RELATIONSHIP_BUG, 0);
$t_my_filter[FILTER_PROPERTY_HIDE_STATUS] = gpc_get_int(FILTER_PROPERTY_HIDE_STATUS, config_get('hide_status_default'));
$t_my_filter[FILTER_PROPERTY_STICKY] = gpc_get_bool(FILTER_PROPERTY_STICKY, config_get('show_sticky_issues'));
$t_my_filter[FILTER_PROPERTY_SORT_FIELD_NAME] = gpc_get_string(FILTER_PROPERTY_SORT_FIELD_NAME, '');
$t_my_filter[FILTER_PROPERTY_SORT_DIRECTION] = gpc_get_string(FILTER_PROPERTY_SORT_DIRECTION, '');