View Issue Details

IDProjectCategoryView StatusLast Update
0018036mantisbtfeaturepublic2015-02-05 17:24
Reporterjoel_li Assigned Todregad  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionno change required 
PlatformUnbunt 12.04OSUnbunt 12.04OS Version12.04
Product Version1.2.18 
Summary0018036: My View - Issues not displayed under Current Status Type
Description

Hi All,
I am unable to get issues under My Views page to be displayed.

There is no error but they do not show up.

Is there any fix / reason for this?

FYI, customised the Mantis 1.2.18 version with the textarea patch from this helpdesk.

TagsNo tags attached.
Attached Files
cfdef_standard.php (14,476 bytes)   
<?php
# MantisBT - a php based bugtracking system

# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
# Copyright (C) 2002 - 2014  MantisBT Team - mantisbt-dev@lists.sourceforge.net

# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.

$g_custom_field_type_definition[ CUSTOM_FIELD_TYPE_STRING ] = array (
	'#display_possible_values' => TRUE,
	'#display_valid_regexp' => TRUE,
	'#display_length_min' => TRUE,
	'#display_length_max' => TRUE,
	'#display_default_value' => TRUE,
	'#function_return_distinct_values' => null,
	'#function_value_to_database' => null,
	'#function_database_to_value' => null,
	'#function_print_input' => 'cfdef_input_textbox',
	'#function_string_value' => null,
	'#function_string_value_for_email' => null,
);

#ODB Production - New Text Area Field
$g_custom_field_type_definition[ CUSTOM_FIELD_TYPE_TEXTAREA] = array (
	'#display_possible_values' => TRUE,
	'#display_valid_regexp' => TRUE,
	'#display_length_min' => TRUE,
	'#display_length_max' => TRUE,
	'#display_default_value' => TRUE,
	'#function_return_distinct_values' => null,
	'#function_value_to_database' => null,
	'#function_database_to_value' => null,
	'#function_print_input' => 'cfdef_input_textarea',
	'#function_string_value' => null,
	'#function_string_value_for_email' => null,
);

$g_custom_field_type_definition[ CUSTOM_FIELD_TYPE_NUMERIC ] = array (
	'#display_possible_values' => TRUE,
	'#display_valid_regexp' => TRUE,
	'#display_length_min' => TRUE,
	'#display_length_max' => TRUE,
	'#display_default_value' => TRUE,
	'#function_return_distinct_values' => null,
	'#function_value_to_database' => null,
	'#function_database_to_value' => null,
	'#function_print_input' => 'cfdef_input_textbox',
	'#function_string_value' => null,
	'#function_string_value_for_email' => null,
);

$g_custom_field_type_definition[ CUSTOM_FIELD_TYPE_FLOAT ] = array (
	'#display_possible_values' => TRUE,
	'#display_valid_regexp' => TRUE,
	'#display_length_min' => TRUE,
	'#display_length_max' => TRUE,
	'#display_default_value' => TRUE,
	'#function_return_distinct_values' => null,
	'#function_value_to_database' => null,
	'#function_database_to_value' => null,
	'#function_print_input' => 'cfdef_input_textbox',
	'#function_string_value' => null,
	'#function_string_value_for_email' => null,
);

$g_custom_field_type_definition[ CUSTOM_FIELD_TYPE_ENUM ] = array (
	'#display_possible_values' => TRUE,
	'#display_valid_regexp' => TRUE,
	'#display_length_min' => TRUE,
	'#display_length_max' => TRUE,
	'#display_default_value' => TRUE,
	'#function_return_distinct_values' => 'cfdef_prepare_list_distinct_values',
	'#function_value_to_database' => null,
	'#function_database_to_value' => null,
	'#function_print_input' => 'cfdef_input_list',
	'#function_string_value' => 'cfdef_prepare_list_value',
	'#function_string_value_for_email' => 'cfdef_prepare_list_value_for_email',
);

$g_custom_field_type_definition[ CUSTOM_FIELD_TYPE_EMAIL ] = array (
	'#display_possible_values' => TRUE,
	'#display_valid_regexp' => TRUE,
	'#display_length_min' => TRUE,
	'#display_length_max' => TRUE,
	'#display_default_value' => TRUE,
	'#function_return_distinct_values' => null,
	'#function_value_to_database' => null,
	'#function_database_to_value' => null,
	'#function_print_input' => 'cfdef_input_textbox',
	'#function_string_value' => 'cfdef_prepare_email_value',
	'#function_string_value_for_email' => 'cfdef_prepare_email_value_for_email',
);

$g_custom_field_type_definition[ CUSTOM_FIELD_TYPE_CHECKBOX ] = array (
	'#display_possible_values' => TRUE,
	'#display_valid_regexp' => TRUE,
	'#display_length_min' => TRUE,
	'#display_length_max' => TRUE,
	'#display_default_value' => TRUE,
	'#function_return_distinct_values' => 'cfdef_prepare_list_distinct_values',
	'#function_value_to_database' => 'cfdef_prepare_list_value_to_database',
	'#function_database_to_value' => 'cfdef_prepare_list_database_to_value',
	'#function_print_input' => 'cfdef_input_checkbox',
	'#function_string_value' => 'cfdef_prepare_list_value',
	'#function_string_value_for_email' => 'cfdef_prepare_list_value_for_email',
);

$g_custom_field_type_definition[ CUSTOM_FIELD_TYPE_RADIO ] = array (
	'#display_possible_values' => TRUE,
	'#display_valid_regexp' => FALSE,
	'#display_length_min' => FALSE,
	'#display_length_max' => FALSE,
	'#display_default_value' => TRUE,
	'#function_return_distinct_values' => 'cfdef_prepare_list_distinct_values',
	'#function_value_to_database' => null,
	'#function_database_to_value' => null,
	'#function_print_input' => 'cfdef_input_radio',
	'#function_string_value' => 'cfdef_prepare_list_value',
	'#function_string_value_for_email' => 'cfdef_prepare_list_value_for_email',
);

$g_custom_field_type_definition[ CUSTOM_FIELD_TYPE_LIST ] = array (
	'#display_possible_values' => TRUE,
	'#display_valid_regexp' => TRUE,
	'#display_length_min' => TRUE,
	'#display_length_max' => TRUE,
	'#display_default_value' => TRUE,
	'#function_return_distinct_values' => 'cfdef_prepare_list_distinct_values',
	'#function_value_to_database' => null,
	'#function_database_to_value' => null,
	'#function_print_input' => 'cfdef_input_list',
	'#function_string_value' => 'cfdef_prepare_list_value',
	'#function_string_value_for_email' => 'cfdef_prepare_list_value_for_email',
);

$g_custom_field_type_definition[ CUSTOM_FIELD_TYPE_MULTILIST ] = array (
	'#display_possible_values' => TRUE,
	'#display_valid_regexp' => TRUE,
	'#display_length_min' => TRUE,
	'#display_length_max' => TRUE,
	'#display_default_value' => TRUE,
	'#function_return_distinct_values' => 'cfdef_prepare_list_distinct_values',
	'#function_value_to_database' => 'cfdef_prepare_list_value_to_database',
	'#function_database_to_value' => 'cfdef_prepare_list_database_to_value',
	'#function_print_input' => 'cfdef_input_list',
	'#function_string_value' => 'cfdef_prepare_list_value',
	'#function_string_value_for_email' => 'cfdef_prepare_list_value_for_email',
);

$g_custom_field_type_definition[ CUSTOM_FIELD_TYPE_DATE ] = array (
	'#display_possible_values' => TRUE,
	'#display_valid_regexp' => TRUE,
	'#display_length_min' => TRUE,
	'#display_length_max' => TRUE,
	'#display_default_value' => TRUE,
	'#function_return_distinct_values' => null,
	'#function_value_to_database' => null,
	'#function_database_to_value' => null,
	'#function_default_to_value' => 'cfdef_prepare_date_default',
	'#function_print_input' => 'cfdef_input_date',
	'#function_string_value' => 'cfdef_prepare_date_value',
	'#function_string_value_for_email' => 'cfdef_prepare_date_value_for_email',
);

function cfdef_prepare_list_database_to_value($p_value) {
	return rtrim( ltrim( $p_value, '|' ), '|' );
}

function cfdef_prepare_list_value_for_email($p_value) {
	// strip start and end markers before converting markers to commas
	return str_replace( '|', ', ', utf8_substr( str_replace( '||', '|', '|' . $p_value . '|' ), 1, -1 ) );
}

function cfdef_prepare_email_value_for_email($p_value) {
	return 'mailto:'.$p_value;
}

function cfdef_prepare_date_value_for_email($p_value) {
	if ($p_value != null) {
		return date( config_get( 'short_date_format' ), $p_value) ;
	}
}

/**
 * Translates the default date value entered by the creator of the custom
 * field into a date value.  For example, translate '=tomorrow' to tomorrow's
 * date.
 * @param $p_value The default date string.
 * @returns The calculated default date value if $p_value starts with '=',
 *          otherwise, returns $p_value.
 */
function cfdef_prepare_date_default( $p_value ) {
	if ( is_blank( $p_value ) ) {
		return '';
	}

	$t_value = trim( $p_value );
	$t_value_length = utf8_strlen( $t_value );

	# We are expanding {tomorrow}, {yesterday}, {+3 days}, {-7 days}, {next week}
	# See strtotime() for more details about supported formats.
	if ( $t_value_length >= 3 && $t_value[0] == '{' && $t_value[$t_value_length - 1] == '}' ) {
		$t_value = utf8_substr( $t_value, 1, $t_value_length - 2 );
		$t_value = @strtotime( $t_value );

		# Different versions of PHP return different values in case of error.
		if ( $t_value == -1 || $t_value === false ) {
			return '';
		}
	}

	return $t_value;
}

#string_custom_field_value
function cfdef_prepare_list_value($p_value) {
	// strip start and end markers before converting markers to commas
	return string_display_line( str_replace( '|', ', ', utf8_substr( str_replace( '||', '|', '|' . $p_value . '|' ), 1, -1 ) ) );
}

function cfdef_prepare_email_value($p_value) {
	return "<a href=\"mailto:" . string_attribute( $p_value ) . "\">" . string_display_line( $p_value ) . "</a>";
}

function cfdef_prepare_date_value($p_value) {
	if ($p_value != null) {
		return date( config_get( 'short_date_format'), $p_value);
	}
}


#print_custom_field_input

function cfdef_input_list($p_field_def, $t_custom_field_value) {
	$t_values = explode( '|', custom_field_prepare_possible_values( $p_field_def['possible_values'] ) );
	$t_list_size = $t_possible_values_count = count( $t_values );

	if ( $t_possible_values_count > 5 ) {
		$t_list_size = 5;
	}

	if ( $p_field_def['type'] == CUSTOM_FIELD_TYPE_ENUM ) {
		$t_list_size = 0;	# for enums the size is 0
	}

	if ( $p_field_def['type'] == CUSTOM_FIELD_TYPE_MULTILIST ) {
		echo '<select ', helper_get_tab_index(), ' name="custom_field_' . $p_field_def['id'] . '[]" size="' . $t_list_size . '" multiple="multiple">';
	} else {
		echo '<select ', helper_get_tab_index(), ' name="custom_field_' . $p_field_def['id'] . '" size="' . $t_list_size . '">';
	}

	$t_selected_values = explode( '|', $t_custom_field_value );
	foreach( $t_values as $t_option ) {
		if( in_array( $t_option, $t_selected_values, true ) ) {
			echo '<option value="' . string_attribute( $t_option ) . '" selected="selected"> ' . string_display_line( $t_option ) . '</option>';
		} else {
			echo '<option value="' . string_attribute( $t_option ) . '">' . string_display_line( $t_option ) . '</option>';
		}
	}
	echo '</select>';
}

function cfdef_input_checkbox($p_field_def, $t_custom_field_value) {
	$t_values = explode( '|', custom_field_prepare_possible_values( $p_field_def['possible_values'] ) );
	$t_checked_values = explode( '|', $t_custom_field_value );
	foreach( $t_values as $t_option ) {
		echo '<input ', helper_get_tab_index(), ' type="checkbox" name="custom_field_' . $p_field_def['id'] . '[]"';
		if( in_array( $t_option, $t_checked_values, true ) ) {
			echo ' value="' . string_attribute( $t_option ) . '" checked="checked">&#160;' . string_display_line( $t_option ) . '&#160;&#160;';
		} else {
			echo ' value="' . string_attribute( $t_option ) . '">&#160;' . string_display_line( $t_option ) . '&#160;&#160;';
		}
	}
}

function cfdef_input_radio( $p_field_def, $p_custom_field_value ) {
	$t_values = explode( '|', custom_field_prepare_possible_values( $p_field_def['possible_values'] ) );

	$t_len = strlen( $p_custom_field_value );
	if ( $t_len >= 2 && ( $p_custom_field_value[0] == '|' ) && ( $p_custom_field_value[$t_len-1] == '|' ) ) {
		$t_checked_value = substr( $p_custom_field_value, 1, $t_len - 2 );
	} else {
		$t_checked_value = $p_custom_field_value;
	}

	foreach ( $t_values as $t_option ) {
		echo '<input ', helper_get_tab_index(), ' type="radio" name="custom_field_' . $p_field_def['id'] . '"';

		if ( $t_option == $t_checked_value ) {
			echo ' value="' . string_attribute( $t_option ) . '" checked="checked">&#160;' . string_display_line( $t_option ) . '&#160;&#160;';
		} else {
			echo ' value="' . string_attribute( $t_option ) . '">&#160;' . string_display_line( $t_option ) . '&#160;&#160;';
		}
	}
}

function cfdef_input_textbox($p_field_def, $t_custom_field_value) {
	echo '<input ', helper_get_tab_index(), ' type="text" name="custom_field_' . $p_field_def['id'] . '" size="80"';
	if( 0 < $p_field_def['length_max'] ) {
		echo ' maxlength="' . $p_field_def['length_max'] . '"';
	} else {
		echo ' maxlength="255"';
	}
	echo ' value="' . string_attribute( $t_custom_field_value ) .'"></input>';
}


function cfdef_input_textarea($p_field_def, $t_custom_field_value) {
#ODB Production - Text Area
	echo '<textarea ', helper_get_tab_index(), ' name="custom_field_' . $p_field_def['id'] . '"';
	if( 0 < $p_field_def['length_max'] ) {
		echo ' maxlength="' . $p_field_def['length_max'] . '"';
	} else {
		echo ' maxlength="255"';
	}
	echo 'cols="70" rows="8">' . $t_custom_field_value .'</textarea>';
}

/**
 * Prints the controls for the date selector.
 *
 * @param $p_field_def  The custom field definition.
 * @param $p_custom_field_value  The custom field value to print.
 */
function cfdef_input_date( $p_field_def, $p_custom_field_value ) {
	print_date_selection_set( 'custom_field_' . $p_field_def['id'], config_get( 'short_date_format' ), $p_custom_field_value, false, true );
}

#value to database
function cfdef_prepare_list_value_to_database($p_value) {
	if ( '' == $p_value ) {
		return '';
	} else {
		return '|' . $p_value . '|';
	}
}

function cfdef_prepare_list_distinct_values($p_field_def) {
	$t_custom_field_table = db_get_table( 'mantis_custom_field_table' );

	$query = "SELECT possible_values
			  FROM $t_custom_field_table
			  WHERE id=" . db_param();
	$result = db_query_bound( $query, Array( $p_field_def['id'] ) );

	$t_row_count = db_num_rows( $result );
	if ( 0 == $t_row_count ) {
		return false;
	}
	$row = db_fetch_array( $result );

	$t_possible_values = custom_field_prepare_possible_values( $row['possible_values'] );
	$t_values_arr = explode( '|', $t_possible_values );
	$t_return_arr = array();

	foreach( $t_values_arr as $t_option ) {
		array_push( $t_return_arr, $t_option );
	}
	return $t_return_arr;
}
cfdef_standard.php (14,476 bytes)   
constant_inc.php (16,069 bytes)   
<?php
# MantisBT - a php based bugtracking system

# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.

define( 'MANTIS_VERSION', '1.2.0' );

# --- constants -------------------
# magic numbers
define( 'ON', 1 );
define( 'OFF', 0 );
define( 'AUTO', 3 );

define( 'BAD', 0 );
define( 'GOOD', 1 );
define( 'WARN', 2 );

# PHP-related constants
define( 'PHP_CLI', 0 );
define( 'PHP_CGI', 1 );

# installation
define( 'CONFIGURED_PASSWORD', "______" );

# error types
define( 'ERROR', E_USER_ERROR );
define( 'WARNING', E_USER_WARNING );
define( 'NOTICE', E_USER_NOTICE );

# access levels
define( 'ANYBODY', 0 );
define( 'VIEWER', 10 );
define( 'REPORTER', 25 );
define( 'UPDATER', 40 );
define( 'DEVELOPER', 55 );
define( 'MANAGER', 70 );
define( 'ADMINISTRATOR', 90 );
define( 'NOBODY', 100 );

define( 'DEFAULT_ACCESS_LEVEL', -1 );

# This is used in add user to project
# status
define( 'NEW_', 10 );

# NEW seems to be a reserved keyword
define( 'FEEDBACK', 20 );
define( 'ACKNOWLEDGED', 30 );
define( 'CONFIRMED', 40 );
define( 'ASSIGNED', 50 );
define( 'RESOLVED', 80 );
define( 'CLOSED', 90 );

# resolution
define( 'OPEN', 10 );
define( 'FIXED', 20 );
define( 'REOPENED', 30 );
define( 'UNABLE_TO_DUPLICATE', 40 );
define( 'NOT_FIXABLE', 50 );
define( 'DUPLICATE', 60 );
define( 'NOT_A_BUG', 70 );
define( 'SUSPENDED', 80 );
define( 'WONT_FIX', 90 );

# priority
define( 'NONE', 10 );
define( 'LOW', 20 );
define( 'NORMAL', 30 );
define( 'HIGH', 40 );
define( 'URGENT', 50 );
define( 'IMMEDIATE', 60 );

# severity
define( 'FEATURE', 10 );
define( 'TRIVIAL', 20 );
define( 'TEXT', 30 );
define( 'TWEAK', 40 );
define( 'MINOR', 50 );
define( 'MAJOR', 60 );
define( 'CRASH', 70 );
define( 'BLOCK', 80 );

# reproducibility
define( 'REPRODUCIBILITY_ALWAYS', 10 );
define( 'REPRODUCIBILITY_SOMETIMES', 30 );
define( 'REPRODUCIBILITY_RANDOM', 50 );
define( 'REPRODUCIBILITY_HAVENOTTRIED', 70 );
define( 'REPRODUCIBILITY_UNABLETODUPLICATE', 90 );
define( 'REPRODUCIBILITY_NOTAPPLICABLE', 100 );

# projection
define( 'PROJECTION_NONE', 10 );
define( 'PROJECTION_TWEAK', 30 );
define( 'PROJECTION_MINOR_FIX', 50 );
define( 'PROJECTION_MAJOR_REWORK', 70 );
define( 'PROJECTION_REDESIGN', 90 );

# ETA
define( 'ETA_NONE', 10 );
define( 'ETA_UNDER_ONE_DAY', 20 );
define( 'ETA_TWO_TO_THREE_DAYS', 30 );
define( 'ETA_UNDER_ONE_WEEK', 40 );
define( 'ETA_UNDER_ONE_MONTH', 50 );
define( 'ETA_OVER_ONE_MONTH', 60 );

# project view_state
define( 'VS_PUBLIC', 10 );
define( 'VS_PRIVATE', 50 );

# direction
define( 'ASCENDING', 101 );
define( 'DESCENDING', 102 );

# unread status
define( 'READ', 201 );
define( 'UNREAD', 202 );

# login methods
define( 'PLAIN', 0 );
define( 'CRYPT', 1 );
define( 'CRYPT_FULL_SALT', 2 );
define( 'MD5', 3 );
define( 'LDAP', 4 );
define( 'BASIC_AUTH', 5 );
define( 'HTTP_AUTH', 6 );

# file upload methods
define( 'DISK', 1 );
define( 'DATABASE', 2 );
define( 'FTP', 3 );

# show variable values
define( 'BOTH', 0 );
define( 'SIMPLE_ONLY', 1 );
define( 'ADVANCED_ONLY', 2 );
define( 'SIMPLE_DEFAULT', 3 );
define( 'ADVANCED_DEFAULT', 4 );

# news values
define( 'BY_LIMIT', 0 );
define( 'BY_DATE', 1 );

# all projects
define( 'ALL_PROJECTS', 0 );

# all users
define( 'ALL_USERS', 0 );

# no user
define( 'NO_USER', 0 );

# history constants
define( 'NORMAL_TYPE', 0 );
define( 'NEW_BUG', 1 );
define( 'BUGNOTE_ADDED', 2 );
define( 'BUGNOTE_UPDATED', 3 );
define( 'BUGNOTE_DELETED', 4 );
define( 'DESCRIPTION_UPDATED', 6 );
define( 'ADDITIONAL_INFO_UPDATED', 7 );
define( 'STEP_TO_REPRODUCE_UPDATED', 8 );
define( 'FILE_ADDED', 9 );
define( 'FILE_DELETED', 10 );
define( 'BUGNOTE_STATE_CHANGED', 11 );
define( 'BUG_MONITOR', 12 );
define( 'BUG_UNMONITOR', 13 );
define( 'BUG_DELETED', 14 );
define( 'BUG_ADD_SPONSORSHIP', 15 );
define( 'BUG_UPDATE_SPONSORSHIP', 16 );
define( 'BUG_DELETE_SPONSORSHIP', 17 );
define( 'BUG_ADD_RELATIONSHIP', 18 );
define( 'BUG_DEL_RELATIONSHIP', 19 );
define( 'BUG_CLONED_TO', 20 );
define( 'BUG_CREATED_FROM', 21 );
define( 'CHECKIN', 22 );
define( 'BUG_REPLACE_RELATIONSHIP', 23 );
define( 'BUG_PAID_SPONSORSHIP', 24 );
define( 'TAG_ATTACHED', 25 );
define( 'TAG_DETACHED', 26 );
define( 'TAG_RENAMED', 27 );
define( 'PLUGIN_HISTORY', 100 );

# bug revisions
define( 'REV_ANY', 0 );
define( 'REV_DESCRIPTION', 1 );
define( 'REV_STEPS_TO_REPRODUCE', 2 );
define( 'REV_ADDITIONAL_INFO', 3 );
define( 'REV_BUGNOTE', 4 );

# bug relationship constants
define( 'BUG_DUPLICATE', 0 );
define( 'BUG_RELATED', 1 );
define( 'BUG_DEPENDANT', 2 );
define( 'BUG_BLOCKS', 3 );
define( 'BUG_HAS_DUPLICATE', 4 );

# error messages
define( 'ERROR_GENERIC', 0 );
define( 'ERROR_SQL', 1 );
define( 'ERROR_REPORT', 3 );
define( 'ERROR_NO_FILE_SPECIFIED', 4 );
define( 'ERROR_FILE_DISALLOWED', 5 );
define( 'ERROR_NO_DIRECTORY', 6 );
define( 'ERROR_DUPLICATE_FILE', 9 );
define( 'ERROR_DUPLICATE_PROJECT', 10 );
define( 'ERROR_EMPTY_FIELD', 11 );
define( 'ERROR_PROTECTED_ACCOUNT', 12 );
define( 'ERROR_ACCESS_DENIED', 13 );
define( 'ERROR_UPLOAD_FAILURE', 15 );
define( 'ERROR_FTP_CONNECT_ERROR', 16 );
define( 'ERROR_HANDLER_ACCESS_TOO_LOW', 17 );
define( 'ERROR_PAGE_REDIRECTION', 18 );
define( 'ERROR_INVALID_REQUEST_METHOD', 19 );
define( 'ERROR_INVALID_SORT_FIELD', 20 );
define( 'ERROR_INVALID_DATE_FORMAT', 21 );
define( 'ERROR_UPDATING_TIMEZONE', 22 );

# ERROR_CONFIG_*
define( 'ERROR_CONFIG_OPT_NOT_FOUND', 100 );
define( 'ERROR_CONFIG_OPT_INVALID', 101 );
define( 'ERROR_CONFIG_OPT_CANT_BE_SET_IN_DB', 102 );

# ERROR_GPC_*
define( 'ERROR_GPC_VAR_NOT_FOUND', 200 );
define( 'ERROR_GPC_ARRAY_EXPECTED', 201 );
define( 'ERROR_GPC_ARRAY_UNEXPECTED', 202 );
define( 'ERROR_GPC_NOT_NUMBER', 203 );

# ERROR_LANG_*
define( 'ERROR_LANG_STRING_NOT_FOUND', 300 );

# ERROR_DB_*
define( 'ERROR_DB_CONNECT_FAILED', 400 );
define( 'ERROR_DB_QUERY_FAILED', 401 );
define( 'ERROR_DB_SELECT_FAILED', 402 );
define( 'ERROR_DB_FIELD_NOT_FOUND', 403 );

# ERROR_FILE_*
define( 'ERROR_FILE_TOO_BIG', 500 );
define( 'ERROR_FILE_NOT_ALLOWED', 501 );
define( 'ERROR_FILE_DUPLICATE', 502 );
define( 'ERROR_FILE_INVALID_UPLOAD_PATH', 503 );
define( 'ERROR_FILE_NO_UPLOAD_FAILURE', 504 );
define( 'ERROR_FILE_MOVE_FAILED', 505 );

# ERROR_BUGNOTE_*
define( 'ERROR_BUGNOTE_NOT_FOUND', 600 );

# ERROR_PROJECT_*
define( 'ERROR_PROJECT_NOT_FOUND', 700 );
define( 'ERROR_PROJECT_NAME_NOT_UNIQUE', 701 );
define( 'ERROR_PROJECT_NAME_INVALID', 702 );
define( 'ERROR_PROJECT_RECURSIVE_HIERARCHY', 703 );

# ERROR_USER_*
define( 'ERROR_USER_NAME_NOT_UNIQUE', 800 );
define( 'ERROR_USER_NOT_FOUND', 801 );
define( 'ERROR_USER_PREFS_NOT_FOUND', 802 );
define( 'ERROR_USER_CREATE_PASSWORD_MISMATCH', 803 );
define( 'ERROR_USER_PROFILE_NOT_FOUND', 804 );
define( 'ERROR_USER_NAME_INVALID', 805 );
define( 'ERROR_USER_DOES_NOT_HAVE_REQ_ACCESS', 806 );
define( 'ERROR_USER_REAL_MATCH_USER', 807 );
define( 'ERROR_USER_CHANGE_LAST_ADMIN', 808 );
define( 'ERROR_USER_REAL_NAME_INVALID', 809 );
define( 'ERROR_USER_BY_NAME_NOT_FOUND', 810 );
define( 'ERROR_USER_BY_ID_NOT_FOUND', 811 );

# ERROR_AUTH_*
define( 'ERROR_AUTH_INVALID_COOKIE', 900 );

# ERROR_NEWS_*
define( 'ERROR_NEWS_NOT_FOUND', 1000 );

# ERROR_BUG_*
define( 'ERROR_BUG_NOT_FOUND', 1100 );
define( 'ERROR_BUG_DUPLICATE_SELF', 1101 );
define( 'ERROR_BUG_RESOLVED_ACTION_DENIED', 1102 );
define( 'ERROR_BUG_REVISION_NOT_FOUND', 1150 );

// @@@ obsolete, remove after lang files are sync'd
define( 'ERROR_BUG_READ_ONLY_ACTION_DENIED', 1103 );

# ERROR_EMAIL_*
define( 'ERROR_EMAIL_INVALID', 1200 );
define( 'ERROR_EMAIL_DISPOSABLE', 1201 );

# ERROR_CUSTOM_FIELD_*
define( 'ERROR_CUSTOM_FIELD_NOT_FOUND', 1300 );
define( 'ERROR_CUSTOM_FIELD_NAME_NOT_UNIQUE', 1301 );
define( 'ERROR_CUSTOM_FIELD_IN_USE', 1302 );
define( 'ERROR_CUSTOM_FIELD_INVALID_VALUE', 1303 );
define( 'ERROR_CUSTOM_FIELD_INVALID_DEFINITION', 1304 );

# ERROR_LDAP_*
define( 'ERROR_LDAP_AUTH_FAILED', 1400 );
define( 'ERROR_LDAP_SERVER_CONNECT_FAILED', 1401 );
define( 'ERROR_LDAP_UPDATE_FAILED', 1402 );
define( 'ERROR_LDAP_USER_NOT_FOUND', 1403 );
define( 'ERROR_LDAP_EXTENSION_NOT_LOADED', 1404 );

# ERROR_CATEGORY_*
define( 'ERROR_CATEGORY_DUPLICATE', 1500 );
define( 'ERROR_CATEGORY_NO_ACTION', 1501 );
define( 'ERROR_CATEGORY_NOT_FOUND', 1502 );
define( 'ERROR_CATEGORY_NOT_FOUND_FOR_PROJECT', 1503 );

# ERROR_VERSION_*
define( 'ERROR_VERSION_DUPLICATE', 1600 );
define( 'ERROR_VERSION_NOT_FOUND', 1601 );

# ERROR_SPONSORSHIP_*
define( 'ERROR_SPONSORSHIP_NOT_ENABLED', 1700 );
define( 'ERROR_SPONSORSHIP_NOT_FOUND', 1701 );
define( 'ERROR_SPONSORSHIP_AMOUNT_TOO_LOW', 1702 );
define( 'ERROR_SPONSORSHIP_HANDLER_ACCESS_LEVEL_TOO_LOW', 1703 );
define( 'ERROR_SPONSORSHIP_ASSIGNER_ACCESS_LEVEL_TOO_LOW', 1704 );
define( 'ERROR_SPONSORSHIP_SPONSOR_NO_EMAIL', 1705 );

# ERROR RELATIONSHIP
define( 'ERROR_RELATIONSHIP_ALREADY_EXISTS', 1800 );
define( 'ERROR_RELATIONSHIP_ACCESS_LEVEL_TO_DEST_BUG_TOO_LOW', 1801 );
define( 'ERROR_RELATIONSHIP_NOT_FOUND', 1802 );
define( 'ERROR_RELATIONSHIP_SAME_BUG', 1803 );

# ERROR_LOST_PASSWORD_*
define( 'ERROR_LOST_PASSWORD_NOT_ENABLED', 1900 );
define( 'ERROR_LOST_PASSWORD_CONFIRM_HASH_INVALID', 1901 );
define( 'ERROR_LOST_PASSWORD_NO_EMAIL_SPECIFIED', 1902 );
define( 'ERROR_LOST_PASSWORD_NOT_MATCHING_DATA', 1903 );
define( 'ERROR_SIGNUP_NOT_MATCHING_CAPTCHA', 1904 );
define( 'ERROR_LOST_PASSWORD_MAX_IN_PROGRESS_ATTEMPTS_REACHED', 1905 );

# ERROR_FILTER_*
define( 'ERROR_FILTER_NOT_FOUND', 2000 );
define( 'ERROR_FILTER_TOO_OLD', 2001 );

# ERROR_TWITTER_*
define( 'ERROR_TWITTER_NO_CURL_EXT', 2100 );

# ERROR_TAG_*
define( 'ERROR_TAG_NOT_FOUND', 2200 );
define( 'ERROR_TAG_DUPLICATE', 2201 );
define( 'ERROR_TAG_NAME_INVALID', 2202 );
define( 'ERROR_TAG_NOT_ATTACHED', 2203 );
define( 'ERROR_TAG_ALREADY_ATTACHED', 2204 );

# ERROR_TOKEN_*
define( 'ERROR_TOKEN_NOT_FOUND', 2300 );

# ERROR_EVENT_*
define( 'ERROR_EVENT_UNDECLARED', 2400 );

# ERROR_PLUGIN *
define( 'ERROR_PLUGIN_NOT_REGISTERED', 2500 );
define( 'ERROR_PLUGIN_ALREADY_INSTALLED', 2501 );
define( 'ERROR_PLUGIN_PAGE_NOT_FOUND', 2502 );
define( 'ERROR_PLUGIN_UPGRADE_FAILED', 2503 );
define( 'ERROR_PLUGIN_GENERIC', 2599 );

# ERROR_COLUMNS_*
define( 'ERROR_COLUMNS_DUPLICATE', 2600 );
define( 'ERROR_COLUMNS_INVALID', 2601 );

# ERROR_SESSION_*
define( 'ERROR_SESSION_HANDLER_INVALID', 2700 );
define( 'ERROR_SESSION_VAR_NOT_FOUND', 2701 );
define( 'ERROR_SESSION_NOT_VALID', 2702 );

# ERROR_FORM_*
define( 'ERROR_FORM_TOKEN_INVALID', 2800 );

# Generic position constants
define( 'POSITION_NONE', 0 );
define( 'POSITION_TOP', 1 );
define( 'POSITION_BOTTOM', 2 );
define( 'POSITION_BOTH', 3 );

# Status Legend Position
define( 'STATUS_LEGEND_POSITION_TOP', POSITION_TOP );
define( 'STATUS_LEGEND_POSITION_BOTTOM', POSITION_BOTTOM );
define( 'STATUS_LEGEND_POSITION_BOTH', POSITION_BOTH );

# Filter Position
define( 'FILTER_POSITION_NONE', POSITION_NONE );
define( 'FILTER_POSITION_TOP', POSITION_TOP );
define( 'FILTER_POSITION_BOTTOM', POSITION_BOTTOM );
define( 'FILTER_POSITION_BOTH', POSITION_BOTH );

// FILTER_POSITION_TOP | FILTER_POSITION_BOTTOM (bitwise OR)
# Flags for settings E-mail categories
define( 'EMAIL_CATEGORY_PROJECT_CATEGORY', 1 );

# Custom Field types
define( 'CUSTOM_FIELD_TYPE_STRING', 0 );
define( 'CUSTOM_FIELD_TYPE_NUMERIC', 1 );
define( 'CUSTOM_FIELD_TYPE_FLOAT', 2 );
define( 'CUSTOM_FIELD_TYPE_ENUM', 3 );
define( 'CUSTOM_FIELD_TYPE_EMAIL', 4 );
define( 'CUSTOM_FIELD_TYPE_CHECKBOX', 5 );
define( 'CUSTOM_FIELD_TYPE_LIST', 6 );
define( 'CUSTOM_FIELD_TYPE_MULTILIST', 7 );
define( 'CUSTOM_FIELD_TYPE_DATE', 8 );
define( 'CUSTOM_FIELD_TYPE_RADIO', 9 );

# Meta filter values
define( 'META_FILTER_MYSELF', -1 );
define( 'META_FILTER_NONE', - 2 );
define( 'META_FILTER_CURRENT', - 3 );
define( 'META_FILTER_ANY', 0 );

# Custom filter types
define( 'FILTER_TYPE_STRING', 0 );
define( 'FILTER_TYPE_INT', 1 );
define( 'FILTER_TYPE_BOOLEAN', 2 );
define( 'FILTER_TYPE_MULTI_STRING', 3 );
define( 'FILTER_TYPE_MULTI_INT', 4 );

# Versions
define( 'VERSION_ALL', null );
define( 'VERSION_FUTURE', 0 );
define( 'VERSION_RELEASED', 1 );

# Contexts for bug summary
define( 'SUMMARY_CAPTION', 1 );
define( 'SUMMARY_FIELD', 2 );
define( 'SUMMARY_EMAIL', 3 );

# bugnote types
define( 'BUGNOTE', 0 );
define( 'REMINDER', 1 );
define( 'TIME_TRACKING', 2 );

# token types
define( 'TOKEN_UNKNOWN', 0 );
define( 'TOKEN_FILTER', 1 );
define( 'TOKEN_GRAPH', 2 );
define( 'TOKEN_LAST_VISITED', 3 );
define( 'TOKEN_AUTHENTICATED', 4 );
define( 'TOKEN_COLLAPSE', 5 );
define( 'TOKEN_USER', 1000 );

# token expirations
define( 'TOKEN_EXPIRY', 60 * 60 );

# Default expiration of 60 minutes ( 3600 seconds )
define( 'TOKEN_EXPIRY_LAST_VISITED', 24 * 60 * 60 );
define( 'TOKEN_EXPIRY_AUTHENTICATED', 5 * 60 );
define( 'TOKEN_EXPIRY_COLLAPSE', 365 * 24 * 60 * 60 );

# config types
define( 'CONFIG_TYPE_INT', 1 );
define( 'CONFIG_TYPE_STRING', 2 );
define( 'CONFIG_TYPE_COMPLEX', 3 );
define( 'CONFIG_TYPE_FLOAT', 4 );

# Control types for date custom fields.
define( 'CUSTOM_FIELD_DATE_ANY', 0 );
define( 'CUSTOM_FIELD_DATE_NONE', 1 );
define( 'CUSTOM_FIELD_DATE_BETWEEN', 2 );
define( 'CUSTOM_FIELD_DATE_ONORBEFORE', 3 );
define( 'CUSTOM_FIELD_DATE_BEFORE', 4 );
define( 'CUSTOM_FIELD_DATE_ON', 5 );
define( 'CUSTOM_FIELD_DATE_AFTER', 6 );
define( 'CUSTOM_FIELD_DATE_ONORAFTER', 7 );

# custom field types
define( 'CUSTOM_FIELD_TYPE_BUG', 0 );
define( 'CUSTOM_FIELD_TYPE_USER', 1 );
define( 'CUSTOM_FIELD_TYPE_BUGNOTE', 2 );
define( 'CUSTOM_FIELD_TYPE_PROJECT', 3 );
define( 'CUSTOM_FIELD_TYPE_FILE', 4 );

# system logging
#  logging levels, can be OR'd together
define( 'LOG_NONE',                     0 );  # no logging
define( 'LOG_EMAIL',                    1 );  # all emails sent
define( 'LOG_EMAIL_RECIPIENT',          2 );  # details of email recipient determination
define( 'LOG_FILTERING',                4 );  # logging for filtering.
define( 'LOG_AJAX',                     8 );  # logging for AJAX / XmlHttpRequests
define( 'LOG_LDAP',                     16 );  # logging for ldap
define( 'LOG_DATABASE',                 32 );  # logging for ldap

# COLUMNS_TARGET_*
define( 'COLUMNS_TARGET_VIEW_PAGE', 1 );
define( 'COLUMNS_TARGET_PRINT_PAGE', 2 );
define( 'COLUMNS_TARGET_CSV_PAGE', 3 );
define( 'COLUMNS_TARGET_EXCEL_PAGE', 4 );

# sponsorship "paid" values
define( 'SPONSORSHIP_UNPAID', 0 );
define( 'SPONSORSHIP_REQUESTED', 1 );
define( 'SPONSORSHIP_PAID', 2 );

# Plugin events
define( 'EVENT_TYPE_DEFAULT', 0 );
define( 'EVENT_TYPE_EXECUTE', 1 );
define( 'EVENT_TYPE_OUTPUT', 2 );
define( 'EVENT_TYPE_CHAIN', 3 );
define( 'EVENT_TYPE_FIRST', 4 );

# Timeline types
define( 'TIMELINE_TARGETTED', 1 );
define( 'TIMELINE_FIXED', 2 );

# PHPMailer Methods
define( 'PHPMAILER_METHOD_MAIL',		0 );
define( 'PHPMAILER_METHOD_SENDMAIL',	1 );
define( 'PHPMAILER_METHOD_SMTP',		2 );

# Lengths - NOTE: these may represent hard-coded values in db schema and should not be changed.
define( 'USERLEN', 32);
define( 'REALLEN', 64);
define( 'PASSLEN', 32);

define( 'SECONDS_PER_DAY', 86400 );
constant_inc.php (16,069 bytes)   
custom_field_api.php (47,226 bytes)   
<?php
# MantisBT - a php based bugtracking system

# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.

/**
 * @package CoreAPI
 * @subpackage CustomFieldAPI
 * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
 * @copyright Copyright (C) 2002 - 2014  MantisBT Team - mantisbt-dev@lists.sourceforge.net
 * @link http://www.mantisbt.org
 */

/**
 * requires bug_api
 */
require_once( 'bug_api.php' );
/**
 * requires helper_api
 */
require_once( 'helper_api.php' );
/**
 * requires date_api
 */
require_once( 'date_api.php' );

# ## Custom Fields API ###
# *******************************************
#	TODO
#	- add an object to store field data like BugData and UserPrefs ?
#	- add caching functions like user, bug, etc
#	- make existing api functions use caching functions
#	- add functions to return individual db columns for a field definition
# *******************************************

$g_custom_field_types[CUSTOM_FIELD_TYPE_STRING] = 'standard';
#ODB Production - Text Area
$g_custom_field_types[CUSTOM_FIELD_TYPE_TEXTAREA] = 'standard';
$g_custom_field_types[CUSTOM_FIELD_TYPE_NUMERIC] = 'standard';
$g_custom_field_types[CUSTOM_FIELD_TYPE_FLOAT] = 'standard';
$g_custom_field_types[CUSTOM_FIELD_TYPE_ENUM] = 'standard';
$g_custom_field_types[CUSTOM_FIELD_TYPE_EMAIL] = 'standard';
$g_custom_field_types[CUSTOM_FIELD_TYPE_CHECKBOX] = 'standard';
$g_custom_field_types[CUSTOM_FIELD_TYPE_LIST] = 'standard';
$g_custom_field_types[CUSTOM_FIELD_TYPE_MULTILIST] = 'standard';
$g_custom_field_types[CUSTOM_FIELD_TYPE_DATE] = 'standard';

foreach( $g_custom_field_types as $type ) {
	require_once( 'cfdefs' . DIRECTORY_SEPARATOR . 'cfdef_' . $type . '.php' );
}
unset( $type );

function custom_field_allow_manage_display( $p_type, $p_display ) {
	global $g_custom_field_type_definition;
	if( isset( $g_custom_field_type_definition[$p_type]['#display_' . $p_display] ) ) {
		return $g_custom_field_type_definition[$p_type]['#display_' . $p_display];
	}
	return false;
}


# ########################################
# SECURITY NOTE: cache globals are initialized here to prevent them
#   being spoofed if register_globals is turned on

$g_cache_custom_field = array();
$g_cache_cf_list = NULL;
$g_cache_cf_linked = array();
$g_cache_name_to_id_map = array();

/**
 * Cache a custom field row if necessary and return the cached copy
 * If the second parameter is true (default), trigger an error
 * if the field can't be found.  If the second parameter is
 * false, return false if the field can't be found.
 * @param int $p_field_id integer representing custom field id
 * @param bool $p_trigger_errors indicates whether to trigger an error if the field is not found
 * @return array array representing custom field
 * @access public
 */
function custom_field_cache_row( $p_field_id, $p_trigger_errors = true ) {
	global $g_cache_custom_field, $g_cache_name_to_id_map;

	$c_field_id = db_prepare_int( $p_field_id );

	$t_custom_field_table = db_get_table( 'mantis_custom_field_table' );

	if( isset( $g_cache_custom_field[$c_field_id] ) ) {
		return $g_cache_custom_field[$c_field_id];
	}

	$query = "SELECT *
				  FROM $t_custom_field_table
				  WHERE id=" . db_param();
	$result = db_query_bound( $query, Array( $c_field_id ) );

	if( 0 == db_num_rows( $result ) ) {
		if( $p_trigger_errors ) {
			error_parameters( 'Custom ' . $p_field_id );
			trigger_error( ERROR_CUSTOM_FIELD_NOT_FOUND, ERROR );
		} else {
			return false;
		}
	}

	$row = db_fetch_array( $result );

	$g_cache_custom_field[$c_field_id] = $row;
	$g_cache_name_to_id_map[$row['name']] = $c_field_id;

	return $row;
}

/**
 * Cache custom fields contained within an array of field id's
 * @param array $p_cf_id_array array of custom field id's
 * @return null
 * @access public
 */
function custom_field_cache_array_rows( $p_cf_id_array ) {
	global $g_cache_custom_field;
	$c_cf_id_array = array();

	foreach( $p_cf_id_array as $t_cf_id ) {
		if( !isset( $g_cache_custom_field[(int) $t_cf_id] ) ) {
			$c_cf_id_array[] = (int) $t_cf_id;
		}
	}

	if( empty( $c_cf_id_array ) ) {
		return;
	}

	$t_custom_field_table = db_get_table( 'mantis_custom_field_table' );

	$query = "SELECT *
				  FROM $t_custom_field_table
				  WHERE id IN (" . implode( ',', $c_cf_id_array ) . ')';
	$result = db_query_bound( $query );

	while( $row = db_fetch_array( $result ) ) {
		$g_cache_custom_field[(int) $row['id']] = $row;
	}
	return;
}

/**
 * Clear the custom field cache (or just the given id if specified)
 * @param int $p_field_id custom field id
 * @return bool
 * @access public
 */
function custom_field_clear_cache( $p_field_id = null ) {
	global $g_cache_custom_field, $g_cached_custom_field_lists;

	$g_cached_custom_field_lists = null;

	if( null === $p_field_id ) {
		$g_cache_custom_field = array();
	} else {
		$c_field_id = db_prepare_int( $p_field_id );
		unset( $g_cache_custom_field[$c_field_id] );
	}

	return true;
}

/**
 * Check to see whether the field is included in the given project
 * return true if the field is included, false otherwise
 * @param int $p_field_id custom field id
 * @param int $p_project_id project id
 * @return bool
 * @access public
 */
function custom_field_is_linked( $p_field_id, $p_project_id ) {
	global $g_cache_cf_linked;

	$c_project_id = db_prepare_int( $p_project_id );
	$c_field_id = db_prepare_int( $p_field_id );

	if( isset( $g_cache_cf_linked[$c_project_id] ) ) {
		if( in_array( $c_field_id, $g_cache_cf_linked[$p_project_id] ) ) {
			return true;
		}
		return false;
	}

	# figure out if this bug_id/field_id combination exists
	$t_custom_field_project_table = db_get_table( 'mantis_custom_field_project_table' );
	$query = "SELECT COUNT(*)
				FROM $t_custom_field_project_table
				WHERE field_id=" . db_param() . " AND
					  project_id=" . db_param();
	$result = db_query_bound( $query, Array( $c_field_id, $c_project_id ) );
	$count = db_result( $result );

	if( $count > 0 ) {
		return true;
	} else {
		return false;
	}
}

/**
 * Check to see whether the field id is defined
 * return true if the field is defined, false otherwise
 * @param int $p_field_id custom field id
 * @return bool
 * @access public
 */
function custom_field_exists( $p_field_id ) {
	if( false == custom_field_cache_row( $p_field_id, false ) ) {
		return false;
	} else {
		return true;
	}
}

/**
 * Return the type of a custom field if it exists.
 * @param int $p_field_id custom field id
 * @return int custom field type
 * @access public
 */
function custom_field_type( $p_field_id ) {
	$t_field = custom_field_cache_row( $p_field_id, false );
	if( $t_field == false ) {
		return - 1;
	} else {
		return $t_field['type'];
	}
}

/**
 * Check to see whether the field id is defined
 * return true if the field is defined, error otherwise
 * @param int $p_field_id custom field id
 * @return bool
 * @access public
 */
function custom_field_ensure_exists( $p_field_id ) {
	if( custom_field_exists( $p_field_id ) ) {
		return true;
	} else {
		error_parameters( 'Custom ' . $p_field_id );
		trigger_error( ERROR_CUSTOM_FIELD_NOT_FOUND, ERROR );
	}
}

/**
 * Check to see whether the name is unique
 * return false if a field with the name already exists, true otherwise
 * if an id is specified, then the corresponding record is excluded from the
 * uniqueness test.
 * @param string $p_name custom field name
 * @param int $p_custom_field_id custom field id
 * @return bool
 * @access public
 */
function custom_field_is_name_unique( $p_name, $p_custom_field_id = null ) {
	$t_custom_field_table = db_get_table( 'mantis_custom_field_table' );
	$query = "SELECT COUNT(*)
				  FROM $t_custom_field_table
				  WHERE name=" . db_param();
	if( $p_custom_field_id !== null ) {
		$c_id = db_prepare_int( $p_custom_field_id );
		$query .= ' AND (id <> ' . db_param() . ')';
	}
	$result = db_query_bound( $query, ( ($p_custom_field_id !== null) ? Array( $p_name, $c_id ) : Array( $p_name ) ) );
	$count = db_result( $result );

	if( $count > 0 ) {
		return false;
	} else {
		return true;
	}
}

/**
 * Check to see whether the name is unique
 * return true if the name has not been used, error otherwise
 * @param string $p_name Custom field name
 * @return bool
 * @access public
 */
function custom_field_ensure_name_unique( $p_name ) {
	if( custom_field_is_name_unique( $p_name ) ) {
		return true;
	} else {
		trigger_error( ERROR_CUSTOM_FIELD_NAME_NOT_UNIQUE, ERROR );
	}
}

/**
 * Return true if the user can read the value of the field for the given bug,
 * false otherwise.
 * @param int $p_field_id custom field id
 * @param int $p_bug_id bug id
 * @param int $p_user_id user id
 * @return bool
 * @access public
 */
function custom_field_has_read_access( $p_field_id, $p_bug_id, $p_user_id = null ) {
	custom_field_ensure_exists( $p_field_id );

	if( null === $p_user_id ) {
		$p_user_id = auth_get_current_user_id();
	}

	$t_access_level_r = custom_field_get_field( $p_field_id, 'access_level_r' );

	$t_project_id = bug_get_field( $p_bug_id, 'project_id' );

	return access_has_project_level( $t_access_level_r, $t_project_id, $p_user_id );
}

/**
 * Return true if the user can read the value of the field for the given project,
 * false otherwise.
 * @param int $p_field_id custom field id
 * @param int $p_project_id bug id
 * @param int $p_user_id user id
 * @return bool
 * @access public
 */
function custom_field_has_read_access_by_project_id( $p_field_id, $p_project_id, $p_user_id = null ) {
	custom_field_ensure_exists( $p_field_id );

	if( null === $p_user_id ) {
		$p_user_id = auth_get_current_user_id();
	}

	$t_access_level_r = custom_field_get_field( $p_field_id, 'access_level_r' );

	return access_has_project_level( $t_access_level_r, $p_project_id, $p_user_id );
}

/**
 * Return true if the user can modify the value of the field for the given project,
 * false otherwise.
 * @param int $p_field_id custom field id
 * @param int $p_project_id bug id
 * @param int $p_user_id user id
 * @return bool
 * @access public
 */
function custom_field_has_write_access_to_project( $p_field_id, $p_project_id, $p_user_id = null ) {
	custom_field_ensure_exists( $p_field_id );

	if( null === $p_user_id ) {
		$p_user_id = auth_get_current_user_id();
	}

	$t_access_level_rw = custom_field_get_field( $p_field_id, 'access_level_rw' );

	return access_has_project_level( $t_access_level_rw, $p_project_id, $p_user_id );
}

/**
 * Return true if the user can modify the value of the field for the given bug,
 * false otherwise.
 * @param int $p_field_id custom field id
 * @param int $p_bug_id bug id
 * @param int $p_user_id user id
 * @return bool
 * @access public
 */
function custom_field_has_write_access( $p_field_id, $p_bug_id, $p_user_id = null ) {
	$t_project_id = bug_get_field( $p_bug_id, 'project_id' );
	return( custom_field_has_write_access_to_project( $p_field_id, $t_project_id, $p_user_id ) );
}

/**
 * create a new custom field with the name $p_name
 * the definition are the default values and can be changes later
 * return the ID of the new definition
 * @param string $p_name custom field name
 * @return int custom field id
 * @access public
 */
function custom_field_create( $p_name ) {
	if( string_contains_scripting_chars( $p_name ) ) {
		error_parameters( lang_get( 'custom_field_name' ) );
		trigger_error( ERROR_CUSTOM_FIELD_INVALID_PROPERTY, ERROR );
	}

	$c_name = trim( $p_name );

	if( is_blank( $c_name ) ) {
		error_parameters( 'name' );
		trigger_error( ERROR_EMPTY_FIELD, ERROR );
	}

	custom_field_ensure_name_unique( $c_name );

	$t_custom_field_table = db_get_table( 'mantis_custom_field_table' );
	$query = "INSERT INTO $t_custom_field_table
					( name, possible_values )
				  VALUES
					( " . db_param() . ',' . db_param() . ')';

	db_query_bound( $query, Array( $c_name, '' ) );

	return db_insert_id( $t_custom_field_table );
}

/**
 * Update the field definition
 * return true on success, false on failure
 * @param int $p_field_id custom field id
 * @param array custom field definition
 * @return bool
 * @access public
 */
function custom_field_update( $p_field_id, $p_def_array ) {
	if( string_contains_scripting_chars( $p_def_array['name'] ) ) {
		error_parameters( lang_get( 'custom_field_name' ) );
		trigger_error( ERROR_CUSTOM_FIELD_INVALID_PROPERTY, ERROR );
	}

	if( is_blank( $p_def_array['name'] ) ) {
		error_parameters( 'name' );
		trigger_error( ERROR_EMPTY_FIELD, ERROR );
	}

	if( $p_def_array['access_level_rw'] < $p_def_array['access_level_r'] ) {
		error_parameters(
			lang_get( 'custom_field_access_level_r' ) . ', ' .
			lang_get( 'custom_field_access_level_rw' )
		);
		trigger_error( ERROR_CUSTOM_FIELD_INVALID_PROPERTY, ERROR );
	}

	if (   $p_def_array['length_min'] < 0
		|| ( $p_def_array['length_max'] != 0 && $p_def_array['length_min'] > $p_def_array['length_max'] )
	) {
		error_parameters( lang_get( 'custom_field_length_min' ) . ', ' . lang_get( 'custom_field_length_max' ));
		trigger_error( ERROR_CUSTOM_FIELD_INVALID_PROPERTY, ERROR );
	}

	if( !custom_field_is_name_unique( $p_def_array['name'], $p_field_id ) ) {
		trigger_error( ERROR_CUSTOM_FIELD_NAME_NOT_UNIQUE, ERROR );
	}

	# Build fields update statement
	$t_update = '';
	foreach( $p_def_array as $field => $value ) {
		$t_update .= "$field = " . db_param() . ', ';
		$t_params[] = is_bool( $value ) ? db_prepare_bool( $value ) : $value;
	}

	# If there are fields to update, execute SQL
	if( $t_update !== '' ) {
		$t_mantis_custom_field_table = db_get_table( 'mantis_custom_field_table' );

		$t_query = "
			UPDATE $t_mantis_custom_field_table
			SET " . rtrim( $t_update, ', ' ) . "
			WHERE id = " . db_param();
		$t_params[] = $p_field_id;
		db_query_bound( $t_query, $t_params );

		custom_field_clear_cache( $p_field_id );

		# db_query errors on failure so:
		return true;
	}

	return false;
}

/**
 * Add a custom field to a project
 * return true on success, false on failure or if already added
 * @param int $p_field_id custom field id
 * @param int $p_project_id project id
 * @return bool
 * @access public
 */
function custom_field_link( $p_field_id, $p_project_id ) {
	$c_field_id = db_prepare_int( $p_field_id );
	$c_project_id = db_prepare_int( $p_project_id );

	custom_field_ensure_exists( $p_field_id );
	project_ensure_exists( $p_project_id );

	if( custom_field_is_linked( $p_field_id, $p_project_id ) ) {
		return false;
	}

	$t_custom_field_project_table = db_get_table( 'mantis_custom_field_project_table' );
	$query = "INSERT INTO $t_custom_field_project_table
					( field_id, project_id )
				  VALUES
					( " . db_param() . ', ' . db_param() . ')';
	db_query_bound( $query, Array( $c_field_id, $c_project_id ) );

	# db_query errors on failure so:
	return true;
}

/**
 * Remove a custom field from a project
 * return true on success, false on failure
 *
 * The values for the custom fields are not deleted.  This is to allow for the
 * case where a bug is moved to another project that has the field, or the
 * field is linked again to the project.
 * @param int $p_field_id custom field id
 * @param int $p_project_id project id
 * @return bool
 * @access public
 */
function custom_field_unlink( $p_field_id, $p_project_id ) {
	$c_field_id = db_prepare_int( $p_field_id );
	$c_project_id = db_prepare_int( $p_project_id );

	$t_custom_field_project_table = db_get_table( 'mantis_custom_field_project_table' );
	$query = "DELETE FROM $t_custom_field_project_table
				  WHERE field_id = " . db_param() . " AND
				  		project_id = " . db_param();
	db_query_bound( $query, Array( $c_field_id, $c_project_id ) );

	# db_query errors on failure so:
	return true;
}

/**
 * Delete the field definition and all associated values and project associations
 * return true on success, false on failure
 * @param int $p_field_id custom field id
 * @return bool
 * @access public
 */
function custom_field_destroy( $p_field_id ) {
	$c_field_id = db_prepare_int( $p_field_id );

	# delete all values
	$t_custom_field_string_table = db_get_table( 'mantis_custom_field_string_table' );
	$query = "DELETE FROM $t_custom_field_string_table
				  WHERE field_id=" . db_param();
	db_query_bound( $query, Array( $c_field_id ) );

	# delete all project associations
	$t_custom_field_project_table = db_get_table( 'mantis_custom_field_project_table' );
	$query = "DELETE FROM $t_custom_field_project_table
				  WHERE field_id=" . db_param();
	db_query_bound( $query, Array( $c_field_id ) );

	$t_custom_field_table = db_get_table( 'mantis_custom_field_table' );

	# delete the definition
	$query = "DELETE FROM $t_custom_field_table
				  WHERE id=" .  db_param();
	db_query_bound( $query, Array( $c_field_id ) );

	custom_field_clear_cache( $p_field_id );

	# db_query errors on failure so:
	return true;
}

/**
 * Delete all associations of custom fields to the specified project
 * return true on success, false on failure
 *
 * To be called from within project_delete().
 * @param int $p_project_id project id
 * @return bool
 * @access public
 */
function custom_field_unlink_all( $p_project_id ) {
	$c_project_id = db_prepare_int( $p_project_id );

	# delete all project associations
	$t_custom_field_project_table = db_get_table( 'mantis_custom_field_project_table' );
	$query = "DELETE FROM $t_custom_field_project_table
				  WHERE project_id=" . db_param();
	db_query_bound( $query, Array( $c_project_id ) );

	# db_query errors on failure so:
	return true;
}

/**
 * Delete all custom values associated with the specified bug.
 * return true on success, false on failure
 *
 * To be called from bug_delete().
 * @param int $p_bug_id bug id
 * @return bool
 * @access public
 */
function custom_field_delete_all_values( $p_bug_id ) {
	$c_bug_id = db_prepare_int( $p_bug_id );

	$t_custom_field_string_table = db_get_table( 'mantis_custom_field_string_table' );
	$query = "DELETE FROM $t_custom_field_string_table
				  WHERE bug_id=" . db_param();
	db_query_bound( $query, Array( $c_bug_id ) );

	# db_query errors on failure so:
	return true;
}

/**
 * Get the id of the custom field with the specified name.
 * false is returned if no custom field found with the specified name.
 * @param string $p_field_name custom field name
 * @param int $p_truncated_length
 * @return bool|int false or custom field id
 * @access public
 */
function custom_field_get_id_from_name( $p_field_name, $p_truncated_length = null ) {
	global $g_cache_name_to_id_map;

	if ( is_blank( $p_field_name ) ) {
		return false;
	}

	if ( isset( $g_cache_name_to_id_map[$p_field_name] ) ) {
		return $g_cache_name_to_id_map[$p_field_name];
	}

	$t_custom_field_table = db_get_table( 'mantis_custom_field_table' );

	if(( null === $p_truncated_length ) || ( utf8_strlen( $p_field_name ) != $p_truncated_length ) ) {
		$query = "SELECT id FROM $t_custom_field_table WHERE name = " . db_param();
		$c_field_name = $p_field_name;
	} else {
		# This is to handle the case where we potentially only have a
		# truncated part of the custom field name.  This happens when we
		# are getting the field from the history logs (as the history's
		# field_name column used to be 32 while custom field name is 64).
		# This is needed to handle legacy database entries, as any
		# history record created after 1.1.0a4 has the correct field
		# size (see #8002)
		$query = "SELECT id FROM $t_custom_field_table WHERE name LIKE " . db_param();
		$c_field_name = $p_field_name . '%';
	}

	$t_result = db_query_bound( $query, array( $c_field_name ) );

	if( db_num_rows( $t_result ) == 0 ) {
		$g_cache_name_to_id_map[$p_field_name] = false;
		return false;
	}

	$row = db_fetch_array( $t_result );
	$g_cache_name_to_id_map[$p_field_name] = $row['id'];

	return $row['id'];
}

/**
 * Return an array of ids of custom fields bound to the specified project
 *
 * The ids will be sorted based on the sequence number associated with the binding
 * @param int $p_project_id project id
 * @return array
 * @access public
 */
function custom_field_get_linked_ids( $p_project_id = ALL_PROJECTS ) {
	global $g_cache_cf_linked, $g_cache_custom_field;

	if( !isset( $g_cache_cf_linked[$p_project_id] ) ) {

		$t_custom_field_table = db_get_table( 'mantis_custom_field_table' );
		$t_custom_field_project_table = db_get_table( 'mantis_custom_field_project_table' );

		if( ALL_PROJECTS == $p_project_id ) {
			$t_project_user_list_table = db_get_table( 'mantis_project_user_list_table' );
			$t_project_table = db_get_table( 'mantis_project_table' );
			$t_user_table = db_get_table( 'mantis_user_table' );
			$t_user_id = auth_get_current_user_id();

			# Select only the ids of custom fields in projects the user has access to
			#  - all custom fields in public projects,
			#  - those in private projects where the user is listed
			#  - in private projects where the user is implicitly listed
			$t_query = "
				SELECT DISTINCT cft.id
				FROM $t_custom_field_table cft
					JOIN $t_custom_field_project_table cfpt ON cfpt.field_id = cft.id
					JOIN $t_project_table pt
						ON pt.id = cfpt.project_id AND pt.enabled = " . db_prepare_bool( true ) . "
					LEFT JOIN $t_project_user_list_table pult
						ON pult.project_id = cfpt.project_id AND pult.user_id = " . db_param() . "
					, $t_user_table ut
				WHERE ut.id = " . db_param() . "
					AND (  pt.view_state = " . VS_PUBLIC . "
						OR pult.user_id = ut.id
						";
			$t_params = array( $t_user_id, $t_user_id );

			# Add private access clause and related parameter
			$t_private_access = config_get( 'private_project_threshold' );
			if( is_array( $t_private_access ) ) {
				if( 1 == count( $t_private_access ) ) {
					$t_access_clause = '= ' . db_param();
					$t_params[] = array_shift( $t_private_access );
				} else {
					$t_access_clause = 'IN (';
					foreach( $t_private_access as $t_elem ) {
						$t_access_clause .= db_param() . ',';
						$t_params[] = $t_elem;
					}
					$t_access_clause = rtrim( $t_access_clause, ',') . ')';
				}
			} else {
				$t_access_clause = '>=' . db_param();
				$t_params[] = $t_private_access;
			}
			$t_query .= "OR ( pult.user_id IS NULL AND ut.access_level $t_access_clause ) )";
		} else {
			if( is_array( $p_project_id ) ) {
				if( 1 == count( $p_project_id ) ) {
					$t_project_clause = '= ' . db_param();
					$t_params[] = array_shift( $p_project_id );
				} else {
					$t_project_clause = 'IN (';
					foreach( $p_project_id as $t_project ) {
						$t_project_clause .= db_param() . ',';
						$t_params[] = $t_project;
					}
					$t_project_clause = rtrim( $t_project_clause, ',') . ')';
				}
			} else {
				$t_project_clause = '= ' . db_param();
				$t_params[] = $p_project_id;
			}
			$t_query = "
				SELECT cft.id
				FROM $t_custom_field_table cft
					JOIN $t_custom_field_project_table cfpt ON cfpt.field_id = cft.id
				WHERE cfpt.project_id $t_project_clause
				ORDER BY sequence ASC, name ASC";
		}

		$result = db_query_bound( $t_query, $t_params );
		$t_row_count = db_num_rows( $result );
		$t_ids = array();

		for( $i = 0;$i < $t_row_count;$i++ ) {
			$row = db_fetch_array( $result );
			array_push( $t_ids, $row['id'] );
		}
		custom_field_cache_array_rows( $t_ids );

		$g_cache_cf_linked[$p_project_id] = $t_ids;
	} else {
		$t_ids = $g_cache_cf_linked[$p_project_id];
	}
	return $t_ids;
}

/**
 * Return an array all custom field ids sorted by name
 * @return array
 * @access public
 */
function custom_field_get_ids() {
	global $g_cache_cf_list, $g_cache_custom_field;

	if( $g_cache_cf_list === NULL ) {
		$t_custom_field_table = db_get_table( 'mantis_custom_field_table' );
		$query = "SELECT *
				  FROM $t_custom_field_table
				  ORDER BY name ASC";
		$result = db_query_bound( $query );
		$t_row_count = db_num_rows( $result );
		$t_ids = array();

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

			$g_cache_custom_field[(int) $row['id']] = $row;

			array_push( $t_ids, $row['id'] );
		}
		$g_cache_cf_list = $t_ids;
	} else {
		$t_ids = $g_cache_cf_list;
	}
	return $t_ids;
}

/**
 * Return an array of ids of projects related to the specified custom field
 * (the array may be empty)
 * @param int $p_field_id custom field id
 * @return array
 * @access public
 */
function custom_field_get_project_ids( $p_field_id ) {
	$c_field_id = db_prepare_int( $p_field_id );

	$t_custom_field_project_table = db_get_table( 'mantis_custom_field_project_table' );
	$query = "SELECT project_id
				  FROM $t_custom_field_project_table
				  WHERE field_id = " . db_param();
	$result = db_query_bound( $query, Array( $c_field_id ) );

	$t_row_count = db_num_rows( $result );
	$t_ids = array();

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

		array_push( $t_ids, $row['project_id'] );
	}

	return $t_ids;
}

/**
 * Return a field definition row for the field or error if the field does not exist
 * @param int $p_field_id custom field id
 * @return array custom field definition
 * @access public
 */
function custom_field_get_definition( $p_field_id ) {
	return custom_field_cache_row( $p_field_id );
}

/**
 * Return a single database field from a custom field definition row for the field
 * if the database field does not exist, display a warning and return ''
 * @param int $p_field_id custom field id
 * @param int $p_field_name custom field name
 * @return string
 * @access public
 */
function custom_field_get_field( $p_field_id, $p_field_name ) {
	$row = custom_field_get_definition( $p_field_id );

	if( isset( $row[$p_field_name] ) ) {
		return $row[$p_field_name];
	} else {
		error_parameters( $p_field_name );
		trigger_error( ERROR_DB_FIELD_NOT_FOUND, WARNING );
		return '';
	}
}

/**
 * Return custom field name including localized name (if available)
 *
 * @param string $p_name Custom field's name
 * @return string CustomFieldName [(LocalizedName)]
 * @access public
 */
function custom_field_get_display_name( $p_name ) {
	$t_local_name = lang_get_defaulted( $p_name );
	if( $t_local_name != $p_name ) {
		$p_name .= " ($t_local_name)";
	}

	return string_display( $p_name );
}

/**
 * Get the value of a custom field for the given bug
 * @todo return values are unclear... should we error when access is denied
 * and provide an api to check whether it will be?
 * @param int $p_field_id custom field id
 * @param int $p_bug_id bug id
 * @return mixed: value is defined, null: no value is defined, false: read access is denied
 * @access public
 */
function custom_field_get_value( $p_field_id, $p_bug_id ) {
	$c_field_id = db_prepare_int( $p_field_id );
	$c_bug_id = db_prepare_int( $p_bug_id );

	$row = custom_field_cache_row( $p_field_id );

	$t_access_level_r = $row['access_level_r'];
	$t_default_value = $row['default_value'];

	if( !custom_field_has_read_access( $p_field_id, $p_bug_id, auth_get_current_user_id() ) ) {
		return false;
	}

	#ODB Production - Text Area
	$t_value_field = ( $row['type'] == CUSTOM_FIELD_TYPE_TEXTAREA ? 'text' : 'value' );

	$t_custom_field_string_table = db_get_table( 'mantis_custom_field_string_table' );
	$query = "SELECT value
				  FROM $t_custom_field_string_table
				  WHERE bug_id=" . db_param() . " AND
				  		field_id=" . db_param();
	$result = db_query_bound( $query, Array( $c_bug_id, $c_field_id ) );

	if( db_num_rows( $result ) > 0 ) {
		return custom_field_database_to_value( db_result( $result ), $row['type'] );
	} else {
		return null;
	}
}

/**
 * Gets the custom fields array for the given bug readable by specified level.
 * Array keys are custom field names. Array is sorted by custom field sequence number;
 * Array items are arrays with the next keys:
 * 'type', 'value', 'access_level_r'
 * @param int $p_bug_id bug id
 * @param int $p_user_access_level Access level
 * @return  array
 * @access public
 */
function custom_field_get_linked_fields( $p_bug_id, $p_user_access_level ) {
	$t_custom_fields = custom_field_get_all_linked_fields( $p_bug_id );

	# removing restricted fields
	foreach( $t_custom_fields as $t_custom_field_name => $t_custom_field_data ) {
		if( $p_user_access_level < $t_custom_field_data['access_level_r'] ) {
			unset( $t_custom_fields[$t_custom_field_name] );
		}
	}
	return $t_custom_fields;
}

/**
 * Gets the custom fields array for the given bug. Array keys are custom field names.
 * Array is sorted by custom field sequence number; Array items are arrays with the next keys:
 * 'type', 'value', 'access_level_r'
 * @param int $p_bug_id bug id
 * @return  array
 * @access public
 */
function custom_field_get_all_linked_fields( $p_bug_id ) {
	global $g_cached_custom_field_lists;

	if( !is_array( $g_cached_custom_field_lists ) ) {
		$g_cached_custom_field_lists = array();
	}

	# is the list in cache ?
	if( !array_key_exists( $p_bug_id, $g_cached_custom_field_lists ) ) {
		$t_custom_field_project_table = db_get_table( 'mantis_custom_field_project_table' );
		$t_custom_field_table = db_get_table( 'mantis_custom_field_table' );
		$t_custom_field_string_table = db_get_table( 'mantis_custom_field_string_table' );

		$query = "
			SELECT f.name, f.type, f.access_level_r, f.default_value, f.type, s.value
			FROM $t_custom_field_project_table p
				INNER JOIN $t_custom_field_table f ON f.id = p.field_id
				LEFT JOIN $t_custom_field_string_table s
					ON s.field_id = p.field_id AND s.bug_id = " . db_param() . "
			WHERE p.project_id = " . db_param() . "
			ORDER BY p.sequence ASC, f.name ASC";

		$t_params = array(
			(int)$p_bug_id,
			bug_get_field( $p_bug_id, 'project_id' )
		);

		$result = db_query_bound( $query, $t_params );
		$t_row_count = db_num_rows( $result );

		$t_custom_fields = array();

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

			if( is_null( $row['value'] ) ) {
				$t_value = $row['default_value'];
			} else {
				$t_value = custom_field_database_to_value( $row['value'], $row['type'] );
			}

			$t_custom_fields[$row['name']] = array(
				'type' => $row['type'],
				'value' => $t_value,
				'access_level_r' => $row['access_level_r'],
			);
		}

		$g_cached_custom_field_lists[$p_bug_id] = $t_custom_fields;
	}

	return $g_cached_custom_field_lists[$p_bug_id];
}

/**
 * Gets the sequence number for the specified custom field for the specified
 * project.  Returns false in case of error.
 * @param int $p_field_id custom field id
 * @param int $p_project_id project id
 * @return int|bool
 * @access public
 */
function custom_field_get_sequence( $p_field_id, $p_project_id ) {
	$c_field_id = db_prepare_int( $p_field_id );
	$c_project_id = db_prepare_int( $p_project_id );

	$t_custom_field_project_table = db_get_table( 'mantis_custom_field_project_table' );
	$query = "SELECT sequence
				  FROM $t_custom_field_project_table
				  WHERE field_id=" . db_param() . " AND
						project_id=" . db_param();
	$result = db_query_bound( $query, Array( $c_field_id, $c_project_id ), 1 );

	if( 0 == db_num_rows( $result ) ) {
		return false;
	}

	$t_row = db_fetch_array( $result );

	return $t_row['sequence'];
}

/**
 * Allows the validation of a custom field value without setting it
 * or needing a bug to exist.
 * @param int $p_field_id custom field id
 * @param string $p_value custom field value
 * @return bool
 * @access public
 */
function custom_field_validate( $p_field_id, $p_value ) {
	$c_field_id = db_prepare_int( $p_field_id );

	custom_field_ensure_exists( $p_field_id );

	$t_custom_field_table = db_get_table( 'mantis_custom_field_table' );
	$query = "SELECT name, type, possible_values, valid_regexp,
				  		 access_level_rw, length_min, length_max, default_value
				  FROM $t_custom_field_table
				  WHERE id=" . db_param();
	$result = db_query_bound( $query, Array( $c_field_id ) );
	$row = db_fetch_array( $result );

	$t_name = $row['name'];
	$t_type = $row['type'];
	$t_possible_values = $row['possible_values'];
	$t_valid_regexp = $row['valid_regexp'];
	$t_length_min = $row['length_min'];
	$t_length_max = $row['length_max'];
	$t_default_value = $row['default_value'];

	$t_valid = true;
	$t_length = utf8_strlen( $p_value );
	switch ($t_type) {
		case CUSTOM_FIELD_TYPE_STRING:
			# Empty fields are valid
			if( $t_length == 0 ) {
				break;
			}
			# Regular expression string validation
			if( !is_blank( $t_valid_regexp ) ) {
				$t_valid &= preg_match( "/$t_valid_regexp/", $p_value );
			}
			# Check the length of the string
			$t_valid &= ( 0 == $t_length_min ) || ( $t_length >= $t_length_min );
			$t_valid &= ( 0 == $t_length_max ) || ( $t_length <= $t_length_max );
			break;
		case CUSTOM_FIELD_TYPE_NUMERIC:
			# Empty fields are valid
			if( $t_length == 0 ) {
				break;
			}
			$t_valid &= is_numeric( $p_value );

			# Check the length of the number
			$t_valid &= ( 0 == $t_length_min ) || ( $t_length >= $t_length_min );
			$t_valid &= ( 0 == $t_length_max ) || ( $t_length <= $t_length_max );

			break;
		case CUSTOM_FIELD_TYPE_FLOAT:
			# Empty fields are valid
			if( $t_length == 0 ) {
				break;
			}
			# Allow both integer and float numbers
			$t_valid &= is_numeric( $p_value ) || is_float( $p_value );

			# Check the length of the number
			$t_valid &= ( 0 == $t_length_min ) || ( $t_length >= $t_length_min );
			$t_valid &= ( 0 == $t_length_max ) || ( $t_length <= $t_length_max );

			break;
		case CUSTOM_FIELD_TYPE_DATE:
			# gpc_get_cf for date returns the value from strftime
			# Either false (php >= 5.1) or -1 (php < 5.1) for failure
			$t_valid &= ( $p_value == null ) || ( ( $p_value !== false ) && ( $p_value > 0 ) );
			break;
		case CUSTOM_FIELD_TYPE_CHECKBOX:
		case CUSTOM_FIELD_TYPE_MULTILIST:
			# Checkbox fields can hold a null value (when no checkboxes are ticked)
			if ( $p_value === '' ) {
				break;
			}

			# If checkbox field value is not null then we need to validate it... (note: no "break" statement here!)
			$t_values = explode( '|', $p_value );
			$t_possible_values = custom_field_prepare_possible_values( $row['possible_values'] );
			$t_possible_values = explode( '|', $t_possible_values );
			$t_invalid_values = array_diff( $t_values, $t_possible_values );
			$t_valid &= ( count( $t_invalid_values ) == 0 );
			break;
		case CUSTOM_FIELD_TYPE_LIST:
		case CUSTOM_FIELD_TYPE_ENUM:
		case CUSTOM_FIELD_TYPE_RADIO:
			# List fields can be empty (when they are not shown on the form or shown with no default values and never clicked)
			if ( is_blank( $p_value ) ) {
				break;
			}

			# If list field value is not empty then we need to validate it... (note: no "break" statement here!)
			$t_possible_values = custom_field_prepare_possible_values( $row['possible_values'] );
			$t_values_arr = explode( '|', $t_possible_values );
			$t_valid &= in_array( $p_value, $t_values_arr );
			break;
		case CUSTOM_FIELD_TYPE_EMAIL:
			if ( $p_value !== '' ) {
				$t_valid &= email_is_valid( $p_value );
			}
			break;
		default:
			break;
	}
	return (bool)$t_valid;
}

/**
 * $p_possible_values: possible values to be pre-processed.  If it has enum values,
 * it will be left as is.  If it has a method, it will be replaced by the list.
 * @param string $p_possible_values
 * @return string|array
 * @access public
 */
function custom_field_prepare_possible_values( $p_possible_values ) {
	$t_possible_values = $p_possible_values;

	if( !is_blank( $t_possible_values ) && ( $t_possible_values[0] == '=' ) ) {
		$t_possible_values = helper_call_custom_function( 'enum_' . utf8_substr( $t_possible_values, 1 ), array() );
	}

	return $t_possible_values;
}

/**
 * Get All Possible Values for a Field.
 * @param array $p_field_def custom field definition
 * @param int $p_project_id project id
 * @return bool|array
 * @access public
 */
function custom_field_distinct_values( $p_field_def, $p_project_id = ALL_PROJECTS ) {
	global $g_custom_field_type_definition;
	$t_custom_field_string_table = db_get_table( 'mantis_custom_field_string_table' );
	$t_mantis_bug_table = db_get_table( 'mantis_bug_table' );
	$t_return_arr = array();

	# If an enumeration type, we get all possible values, not just used values
	if( isset( $g_custom_field_type_definition[$p_field_def['type']]['#function_return_distinct_values'] ) ) {
		return call_user_func( $g_custom_field_type_definition[$p_field_def['type']]['#function_return_distinct_values'], $p_field_def );
	} else {
		$t_from = "$t_custom_field_string_table cfst";
		$t_where1 = 'cfst.field_id = ' . db_param();
		$t_params[] = $p_field_def['id'];

		if( ALL_PROJECTS != $p_project_id ) {
			$t_from .= " JOIN $t_mantis_bug_table bt ON bt.id = cfst.bug_id";
			$t_where2 = 'AND bt.project_id = ' . db_param();
			$t_params[] = $p_project_id;
		} else {
			$t_where2 = '';
		}
		$t_query = "
			SELECT DISTINCT cfst.value
			FROM $t_from
			WHERE $t_where1 $t_where2
			ORDER BY cfst.value";

		$t_result = db_query_bound( $t_query, $t_params );
		$t_row_count = db_num_rows( $t_result );
		if( 0 == $t_row_count ) {
			return false;
		}

		for( $i = 0;$i < $t_row_count;$i++ ) {
			$row = db_fetch_array( $t_result );
			if( !is_blank( trim( $row['value'] ) ) ) {
				array_push( $t_return_arr, $row['value'] );
			}
		}
	}
	return $t_return_arr;
}

/**
 * Convert the value to save it into the database, depending of the type
 * return value for database
 * @param mixed $p_value
 * @param int $p_type
 * @return mixed
 * @access public
 */
function custom_field_value_to_database( $p_value, $p_type ) {
	global $g_custom_field_type_definition;
	if( isset( $g_custom_field_type_definition[$p_type]['#function_value_to_database'] ) ) {
		return call_user_func( $g_custom_field_type_definition[$p_type]['#function_value_to_database'], $p_value );
	}
	return $p_value;
}

/**
 * Convert the database-value to value, depending of the type
 * return value for further operation
 * @param mixed $p_value
 * @param int $p_type
 * @return mixed
 * @access public
 */
function custom_field_database_to_value( $p_value, $p_type ) {
	global $g_custom_field_type_definition;
	if( isset( $g_custom_field_type_definition[$p_type]['#function_database_to_value'] ) ) {
		return call_user_func( $g_custom_field_type_definition[$p_type]['#function_database_to_value'], $p_value );
	}
	return $p_value;
}

/**
 * Convert the default-value to value depending on the type.  For example, in case of date, this
 * would translate 'tomorrow' to tomorrow's date.
 * @param mixed $p_value
 * @param int $p_type
 * @return mixed
 * @access public
 */
function custom_field_default_to_value( $p_value, $p_type ) {
	global $g_custom_field_type_definition;

	if( isset( $g_custom_field_type_definition[$p_type]['#function_default_to_value'] ) ) {
		return call_user_func( $g_custom_field_type_definition[$p_type]['#function_default_to_value'], $p_value );
	}

	return $p_value;
}

/**
 * Set the value of a custom field for a given bug
 * return true on success, false on failure
 * @param int $p_field_id custom field id
 * @param int $p_bug_id bug id
 * @param mixed $p_value
 * @param boolean $p_log create history logs for new values
 * @return bool
 * @access public
 */
function custom_field_set_value( $p_field_id, $p_bug_id, $p_value, $p_log_insert=true ) {
	$c_field_id = db_prepare_int( $p_field_id );
	$c_bug_id = db_prepare_int( $p_bug_id );

	custom_field_ensure_exists( $p_field_id );

	if ( !custom_field_validate( $p_field_id, $p_value ) )
		return false;

	$t_name = custom_field_get_field( $p_field_id, 'name' );
	$t_type = custom_field_get_field( $p_field_id, 'type' );
	$t_custom_field_string_table = db_get_table( 'mantis_custom_field_string_table' );

	#ODB Production - Text Area
	$t_value_field = ( $t_type == CUSTOM_FIELD_TYPE_TEXTAREA ) ? 'text' : 'value';

	# Determine whether an existing value needs to be updated or a new value inserted
	$query = "SELECT value
				  FROM $t_custom_field_string_table
				  WHERE field_id=" . db_param() . " AND
				  		bug_id=" . db_param();
	$result = db_query_bound( $query, Array( $c_field_id, $c_bug_id ) );

	if( db_num_rows( $result ) > 0 ) {
		$query = "UPDATE $t_custom_field_string_table
					  SET value=" . db_param() . "
					  WHERE field_id=" . db_param() . " AND
					  		bug_id=" . db_param();
		db_query_bound( $query, Array( custom_field_value_to_database( $p_value, $t_type ), $c_field_id, $c_bug_id ) );

		$row = db_fetch_array( $result );
		history_log_event_direct( $c_bug_id, $t_name, custom_field_database_to_value( $row['value'], $t_type ), $p_value );
	} else {
		$query = "INSERT INTO $t_custom_field_string_table
						( field_id, bug_id, value )
					  VALUES
						( " . db_param() . ', ' . db_param() . ', ' . db_param() . ')';
		db_query_bound( $query, Array( $c_field_id, $c_bug_id, custom_field_value_to_database( $p_value, $t_type ) ) );
		# Don't log history events for new bug reports or on other special occasions
		if ( $p_log_insert ) {
			history_log_event_direct( $c_bug_id, $t_name, '', $p_value );
		}
	}

	custom_field_clear_cache( $p_field_id );

	# db_query errors on failure so:
	return true;
}

/**
 * Sets the sequence number for the specified custom field for the specified
 * project.
 * @param int $p_field_id custom field id
 * @param int $p_project_id project id
 * @param int $p_sequence
 * @return bool
 * @access public
 */
function custom_field_set_sequence( $p_field_id, $p_project_id, $p_sequence ) {
	$c_field_id = db_prepare_int( $p_field_id );
	$c_project_id = db_prepare_int( $p_project_id );
	$c_sequence = db_prepare_int( $p_sequence );

	$t_custom_field_project_table = db_get_table( 'mantis_custom_field_project_table' );

	$query = "UPDATE $t_custom_field_project_table
				  SET sequence=" . db_param() . "
				  WHERE field_id=" . db_param() . " AND
				  		project_id=" . db_param();
	$result = db_query_bound( $query, Array( $c_sequence, $c_field_id, $c_project_id ) );

	custom_field_clear_cache( $p_field_id );

	return true;
}

/**
 * Print an input field
 * $p_field_def contains the definition of the custom field (including it's field id
 * $p_bug_id    contains the bug where this field belongs to. If it's left
 * away, it'll default to 0 and thus belongs to a new (i.e. non-existant) bug
 * NOTE: This probably belongs in the print_api.php
 * @param array $p_field_def custom field definition
 * @param int $p_bug_id bug id
 * @access public
 */
function print_custom_field_input( $p_field_def, $p_bug_id = null ) {
	if( null === $p_bug_id ) {
		$t_custom_field_value = custom_field_default_to_value( $p_field_def['default_value'], $p_field_def['type'] );
	} else {
		$t_custom_field_value = custom_field_get_value( $p_field_def['id'], $p_bug_id );
		# If the custom field value is undefined and the field cannot hold a null value, use the default value instead
		if( $t_custom_field_value === null &&
			( $p_field_def['type'] == CUSTOM_FIELD_TYPE_ENUM ||
				$p_field_def['type'] == CUSTOM_FIELD_TYPE_LIST ||
				$p_field_def['type'] == CUSTOM_FIELD_TYPE_MULTILIST ||
				$p_field_def['type'] == CUSTOM_FIELD_TYPE_RADIO ) ) {
			$t_custom_field_value = custom_field_default_to_value( $p_field_def['default_value'], $p_field_def['type'] );
		}
	}

	global $g_custom_field_type_definition;
	if( isset( $g_custom_field_type_definition[$p_field_def['type']]['#function_print_input'] ) ) {
		call_user_func( $g_custom_field_type_definition[$p_field_def['type']]['#function_print_input'], $p_field_def, $t_custom_field_value );
	} else {
		trigger_error( ERROR_CUSTOM_FIELD_INVALID_DEFINITION, ERROR );
	}
}

/**
 * Prepare a string containing a custom field value for display
 * @todo This probably belongs in the string_api.php
 * @param array  $p_def contains the definition of the custom field
 * @param int $p_field_id contains the id of the field
 * @param int $p_bug_id contains the bug id to display the custom field value for
 * @return string
 * @access public
 */
function string_custom_field_value( $p_def, $p_field_id, $p_bug_id ) {
	$t_custom_field_value = custom_field_get_value( $p_field_id, $p_bug_id );
	if( $t_custom_field_value === null ) {
		return '';
	}
	global $g_custom_field_type_definition;
	if( isset( $g_custom_field_type_definition[$p_def['type']]['#function_string_value'] ) ) {
		return call_user_func( $g_custom_field_type_definition[$p_def['type']]['#function_string_value'], $t_custom_field_value );
	}
	return string_display_links( $t_custom_field_value );
}

/**
 * Print a custom field value for display
 * NOTE: This probably belongs in the print_api.php
 * @param array  $p_def contains the definition of the custom field
 * @param int $p_field_id contains the id of the field
 * @param int $p_bug_id contains the bug id to display the custom field value for
 * @return null
 * @access public
 */
function print_custom_field_value( $p_def, $p_field_id, $p_bug_id ) {
	echo string_custom_field_value( $p_def, $p_field_id, $p_bug_id );
}

/**
 * Prepare a string containing a custom field value for email
 * NOTE: This probably belongs in the string_api.php
 * @param string $p_value value of custom field
 * @param int $p_type	type of custom field
 * @return string value ready for sending via email
 * @access public
 */
function string_custom_field_value_for_email( $p_value, $p_type ) {
	global $g_custom_field_type_definition;
	if( isset( $g_custom_field_type_definition[$p_type]['#function_string_value_for_email'] ) ) {
		return call_user_func( $g_custom_field_type_definition[$p_type]['#function_string_value_for_email'], $p_value );
	}
	return $p_value;
}
custom_field_api.php (47,226 bytes)   
filter_api.php (184,241 bytes)   
<?php
# MantisBT - a php based bugtracking system

# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.

/**
 * @package CoreAPI
 * @subpackage FilterAPI
 * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
 * @copyright Copyright (C) 2002 - 2014  MantisBT Team - mantisbt-dev@lists.sourceforge.net
 * @link http://www.mantisbt.org
 */

/**
 * requires current_user_api
 */
require_once( 'current_user_api.php' );
/**
 * requires user_api
 */
require_once( 'user_api.php' );
/**
 * requires bug_api
 */
require_once( 'bug_api.php' );
/**
 * requires collapse_api
 */
require_once( 'collapse_api.php' );
/**
 * requires relationship_api
 */
require_once( 'relationship_api.php' );
/**
 * requires tag_api
 */
require_once( 'tag_api.php' );
/**
 * requires config_filter_defaults_inc
 */
require_once( $g_absolute_path . 'config_filter_defaults_inc.php' );

/**
 * Allow plugins to define a set of class-based filters, and register/load
 * them here to be used by the rest of filter_api.
 * @return array Mapping of field name to filter object
 */
function filter_get_plugin_filters() {
	static $s_field_array = null;

	if ( is_null( $s_field_array ) ) {
		$s_field_array = array();

		$t_all_plugin_filters = event_signal( 'EVENT_FILTER_FIELDS' );
		foreach( $t_all_plugin_filters as $t_plugin => $t_plugin_filters ) {
			foreach( $t_plugin_filters as $t_callback => $t_plugin_filter_array ) {
				if ( is_array( $t_plugin_filter_array ) ) {
					foreach( $t_plugin_filter_array as $t_filter_class ) {
						if ( class_exists( $t_filter_class ) && is_subclass_of( $t_filter_class, 'MantisFilter' ) ) {
							$t_filter_object = new $t_filter_class();
							$t_field_name = $t_plugin . '_' . $t_filter_object->field;
							$s_field_array[ $t_field_name ] = $t_filter_object;
						}
					}
				}
			}
		}
	}

	return $s_field_array;
}
/**
 *  Get a permalink for the current active filter.  The results of using these fields by other users
 *  can be inconsistent with the original results due to fields like "Myself", "Current Project",
 *  and due to access level.
 * @param array $p_custom_filter
 * @return string the search.php?xxxx or an empty string if no criteria applied.
 */
function filter_get_url( $p_custom_filter ) {
	$t_query = array();

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_PROJECT_ID] ) ) {
		$t_project_id = $p_custom_filter[FILTER_PROPERTY_PROJECT_ID];

		if( count( $t_project_id ) == 1 && $t_project_id[0] == META_FILTER_CURRENT ) {
			$t_project_id = array(
				helper_get_current_project(),
			);
		}

		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_PROJECT_ID, $t_project_id );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_FREE_TEXT] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_FREE_TEXT, $p_custom_filter[FILTER_PROPERTY_FREE_TEXT] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_CATEGORY] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_CATEGORY, $p_custom_filter[FILTER_PROPERTY_CATEGORY] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_REPORTER_ID] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_REPORTER_ID, $p_custom_filter[FILTER_PROPERTY_REPORTER_ID] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_STATUS_ID] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_STATUS_ID, $p_custom_filter[FILTER_PROPERTY_STATUS_ID] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_MONITOR_USER_ID] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_MONITOR_USER_ID, $p_custom_filter[FILTER_PROPERTY_MONITOR_USER_ID] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_HANDLER_ID] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_HANDLER_ID, $p_custom_filter[FILTER_PROPERTY_HANDLER_ID] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_NOTE_USER_ID] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_NOTE_USER_ID, $p_custom_filter[FILTER_PROPERTY_NOTE_USER_ID] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_SEVERITY_ID] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_SEVERITY_ID, $p_custom_filter[FILTER_PROPERTY_SEVERITY_ID] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_RESOLUTION_ID] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_RESOLUTION_ID, $p_custom_filter[FILTER_PROPERTY_RESOLUTION_ID] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_PRIORITY_ID] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_PRIORITY_ID, $p_custom_filter[FILTER_PROPERTY_PRIORITY_ID] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_VIEW_STATE_ID] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_VIEW_STATE_ID, $p_custom_filter[FILTER_PROPERTY_VIEW_STATE_ID] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_SHOW_STICKY_ISSUES] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_SHOW_STICKY_ISSUES, $p_custom_filter[FILTER_PROPERTY_SHOW_STICKY_ISSUES] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_PRODUCT_VERSION] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_PRODUCT_VERSION, $p_custom_filter[FILTER_PROPERTY_PRODUCT_VERSION] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_PRODUCT_BUILD] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_PRODUCT_BUILD, $p_custom_filter[FILTER_PROPERTY_PRODUCT_BUILD] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_FIXED_IN_VERSION] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_FIXED_IN_VERSION, $p_custom_filter[FILTER_PROPERTY_FIXED_IN_VERSION] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_TARGET_VERSION] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_TARGET_VERSION, $p_custom_filter[FILTER_PROPERTY_TARGET_VERSION] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_SORT_FIELD_NAME] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_SORT_FIELD_NAME, $p_custom_filter[FILTER_PROPERTY_SORT_FIELD_NAME] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_SORT_DIRECTION] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_SORT_DIRECTION, $p_custom_filter[FILTER_PROPERTY_SORT_DIRECTION] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_SEARCH_ISSUES_PER_PAGE] ) ) {
		if( $p_custom_filter[FILTER_SEARCH_ISSUES_PER_PAGE] != config_get( 'default_limit_view' ) ) {
			$t_query[] = filter_encode_field_and_value( FILTER_PROPERTY_ISSUES_PER_PAGE, $p_custom_filter[FILTER_SEARCH_ISSUES_PER_PAGE] );
		}
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_HIGHLIGHT_CHANGED] ) ) {
		if( $p_custom_filter[FILTER_PROPERTY_HIGHLIGHT_CHANGED] != config_get( 'default_show_changed' ) ) {
			$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_HIGHLIGHT_CHANGED, $p_custom_filter[FILTER_PROPERTY_HIGHLIGHT_CHANGED] );
		}
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_HIDE_STATUS_ID] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_HIDE_STATUS_ID, $p_custom_filter[FILTER_PROPERTY_HIDE_STATUS_ID] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_NOT_ASSIGNED] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_NOT_ASSIGNED, $p_custom_filter[FILTER_PROPERTY_NOT_ASSIGNED] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_FILTER_BY_DATE] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_FILTER_BY_DATE, $p_custom_filter[FILTER_PROPERTY_FILTER_BY_DATE] );

		# The start and end dates are only applicable if filter by date is set.
		if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_START_DAY] ) ) {
			$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_START_DAY, $p_custom_filter[FILTER_PROPERTY_START_DAY] );
		}

		if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_END_DAY] ) ) {
			$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_END_DAY, $p_custom_filter[FILTER_PROPERTY_END_DAY] );
		}

		if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_START_MONTH] ) ) {
			$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_START_MONTH, $p_custom_filter[FILTER_PROPERTY_START_MONTH] );
		}

		if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_END_MONTH] ) ) {
			$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_END_MONTH, $p_custom_filter[FILTER_PROPERTY_END_MONTH] );
		}

		if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_START_YEAR] ) ) {
			$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_START_YEAR, $p_custom_filter[FILTER_PROPERTY_START_YEAR] );
		}

		if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_END_YEAR] ) ) {
			$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_END_YEAR, $p_custom_filter[FILTER_PROPERTY_END_YEAR] );
		}
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_RELATIONSHIP_TYPE] ) ) {
		if( $p_custom_filter[FILTER_PROPERTY_RELATIONSHIP_TYPE] != -1 ) {
			$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_RELATIONSHIP_TYPE, $p_custom_filter[FILTER_PROPERTY_RELATIONSHIP_TYPE] );
		}
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_RELATIONSHIP_BUG] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_RELATIONSHIP_BUG, $p_custom_filter[FILTER_PROPERTY_RELATIONSHIP_BUG] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_PLATFORM] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_PLATFORM, $p_custom_filter[FILTER_PROPERTY_PLATFORM] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_OS] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_OS, $p_custom_filter[FILTER_PROPERTY_OS] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_OS_BUILD] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_OS_BUILD, $p_custom_filter[FILTER_PROPERTY_OS_BUILD] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_TAG_STRING] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_TAG_STRING, $p_custom_filter[FILTER_PROPERTY_TAG_STRING] );
	}

	if( !filter_field_is_any( $p_custom_filter[FILTER_PROPERTY_TAG_SELECT] ) ) {
		$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_TAG_SELECT, $p_custom_filter[FILTER_PROPERTY_TAG_SELECT] );
	}

	$t_query[] = filter_encode_field_and_value( FILTER_SEARCH_MATCH_TYPE, $p_custom_filter[FILTER_PROPERTY_MATCH_TYPE] );

	if( isset( $p_custom_filter['custom_fields'] ) ) {
		foreach( $p_custom_filter['custom_fields'] as $t_custom_field_id => $t_custom_field_values ) {
			if( !filter_field_is_any( $t_custom_field_values ) ) {
				$t_query[] = filter_encode_field_and_value( 'custom_field_' . $t_custom_field_id, $t_custom_field_values );
			}
		}
	}

	# Allow plugins to add filter fields
	$t_plugin_filter_array = filter_get_plugin_filters();
	foreach( $t_plugin_filter_array as $t_field_name => $t_filter_object ) {
		if( !filter_field_is_any( $p_custom_filter[ $t_field_name ] ) ) {
			$t_query[] = filter_encode_field_and_value( $t_field_name, $p_custom_filter[ $t_field_name ], $t_filter_object->type );
		}
	}

	if( count( $t_query ) > 0 ) {
		$t_query_str = implode( $t_query, '&' );
		$t_url = config_get( 'path' ) . 'search.php?' . $t_query_str;
	} else {
		$t_url = '';
	}

	return $t_url;
}

/**
 *  Encodes a field and it's value for the filter URL.  This handles the URL encoding
 *  and arrays.
 * @param string $p_field_name The field name.
 * @param string $p_field_value The field value (can be an array)
 * @return string url encoded string
 */
function filter_encode_field_and_value( $p_field_name, $p_field_value, $p_field_type=null ) {
	$t_query_array = array();
	if( is_array( $p_field_value ) ) {
		$t_count = count( $p_field_value );
		if( $t_count > 1 || $p_field_type == FILTER_TYPE_MULTI_STRING || $p_field_type == FILTER_TYPE_MULTI_INT ) {
			foreach( $p_field_value as $t_value ) {
				$t_query_array[] = urlencode( $p_field_name . '[]' ) . '=' . urlencode( $t_value );
			}
		}
		else if( $t_count == 1 ) {
			$t_query_array[] = urlencode( $p_field_name ) . '=' . urlencode( $p_field_value[0] );
		}
	} else {
		$t_query_array[] = urlencode( $p_field_name ) . '=' . urlencode( $p_field_value );
	}

	return implode( $t_query_array, '&' );
}

# ==========================================================================
# GENERAL FUNCTIONS                            						      =
# ==========================================================================
/**
 *  Checks the supplied value to see if it is an ANY value.
 * @param string $p_field_value - The value to check.
 * @return bool true for "ANY" values and false for others.  "ANY" means filter criteria not active.
 */
function filter_field_is_any( $p_field_value ) {
	if( is_array( $p_field_value ) ) {
		if( count( $p_field_value ) == 0 ) {
			return true;
		}

		foreach( $p_field_value as $t_value ) {
			if(( META_FILTER_ANY == $t_value ) && ( is_numeric( $t_value ) ) ) {
				return true;
			}
		}
	} else {
		if( is_string( $p_field_value ) && is_blank( $p_field_value ) ) {
			return true;
		}

		if( is_bool( $p_field_value ) && !$p_field_value ) {
			return true;
		}

		if(( META_FILTER_ANY == $p_field_value ) && ( is_numeric( $p_field_value ) ) ) {
			return true;
		}
	}

	return false;
}

/**
     *  Checks the supplied value to see if it is a NONE value.
     * @param string $p_field_value - The value to check.
     * @return bool true for "NONE" values and false for others.
 * @todo is a check for these necessary?  if ( ( $t_filter_value === 'none' ) || ( $t_filter_value === '[none]' ) )
     */
function filter_field_is_none( $p_field_value ) {
	if( is_array( $p_field_value ) ) {
		foreach( $p_field_value as $t_value ) {
			if(( META_FILTER_NONE == $t_value ) && ( is_numeric( $t_value ) ) ) {
				return true;
			}
		}
	} else {
		if( is_string( $p_field_value ) && is_blank( $p_field_value ) ) {
			return false;
		}

		if(( META_FILTER_NONE == $p_field_value ) && ( is_numeric( $p_field_value ) ) ) {
			return true;
		}
	}

	return false;
}

/**
 *  Checks the supplied value to see if it is a MYSELF value.
 * @param string $p_field_value - The value to check.
 * @return bool true for "MYSELF" values and false for others.
 */
function filter_field_is_myself( $p_field_value ) {
	return( META_FILTER_MYSELF == $p_field_value ? TRUE : FALSE );
}

/**
     * @param $p_count
     * @param $p_per_page
     * @return int
     */
function filter_per_page( $p_filter, $p_count, $p_per_page ) {
	$p_per_page = (( NULL == $p_per_page ) ? (int) $p_filter[FILTER_PROPERTY_ISSUES_PER_PAGE] : $p_per_page );
	$p_per_page = (( 0 == $p_per_page || -1 == $p_per_page ) ? $p_count : $p_per_page );

	return (int) abs( $p_per_page );
}

/**
     *  Use $p_count and $p_per_page to determine how many pages to split this list up into.
     *  For the sake of consistency have at least one page, even if it is empty.
     * @param $p_count
     * @param $p_per_page
     * @return $t_page_count
     */
function filter_page_count( $p_count, $p_per_page ) {
	$t_page_count = ceil( $p_count / $p_per_page );
	if( $t_page_count < 1 ) {
		$t_page_count = 1;
	}
	return $t_page_count;
}

/**
     *  Checks to make sure $p_page_number isn't past the last page.
     *  and that $p_page_number isn't before the first page
     *   @param $p_page_number
     *   @param $p_page_count
     */
function filter_valid_page_number( $p_page_number, $p_page_count ) {
	if( $p_page_number > $p_page_count ) {
		$p_page_number = $p_page_count;
	}

	if( $p_page_number < 1 ) {
		$p_page_number = 1;
	}
	return $p_page_number;
}

/**
     *  Figure out the offset into the db query, offset is which record to start querying from
     * @param int $p_page_number
     * @param int $p_per_page
     * @return int
     */
function filter_offset( $p_page_number, $p_per_page ) {
	return(( (int) $p_page_number -1 ) * (int) $p_per_page );
}

/**
 *  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.s
 * @param array $p_filter_arr
 * @return mixed
 * @todo function needs to be abstracted
 */
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) utf8_substr( $p_filter_arr['_version'], 1 );
	if( utf8_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[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_SHOW_STICKY_ISSUES] ) ) {
		$p_filter_arr[FILTER_PROPERTY_SHOW_STICKY_ISSUES] = 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 => META_FILTER_ANY,
		);
	}

	if( !isset( $p_filter_arr[FILTER_PROPERTY_OS] ) ) {
		$p_filter_arr[FILTER_PROPERTY_OS] = array(
			0 => META_FILTER_ANY,
		);
	}

	if( !isset( $p_filter_arr[FILTER_PROPERTY_OS_BUILD] ) ) {
		$p_filter_arr[FILTER_PROPERTY_OS_BUILD] = array(
			0 => 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_FREE_TEXT] ) ) {
		$p_filter_arr[FILTER_PROPERTY_FREE_TEXT] = '';
	}
	if( !isset( $p_filter_arr[FILTER_PROPERTY_NOT_ASSIGNED] ) ) {
		$p_filter_arr[FILTER_PROPERTY_NOT_ASSIGNED] = gpc_get_bool( FILTER_PROPERTY_NOT_ASSIGNED, false );
	}
	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_ID] ) ) {
		$p_filter_arr[FILTER_PROPERTY_VIEW_STATE_ID] = gpc_get( FILTER_PROPERTY_VIEW_STATE_ID, '' );
	}
	else if( filter_field_is_any( $p_filter_arr[FILTER_PROPERTY_VIEW_STATE_ID] ) ) {
		$p_filter_arr[FILTER_PROPERTY_VIEW_STATE_ID] = 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] = 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 => 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 ] = 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, 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_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 => 'string',
		FILTER_PROPERTY_SEVERITY_ID => 'int',
		FILTER_PROPERTY_STATUS_ID => 'int',
		FILTER_PROPERTY_REPORTER_ID => 'int',
		FILTER_PROPERTY_HANDLER_ID => 'int',
		FILTER_PROPERTY_NOTE_USER_ID => 'int',
		FILTER_PROPERTY_RESOLUTION_ID => 'int',
		FILTER_PROPERTY_PRIORITY_ID => 'int',
		FILTER_PROPERTY_PRODUCT_BUILD => 'string',
		FILTER_PROPERTY_PRODUCT_VERSION => 'string',
		FILTER_PROPERTY_HIDE_STATUS_ID => 'int',
		FILTER_PROPERTY_FIXED_IN_VERSION => 'string',
		FILTER_PROPERTY_TARGET_VERSION => 'string',
		FILTER_PROPERTY_MONITOR_USER_ID => '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( FILTER_PROPERTY_HIDE_STATUS_ID == $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;
}

/**
 *  Get the standard filter that is to be used when no filter was previously saved.
 *  When creating specific filters, this can be used as a basis for the filter, where
 *  specific entries can be overridden.
 * @return mixed
 */
function filter_get_default() {
	$t_hide_status_default = config_get( 'hide_status_default' );
	$t_default_show_changed = config_get( 'default_show_changed' );

	$t_filter = array(
		FILTER_PROPERTY_CATEGORY => Array(
			'0' => META_FILTER_ANY,
		),
		FILTER_PROPERTY_SEVERITY_ID => Array(
			'0' => META_FILTER_ANY,
		),
		FILTER_PROPERTY_STATUS_ID => Array(
			'0' => META_FILTER_ANY,
		),
		FILTER_PROPERTY_HIGHLIGHT_CHANGED => $t_default_show_changed,
		FILTER_PROPERTY_REPORTER_ID => Array(
			'0' => META_FILTER_ANY,
		),
		FILTER_PROPERTY_HANDLER_ID => Array(
			'0' => META_FILTER_ANY,
		),
		FILTER_PROPERTY_PROJECT_ID => Array(
			'0' => META_FILTER_CURRENT,
		),
		FILTER_PROPERTY_RESOLUTION_ID => Array(
			'0' => META_FILTER_ANY,
		),
		FILTER_PROPERTY_PRODUCT_BUILD => Array(
			'0' => META_FILTER_ANY,
		),
		FILTER_PROPERTY_PRODUCT_VERSION => Array(
			'0' => META_FILTER_ANY,
		),
		FILTER_PROPERTY_HIDE_STATUS_ID => Array(
			'0' => $t_hide_status_default,
		),
		FILTER_PROPERTY_MONITOR_USER_ID => Array(
			'0' => META_FILTER_ANY,
		),
		FILTER_PROPERTY_SORT_FIELD_NAME => 'last_updated',
		FILTER_PROPERTY_SORT_DIRECTION => 'DESC',
		FILTER_PROPERTY_ISSUES_PER_PAGE => config_get( 'default_limit_view' ),
		FILTER_PROPERTY_MATCH_TYPE => FILTER_MATCH_ALL
	);

	return filter_ensure_valid_filter( $t_filter );
}

/**
 *  Deserialize filter string
 * @param string $p_serialized_filter
 * @return mixed $t_filter array
 * @see filter_ensure_valid_filter
 */
function filter_deserialize( $p_serialized_filter ) {
	if( is_blank( $p_serialized_filter ) ) {
		return false;
	}

	# check to see if new cookie is needed
	$t_setting_arr = explode( '#', $p_serialized_filter, 2 );
	if(( $t_setting_arr[0] == 'v1' ) || ( $t_setting_arr[0] == 'v2' ) || ( $t_setting_arr[0] == 'v3' ) || ( $t_setting_arr[0] == 'v4' ) ) {

		# these versions can't be salvaged, they are too old to update
		return false;
	}

	# We shouldn't need to do this anymore, as filters from v5 onwards should cope with changing
	# filter indices dynamically
	$t_filter_array = array();
	if( isset( $t_setting_arr[1] ) ) {
		$t_filter_array = unserialize( $t_setting_arr[1] );
	} else {
		return false;
	}
	if( $t_filter_array['_version'] != config_get( 'cookie_version' ) ) {

		# if the version is not new enough, update it using defaults
		return filter_ensure_valid_filter( $t_filter_array );
	}

	return $t_filter_array;
}

/**
 *  Check if the filter cookie exists and is of the correct version.
 * @return bool
 */
function filter_is_cookie_valid() {
	$t_view_all_cookie_id = gpc_get_cookie( config_get( 'view_all_cookie' ), '' );
	$t_view_all_cookie = filter_db_get_filter( $t_view_all_cookie_id );

	# check to see if the cookie does not exist
	if( is_blank( $t_view_all_cookie ) ) {
		return false;
	}

	# check to see if new cookie is needed
	$t_setting_arr = explode( '#', $t_view_all_cookie, 2 );
	if(( $t_setting_arr[0] == 'v1' ) || ( $t_setting_arr[0] == 'v2' ) || ( $t_setting_arr[0] == 'v3' ) || ( $t_setting_arr[0] == 'v4' ) ) {
		return false;
	}

	# We shouldn't need to do this anymore, as filters from v5 onwards should cope with changing
	# filter indices dynamically
	$t_filter_cookie_arr = array();
	if( isset( $t_setting_arr[1] ) ) {
		$t_filter_cookie_arr = unserialize( $t_setting_arr[1] );
	} else {
		return false;
	}
	if( $t_filter_cookie_arr['_version'] != config_get( 'cookie_version' ) ) {
		return false;
	}

	return true;
}

/**
 *  Get the array fields specified by $p_filter_id
 *  using the cached row if it's available
 * @param int $p_filter_id
 * @return mixed a filter row
 */
function filter_get_row( $p_filter_id ) {
	return filter_cache_row( $p_filter_id );
}

/**
 *  Get the value of the filter field specified by filter id and field name
 * @param int $p_filter_id
 * @param string $p_field_name
 * @return string
 */
function filter_get_field( $p_filter_id, $p_field_name ) {
	$row = filter_get_row( $p_filter_id );

	if( isset( $row[$p_field_name] ) ) {
		return $row[$p_field_name];
	} else {
		error_parameters( $p_field_name );
		trigger_error( ERROR_DB_FIELD_NOT_FOUND, WARNING );
		return '';
	}
}

/**
 *  Add sort parameters to the query clauses
 * @param array $p_filter
 * @param bool $p_show_sticky
 * @param array $p_query_clauses
 * @return array $p_query_clauses
 */
function filter_get_query_sort_data( &$p_filter, $p_show_sticky, $p_query_clauses ) {
	$t_bug_table = db_get_table( 'mantis_bug_table' );
	$t_custom_field_string_table = db_get_table( 'mantis_custom_field_string_table' );

	# if sort is blank then default the sort and direction.  This is to fix the
	# symptoms of #3953.  Note that even if the main problem is fixed, we may
	# have to keep this code for a while to handle filters saved with this blank field.
	if( is_blank( $p_filter[FILTER_PROPERTY_SORT_FIELD_NAME] ) ) {
		$p_filter[FILTER_PROPERTY_SORT_FIELD_NAME] = 'last_updated';
		$p_filter[FILTER_PROPERTY_SORT_DIRECTION] = 'DESC';
	}

	$p_query_clauses['order'] = array();
	$t_sort_fields = explode( ',', $p_filter[FILTER_PROPERTY_SORT_FIELD_NAME] );
	$t_dir_fields = explode( ',', $p_filter[FILTER_PROPERTY_SORT_DIRECTION] );

	$t_plugin_columns = columns_get_plugin_columns();

	if ( gpc_string_to_bool( $p_filter[FILTER_PROPERTY_SHOW_STICKY_ISSUES] ) && ( NULL !== $p_show_sticky ) ) {
		$p_query_clauses['order'][] = "$t_bug_table.sticky DESC";
	}

	$t_count = count( $t_sort_fields );
	for( $i = 0;$i < $t_count;$i++ ) {
		$c_sort = $t_sort_fields[$i];
		$c_dir = 'DESC' == $t_dir_fields[$i] ? 'DESC' : 'ASC';

		if( !in_array( $t_sort_fields[$i], array_slice( $t_sort_fields, $i + 1 ) ) ) {

			# if sorting by a custom field
			if( strpos( $c_sort, 'custom_' ) === 0 ) {
				$t_custom_field = utf8_substr( $c_sort, utf8_strlen( 'custom_' ) );
				$t_custom_field_id = custom_field_get_id_from_name( $t_custom_field );
				#ODB Production - Text Area
				$t_def = custom_field_get_definition( $t_custom_field_id );
				$t_value_field = ( $t_def['type'] == CUSTOM_FIELD_TYPE_TEXTAREA ? 'text' : 'value' );
				$c_cf_alias = 'custom_field_' . $t_custom_field_id;
				$t_cf_table_alias = $t_custom_field_string_table . '_' . $t_custom_field_id;
				$t_cf_select = "$t_cf_table_alias.value $c_cf_alias";

				# check to be sure this field wasn't already added to the query.
				if( !in_array( $t_cf_select, $p_query_clauses['select'] ) ) {
					$p_query_clauses['select'][] = $t_cf_select;
					$p_query_clauses['join'][] = "LEFT JOIN $t_custom_field_string_table $t_cf_table_alias ON $t_bug_table.id = $t_cf_table_alias.bug_id AND $t_cf_table_alias.field_id = $t_custom_field_id";
				}

				$p_query_clauses['order'][] = "$c_cf_alias $c_dir";

			# if sorting by plugin columns
			} else if ( isset( $t_plugin_columns[ $t_sort_fields[$i] ] ) ) {
				$t_column_object = $t_plugin_columns[ $t_sort_fields[$i] ];

				if ( $t_column_object->sortable ) {
					$t_clauses = $t_column_object->sortquery( $c_dir );

					if ( is_array( $t_clauses ) ) {
						if ( isset( $t_clauses['join'] ) ) {
							$p_query_clauses['join'][] = $t_clauses['join'];
						}
						if ( isset( $t_clauses['order'] ) ) {
							$p_query_clauses['order'][] = $t_clauses['order'];
						}
					}
				}

			# standard column
			} else {
				$t_sort_col = "$t_bug_table.$c_sort";

				# when sorting by due_date, always display undefined dates last
				if( 'due_date' == $c_sort && 'ASC' == $c_dir ) {
					$t_sort_due_date = "$t_sort_col = 1";
					$p_query_clauses['select'][] = $t_sort_due_date;
					$t_sort_col = "$t_sort_due_date, $t_sort_col";
				}

				$p_query_clauses['order'][] = "$t_sort_col $c_dir";
			}
		}
	}

	# add basic sorting if necessary
	if( !in_array( 'last_updated', $t_sort_fields ) ) {
		$p_query_clauses['order'][] = "$t_bug_table.last_updated DESC";
	}
	if( !in_array( 'date_submitted', $t_sort_fields ) ) {
		$p_query_clauses['order'][] = "$t_bug_table.date_submitted DESC";
	}

	return $p_query_clauses;
}

/**
     *  Remove any duplicate values in certain elements of query_clauses
     *  Do not loop over query clauses as some keys may contain valid duplicate values.
     *  We basically want unique values for just the base query elements select, from, and join
     *  'where' and 'where_values' key should not have duplicates as that is handled earlier and applying
     *  array_unique here could cause problems with the query.
     * @param $p_query_clauses
     * @return $p_query_clauses
     */
function filter_unique_query_clauses( $p_query_clauses ) {
	$p_query_clauses['select'] = array_unique( $p_query_clauses['select'] );
	$p_query_clauses['from'] = array_unique( $p_query_clauses['from'] );
	$p_query_clauses['join'] = array_unique( $p_query_clauses['join'] );
	return $p_query_clauses;
}

/**
     *  Build a query with the query clauses array, query for bug count and return the result
     * @param array $p_query_clauses
     * @return int
     */
function filter_get_bug_count( $p_query_clauses ) {
	$t_bug_table = db_get_table( 'mantis_bug_table' );
	$p_query_clauses = filter_unique_query_clauses( $p_query_clauses );
	$t_select_string = "SELECT Count( DISTINCT $t_bug_table.id ) as idcnt ";
	$t_from_string = " FROM " . implode( ', ', $p_query_clauses['from'] );
	$t_join_string = (( count( $p_query_clauses['join'] ) > 0 ) ? implode( ' ', $p_query_clauses['join'] ) : '' );
	$t_where_string = count( $p_query_clauses['project_where']) > 0 ? 'WHERE '. implode( ' AND ', $p_query_clauses['project_where'] ) : '';
	if ( count( $p_query_clauses['where'] ) > 0 ) {
		$t_where_string .= ' AND ( ';
		$t_where_string .= implode( $p_query_clauses['operator'], $p_query_clauses['where'] );
		$t_where_string .= ' ) ';
	}
	$t_result = db_query_bound( "$t_select_string $t_from_string $t_join_string $t_where_string", $p_query_clauses['where_values'] );
	return db_result( $t_result );
}

/**
 * @todo Had to make all these parameters required because we can't use
 *  call-time pass by reference anymore.  I really preferred not having
 *  to pass all the params in if you didn't want to, but I wanted to get
 *  rid of the errors for now.  If we can think of a better way later
 *  (maybe return an object) that would be great.
 *
 * @param int $p_page_number the page you want to see (set to the actual page on return)
 * @param int $p_per_page the number of bugs to see per page (set to actual on return)
 *      -1   indicates you want to see all bugs
 *      null indicates you want to use the value specified in the filter
 * @param int $p_page_count you don't need to give a value here, the number of pages will be stored here on return
 * @param int $p_bug_count you don't need to give a value here, the number of bugs will be stored here on return
 * @param mixed $p_custom_filter Filter to use.
 * @param int $p_project_id project id to use in filtering.
 * @param int $p_user_id user id to use as current user when filtering.
 * @param bool $p_show_sticky get sticky issues only.
 */
function filter_get_bug_rows( &$p_page_number, &$p_per_page, &$p_page_count, &$p_bug_count, $p_custom_filter = null, $p_project_id = null, $p_user_id = null, $p_show_sticky = null ) {
	log_event( LOG_FILTERING, 'START NEW FILTER QUERY' );

	$t_bug_table = db_get_table( 'mantis_bug_table' );
	$t_bug_text_table = db_get_table( 'mantis_bug_text_table' );
	$t_bugnote_table = db_get_table( 'mantis_bugnote_table' );
	$t_category_table = db_get_table( 'mantis_category_table' );
	$t_custom_field_string_table = db_get_table( 'mantis_custom_field_string_table' );
	$t_bugnote_text_table = db_get_table( 'mantis_bugnote_text_table' );
	$t_project_table = db_get_table( 'mantis_project_table' );
	$t_bug_monitor_table = db_get_table( 'mantis_bug_monitor_table' );
	$t_limit_reporters = config_get( 'limit_reporters' );
	$t_bug_relationship_table = db_get_table( 'mantis_bug_relationship_table' );
	$t_report_bug_threshold = config_get( 'report_bug_threshold' );
	$t_where_param_count = 0;

	$t_current_user_id = auth_get_current_user_id();

	if ( $p_user_id === null || $p_user_id === 0 ) {
		$t_user_id = $t_current_user_id;
	} else {
		$t_user_id = $p_user_id;
	}

	$c_user_id = db_prepare_int( $t_user_id );

	if( null === $p_project_id ) {

		# @@@ If project_id is not specified, then use the project id(s) in the filter if set, otherwise, use current project.
		$t_project_id = helper_get_current_project();
	} else {
		$t_project_id = $p_project_id;
	}

	if( $p_custom_filter === null ) {

		# Prefer current_user_get_bug_filter() over user_get_filter() when applicable since it supports
		# cookies set by previous version of the code.
		if( $t_user_id == $t_current_user_id ) {
			$t_filter = current_user_get_bug_filter();
		} else {
			$t_filter = user_get_bug_filter( $t_user_id, $t_project_id );
		}
	} else {
		$t_filter = $p_custom_filter;
	}

	$t_filter = filter_ensure_valid_filter( $t_filter );

	if( false === $t_filter ) {
		return false;

		# signify a need to create a cookie
		# @@@ error instead?
	}

	$t_view_type = $t_filter['_view_type'];

	// project query clauses must be AND-ed always, irrespective of how the filter
	// clauses are requested by the user ( all matching -> AND, any matching -> OR )
	$t_where_clauses = array();

	$t_project_where_clauses =  array(
		"$t_project_table.enabled = " . db_param(),
	);
	$t_where_params = array(
		1,
	);
	$t_select_clauses = array(
		"$t_bug_table.*",
	);

	$t_from_clauses = array(
		$t_bug_table,
	);

	$t_join_clauses = array(
		"JOIN $t_project_table ON $t_project_table.id = $t_bug_table.project_id",
	);

	// normalize the project filtering into an array $t_project_ids
	if( 'simple' == $t_view_type ) {
		log_event( LOG_FILTERING, 'Simple Filter' );
		$t_project_ids = array(
			$t_project_id,
		);
		$t_include_sub_projects = true;
	} else {
		log_event( LOG_FILTERING, 'Advanced Filter' );
		if( !is_array( $t_filter[FILTER_PROPERTY_PROJECT_ID] ) ) {
			$t_project_ids = array(
				db_prepare_int( $t_filter[FILTER_PROPERTY_PROJECT_ID] ),
			);
		} else {
			$t_project_ids = array_map( 'db_prepare_int', $t_filter[FILTER_PROPERTY_PROJECT_ID] );
		}

		$t_include_sub_projects = (( count( $t_project_ids ) == 1 ) && ( ( $t_project_ids[0] == META_FILTER_CURRENT ) || ( $t_project_ids[0] == ALL_PROJECTS ) ) );
	}

	log_event( LOG_FILTERING, 'project_ids = @P' . implode( ', @P', $t_project_ids ) );
	log_event( LOG_FILTERING, 'include sub-projects = ' . ( $t_include_sub_projects ? '1' : '0' ) );

	// if the array has ALL_PROJECTS, then reset the array to only contain ALL_PROJECTS.
	// replace META_FILTER_CURRENT with the actualy current project id.
	$t_all_projects_found = false;
	$t_new_project_ids = array();
	foreach( $t_project_ids as $t_pid ) {
		if( $t_pid == META_FILTER_CURRENT ) {
			$t_pid = $t_project_id;
		}

		if( $t_pid == ALL_PROJECTS ) {
			$t_all_projects_found = true;
			log_event( LOG_FILTERING, 'all projects selected' );
			break;
		}

		// filter out inaccessible projects.
		if( !access_has_project_level( VIEWER, $t_pid, $t_user_id ) ) {
			continue;
		}

		$t_new_project_ids[] = $t_pid;
	}

	$t_projects_query_required = true;
	if( $t_all_projects_found ) {
		if( user_is_administrator( $t_user_id ) ) {
			log_event( LOG_FILTERING, 'all projects + administrator, hence no project filter.' );
			$t_projects_query_required = false;
		} else {
			$t_project_ids = user_get_accessible_projects( $t_user_id );
		}
	} else {
		$t_project_ids = $t_new_project_ids;
	}

	if( $t_projects_query_required ) {

		// expand project ids to include sub-projects
		if( $t_include_sub_projects ) {
			$t_top_project_ids = $t_project_ids;

			foreach( $t_top_project_ids as $t_pid ) {
				log_event( LOG_FILTERING, 'Getting sub-projects for project id @P' . $t_pid );
				$t_subproject_ids = user_get_all_accessible_subprojects( $t_user_id, $t_pid );
				if (!$t_subproject_ids) continue;
				$t_project_ids = array_merge( $t_project_ids, $t_subproject_ids );
			}

			$t_project_ids = array_unique( $t_project_ids );
		}

		// if no projects are accessible, then return an empty array.
		if( count( $t_project_ids ) == 0 ) {
			log_event( LOG_FILTERING, 'no accessible projects' );
			return array();
		}

		log_event( LOG_FILTERING, 'project_ids after including sub-projects = @P' . implode( ', @P', $t_project_ids ) );

		// this array is to be populated with project ids for which we only want to show public issues.  This is due to the limited
		// access of the current user.
		$t_public_only_project_ids = array();

		// this array is populated with project ids that the current user has full access to.
		$t_private_and_public_project_ids = array();

		foreach( $t_project_ids as $t_pid ) {
			$t_access_required_to_view_private_bugs = config_get( 'private_bug_threshold', null, null, $t_pid );
			if( access_has_project_level( $t_access_required_to_view_private_bugs, $t_pid, $t_user_id ) ) {
				$t_private_and_public_project_ids[] = $t_pid;
			} else {
				$t_public_only_project_ids[] = $t_pid;
			}
		}

		log_event( LOG_FILTERING, 'project_ids (with public/private access) = @P' . implode( ', @P', $t_private_and_public_project_ids ) );
		log_event( LOG_FILTERING, 'project_ids (with public access) = @P' . implode( ', @P', $t_public_only_project_ids ) );

		$t_count_private_and_public_project_ids = count( $t_private_and_public_project_ids );
		if( $t_count_private_and_public_project_ids == 1 ) {
			$t_private_and_public_query = "( $t_bug_table.project_id = " . $t_private_and_public_project_ids[0] . " )";
		}
		else if( $t_count_private_and_public_project_ids > 1 ) {
			$t_private_and_public_query = "( $t_bug_table.project_id in (" . implode( ', ', $t_private_and_public_project_ids ) . ") )";
		} else {
			$t_private_and_public_query = null;
		}

		$t_count_public_only_project_ids = count( $t_public_only_project_ids );
		$t_public_view_state_check = "( ( $t_bug_table.view_state = " . VS_PUBLIC . " ) OR ( $t_bug_table.reporter_id = $t_user_id ) )";
		if( $t_count_public_only_project_ids == 1 ) {
			$t_public_only_query = "( ( $t_bug_table.project_id = " . $t_public_only_project_ids[0] . " ) AND $t_public_view_state_check )";
		}
		else if( $t_count_public_only_project_ids > 1 ) {
			$t_public_only_query = "( ( $t_bug_table.project_id in (" . implode( ', ', $t_public_only_project_ids ) . ") ) AND $t_public_view_state_check )";
		} else {
			$t_public_only_query = null;
		}

		// both queries can't be null, so we either have one of them or both.

		if( $t_private_and_public_query === null ) {
			$t_project_query = $t_public_only_query;
		} else if( $t_public_only_query === null ) {
			$t_project_query = $t_private_and_public_query;
		} else {
			$t_project_query = "( $t_public_only_query OR $t_private_and_public_query )";
		}

		log_event( LOG_FILTERING, 'project query = ' . $t_project_query );
		array_push( $t_project_where_clauses, $t_project_query );
	}

	# date filter
	if(( 'on' == $t_filter[FILTER_PROPERTY_FILTER_BY_DATE] ) && is_numeric( $t_filter[FILTER_PROPERTY_START_MONTH] ) && is_numeric( $t_filter[FILTER_PROPERTY_START_DAY] ) && is_numeric( $t_filter[FILTER_PROPERTY_START_YEAR] ) && is_numeric( $t_filter[FILTER_PROPERTY_END_MONTH] ) && is_numeric( $t_filter[FILTER_PROPERTY_END_DAY] ) && is_numeric( $t_filter[FILTER_PROPERTY_END_YEAR] ) ) {

		$t_start_string = $t_filter[FILTER_PROPERTY_START_YEAR] . "-" . $t_filter[FILTER_PROPERTY_START_MONTH] . "-" . $t_filter[FILTER_PROPERTY_START_DAY] . " 00:00:00";
		$t_end_string = $t_filter[FILTER_PROPERTY_END_YEAR] . "-" . $t_filter[FILTER_PROPERTY_END_MONTH] . "-" . $t_filter[FILTER_PROPERTY_END_DAY] . " 23:59:59";

		$t_where_params[] = strtotime( $t_start_string );
		$t_where_params[] = strtotime( $t_end_string );
		array_push( $t_project_where_clauses, "($t_bug_table.date_submitted BETWEEN " . db_param() . " AND " . db_param() . " )" );
	}

	# view state
	$t_view_state = db_prepare_int( $t_filter[FILTER_PROPERTY_VIEW_STATE_ID] );
	if( !filter_field_is_any( $t_filter[FILTER_PROPERTY_VIEW_STATE_ID] ) ) {
		$t_view_state_query = "($t_bug_table.view_state=" . db_param() . ')';
		log_event( LOG_FILTERING, 'view_state query = ' . $t_view_state_query );
		$t_where_params[] = $t_view_state;
		array_push( $t_where_clauses, $t_view_state_query );
	} else {
		log_event( LOG_FILTERING, 'no view_state query' );
	}

	# reporter
	if( !filter_field_is_any( $t_filter[FILTER_PROPERTY_REPORTER_ID] ) ) {
		$t_clauses = array();

		foreach( $t_filter[FILTER_PROPERTY_REPORTER_ID] as $t_filter_member ) {
			if( filter_field_is_none( $t_filter_member ) ) {
				array_push( $t_clauses, "0" );
			} else {
				$c_reporter_id = db_prepare_int( $t_filter_member );
				if( filter_field_is_myself( $c_reporter_id ) ) {
					array_push( $t_clauses, $c_user_id );
				} else {
					array_push( $t_clauses, $c_reporter_id );
				}
			}
		}

		if( 1 < count( $t_clauses ) ) {
			$t_reporter_query = "( $t_bug_table.reporter_id in (" . implode( ', ', $t_clauses ) . ") )";
		} else {
			$t_reporter_query = "( $t_bug_table.reporter_id=$t_clauses[0] )";
		}

		log_event( LOG_FILTERING, 'reporter query = ' . $t_reporter_query );
		array_push( $t_where_clauses, $t_reporter_query );
	} else {
		log_event( LOG_FILTERING, 'no reporter query' );
	}

	# limit reporter
	# @@@ thraxisp - access_has_project_level checks greater than or equal to,
	#   this assumed that there aren't any holes above REPORTER where the limit would apply
	#
	if(( ON === $t_limit_reporters ) && ( !access_has_project_level( REPORTER + 1, $t_project_id, $t_user_id ) ) ) {
		$c_reporter_id = $c_user_id;
		$t_where_params[] = $c_reporter_id;
		array_push( $t_where_clauses, "($t_bug_table.reporter_id=" . db_param() . ')' );
	}

	# handler
	if( !filter_field_is_any( $t_filter[FILTER_PROPERTY_HANDLER_ID] ) ) {
		$t_clauses = array();

		foreach( $t_filter[FILTER_PROPERTY_HANDLER_ID] as $t_filter_member ) {
			if( filter_field_is_none( $t_filter_member ) ) {
				array_push( $t_clauses, 0 );
			} else {
				$c_handler_id = db_prepare_int( $t_filter_member );
				if( filter_field_is_myself( $c_handler_id ) ) {
					array_push( $t_clauses, $c_user_id );
				} else {
					array_push( $t_clauses, $c_handler_id );
				}
			}
		}

		if( 1 < count( $t_clauses ) ) {
			$t_handler_query = "( $t_bug_table.handler_id in (" . implode( ', ', $t_clauses ) . ") )";
		} else {
			$t_handler_query = "( $t_bug_table.handler_id=$t_clauses[0] )";
		}

		log_event( LOG_FILTERING, 'handler query = ' . $t_handler_query );
		array_push( $t_where_clauses, $t_handler_query );
	} else {
		log_event( LOG_FILTERING, 'no handler query' );
	}

	# category
	if( !filter_field_is_any( $t_filter[FILTER_PROPERTY_CATEGORY] ) ) {
		$t_clauses = array();

		foreach( $t_filter[FILTER_PROPERTY_CATEGORY] as $t_filter_member ) {
			if( !filter_field_is_none( $t_filter_member ) ) {
				array_push( $t_clauses, $t_filter_member );
			}
		}

		if( 1 < count( $t_clauses ) ) {
			$t_where_tmp = array();
			foreach( $t_clauses as $t_clause ) {
				$t_where_tmp[] = db_param();
				$t_where_params[] = $t_clause;
			}
			array_push( $t_where_clauses, "( $t_bug_table.category_id in ( SELECT id FROM $t_category_table WHERE name in (" . implode( ', ', $t_where_tmp ) . ") ) )" );
		} else {
			$t_where_params[] = $t_clauses[0];
			array_push( $t_where_clauses, "( $t_bug_table.category_id in ( SELECT id FROM $t_category_table WHERE name=" . db_param() . ") )" );
		}
	}

	# severity
	if( !filter_field_is_any( $t_filter[FILTER_PROPERTY_SEVERITY_ID] ) ) {
		$t_clauses = array();

		foreach( $t_filter[FILTER_PROPERTY_SEVERITY_ID] as $t_filter_member ) {
			$c_show_severity = db_prepare_int( $t_filter_member );
			array_push( $t_clauses, $c_show_severity );
		}
		if( 1 < count( $t_clauses ) ) {
			$t_where_tmp = array();
			foreach( $t_clauses as $t_clause ) {
				$t_where_tmp[] = db_param();
				$t_where_params[] = $t_clause;
			}
			array_push( $t_where_clauses, "( $t_bug_table.severity in (" . implode( ', ', $t_where_tmp ) . ") )" );
		} else {
			$t_where_params[] = $t_clauses[0];
			array_push( $t_where_clauses, "( $t_bug_table.severity=" . db_param() . " )" );
		}
	}

	# show / hide status
	# take a list of all available statuses then remove the ones that we want hidden, then make sure
	# the ones we want shown are still available
	$t_desired_statuses = array();
	$t_available_statuses = MantisEnum::getValues( config_get( 'status_enum_string' ) );

	if( 'simple' == $t_filter['_view_type'] ) {

		# simple filtering: if showing any, restrict by the hide status value, otherwise ignore the hide
		$t_any_found = false;
		$t_this_status = $t_filter[FILTER_PROPERTY_STATUS_ID][0];
		$t_this_hide_status = $t_filter[FILTER_PROPERTY_HIDE_STATUS_ID][0];

		if( filter_field_is_any( $t_this_status ) ) {
			foreach( $t_available_statuses as $t_this_available_status ) {
				if( $t_this_hide_status > $t_this_available_status ) {
					$t_desired_statuses[] = $t_this_available_status;
				}
			}
		} else {
			$t_desired_statuses[] = $t_this_status;
		}
	} else {
		# advanced filtering: ignore the hide
		if( filter_field_is_any( $t_filter[FILTER_PROPERTY_STATUS_ID] ) ) {
			$t_desired_statuses = array();
		} else {
			foreach( $t_filter[FILTER_PROPERTY_STATUS_ID] as $t_this_status ) {
				$t_desired_statuses[] = $t_this_status;
			}
		}
	}

	if( count( $t_desired_statuses ) > 0 ) {
		$t_clauses = array();

		foreach( $t_desired_statuses as $t_filter_member ) {
			$c_show_status = db_prepare_int( $t_filter_member );
			array_push( $t_clauses, $c_show_status );
		}
		if( 1 < count( $t_clauses ) ) {
			$t_where_tmp = array();
			foreach( $t_clauses as $t_clause ) {
				$t_where_tmp[] = db_param();
				$t_where_params[] = $t_clause;
			}
			array_push( $t_where_clauses, "( $t_bug_table.status in (" . implode( ', ', $t_where_tmp ) . ") )" );
		} else {
			$t_where_params[] = $t_clauses[0];
			array_push( $t_where_clauses, "( $t_bug_table.status=" . db_param() . " )" );
		}
	}

	# resolution
	if( !filter_field_is_any( $t_filter[FILTER_PROPERTY_RESOLUTION_ID] ) ) {
		$t_clauses = array();

		foreach( $t_filter[FILTER_PROPERTY_RESOLUTION_ID] as $t_filter_member ) {
			$c_show_resolution = db_prepare_int( $t_filter_member );
			array_push( $t_clauses, $c_show_resolution );
		}
		if( 1 < count( $t_clauses ) ) {
			$t_where_tmp = array();
			foreach( $t_clauses as $t_clause ) {
				$t_where_tmp[] = db_param();
				$t_where_params[] = $t_clause;
			}
			array_push( $t_where_clauses, "( $t_bug_table.resolution in (" . implode( ', ', $t_where_tmp ) . ") )" );
		} else {
			$t_where_params[] = $t_clauses[0];
			array_push( $t_where_clauses, "( $t_bug_table.resolution=" . db_param() . " )" );
		}
	}

	# priority
	if( !filter_field_is_any( $t_filter[FILTER_PROPERTY_PRIORITY_ID] ) ) {
		$t_clauses = array();

		foreach( $t_filter[FILTER_PROPERTY_PRIORITY_ID] as $t_filter_member ) {
			$c_show_priority = db_prepare_int( $t_filter_member );
			array_push( $t_clauses, $c_show_priority );
		}
		if( 1 < count( $t_clauses ) ) {
			$t_where_tmp = array();
			foreach( $t_clauses as $t_clause ) {
				$t_where_tmp[] = db_param();
				$t_where_params[] = $t_clause;
			}
			array_push( $t_where_clauses, "( $t_bug_table.priority in (" . implode( ', ', $t_where_tmp ) . ") )" );
		} else {
			$t_where_params[] = $t_clauses[0];
			array_push( $t_where_clauses, "( $t_bug_table.priority=" . db_param() . " )" );
		}
	}

	# product build
	if( !filter_field_is_any( $t_filter[FILTER_PROPERTY_PRODUCT_BUILD] ) ) {
		$t_clauses = array();

		foreach( $t_filter[FILTER_PROPERTY_PRODUCT_BUILD] as $t_filter_member ) {
			$t_filter_member = stripslashes( $t_filter_member );
			if( filter_field_is_none( $t_filter_member ) ) {
				array_push( $t_clauses, '' );
			} else {
				$c_show_build = db_prepare_string( $t_filter_member );
				array_push( $t_clauses, $c_show_build );
			}
		}
		if( 1 < count( $t_clauses ) ) {
			$t_where_tmp = array();
			foreach( $t_clauses as $t_clause ) {
				$t_where_tmp[] = db_param();
				$t_where_params[] = $t_clause;
			}
			array_push( $t_where_clauses, "( $t_bug_table.build in (" . implode( ', ', $t_where_tmp ) . ") )" );
		} else {
			$t_where_params[] = $t_clauses[0];
			array_push( $t_where_clauses, "( $t_bug_table.build=" . db_param() . " )" );
		}
	}

	# product version
	if( !filter_field_is_any( $t_filter[FILTER_PROPERTY_PRODUCT_VERSION] ) ) {
		$t_clauses = array();

		foreach( $t_filter[FILTER_PROPERTY_PRODUCT_VERSION] as $t_filter_member ) {
			$t_filter_member = stripslashes( $t_filter_member );
			if( filter_field_is_none( $t_filter_member ) ) {
				array_push( $t_clauses, '' );
			} else {
				$c_show_version = db_prepare_string( $t_filter_member );
				array_push( $t_clauses, $c_show_version );
			}
		}

		if( 1 < count( $t_clauses ) ) {
			$t_where_tmp = array();
			foreach( $t_clauses as $t_clause ) {
				$t_where_tmp[] = db_param();
				$t_where_params[] = $t_clause;
			}
			array_push( $t_where_clauses, "( $t_bug_table.version in (" . implode( ', ', $t_where_tmp ) . ") )" );
		} else {
			$t_where_params[] = $t_clauses[0];
			array_push( $t_where_clauses, "( $t_bug_table.version=" . db_param() . " )" );
		}
	}

	# profile
	if( !filter_field_is_any( $t_filter['show_profile'] ) ) {
		$t_clauses = array();

		foreach( $t_filter['show_profile'] as $t_filter_member ) {
			$t_filter_member = stripslashes( $t_filter_member );
			if( filter_field_is_none( $t_filter_member ) ) {
				array_push( $t_clauses, "0" );
			} else {
				$c_show_profile = db_prepare_int( $t_filter_member );
				array_push( $t_clauses, "$c_show_profile" );
			}
		}
		if( 1 < count( $t_clauses ) ) {
			$t_where_tmp = array();
			foreach( $t_clauses as $t_clause ) {
				$t_where_tmp[] = db_param();
				$t_where_params[] = $t_clause;
			}
			array_push( $t_where_clauses, "( $t_bug_table.profile_id in (" . implode( ', ', $t_where_tmp ) . ") )" );
		} else {
			$t_where_params[] = $t_clauses[0];
			array_push( $t_where_clauses, "( $t_bug_table.profile_id=" . db_param() . " )" );
		}
	}

	# platform
	if( !filter_field_is_any( $t_filter[FILTER_PROPERTY_PLATFORM] ) ) {
		$t_clauses = array();

		foreach( $t_filter[FILTER_PROPERTY_PLATFORM] as $t_filter_member ) {
			$t_filter_member = stripslashes( $t_filter_member );
			if( filter_field_is_none( $t_filter_member ) ) {
				array_push( $t_clauses, '' );
			} else {
				$c_platform = db_prepare_string( $t_filter_member );
				array_push( $t_clauses, $c_platform );
			}
		}

		if( 1 < count( $t_clauses ) ) {
			$t_where_tmp = array();
			foreach( $t_clauses as $t_clause ) {
				$t_where_tmp[] = db_param();
				$t_where_params[] = $t_clause;
			}
			array_push( $t_where_clauses, "( $t_bug_table.platform in (" . implode( ', ', $t_where_tmp ) . ") )" );
		} else {
			$t_where_params[] = $t_clauses[0];
			array_push( $t_where_clauses, "( $t_bug_table.platform = " . db_param() . " )" );
		}
	}

	# os
	if( !filter_field_is_any( $t_filter[FILTER_PROPERTY_OS] ) ) {
		$t_clauses = array();

		foreach( $t_filter[FILTER_PROPERTY_OS] as $t_filter_member ) {
			$t_filter_member = stripslashes( $t_filter_member );
			if( filter_field_is_none( $t_filter_member ) ) {
				array_push( $t_clauses, '' );
			} else {
				$c_os = db_prepare_string( $t_filter_member );
				array_push( $t_clauses, $c_os );
			}
		}

		if( 1 < count( $t_clauses ) ) {
			$t_where_tmp = array();
			foreach( $t_clauses as $t_clause ) {
				$t_where_tmp[] = db_param();
				$t_where_params[] = $t_clause;
			}
			array_push( $t_where_clauses, "( $t_bug_table.os in (" . implode( ', ', $t_where_tmp ) . ") )" );
		} else {
			$t_where_params[] = $t_clauses[0];
			array_push( $t_where_clauses, "( $t_bug_table.os = " . db_param() . " )" );
		}
	}

	# os_build
	if( !filter_field_is_any( $t_filter[FILTER_PROPERTY_OS_BUILD] ) ) {
		$t_clauses = array();

		foreach( $t_filter[FILTER_PROPERTY_OS_BUILD] as $t_filter_member ) {
			$t_filter_member = stripslashes( $t_filter_member );
			if( filter_field_is_none( $t_filter_member ) ) {
				array_push( $t_clauses, '' );
			} else {
				$c_os_build = db_prepare_string( $t_filter_member );
				array_push( $t_clauses, $c_os_build );
			}
		}

		if( 1 < count( $t_clauses ) ) {
			$t_where_tmp = array();
			foreach( $t_clauses as $t_clause ) {
				$t_where_tmp[] = db_param();
				$t_where_params[] = $t_clause;
			}
			array_push( $t_where_clauses, "( $t_bug_table.os_build in (" . implode( ', ', $t_where_tmp ) . ") )" );
		} else {
			$t_where_params[] = $t_clauses[0];
			array_push( $t_where_clauses, "( $t_bug_table.os_build = " . db_param() . " )" );
		}
	}

	# fixed in version
	if( !filter_field_is_any( $t_filter[FILTER_PROPERTY_FIXED_IN_VERSION] ) ) {
		$t_clauses = array();

		foreach( $t_filter[FILTER_PROPERTY_FIXED_IN_VERSION] as $t_filter_member ) {
			$t_filter_member = stripslashes( $t_filter_member );
			if( filter_field_is_none( $t_filter_member ) ) {
				array_push( $t_clauses, '' );
			} else {
				$c_fixed_in_version = db_prepare_string( $t_filter_member );
				array_push( $t_clauses, $c_fixed_in_version );
			}
		}
		if( 1 < count( $t_clauses ) ) {
			$t_where_tmp = array();
			foreach( $t_clauses as $t_clause ) {
				$t_where_tmp[] = db_param();
				$t_where_params[] = $t_clause;
			}
			array_push( $t_where_clauses, "( $t_bug_table.fixed_in_version in (" . implode( ', ', $t_where_tmp ) . ") )" );
		} else {
			$t_where_params[] = $t_clauses[0];
			array_push( $t_where_clauses, "( $t_bug_table.fixed_in_version=" . db_param() . " )" );
		}
	}

	# target version
	if( !filter_field_is_any( $t_filter[FILTER_PROPERTY_TARGET_VERSION] ) ) {
		$t_clauses = array();

		foreach( $t_filter[FILTER_PROPERTY_TARGET_VERSION] as $t_filter_member ) {
			$t_filter_member = stripslashes( $t_filter_member );
			if( filter_field_is_none( $t_filter_member ) ) {
				array_push( $t_clauses, '' );
			} else {
				$c_target_version = db_prepare_string( $t_filter_member );
				array_push( $t_clauses, $c_target_version );
			}
		}

		# echo var_dump( $t_clauses ); exit;
		if( 1 < count( $t_clauses ) ) {
			$t_where_tmp = array();
			foreach( $t_clauses as $t_clause ) {
				$t_where_tmp[] = db_param();
				$t_where_params[] = $t_clause;
			}
			array_push( $t_where_clauses, "( $t_bug_table.target_version in (" . implode( ', ', $t_where_tmp ) . ") )" );
		} else {
			$t_where_params[] = $t_clauses[0];
			array_push( $t_where_clauses, "( $t_bug_table.target_version=" . db_param() . " )" );
		}
	}

	# users monitoring a bug
	if( !filter_field_is_any( $t_filter[FILTER_PROPERTY_MONITOR_USER_ID] ) ) {
		$t_clauses = array();
		$t_table_name = 'user_monitor';
		array_push( $t_join_clauses, "LEFT JOIN $t_bug_monitor_table $t_table_name ON $t_table_name.bug_id = $t_bug_table.id" );

		foreach( $t_filter[FILTER_PROPERTY_MONITOR_USER_ID] as $t_filter_member ) {
			$c_user_monitor = db_prepare_int( $t_filter_member );
			if( filter_field_is_myself( $c_user_monitor ) ) {
				array_push( $t_clauses, $c_user_id );
			} else {
				array_push( $t_clauses, $c_user_monitor );
			}
		}
		if( 1 < count( $t_clauses ) ) {
			$t_where_tmp = array();
			foreach( $t_clauses as $t_clause ) {
				$t_where_tmp[] = db_param();
				$t_where_params[] = $t_clause;
			}
			array_push( $t_where_clauses, "( $t_table_name.user_id in (" . implode( ', ', $t_where_tmp ) . ") )" );
		} else {
			$t_where_params[] = $t_clauses[0];
			array_push( $t_where_clauses, "( $t_table_name.user_id=" . db_param() . " )" );
		}
	}

	# bug relationship
	$t_any_found = false;
	$c_rel_type = $t_filter[FILTER_PROPERTY_RELATIONSHIP_TYPE];
	$c_rel_bug = $t_filter[FILTER_PROPERTY_RELATIONSHIP_BUG];
	if( -1 == $c_rel_type || 0 == $c_rel_bug ) {
		$t_any_found = true;
	}
	if( !$t_any_found ) {
		# use the complementary type
		$t_comp_type = relationship_get_complementary_type( $c_rel_type );
		$t_clauses = array();
		$t_table_name = 'relationship';
		array_push( $t_join_clauses, "LEFT JOIN $t_bug_relationship_table $t_table_name ON $t_table_name.destination_bug_id = $t_bug_table.id" );
		array_push( $t_join_clauses, "LEFT JOIN $t_bug_relationship_table ${t_table_name}2 ON ${t_table_name}2.source_bug_id = $t_bug_table.id" );

		// get reverse relationships
		$t_where_params[] = $t_comp_type;
		$t_where_params[] = $c_rel_bug;
		$t_where_params[] = $c_rel_type;
		$t_where_params[] = $c_rel_bug;
		array_push( $t_clauses, "($t_table_name.relationship_type=" . db_param() . " AND $t_table_name.source_bug_id=" . db_param() . ')' );
		array_push( $t_clauses, "($t_table_name" . "2.relationship_type=" . db_param() . " AND $t_table_name" . "2.destination_bug_id=" . db_param() . ')' );
		array_push( $t_where_clauses, '(' . implode( ' OR ', $t_clauses ) . ')' );
	}

	# tags
	$c_tag_string = trim( $t_filter[FILTER_PROPERTY_TAG_STRING] );
	$c_tag_select = trim( $t_filter[FILTER_PROPERTY_TAG_SELECT] );
	if( is_blank( $c_tag_string ) && !is_blank( $c_tag_select ) && $c_tag_select != 0 ) {
		$t_tag = tag_get( $c_tag_select );
		$c_tag_string = $t_tag['name'];
	}

	if( !is_blank( $c_tag_string ) ) {
		$t_tags = tag_parse_filters( $c_tag_string );

		if( count( $t_tags ) ) {

			$t_tags_all = array();
			$t_tags_any = array();
			$t_tags_none = array();

			foreach( $t_tags as $t_tag_row ) {
				switch( $t_tag_row['filter'] ) {
					case 1:
						$t_tags_all[] = $t_tag_row;
						break;
					case 0:
						$t_tags_any[] = $t_tag_row;
						break;
					case -1:
						$t_tags_none[] = $t_tag_row;
						break;
				}
			}

			if( 0 < $t_filter[FILTER_PROPERTY_TAG_SELECT] && tag_exists( $t_filter[FILTER_PROPERTY_TAG_SELECT] ) ) {
				$t_tags_any[] = tag_get( $t_filter[FILTER_PROPERTY_TAG_SELECT] );
			}

			$t_bug_tag_table = db_get_table( 'mantis_bug_tag_table' );

			if( count( $t_tags_all ) ) {
				$t_clauses = array();
				foreach( $t_tags_all as $t_tag_row ) {
					array_push( $t_clauses, "$t_bug_table.id IN ( SELECT bug_id FROM $t_bug_tag_table WHERE $t_bug_tag_table.tag_id = $t_tag_row[id] )" );
				}
				array_push( $t_where_clauses, '(' . implode( ' AND ', $t_clauses ) . ')' );
			}

			if( count( $t_tags_any ) ) {
				$t_clauses = array();
				foreach( $t_tags_any as $t_tag_row ) {
					array_push( $t_clauses, "$t_bug_tag_table.tag_id = $t_tag_row[id]" );
				}
				array_push( $t_where_clauses, "$t_bug_table.id IN ( SELECT bug_id FROM $t_bug_tag_table WHERE ( " . implode( ' OR ', $t_clauses ) . ') )' );
			}

			if( count( $t_tags_none ) ) {
				$t_clauses = array();
				foreach( $t_tags_none as $t_tag_row ) {
					array_push( $t_clauses, "$t_bug_tag_table.tag_id = $t_tag_row[id]" );
				}
				array_push( $t_where_clauses, "$t_bug_table.id NOT IN ( SELECT bug_id FROM $t_bug_tag_table WHERE ( " . implode( ' OR ', $t_clauses ) . ') )' );
			}
		}
	}

	# note user id
	if( !filter_field_is_any( $t_filter[FILTER_PROPERTY_NOTE_USER_ID] ) ) {
		$t_bugnote_table_alias = 'mbnt';
		$t_clauses = array();
		array_push( $t_join_clauses, "LEFT JOIN $t_bugnote_table  $t_bugnote_table_alias ON $t_bug_table.id = $t_bugnote_table_alias.bug_id" );

		foreach( $t_filter[FILTER_PROPERTY_NOTE_USER_ID] as $t_filter_member ) {
			$c_note_user_id = db_prepare_int( $t_filter_member );
			if( filter_field_is_myself( $c_note_user_id ) ) {
				array_push( $t_clauses, $c_user_id );
			} else {
				array_push( $t_clauses, $c_note_user_id );
			}
		}
		if( 1 < count( $t_clauses ) ) {
			$t_where_tmp = array();
			foreach( $t_clauses as $t_clause ) {
				$t_where_tmp[] = db_param();
				$t_where_params[] = $t_clause;
			}
			array_push( $t_where_clauses, "( $t_bugnote_table_alias.reporter_id in (" . implode( ', ', $t_where_tmp ) . ") )" );
		} else {
			$t_where_params[] = $t_clauses[0];
			array_push( $t_where_clauses, "( $t_bugnote_table_alias.reporter_id=" . db_param() . " )" );
		}
	}

	# plugin filters
	$t_plugin_filters = filter_get_plugin_filters();
	foreach( $t_plugin_filters as $t_field_name => $t_filter_object ) {
		if ( !filter_field_is_any( $t_filter[ $t_field_name ] ) || $t_filter_object->type == FILTER_TYPE_BOOLEAN ) {
			$t_filter_query = $t_filter_object->query( $t_filter[ $t_field_name ] );
			if ( is_array( $t_filter_query ) ) {
				if ( isset( $t_filter_query['join'] ) ) {
					array_push( $t_join_clauses, $t_filter_query['join'] );
				}
				if ( isset( $t_filter_query['where'] ) ) {
					array_push( $t_where_clauses, $t_filter_query['where'] );
				}
				if ( isset( $t_filter_query['params'] ) && is_array( $t_filter_query['params'] ) ) {
					$t_where_params = array_merge( $t_where_params, $t_filter_query['params'] );
				}
			}
		}
	}

	# custom field filters
	if( ON == config_get( 'filter_by_custom_fields' ) ) {

		# custom field filtering
		# @@@ At the moment this gets the linked fields relating to the current project
		#     It should get the ones relating to the project in the filter or all projects
		#     if multiple projects.
		$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 );
			if( !$t_field_info['filter_by'] ) {
				continue;

				# skip this custom field it shouldn't be filterable
			}

			$t_custom_where_clause = '';

			# Ignore all custom filters that are not set, or that are set to '' or "any"
			if( !filter_field_is_any( $t_filter['custom_fields'][$t_cfid] ) ) {
				$t_def = custom_field_get_definition( $t_cfid );
				$t_table_name = $t_custom_field_string_table . '_' . $t_cfid;

				# We need to filter each joined table or the result query will explode in dimensions
				# Each custom field will result in a exponential growth like Number_of_Issues^Number_of_Custom_Fields
				# and only after this process ends (if it is able to) the result query will be filtered
				# by the WHERE clause and by the DISTINCT clause
				$t_cf_join_clause = "LEFT JOIN $t_custom_field_string_table $t_table_name ON $t_bug_table.id = $t_table_name.bug_id AND $t_table_name.field_id = $t_cfid";

				if( $t_def['type'] == CUSTOM_FIELD_TYPE_DATE ) {
					switch( $t_filter['custom_fields'][$t_cfid][0] ) {
						case CUSTOM_FIELD_DATE_ANY:
							break;
						case CUSTOM_FIELD_DATE_NONE:
							array_push( $t_join_clauses, $t_cf_join_clause );
							$t_custom_where_clause = '(( ' . $t_table_name . '.bug_id is null) OR ( ' . $t_table_name . '.value = 0)';
							break;
						case CUSTOM_FIELD_DATE_BEFORE:
							array_push( $t_join_clauses, $t_cf_join_clause );
							$t_custom_where_clause = '(( ' . $t_table_name . '.value != 0 AND (' . $t_table_name . '.value+0) < ' . ( $t_filter['custom_fields'][$t_cfid][2] ) . ')';
							break;
						case CUSTOM_FIELD_DATE_AFTER:
							array_push( $t_join_clauses, $t_cf_join_clause );
							$t_custom_where_clause = '( (' . $t_table_name . '.value+0) > ' . ( $t_filter['custom_fields'][$t_cfid][1] + 1 );
							break;
						default:
							array_push( $t_join_clauses, $t_cf_join_clause );
							$t_custom_where_clause = '( (' . $t_table_name . '.value+0) BETWEEN ' . $t_filter['custom_fields'][$t_cfid][1] . ' AND ' . $t_filter['custom_fields'][$t_cfid][2];
							break;
					}
				} else {

					array_push( $t_join_clauses, $t_cf_join_clause );

					$t_filter_array = array();
					foreach( $t_filter['custom_fields'][$t_cfid] as $t_filter_member ) {
						$t_filter_member = stripslashes( $t_filter_member );
						if( filter_field_is_none( $t_filter_member ) ) {

							# coerce filter value if selecting META_FILTER_NONE so it will match empty fields
							$t_filter_member = '';

							# but also add those _not_ present in the custom field string table
							array_push( $t_filter_array, "$t_bug_table.id NOT IN (SELECT bug_id FROM $t_custom_field_string_table WHERE field_id=$t_cfid)" );
						}

						switch( $t_def['type'] ) {
							case CUSTOM_FIELD_TYPE_CHECKBOX:
							case CUSTOM_FIELD_TYPE_MULTILIST:
								if( $t_filter_member != '' ) {
									$t_filter_member = '%|' . $t_filter_member . '|%';
								}
								$t_where_params[] = $t_filter_member;
								array_push( $t_filter_array, db_helper_like( "$t_table_name.value" ) );
								break;
							#ODB Production - Text Area
							case CUSTOM_FIELD_TYPE_TEXTAREA:
								$t_where_params[] = '%' . $t_filter_member . '%';
								array_push( $t_filter_array, db_helper_like( "$t_table_name.text" ) );
								break;
							default:
								$t_where_params[] = $t_filter_member;
								array_push( $t_filter_array, "$t_table_name.value = " . db_param() );
						}
					}
					$t_custom_where_clause .= '(' . implode( ' OR ', $t_filter_array );
				}
				if( !is_blank( $t_custom_where_clause ) ) {
					array_push( $t_where_clauses, $t_custom_where_clause . ')' );
				}
			}
		}
	}

	# Text search
	if( !is_blank( $t_filter[FILTER_PROPERTY_FREE_TEXT] ) ) {

		# break up search terms by spacing or quoting
		preg_match_all( "/-?([^'\"\s]+|\"[^\"]+\"|'[^']+')/", $t_filter[FILTER_PROPERTY_FREE_TEXT], $t_matches, PREG_SET_ORDER );

		# organize terms without quoting, paying attention to negation
		$t_search_terms = array();
		foreach( $t_matches as $t_match ) {
			$t_search_terms[ trim( $t_match[1], "\'\"" ) ] = ( $t_match[0][0] == '-' );
		}

		# build a big where-clause and param list for all search terms, including negations
		$t_first = true;
		$t_textsearch_where_clause = "( ";
		foreach( $t_search_terms as $t_search_term => $t_negate ) {
			if ( !$t_first ) {
				$t_textsearch_where_clause .= ' AND ';
			}

			if ( $t_negate ) {
				$t_textsearch_where_clause .= 'NOT ';
			}

			$c_search = '%' . $t_search_term . '%';
			$t_textsearch_where_clause .= '( ' . db_helper_like( "$t_bug_table.summary" ) .
				' OR ' . db_helper_like( "$t_bug_text_table.description" ) .
				' OR ' . db_helper_like( "$t_bug_text_table.steps_to_reproduce" ) .
				' OR ' . db_helper_like( "$t_bug_text_table.additional_information" ) .
				' OR ' . db_helper_like( "$t_bugnote_text_table.note" );

			$t_where_params[] = $c_search;
			$t_where_params[] = $c_search;
			$t_where_params[] = $c_search;
			$t_where_params[] = $c_search;
			$t_where_params[] = $c_search;

			if( is_numeric( $t_search_term ) ) {
				// PostgreSQL on 64-bit OS hack (see #14014)
				if( PHP_INT_MAX > 0x7FFFFFFF && db_is_pgsql() ) {
					$t_search_max = 0x7FFFFFFF;
				} else {
					$t_search_max = PHP_INT_MAX;
				}
				// Note: no need to test negative values, '-' sign has been removed
				if( $t_search_term <= $t_search_max ) {
					$c_search_int = (int) $t_search_term;
					$t_textsearch_where_clause .= " OR $t_bug_table.id = " . db_param();
					$t_textsearch_where_clause .= " OR $t_bugnote_table.id = " . db_param();
					$t_where_params[] = $c_search_int;
					$t_where_params[] = $c_search_int;
				}
			}

			$t_textsearch_where_clause .= ' )';
			$t_first = false;
		}
		$t_textsearch_where_clause .= ' )';

		# add text query elements to arrays
		if ( !$t_first ) {
			$t_join_clauses[] = "JOIN $t_bug_text_table ON $t_bug_table.bug_text_id = $t_bug_text_table.id";
			$t_join_clauses[] = "LEFT JOIN $t_bugnote_table ON $t_bug_table.id = $t_bugnote_table.bug_id";
			# Outer join required otherwise we don't retrieve issues without notes
			$t_join_clauses[] = "LEFT JOIN $t_bugnote_text_table ON $t_bugnote_table.bugnote_text_id = $t_bugnote_text_table.id";
			$t_where_clauses[] = $t_textsearch_where_clause;
		}
	}

	# End text search

	# Determine join operator
	if ( $t_filter[FILTER_PROPERTY_MATCH_TYPE] == FILTER_MATCH_ANY )
		$t_join_operator = ' OR ';
	else
		$t_join_operator = ' AND ';

	log_event(LOG_FILTERING, 'Join operator : ' . $t_join_operator);

	$t_query_clauses['select'] = $t_select_clauses;
	$t_query_clauses['from'] = $t_from_clauses;
	$t_query_clauses['join'] = $t_join_clauses;
	$t_query_clauses['where'] = $t_where_clauses;
	$t_query_clauses['where_values'] = $t_where_params;
	$t_query_clauses['project_where'] = $t_project_where_clauses;
	$t_query_clauses['operator'] = $t_join_operator;
	$t_query_clauses = filter_get_query_sort_data( $t_filter, $p_show_sticky, $t_query_clauses );

	# assigning to $p_* for this function writes the values back in case the caller wants to know
	# Get the total number of bugs that meet the criteria.
	$p_bug_count = filter_get_bug_count( $t_query_clauses );
	if( 0 == $p_bug_count ) {
		return array();
	}
	$p_per_page = filter_per_page( $t_filter, $p_bug_count, $p_per_page );
	$p_page_count = filter_page_count( $p_bug_count, $p_per_page );
	$p_page_number = filter_valid_page_number( $p_page_number, $p_page_count );
	$t_offset = filter_offset( $p_page_number, $p_per_page );
	$t_query_clauses = filter_unique_query_clauses( $t_query_clauses );
	$t_select_string = "SELECT DISTINCT " . implode( ', ', $t_query_clauses['select'] );
	$t_from_string = " FROM " . implode( ', ', $t_query_clauses['from'] );
	$t_order_string = " ORDER BY " . implode( ', ', $t_query_clauses['order'] );
	$t_join_string = count( $t_query_clauses['join'] ) > 0 ? implode( ' ', $t_query_clauses['join'] ) : '';
	$t_where_string = 'WHERE '. implode( ' AND ', $t_query_clauses['project_where'] );
	if ( count( $t_query_clauses['where'] ) > 0 ) {
		$t_where_string .= ' AND ( ';
		$t_where_string .= implode( $t_join_operator, $t_query_clauses['where'] );
		$t_where_string .= ' ) ';
	}


	$t_result = db_query_bound( "$t_select_string $t_from_string $t_join_string $t_where_string $t_order_string", $t_query_clauses['where_values'], $p_per_page, $t_offset );
	$t_row_count = db_num_rows( $t_result );

	$t_id_array_lastmod = array();
	for( $i = 0;$i < $t_row_count;$i++ ) {
		$t_row = db_fetch_array( $t_result );
		$t_id_array_lastmod[] = (int) $t_row['id'];
		$t_rows[] = $t_row;
	}

	return filter_cache_result( $t_rows, $t_id_array_lastmod );
}

/**
 *  Cache the filter results with bugnote stats for later use
 * @param array $p_rows results of the filter query
 * @param array $p_id_array_lastmod array of bug ids
 * @return array
 */
function filter_cache_result( $p_rows, $p_id_array_lastmod ) {
	$t_bugnote_table = db_get_table( 'mantis_bugnote_table' );

	$t_id_array_lastmod = array_unique( $p_id_array_lastmod );
	$t_where_string = "WHERE $t_bugnote_table.bug_id in (" . implode( ", ", $t_id_array_lastmod ) . ')';
	$t_query = "SELECT DISTINCT bug_id,MAX(last_modified) as last_modified, COUNT(last_modified) as count FROM $t_bugnote_table $t_where_string GROUP BY bug_id";

	# perform query
	$t_result = db_query_bound( $t_query );
	$t_row_count = db_num_rows( $t_result );
	for( $i = 0;$i < $t_row_count;$i++ ) {
		$t_row = db_fetch_array( $t_result );
		$t_stats[$t_row['bug_id']] = $t_row;
	}

	$t_rows = array();
	foreach( $p_rows as $t_row ) {
		if( !isset( $t_stats[$t_row['id']] ) ) {
			$t_rows[] = bug_row_to_object( bug_cache_database_result( $t_row, false ) );
		} else {
			$t_rows[] = bug_row_to_object( bug_cache_database_result( $t_row, $t_stats[ $t_row['id'] ] ) );
		}
	}
	return $t_rows;
}

/**
 *  Mainly based on filter_draw_selection_area2() but adds the support for the collapsible
 *  filter display.
 * @param int $p_page_number
 * @param bool $p_for_screen
 * @see filter_draw_selection_area2
 */
function filter_draw_selection_area( $p_page_number, $p_for_screen = true ) {
	collapse_open( 'filter' );
	filter_draw_selection_area2( $p_page_number, $p_for_screen, true );
	collapse_closed( 'filter' );
	filter_draw_selection_area2( $p_page_number, $p_for_screen, false );
	collapse_end( 'filter' );
}

/**
 *  Prints the filter selection area for both the bug list view screen and
 *  the bug list print screen. This function was an attempt to make it easier to
 *  add new filters and rearrange them on screen for both pages.
 * @param int $p_page_number
 * @param bool $p_for_screen
 * @param bool $p_expanded
 */
function filter_draw_selection_area2( $p_page_number, $p_for_screen = true, $p_expanded = true ) {
	$t_form_name_suffix = $p_expanded ? '_open' : '_closed';

	$t_filter = current_user_get_bug_filter();
	$t_filter = filter_ensure_valid_filter( $t_filter );
	$t_project_id = helper_get_current_project();
	$t_page_number = (int) $p_page_number;

	$t_view_type = $t_filter['_view_type'];

	$t_tdclass = 'small-caption';
	$t_trclass = 'row-category2';
	$t_action = 'view_all_set.php?f=3';

	if( $p_for_screen == false ) {
		$t_tdclass = 'print';
		$t_trclass = '';
		$t_action = 'view_all_set.php';
	}
	?>

		<br />
		<form method="post" name="filters<?php echo $t_form_name_suffix?>" id="filters_form<?php echo $t_form_name_suffix?>" action="<?php echo $t_action;?>">
		<?php # CSRF protection not required here - form does not result in modifications ?>
		<input type="hidden" name="type" value="1" />
		<?php
			if( $p_for_screen == false ) {
		echo '<input type="hidden" name="print" value="1" />';
		echo '<input type="hidden" name="offset" value="0" />';
	}
	?>
		<input type="hidden" name="page_number" value="<?php echo $t_page_number?>" />
		<input type="hidden" name="view_type" value="<?php echo $t_view_type?>" />
		<table class="width100" cellspacing="1">

		<?php
		$t_filter_cols = config_get( 'filter_custom_fields_per_row' );
	if( $p_expanded ) {
		$t_custom_cols = $t_filter_cols;

		$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_values = array();
		$t_num_custom_rows = 0;
		$t_per_row = 0;

		if( ON == config_get( 'filter_by_custom_fields' ) ) {
			$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 );
				if( $t_field_info['access_level_r'] <= $t_current_user_access_level && $t_field_info['filter_by'] ) {
					$t_accessible_custom_fields_ids[] = $t_cfid;
					$t_accessible_custom_fields_names[] = $t_field_info['name'];
					$t_accessible_custom_fields_types[] = $t_field_info['type'];
					$t_accessible_custom_fields_values[] = custom_field_distinct_values( $t_field_info );
				}
			}

			if( count( $t_accessible_custom_fields_ids ) > 0 ) {
				$t_per_row = config_get( 'filter_custom_fields_per_row' );
				$t_num_custom_rows = ceil( count( $t_accessible_custom_fields_ids ) / $t_per_row );
			}
		}

		$t_filters_url = 'view_filters_page.php?for_screen=' . $p_for_screen;
		if( 'advanced' == $t_view_type ) {
			$t_filters_url = $t_filters_url . '&amp;view_type=advanced';
		}
		$t_filters_url = $t_filters_url . '&amp;target_field=';

		$t_show_product_version =  version_should_show_product_version( $t_project_id );
		$t_show_build = $t_show_product_version && ( config_get( 'enable_product_build' ) == ON );

		# overload handler_id setting if user isn't supposed to see them (ref #6189)
		if( !access_has_any_project( config_get( 'view_handler_threshold' ) ) ) {
			$t_filter[FILTER_PROPERTY_HANDLER_ID] = array(
				META_FILTER_ANY,
			);
		}
		?>

		<tr <?php echo "class=\"" . $t_trclass . "\"";?>>
			<td class="small-caption" valign="top">
				<a href="<?php echo $t_filters_url . FILTER_PROPERTY_REPORTER_ID . '[]';?>" id="reporter_id_filter"><?php echo lang_get( 'reporter' )?>:</a>
			</td>
			<td class="small-caption" valign="top">
				<a href="<?php echo $t_filters_url . FILTER_PROPERTY_MONITOR_USER_ID . '[]';?>" id="user_monitor_filter"><?php echo lang_get( 'monitored_by' )?>:</a>
			</td>
			<td class="small-caption" valign="top">
				<a href="<?php echo $t_filters_url . FILTER_PROPERTY_HANDLER_ID . '[]';?>" id="handler_id_filter"><?php echo lang_get( 'assigned_to' )?>:</a>
			</td>
			<td colspan="2" class="small-caption" valign="top">
				<a href="<?php echo $t_filters_url . FILTER_PROPERTY_CATEGORY . '[]';?>" id="show_category_filter"><?php echo lang_get( 'category' )?>:</a>
			</td>
			<td class="small-caption" valign="top">
				<a href="<?php echo $t_filters_url . FILTER_PROPERTY_SEVERITY_ID . '[]';?>" id="show_severity_filter"><?php echo lang_get( 'severity' )?>:</a>
			</td>
			<td class="small-caption" valign="top">
				<a href="<?php echo $t_filters_url . FILTER_PROPERTY_RESOLUTION_ID . '[]';?>" id="show_resolution_filter"><?php echo lang_get( 'resolution' )?>:</a>
			</td>
			<td class="small-caption" valign="top">
				<?php if( ON == config_get( 'enable_profiles' ) ) { ?>
					<a href="<?php echo $t_filters_url . 'show_profile[]';?>" id="show_profile_filter"><?php echo lang_get( 'profile' )?>:</a>
				<?php } ?>
			</td>
			<?php if( $t_filter_cols > 8 ) {
			echo '<td class="small-caption" valign="top" colspan="' . ( $t_filter_cols - 8 ) . '">&#160;</td>';
		}?>
		</tr>

		<tr class="row-1">
			<td class="small-caption" valign="top" id="reporter_id_filter_target">
							<?php
								$t_output = '';
		$t_any_found = false;
		if( count( $t_filter[FILTER_PROPERTY_REPORTER_ID] ) == 0 ) {
			echo lang_get( 'any' );
		} else {
			$t_first_flag = true;
			foreach( $t_filter[FILTER_PROPERTY_REPORTER_ID] as $t_current ) {
				$t_this_name = '';
				echo '<input type="hidden" name="', FILTER_PROPERTY_REPORTER_ID, '[]" value="', string_attribute( $t_current ), '" />';
				if( filter_field_is_any( $t_current ) ) {
					$t_any_found = true;
				}
				else if( filter_field_is_myself( $t_current ) ) {
					if( access_has_project_level( config_get( 'report_bug_threshold' ) ) ) {
						$t_this_name = '[' . lang_get( 'myself' ) . ']';
					} else {
						$t_any_found = true;
					}
				} else if( filter_field_is_none( $t_current ) ) {
					$t_this_name = lang_get( 'none' );
				} else {
					$t_this_name = user_get_name( $t_current );
				}
				if( $t_first_flag != true ) {
					$t_output = $t_output . '<br />';
				} else {
					$t_first_flag = false;
				}
				$t_output = $t_output . string_display_line( $t_this_name );
			}
			if( true == $t_any_found ) {
				echo lang_get( 'any' );
			} else {
				echo $t_output;
			}
		}
		?>
			</td>
			<td class="small-caption" valign="top" id="user_monitor_filter_target">
							<?php
								$t_output = '';
		$t_any_found = false;
		if( count( $t_filter[FILTER_PROPERTY_MONITOR_USER_ID] ) == 0 ) {
			echo lang_get( 'any' );
		} else {
			$t_first_flag = true;
			foreach( $t_filter[FILTER_PROPERTY_MONITOR_USER_ID] as $t_current ) {
				echo '<input type="hidden" name="', FILTER_PROPERTY_MONITOR_USER_ID, '[]" value="', string_attribute( $t_current ), '" />';
				$t_this_name = '';
				if( filter_field_is_any( $t_current ) ) {
					$t_any_found = true;
				}
				else if( filter_field_is_myself( $t_current ) ) {
					if( access_has_project_level( config_get( 'monitor_bug_threshold' ) ) ) {
						$t_this_name = '[' . lang_get( 'myself' ) . ']';
					} else {
						$t_any_found = true;
					}
				} else {
					$t_this_name = user_get_name( $t_current );
				}
				if( $t_first_flag != true ) {
					$t_output = $t_output . '<br />';
				} else {
					$t_first_flag = false;
				}
				$t_output = $t_output . string_display_line( $t_this_name );
			}
			if( true == $t_any_found ) {
				echo lang_get( 'any' );
			} else {
				echo string_display( $t_output );
			}
		}
		?>
			</td>
			<td class="small-caption" valign="top" id="handler_id_filter_target">
							<?php
								$t_output = '';
		$t_any_found = false;
		if( count( $t_filter[FILTER_PROPERTY_HANDLER_ID] ) == 0 ) {
			echo lang_get( 'any' );
		} else {
			$t_first_flag = true;
			foreach( $t_filter[FILTER_PROPERTY_HANDLER_ID] as $t_current ) {
				echo '<input type="hidden" name="', FILTER_PROPERTY_HANDLER_ID, '[]" value="', string_attribute( $t_current ), '" />';
				$t_this_name = '';
				if( filter_field_is_none( $t_current ) ) {
					$t_this_name = lang_get( 'none' );
				} else if( filter_field_is_any( $t_current ) ) {
					$t_any_found = true;
				} else if( filter_field_is_myself( $t_current ) ) {
					if( access_has_project_level( config_get( 'handle_bug_threshold' ) ) ) {
						$t_this_name = '[' . lang_get( 'myself' ) . ']';
					} else {
						$t_any_found = true;
					}
				} else {
					$t_this_name = user_get_name( $t_current );
				}
				if( $t_first_flag != true ) {
					$t_output = $t_output . '<br />';
				} else {
					$t_first_flag = false;
				}
				$t_output = $t_output . string_display_line( $t_this_name );
			}
			if( true == $t_any_found ) {
				echo lang_get( 'any' );
			} else {
				echo string_display( $t_output );
			}
		}
		?>
			</td>
			<td colspan="2" class="small-caption" valign="top" id="show_category_filter_target">
							<?php
								$t_output = '';
		$t_any_found = false;
		if( count( $t_filter[FILTER_PROPERTY_CATEGORY] ) == 0 ) {
			echo lang_get( 'any' );
		} else {
			$t_first_flag = true;
			foreach( $t_filter[FILTER_PROPERTY_CATEGORY] as $t_current ) {
				echo '<input type="hidden" name="', FILTER_PROPERTY_CATEGORY, '[]" value="', string_attribute( $t_current ), '" />';
				$t_this_string = '';
				if( filter_field_is_any( $t_current ) ) {
					$t_any_found = true;
				} else {
					$t_this_string = $t_current;
				}
				if( $t_first_flag != true ) {
					$t_output = $t_output . '<br />';
				} else {
					$t_first_flag = false;
				}
				$t_output = $t_output . string_display_line( $t_this_string );
			}
			if( true == $t_any_found ) {
				echo lang_get( 'any' );
			} else {
				echo $t_output;
			}
		}
		?>
			</td>
			<td class="small-caption" valign="top" id="show_severity_filter_target">
							<?php
								$t_output = '';
		$t_any_found = false;
		if( count( $t_filter[FILTER_PROPERTY_SEVERITY_ID] ) == 0 ) {
			echo lang_get( 'any' );
		} else {
			$t_first_flag = true;
			foreach( $t_filter[FILTER_PROPERTY_SEVERITY_ID] as $t_current ) {
				echo '<input type="hidden" name="', FILTER_PROPERTY_SEVERITY_ID, '[]" value="', string_attribute( $t_current ), '" />';
				$t_this_string = '';
				if( filter_field_is_any( $t_current ) ) {
					$t_any_found = true;
				} else {
					$t_this_string = get_enum_element( 'severity', $t_current );
				}
				if( $t_first_flag != true ) {
					$t_output = $t_output . '<br />';
				} else {
					$t_first_flag = false;
				}
				$t_output = $t_output . string_display_line( $t_this_string );
			}
			if( true == $t_any_found ) {
				echo lang_get( 'any' );
			} else {
				echo $t_output;
			}
		}
		?>
			</td>
			<td class="small-caption" valign="top" id="show_resolution_filter_target">
							<?php
								$t_output = '';
		$t_any_found = false;
		if( count( $t_filter[FILTER_PROPERTY_RESOLUTION_ID] ) == 0 ) {
			echo lang_get( 'any' );
		} else {
			$t_first_flag = true;
			foreach( $t_filter[FILTER_PROPERTY_RESOLUTION_ID] as $t_current ) {
				?>
										<input type="hidden" name="show_resolution[]" value="<?php echo string_attribute( $t_current );?>" />
										<?php
										$t_this_string = '';
				if( filter_field_is_any( $t_current ) ) {
					$t_any_found = true;
				} else {
					$t_this_string = get_enum_element( 'resolution', $t_current );
				}
				if( $t_first_flag != true ) {
					$t_output = $t_output . '<br />';
				} else {
					$t_first_flag = false;
				}
				$t_output = $t_output . string_display_line( $t_this_string );
			}
			if( true == $t_any_found ) {
				echo lang_get( 'any' );
			} else {
				echo $t_output;
			}
		}
		?>
			</td>
			<?php if( ON == config_get( 'enable_profiles' ) ) { ?>
			<td class="small-caption" valign="top" id="show_profile_filter_target">
							<?php
								$t_output = '';
		$t_any_found = false;
		if( count( $t_filter['show_profile'] ) == 0 ) {
			echo lang_get( 'any' );
		} else {
			$t_first_flag = true;
			foreach( $t_filter['show_profile'] as $t_current ) {
				?>
										<input type="hidden" name="show_profile[]" value="<?php echo string_attribute( $t_current );?>" />
										<?php
										$t_this_string = '';
				if( filter_field_is_any( $t_current ) ) {
					$t_any_found = true;
				} else {
					$t_profile = profile_get_row_direct( $t_current );

					$t_this_string = "${t_profile['platform']} ${t_profile['os']} ${t_profile['os_build']}";
				}
				if( $t_first_flag != true ) {
					$t_output = $t_output . '<br />';
				} else {
					$t_first_flag = false;
				}
				$t_output = $t_output . string_display_line( $t_this_string );
			}
			if( true == $t_any_found ) {
				echo lang_get( 'any' );
			} else {
				echo $t_output;
			}
		}
		?>
			</td>
			<?php } else { ?>
				<td></td>
			<?php }
				  if( $t_filter_cols > 8 ) {
			echo '<td class="small-caption" valign="top" colspan="' . ( $t_filter_cols - 8 ) . '">&#160;</td>';
		}?>
			</tr>

		<tr <?php echo "class=\"" . $t_trclass . "\"";?>>
			<td class="small-caption" valign="top">
				<a href="<?php echo $t_filters_url . FILTER_PROPERTY_STATUS_ID . '[]';?>" id="show_status_filter"><?php echo lang_get( 'status' )?>:</a>
			</td>
			<td class="small-caption" valign="top">
				<?php if( 'simple' == $t_view_type ) {?>
					<a href="<?php echo $t_filters_url . FILTER_PROPERTY_HIDE_STATUS_ID . '[]';?>" id="hide_status_filter"><?php echo lang_get( 'hide_status' )?>:</a>
				<?php
		}?>
			</td>
			<td class="small-caption" valign="top">
			<?php if ( $t_show_build ) { ?>
				<a href="<?php echo $t_filters_url . FILTER_PROPERTY_PRODUCT_BUILD . '[]';?>" id="show_build_filter"><?php echo lang_get( 'product_build' )?>:</a>
			<?php } ?>
			</td>
			<?php if( $t_show_product_version ) {?>
			<td colspan="2" class="small-caption" valign="top">
				<a href="<?php echo $t_filters_url . FILTER_PROPERTY_PRODUCT_VERSION . '[]';?>" id="show_version_filter"><?php echo lang_get( 'product_version' )?>:</a>
			</td>
			<td colspan="1" class="small-caption" valign="top">
				<a href="<?php echo $t_filters_url . FILTER_PROPERTY_FIXED_IN_VERSION . '[]';?>" id="show_fixed_in_version_filter"><?php echo lang_get( 'fixed_in_version' )?>:</a>
			</td>
			<td colspan="1" class="small-caption" valign="top">
				<a href="<?php echo $t_filters_url . FILTER_PROPERTY_TARGET_VERSION . '[]';?>" id="show_target_version_filter"><?php echo lang_get( 'target_version' )?>:</a>
			</td>
			<?php
		} else {?>
			<td colspan="2" class="small-caption" valign="top">
				&#160;
			</td>
			<td colspan="1" class="small-caption" valign="top">
				&#160;
			</td>
			<td colspan="1" class="small-caption" valign="top">
				&nbsp;
			</td>
			<?php
		}?>
			<td colspan="1" class="small-caption" valign="top">
				<a href="<?php echo $t_filters_url . FILTER_PROPERTY_PRIORITY_ID . '[]';?>" id="show_priority_filter"><?php echo lang_get( 'priority' )?>:</a>
			</td>
			<?php if( $t_filter_cols > 8 ) {
			echo '<td class="small-caption" valign="top" colspan="' . ( $t_filter_cols - 7 ) . '">&#160;</td>';
		}?>
		</tr>

		<tr class="row-1">
			<td class="small-caption" valign="top" id="show_status_filter_target">
							<?php
								$t_output = '';
		$t_any_found = false;
		if( count( $t_filter[FILTER_PROPERTY_STATUS_ID] ) == 0 ) {
			echo lang_get( 'any' );
		} else {
			$t_first_flag = true;
			foreach( $t_filter[FILTER_PROPERTY_STATUS_ID] as $t_current ) {
				echo '<input type="hidden" name="', FILTER_PROPERTY_STATUS_ID, '[]" value="', string_attribute( $t_current ), '" />';
				$t_this_string = '';
				if( filter_field_is_any( $t_current ) ) {
					$t_any_found = true;
				} else {
					$t_this_string = get_enum_element( 'status', $t_current );
				}
				if( $t_first_flag != true ) {
					$t_output = $t_output . '<br />';
				} else {
					$t_first_flag = false;
				}
				$t_output = $t_output . string_display_line( $t_this_string );
			}
			if( true == $t_any_found ) {
				echo lang_get( 'any' );
			} else {
				echo $t_output;
			}
		}
		?>
			</td>
			<td class="small-caption" valign="top" id="hide_status_filter_target">
							<?php
								if( 'simple' == $t_view_type ) {
			$t_output = '';
			$t_none_found = false;
			if( count( $t_filter[FILTER_PROPERTY_HIDE_STATUS_ID] ) == 0 ) {
				echo lang_get( 'none' );
			} else {
				$t_first_flag = true;
				foreach( $t_filter[FILTER_PROPERTY_HIDE_STATUS_ID] as $t_current ) {
					echo '<input type="hidden" name="', FILTER_PROPERTY_HIDE_STATUS_ID, '[]" value="', string_attribute( $t_current ), '" />';
					$t_this_string = '';
					if( filter_field_is_none( $t_current ) ) {
						$t_none_found = true;
					} else {
						$t_this_string = get_enum_element( 'status', $t_current );
					}
					if( $t_first_flag != true ) {
						$t_output = $t_output . '<br />';
					} else {
						$t_first_flag = false;
					}
					$t_output = $t_output . string_display_line( $t_this_string );
				}
				$t_hide_status_post = '';
				if( count( $t_filter[FILTER_PROPERTY_HIDE_STATUS_ID] ) == 1 ) {
					$t_hide_status_post = ' (' . lang_get( 'and_above' ) . ')';
				}
				if( true == $t_none_found ) {
					echo lang_get( 'none' );
				} else {
					echo $t_output . string_display_line( $t_hide_status_post );
				}
			}
		}
		?>
			</td>
			<?php if ( $t_show_build ) { ?>
			<td class="small-caption" valign="top" id="show_build_filter_target">
							<?php
								$t_output = '';
		$t_any_found = false;
		if( count( $t_filter[FILTER_PROPERTY_PRODUCT_BUILD] ) == 0 ) {
			echo lang_get( 'any' );
		} else {
			$t_first_flag = true;
			foreach( $t_filter[FILTER_PROPERTY_PRODUCT_BUILD] as $t_current ) {
				$t_current = stripslashes( $t_current );
				echo '<input type="hidden" name="', FILTER_PROPERTY_PRODUCT_BUILD, '[]" value="', string_attribute( $t_current ), '" />';
				$t_this_string = '';
				if( filter_field_is_any( $t_current ) ) {
					$t_any_found = true;
				} else if( filter_field_is_none( $t_current ) ) {
					$t_this_string = lang_get( 'none' );
				} else {
					$t_this_string = $t_current;
				}
				if( $t_first_flag != true ) {
					$t_output = $t_output . '<br />';
				} else {
					$t_first_flag = false;
				}
				$t_output = $t_output . string_display_line( $t_this_string );
			}
			if( true == $t_any_found ) {
				echo lang_get( 'any' );
			} else {
				echo $t_output;
			}
		}
		?>
			</td>
			<?php } else { ?>
			<td class="small-caption" valign="top"></td>
			<?php }
				if( $t_show_product_version ) {
			?>
			<td colspan="2" class="small-caption" valign="top" id="show_version_filter_target">
							<?php
								$t_output = '';
			$t_any_found = false;
			if( count( $t_filter[FILTER_PROPERTY_PRODUCT_VERSION] ) == 0 ) {
				echo lang_get( 'any' );
			} else {
				$t_first_flag = true;
				foreach( $t_filter[FILTER_PROPERTY_PRODUCT_VERSION] as $t_current ) {
					$t_current = stripslashes( $t_current );
					echo '<input type="hidden" name="', FILTER_PROPERTY_PRODUCT_VERSION, '[]" value="', string_attribute( $t_current ), '" />';
					$t_this_string = '';
					if( filter_field_is_any( $t_current ) ) {
						$t_any_found = true;
					}
					else if( filter_field_is_none( $t_current ) ) {
						$t_this_string = lang_get( 'none' );
					} else {
						$t_this_string = $t_current;
					}
					if( $t_first_flag != true ) {
						$t_output = $t_output . '<br />';
					} else {
						$t_first_flag = false;
					}
					$t_output = $t_output . string_display_line( $t_this_string );
				}
				if( true == $t_any_found ) {
					echo lang_get( 'any' );
				} else {
					echo $t_output;
				}
			}
			?>
			</td>
			<td colspan="1" class="small-caption" valign="top" id="show_fixed_in_version_filter_target">
							<?php
								$t_output = '';
			$t_any_found = false;
			if( count( $t_filter[FILTER_PROPERTY_FIXED_IN_VERSION] ) == 0 ) {
				echo lang_get( 'any' );
			} else {
				$t_first_flag = true;
				foreach( $t_filter[FILTER_PROPERTY_FIXED_IN_VERSION] as $t_current ) {
					$t_current = stripslashes( $t_current );
					echo '<input type="hidden" name="', FILTER_PROPERTY_FIXED_IN_VERSION, '[]" value="', string_attribute( $t_current ), '" />';
					$t_this_string = '';
					if( filter_field_is_any( $t_current ) ) {
						$t_any_found = true;
					} else if( filter_field_is_none( $t_current ) ) {
						$t_this_string = lang_get( 'none' );
					} else {
						$t_this_string = $t_current;
					}
					if( $t_first_flag != true ) {
						$t_output = $t_output . '<br />';
					} else {
						$t_first_flag = false;
					}
					$t_output = $t_output . string_display_line( $t_this_string );
				}
				if( true == $t_any_found ) {
					echo lang_get( 'any' );
				} else {
					echo $t_output;
				}
			}
			?>
			</td>
				<td colspan="1" class="small-caption" valign="top" id="show_target_version_filter_target">
								<?php
									$t_output = '';
			$t_any_found = false;
			if( count( $t_filter[FILTER_PROPERTY_TARGET_VERSION] ) == 0 ) {
				echo lang_get( 'any' );
			} else {
				$t_first_flag = true;
				foreach( $t_filter[FILTER_PROPERTY_TARGET_VERSION] as $t_current ) {
					$t_current = stripslashes( $t_current );
					echo '<input type="hidden" name="', FILTER_PROPERTY_TARGET_VERSION, '[]" value="', string_attribute( $t_current ), '" />';
					$t_this_string = '';
					if( filter_field_is_any( $t_current ) ) {
						$t_any_found = true;
					} else if( filter_field_is_none( $t_current ) ) {
						$t_this_string = lang_get( 'none' );
					} else {
						$t_this_string = $t_current;
					}
					if( $t_first_flag != true ) {
						$t_output = $t_output . '<br />';
					} else {
						$t_first_flag = false;
					}
					$t_output = $t_output . string_display_line( $t_this_string );
				}
				if( true == $t_any_found ) {
					echo lang_get( 'any' );
				} else {
					echo $t_output;
				}
			}
			?>
				</td>
			<?php
		} else {?>
			<td colspan="2" class="small-caption" valign="top">
				&#160;
			</td>
			<td colspan="1" class="small-caption" valign="top">
				&#160;
			</td>
			<td colspan="1" class="small-caption" valign="top">
				&nbsp;
			</td>
			<?php
		}?>
			<td colspan="1" class="small-caption" valign="top" id="show_priority_filter_target">
              <?php
							  $t_output = '';
		$t_any_found = false;
		if( count( $t_filter[FILTER_PROPERTY_PRIORITY_ID] ) == 0 ) {
			echo lang_get( 'any' );
		} else {
			$t_first_flag = true;
			foreach( $t_filter[FILTER_PROPERTY_PRIORITY_ID] as $t_current ) {
				echo '<input type="hidden" name="', FILTER_PROPERTY_PRIORITY_ID, '[]" value="', string_attribute( $t_current ), '" />';
				$t_this_string = '';
				if( filter_field_is_any( $t_current ) ) {
					$t_any_found = true;
				} else {
					$t_this_string = get_enum_element( 'priority', $t_current );
				}
				if( $t_first_flag != true ) {
					$t_output = $t_output . '<br />';
				} else {
					$t_first_flag = false;
				}
				$t_output = $t_output . string_display_line( $t_this_string );
			}
			if( true == $t_any_found ) {
				echo lang_get( 'any' );
			} else {
				echo $t_output;
			}
		}
		?>
	    	</td>
			<?php if( $t_filter_cols > 8 ) {
			echo '<td class="small-caption" valign="top" colspan="' . ( $t_filter_cols - 7 ) . '">&#160;</td>';
		}?>

		</tr>

		<tr <?php echo "class=\"" . $t_trclass . "\"";?>>
			<td class="small-caption" valign="top">
				<a href="<?php echo $t_filters_url . FILTER_PROPERTY_ISSUES_PER_PAGE;?>" id="per_page_filter"><?php echo lang_get( 'show' )?>:</a>
			</td>
			<td class="small-caption" valign="top">
				<a href="<?php echo $t_filters_url . FILTER_PROPERTY_VIEW_STATE_ID;?>" id="view_state_filter"><?php echo lang_get( 'view_status' )?>:</a>
			</td>
			<td class="small-caption" valign="top">
				<a href="<?php echo $t_filters_url . FILTER_PROPERTY_SHOW_STICKY_ISSUES;?>" id="sticky_issues_filter"><?php echo lang_get( 'sticky' )?>:</a>
			</td>
			<td class="small-caption" valign="top" colspan="2">
				<a href="<?php echo $t_filters_url . FILTER_PROPERTY_HIGHLIGHT_CHANGED;?>" id="highlight_changed_filter"><?php echo lang_get( 'changed' )?>:</a>
			</td>
			<td class="small-caption" valign="top" >
				<a href="<?php echo $t_filters_url . FILTER_PROPERTY_FILTER_BY_DATE;?>" id="do_filter_by_date_filter"><?php echo lang_get( 'use_date_filters' )?>:</a>
			</td>
			<td class="small-caption" valign="top" colspan="2">
				<a href="<?php echo $t_filters_url . FILTER_PROPERTY_RELATIONSHIP_TYPE;?>" id="relationship_type_filter"><?php echo lang_get( 'bug_relationships' )?>:</a>
			</td>
			<?php if( $t_filter_cols > 8 ) {
			echo '<td class="small-caption" valign="top" colspan="' . ( $t_filter_cols - 8 ) . '">&#160;</td>';
		}?>
		</tr>
		<tr class="row-1">
			<td class="small-caption" valign="top" id="per_page_filter_target">
				<?php
					echo( $t_filter[FILTER_PROPERTY_ISSUES_PER_PAGE] == 0 ) ? lang_get( 'all' ) : string_display_line( $t_filter[FILTER_PROPERTY_ISSUES_PER_PAGE] );
		echo '<input type="hidden" name="', FILTER_PROPERTY_ISSUES_PER_PAGE, '" value="', string_attribute( $t_filter[FILTER_PROPERTY_ISSUES_PER_PAGE] ), '" />';
		?>
			</td>
			<td class="small-caption" valign="top" id="view_state_filter_target">
				<?php
				if( VS_PUBLIC === $t_filter[FILTER_PROPERTY_VIEW_STATE_ID] ) {
			echo lang_get( 'public' );
		} else if( VS_PRIVATE === $t_filter[FILTER_PROPERTY_VIEW_STATE_ID] ) {
			echo lang_get( 'private' );
		} else {
			echo lang_get( 'any' );
			$t_filter[FILTER_PROPERTY_VIEW_STATE_ID] = META_FILTER_ANY;
		}
		echo '<input type="hidden" name="', FILTER_PROPERTY_VIEW_STATE_ID, '" value="', string_attribute( $t_filter[FILTER_PROPERTY_VIEW_STATE_ID] ), '" />';
		?>
			</td>
			<td class="small-caption" valign="top" id="sticky_issues_filter_target">
				<?php
					$t_sticky_filter_state = gpc_string_to_bool( $t_filter[FILTER_PROPERTY_SHOW_STICKY_ISSUES] );
		print( $t_sticky_filter_state ? lang_get( 'yes' ) : lang_get( 'no' ) );
		?>
				<input type="hidden" name="sticky_issues" value="<?php echo $t_sticky_filter_state ? 'on' : 'off';?>" />
			</td>
			<td class="small-caption" valign="top" colspan="2" id="highlight_changed_filter_target">
				<?php
					echo $t_filter[FILTER_PROPERTY_HIGHLIGHT_CHANGED];
		echo '<input type="hidden" name="', FILTER_PROPERTY_HIGHLIGHT_CHANGED, '" value="', string_attribute( $t_filter[FILTER_PROPERTY_HIGHLIGHT_CHANGED] ), '" />';
		?>
			</td>
			<td class="small-caption" valign="top"  id="do_filter_by_date_filter_target">
							<?php
							if(( ON == config_get( 'dhtml_filters' ) ) && ( ON == config_get( 'use_javascript' ) ) ) {
			?>
		<script type="text/javascript" language="JavaScript">
		<!--
			function SwitchDateFields() {
		    	// All fields need to be enabled to go back to the script
				document.filters_open.start_month.disabled = ! document.filters_open.do_filter_by_date.checked;
				document.filters_open.start_day.disabled = ! document.filters_open.do_filter_by_date.checked;
				document.filters_open.start_year.disabled = ! document.filters_open.do_filter_by_date.checked;
				document.filters_open.end_month.disabled = ! document.filters_open.do_filter_by_date.checked;
				document.filters_open.end_day.disabled = ! document.filters_open.do_filter_by_date.checked;
				document.filters_open.end_year.disabled = ! document.filters_open.do_filter_by_date.checked;

		   		return true;
			}
		// -->
		</script>
							<?php
		}

		# end if dhtml_filters
		if( 'on' == $t_filter[FILTER_PROPERTY_FILTER_BY_DATE] ) {
			echo '<input type="hidden" name="', FILTER_PROPERTY_FILTER_BY_DATE, '" value="', string_attribute( $t_filter[FILTER_PROPERTY_FILTER_BY_DATE] ), '" />';
			echo '<input type="hidden" name="', FILTER_PROPERTY_START_MONTH, '" value="', string_attribute( $t_filter[FILTER_PROPERTY_START_MONTH] ), '" />';
			echo '<input type="hidden" name="', FILTER_PROPERTY_START_DAY, '" value="', string_attribute( $t_filter[FILTER_PROPERTY_START_DAY] ), '" />';
			echo '<input type="hidden" name="', FILTER_PROPERTY_START_YEAR, '" value="', string_attribute( $t_filter[FILTER_PROPERTY_START_YEAR] ), '" />';
			echo '<input type="hidden" name="', FILTER_PROPERTY_END_MONTH, '" value="', string_attribute( $t_filter[FILTER_PROPERTY_END_MONTH] ), '" />';
			echo '<input type="hidden" name="', FILTER_PROPERTY_END_DAY, '" value="', string_attribute( $t_filter[FILTER_PROPERTY_END_DAY] ), '" />';
			echo '<input type="hidden" name="', FILTER_PROPERTY_END_YEAR, '" value="', string_attribute( $t_filter[FILTER_PROPERTY_END_YEAR] ), '" />';

			$t_chars = preg_split( '//', config_get( 'short_date_format' ), -1, PREG_SPLIT_NO_EMPTY );
			$t_time = mktime( 0, 0, 0, $t_filter[FILTER_PROPERTY_START_MONTH], $t_filter[FILTER_PROPERTY_START_DAY], $t_filter[FILTER_PROPERTY_START_YEAR] );
			foreach( $t_chars as $t_char ) {
				if( strcasecmp( $t_char, "M" ) == 0 ) {
					echo ' ';
					echo date( 'F', $t_time );
				}
				if( strcasecmp( $t_char, "D" ) == 0 ) {
					echo ' ';
					echo date( 'd', $t_time );
				}
				if( strcasecmp( $t_char, "Y" ) == 0 ) {
					echo ' ';
					echo date( 'Y', $t_time );
				}
			}

			echo ' - ';

			$t_time = mktime( 0, 0, 0, $t_filter[FILTER_PROPERTY_END_MONTH], $t_filter[FILTER_PROPERTY_END_DAY], $t_filter[FILTER_PROPERTY_END_YEAR] );
			foreach( $t_chars as $t_char ) {
				if( strcasecmp( $t_char, "M" ) == 0 ) {
					echo ' ';
					echo date( 'F', $t_time );
				}
				if( strcasecmp( $t_char, "D" ) == 0 ) {
					echo ' ';
					echo date( 'd', $t_time );
				}
				if( strcasecmp( $t_char, "Y" ) == 0 ) {
					echo ' ';
					echo date( 'Y', $t_time );
				}
			}
		} else {
			echo lang_get( 'no' );
		}
		?>
			</td>

			<td class="small-caption" valign="top" colspan="2" id="relationship_type_filter_target">
							<?php
								echo '<input type="hidden" name="', FILTER_PROPERTY_RELATIONSHIP_TYPE, '" value="', string_attribute( $t_filter[FILTER_PROPERTY_RELATIONSHIP_TYPE]), '" />';
		echo '<input type="hidden" name="', FILTER_PROPERTY_RELATIONSHIP_BUG, '" value="', string_attribute( $t_filter[FILTER_PROPERTY_RELATIONSHIP_BUG] ), '" />';
		$c_rel_type = $t_filter[FILTER_PROPERTY_RELATIONSHIP_TYPE];
		$c_rel_bug = $t_filter[FILTER_PROPERTY_RELATIONSHIP_BUG];
		if( -1 == $c_rel_type || 0 == $c_rel_bug ) {
			echo lang_get( 'any' );
		} else {
			echo relationship_get_description_for_history( $c_rel_type ) . ' ' . $c_rel_bug;
		}

		?>
			</td>
			<?php if( $t_filter_cols > 8 ) {
			echo '<td class="small-caption" valign="top" colspan="' . ( $t_filter_cols - 8 ) . '">&#160;</td>';
		}?>
		</tr>
		<tr <?php echo "class=\"" . $t_trclass . "\"";?>>
			<td class="small-caption" valign="top">
				<?php if( ON == config_get( 'enable_profiles' ) ) { ?>
					<a href="<?php echo $t_filters_url . FILTER_PROPERTY_PLATFORM;?>" id="platform_filter"><?php echo lang_get( 'platform' )?>:</a>
				<?php } ?>
			</td>
			<td class="small-caption" valign="top">
				<?php if( ON == config_get( 'enable_profiles' ) ) { ?>
					<a href="<?php echo $t_filters_url . FILTER_PROPERTY_OS;?>" id="os_filter"><?php echo lang_get( 'os' )?>:</a>
				<?php } ?>
			</td>
			<td class="small-caption" valign="top">
				<?php if( ON == config_get( 'enable_profiles' ) ) { ?>
					<a href="<?php echo $t_filters_url . FILTER_PROPERTY_OS_BUILD;?>" id="os_build_filter"><?php echo lang_get( 'os_version' )?>:</a>
				<?php } ?>
			</td>
			<td class="small-caption" valign="top" colspan="5">
				<?php if ( access_has_global_level( config_get( 'tag_view_threshold' ) ) ) { ?>
				<a href="<?php echo $t_filters_url . FILTER_PROPERTY_TAG_STRING;?>" id="tag_string_filter"><?php echo lang_get( 'tags' )?>:</a>
				<?php } ?>
			</td>
			<?php if( $t_filter_cols > 8 ) {
			echo '<td class="small-caption" valign="top" colspan="' . ( $t_filter_cols - 8 ) . '">&#160;</td>';
		}?>
		</tr>
		<tr class="row-1">
			<?php if( ON == config_get( 'enable_profiles' ) ) { ?>
			<td class="small-caption" valign="top" id="platform_filter_target">
				<?php
					print_multivalue_field( FILTER_PROPERTY_PLATFORM, $t_filter[FILTER_PROPERTY_PLATFORM] );
		?>
			</td>
			<td class="small-caption" valign="top" id="os_filter_target">
				<?php
					print_multivalue_field( FILTER_PROPERTY_OS, $t_filter[FILTER_PROPERTY_OS] );
		?>
			</td>
			<td class="small-caption" valign="top" id="os_build_filter_target">
				<?php
					print_multivalue_field( FILTER_PROPERTY_OS_BUILD, $t_filter[FILTER_PROPERTY_OS_BUILD] );
		?>
			</td>
			<?php } else {?>
				<td colspan="3">&#160;</td>
			<?php } ?>

			<td class="small-caption" valign="top" id="tag_string_filter_target" colspan="5">
				<?php
					$t_tag_string = $t_filter[FILTER_PROPERTY_TAG_STRING];
		if( $t_filter[FILTER_PROPERTY_TAG_SELECT] != 0 && tag_exists( $t_filter[FILTER_PROPERTY_TAG_SELECT] ) ) {
			$t_tag_string .= ( is_blank( $t_tag_string ) ? '' : config_get( 'tag_separator' ) );
			$t_tag_string .= tag_get_field( $t_filter[FILTER_PROPERTY_TAG_SELECT], 'name' );
		}
		echo string_html_entities( $t_tag_string );
		echo '<input type="hidden" name="', FILTER_PROPERTY_TAG_STRING, '" value="', string_attribute( $t_tag_string ), '" />';
		?>
			</td>
		</tr>
		<?php

		# get plugin filters
		$t_plugin_filters = filter_get_plugin_filters();
		$t_column = 0;
		$t_fields = '';
		$t_values = '';

		# output a filter form element for each plugin filter
		foreach( $t_plugin_filters as $t_field_name => $t_filter_object ) {
			$t_fields .= '<td class="small-caption" valign="top"> <a href="' . $t_filters_url . string_attribute( $t_field_name ) .
				'" id="' . string_attribute( $t_field_name ) . '_filter">' . string_display_line( $t_filter_object->title ) . '</a> </td>';

			$t_values .= '<td class="small-caption" valign="top" id="' . string_attribute( $t_field_name ) . '_filter_target"> ';

			if ( !isset( $t_filter[ $t_field_name ] ) ) {
				$t_values .= lang_get( 'any' );
			} else {
				switch( $t_filter_object->type ) {
					case FILTER_TYPE_STRING:
					case FILTER_TYPE_INT:
						if ( filter_field_is_any( $t_filter[ $t_field_name ] ) ) {
							$t_values .= lang_get( 'any' );
						} else {
							$t_values .= string_display_line( $t_filter[ $t_field_name ] );
						}
						$t_values .= '<input type="hidden" name="' . string_attribute( $t_field_name ) . '" value="' . string_attribute( $t_filter[ $t_field_name ] ) . '"/>';
						break;

					case FILTER_TYPE_BOOLEAN:
						$t_values .= string_display_line( $t_filter_object->display( (bool)$t_filter[ $t_field_name ] ) );
						$t_values .= '<input type="hidden" name="' . string_attribute( $t_field_name ) . '" value="' . (bool)$t_filter[ $t_field_name ] . '"/>';
						break;

					case FILTER_TYPE_MULTI_STRING:
					case FILTER_TYPE_MULTI_INT:
						$t_first = true;
						$t_output = '';

						if ( !is_array( $t_filter[ $t_field_name ] ) ) {
							$t_filter[ $t_field_name ] = array( $t_filter[ $t_field_name ] );
						}

						foreach( $t_filter[ $t_field_name ] as $t_current ) {
							if ( filter_field_is_any( $t_current ) ) {
								$t_output .= lang_get( 'any' );
							} else {
								$t_output .= ( $t_first ? '' : '<br />' ) . string_display_line( $t_filter_object->display( $t_current ) );
								$t_first = false;
							}
							$t_values .= '<input type="hidden" name="' . string_attribute( $t_field_name ) . '[]" value="' . string_attribute( $t_current ) . '"/>';
						}

						$t_values .= $t_output;
						break;
				}
			}

			$t_values .= '</td>';

			$t_column++;

			# wrap at the appropriate column
			if ( $t_column >= $t_filter_cols ) {
				echo '<tr class="', $t_trclass, '">', $t_fields, '</tr>';
				echo '<tr class="row-1">', $t_values, '</tr>';

				$t_fields = '';
				$t_values = '';
				$t_column = 0;
			}
		}

		# output any remaining plugin filters
		if ( $t_column > 0 ) {
			if ( $t_column < $t_filter_cols ) {
				$t_fields .= '<td class="small-caption" colspan="' . ( $t_filter_cols - $t_column ) . '">&#160;</td>';
				$t_values .= '<td class="small-caption" colspan="' . ( $t_filter_cols - $t_column ) . '">&#160;</td>';
			}

			echo '<tr class="', $t_trclass, '">', $t_fields, '</tr>';
			echo '<tr class="row-1">', $t_values, '</tr>';
		}

		if( ON == config_get( 'filter_by_custom_fields' ) ) {

			# -- Custom Field Searching --

			if( count( $t_accessible_custom_fields_ids ) > 0 ) {
				$t_per_row = config_get( 'filter_custom_fields_per_row' );
				$t_num_fields = count( $t_accessible_custom_fields_ids );
				$t_row_idx = 0;
				$t_col_idx = 0;

				$t_fields = '';
				$t_values = '';

				for( $i = 0;$i < $t_num_fields;$i++ ) {
					if( $t_col_idx == 0 ) {
						$t_fields = '<tr class="' . $t_trclass . '">';
						$t_values = '<tr class="row-1">';
					}

					if( isset( $t_accessible_custom_fields_names[$i] ) ) {
						$t_fields .= '<td class="small-caption" valign="top"> ';
						$t_fields .= '<a href="' . $t_filters_url . 'custom_field_' . $t_accessible_custom_fields_ids[$i] . '[]" id="custom_field_' . $t_accessible_custom_fields_ids[$i] . '_filter">';
						$t_fields .= string_display_line( lang_get_defaulted( $t_accessible_custom_fields_names[$i] ) );
						$t_fields .= '</a> </td> ';
					}
					$t_output = '';
					$t_any_found = false;

					$t_values .= '<td class="small-caption" valign="top" id="custom_field_' . $t_accessible_custom_fields_ids[$i] . '_filter_target"> ';
					if( !isset( $t_filter['custom_fields'][$t_accessible_custom_fields_ids[$i]] ) ) {
						$t_values .= lang_get( 'any' );
					} else {
						if( $t_accessible_custom_fields_types[$i] == CUSTOM_FIELD_TYPE_DATE ) {

							/** @todo moved embedded javascript here from print_filter_custom_field_date
							 *  it appears not to load properly on Firefox and other browsers if loaded through the httpxmlreq
							 */
							$t_field_id = $t_accessible_custom_fields_ids[$i];
							$t_js_toggle_func = "toggle_custom_date_field_" . $t_field_id . "_controls";
							if(( ON == config_get( 'dhtml_filters' ) ) && ( ON == config_get( 'use_javascript' ) ) ) {
								?>
	<script type="text/javascript" language="JavaScript">
	<!--
	function <?php echo $t_js_toggle_func . "_start";?>(disable) {
			document.filters_open.custom_field_<?php echo $t_field_id;?>_start_year.disabled = disable ;
			document.filters_open.custom_field_<?php echo $t_field_id;?>_start_month.disabled = disable ;
			document.filters_open.custom_field_<?php echo $t_field_id;?>_start_day.disabled = disable ;
	} ;

	function <?php echo $t_js_toggle_func . "_end";?>(disable) {
			document.filters_open.custom_field_<?php echo $t_field_id;?>_end_year.disabled = disable ;
			document.filters_open.custom_field_<?php echo $t_field_id;?>_end_month.disabled = disable ;
			document.filters_open.custom_field_<?php echo $t_field_id;?>_end_day.disabled = disable ;
	} ;

	function <?php echo $t_js_toggle_func;?>() {
		switch (document.filters_open.custom_field_<?php echo $t_field_id;?>_control.selectedIndex) {
		case <?php echo CUSTOM_FIELD_DATE_ANY;?>:
		case <?php echo CUSTOM_FIELD_DATE_NONE;?>:
			<?php echo $t_js_toggle_func . "_start";?>(true) ;
			<?php echo $t_js_toggle_func . "_end";?>(true) ;
			break ;
		case <?php echo CUSTOM_FIELD_DATE_BETWEEN;?>:
			<?php echo $t_js_toggle_func . "_start";?>(false) ;
			<?php echo $t_js_toggle_func . "_end";?>(false) ;
			break ;
		default:
			<?php echo $t_js_toggle_func . "_start";?>(false) ;
			<?php echo $t_js_toggle_func . "_end";?>(true) ;
			break ;
		}
	}
	// -->
	</script>
<?php
							}

							# end if dhtml_filters
							$t_short_date_format = config_get( 'short_date_format' );
							if( !isset( $t_filter['custom_fields'][$t_accessible_custom_fields_ids[$i]][1] ) ) {
								$t_filter['custom_fields'][$t_accessible_custom_fields_ids[$i]][1] = 0;
							}
							$t_start = date( $t_short_date_format, $t_filter['custom_fields'][$t_accessible_custom_fields_ids[$i]][1] );

							if( !isset( $t_filter['custom_fields'][$t_accessible_custom_fields_ids[$i]][2] ) ) {
								$t_filter['custom_fields'][$t_accessible_custom_fields_ids[$i]][2] = 0;
							}
							$t_end = date( $t_short_date_format, $t_filter['custom_fields'][$t_accessible_custom_fields_ids[$i]][2] );
							switch( $t_filter['custom_fields'][$t_accessible_custom_fields_ids[$i]][0] ) {
								case CUSTOM_FIELD_DATE_ANY:
									$t_values .= lang_get( 'any' );
									break;
								case CUSTOM_FIELD_DATE_NONE:
									$t_values .= lang_get( 'none' );
									break;
								case CUSTOM_FIELD_DATE_BETWEEN:
									$t_values .= lang_get( 'between_date' ) . '<br />';
									$t_values .= $t_start . '<br />' . $t_end;
									break;
								case CUSTOM_FIELD_DATE_ONORBEFORE:
									$t_values .= lang_get( 'on_or_before_date' ) . '<br />';
									$t_values .= $t_end;
									break;
								case CUSTOM_FIELD_DATE_BEFORE:
									$t_values .= lang_get( 'before_date' ) . '<br />';
									$t_values .= $t_end;
									break;
								case CUSTOM_FIELD_DATE_ON:
									$t_values .= lang_get( 'on_date' ) . '<br />';
									$t_values .= $t_start;
									break;
								case CUSTOM_FIELD_DATE_AFTER:
									$t_values .= lang_get( 'after_date' ) . '<br />';
									$t_values .= $t_start;
									break;
								case CUSTOM_FIELD_DATE_ONORAFTER:
									$t_values .= lang_get( 'on_or_after_date' ) . '<br />';
									$t_values .= $t_start;
									break;
							}
						} else {
							$t_first_flag = true;
							foreach( $t_filter['custom_fields'][$t_accessible_custom_fields_ids[$i]] as $t_current ) {
								$t_current = stripslashes( $t_current );
								$t_this_string = '';
								if( filter_field_is_any( $t_current ) ) {
									$t_any_found = true;
								} else if( filter_field_is_none( $t_current ) ) {
									$t_this_string = lang_get( 'none' );
								} else {
									$t_this_string = $t_current;
								}

								if( $t_first_flag != true ) {
									$t_output = $t_output . '<br />';
								} else {
									$t_first_flag = false;
								}

								$t_output = $t_output . string_display_line( $t_this_string );
								$t_values .= '<input type="hidden" name="custom_field_' . $t_accessible_custom_fields_ids[$i] . '[]" value="' . string_attribute( $t_current ) . '" />';
							}
						}

						if( true == $t_any_found ) {
							$t_values .= lang_get( 'any' );
						} else {
							$t_values .= $t_output;
						}
					}
					$t_values .= ' </td>';

					$t_col_idx++;

					if( $t_col_idx == $t_per_row ) {
						if( $t_filter_cols > $t_per_row ) {
							$t_fields .= '<td colspan="' . ( $t_filter_cols - $t_per_row ) . '">&#160;</td> ';
							$t_values .= '<td colspan="' . ( $t_filter_cols - $t_per_row ) . '">&#160;</td> ';
						}

						$t_fields .= '</tr>' . "\n";
						$t_values .= '</tr>' . "\n";

						echo $t_fields;
						echo $t_values;

						$t_col_idx = 0;
						$t_row_idx++;
					}
				}

				if( $t_col_idx > 0 ) {
					if( $t_col_idx < $t_per_row ) {
						$t_fields .= '<td colspan="' . ( $t_per_row - $t_col_idx ) . '">&#160;</td> ';
						$t_values .= '<td colspan="' . ( $t_per_row - $t_col_idx ) . '">&#160;</td> ';
					}

					if( $t_filter_cols > $t_per_row ) {
						$t_fields .= '<td colspan="' . ( $t_filter_cols - $t_per_row ) . '">&#160;</td> ';
						$t_values .= '<td colspan="' . ( $t_filter_cols - $t_per_row ) . '">&#160;</td> ';
					}

					$t_fields .= '</tr>' . "\n";
					$t_values .= '</tr>' . "\n";

					echo $t_fields;
					echo $t_values;
				}
			}
		}
		?>
		<tr class="row-1">
			<td class="small-caption category2" valign="top">
                <a href="<?php echo $t_filters_url . FILTER_PROPERTY_NOTE_USER_ID;?>" id="note_user_id_filter"><?php echo lang_get( 'note_user_id' )?>:</a>
            </td>
            <td class="small-caption" valign="top" id="note_user_id_filter_target">
                <?php
                    $t_output = '';
		$t_any_found = false;
		if( count( $t_filter[FILTER_PROPERTY_NOTE_USER_ID] ) == 0 ) {
			echo lang_get( 'any' );
		} else {
			$t_first_flag = true;
			foreach( $t_filter[FILTER_PROPERTY_NOTE_USER_ID] as $t_current ) {
				echo '<input type="hidden" name="', FILTER_PROPERTY_NOTE_USER_ID, '[]" value="', string_attribute( $t_current ), '" />';
				$t_this_name = '';
				if( filter_field_is_none( $t_current ) ) {
					$t_this_name = lang_get( 'none' );
				} else if( filter_field_is_any( $t_current ) ) {
					$t_any_found = true;
				} else if( filter_field_is_myself( $t_current ) ) {
					if( access_has_project_level( config_get( 'handle_bug_threshold' ) ) ) {
						$t_this_name = '[' . lang_get( 'myself' ) . ']';
					} else {
						$t_any_found = true;
					}
				} else {
					$t_this_name = user_get_name( $t_current );
				}
				if( $t_first_flag != true ) {
					$t_output = $t_output . '<br />';
				} else {
					$t_first_flag = false;
				}
				$t_output = $t_output . string_display_line( $t_this_name );
			}
			if( true == $t_any_found ) {
				echo lang_get( 'any' );
			} else {
				echo $t_output;
			}
		}
		?>
            </td>
			<td class="small-caption" valign="top">
				<a href="<?php echo $t_filters_url . 'show_sort';?>" id="show_sort_filter"><?php echo lang_get( 'sort' )?>:</a>
			</td>
			<td class="small-caption" valign="top" id="show_sort_filter_target">
				<?php
					$t_sort_fields = explode( ',', $t_filter[FILTER_PROPERTY_SORT_FIELD_NAME] );
		$t_dir_fields = explode( ',', $t_filter[FILTER_PROPERTY_SORT_DIRECTION] );

		for( $i = 0;$i < 2;$i++ ) {
			if( isset( $t_sort_fields[$i] ) ) {
				if( 0 < $i ) {
					echo ', ';
				}
				$t_sort = $t_sort_fields[$i];
				if( strpos( $t_sort, 'custom_' ) === 0 ) {
					$t_field_name = string_display( lang_get_defaulted( utf8_substr( $t_sort, utf8_strlen( 'custom_' ) ) ) );
				} else {
					$t_field_name = string_get_field_name( $t_sort );
				}

				echo $t_field_name . ' ' . lang_get( 'bugnote_order_' . utf8_strtolower( $t_dir_fields[$i] ) );
				echo '<input type="hidden" name="', FILTER_PROPERTY_SORT_FIELD_NAME, '_', $i, '" value="', string_attribute( $t_sort_fields[$i] ), '" />';
				echo '<input type="hidden" name="', FILTER_PROPERTY_SORT_DIRECTION, '_', $i, '" value="', string_attribute( $t_dir_fields[$i] ), '" />';
			}
		}
		?>
			</td>
			<?php
				if( 'advanced' == $t_view_type ) {
			?>
					<td class="small-caption" valign="top" colspan="2">
						<a href="<?php echo $t_filters_url . FILTER_PROPERTY_PROJECT_ID;?>" id="project_id_filter"><?php echo lang_get( 'email_project' )?>:</a>
					</td>
					<td class="small-caption" valign="top"  id="project_id_filter_target">
						<?php
							$t_output = '';
			if( !is_array( $t_filter[FILTER_PROPERTY_PROJECT_ID] ) ) {
				$t_filter[FILTER_PROPERTY_PROJECT_ID] = Array(
					$t_filter[FILTER_PROPERTY_PROJECT_ID],
				);
			}
			if( count( $t_filter[FILTER_PROPERTY_PROJECT_ID] ) == 0 ) {
				echo lang_get( 'current' );
			} else {
				$t_first_flag = true;
				foreach( $t_filter[FILTER_PROPERTY_PROJECT_ID] as $t_current ) {
					echo '<input type="hidden" name="', FILTER_PROPERTY_PROJECT_ID, '[]" value="', string_attribute( $t_current ), '" />';
					$t_this_name = '';
					if( META_FILTER_CURRENT == $t_current ) {
						$t_this_name = lang_get( 'current' );
					} else {
						$t_this_name = project_get_name( $t_current, false );
					}
					if( $t_first_flag != true ) {
						$t_output = $t_output . '<br />';
					} else {
						$t_first_flag = false;
					}
					$t_output = $t_output . string_display_line( $t_this_name );
				}
				echo $t_output;
			}
			?>
					</td>
					<?php
					if( $t_filter_cols > 6 ) {
				echo '<td class="small-caption" valign="top" colspan="' . ( $t_filter_cols - 5 ) . '">&#160;</td>';
			}
		} else {
			if( $t_filter_cols > 3 ) {
				echo '<td class="small-caption" valign="top" colspan="' . ( $t_filter_cols - 2 ) . '">&#160;</td>';
			}
		}
		?>
		</tr>
		<tr class="row-1">
			<td class="small-caption" valign="top"><a href="<?php echo $t_filters_url . FILTER_PROPERTY_MATCH_TYPE;?>" id="match_type_filter"><?php echo lang_get( 'filter_match_type' )?>:</a></td>
			<td class="small-caption" valign="top" id="match_type_filter_target">
			<?php
				switch( $t_filter[FILTER_PROPERTY_MATCH_TYPE] ) {
					case FILTER_MATCH_ANY:
						echo lang_get ('filter_match_any');
						break;
					case FILTER_MATCH_ALL:
					default:
						echo lang_get ('filter_match_all');
						break;
				}
			?>
			<input type="hidden" name="match_type" value="<?php echo $t_filter[FILTER_PROPERTY_MATCH_TYPE] ?>"/>
			</td>
			<td colspan="6">&#160;</td>
		</tr>
		<?php
	}

	// expanded
	?>
		<tr>
			<td colspan="2">
				<?php
					collapse_icon( 'filter' );
	echo lang_get( 'search' ) . '&#160;';
	echo '<input type="text" size="16" name="', FILTER_PROPERTY_FREE_TEXT, '" value="', string_attribute( $t_filter[FILTER_PROPERTY_FREE_TEXT] ), '" />';
	?>

				<input type="submit" name="filter" class="button-small" value="<?php echo lang_get( 'filter_button' )?>" />
			</td>
			</form>
			<td class="center" colspan="<?php echo( $t_filter_cols - 6 )?>"> <!-- use this label for padding -->
				<?php
					if( ON == config_get( 'dhtml_filters' ) ) {
		$f_switch_view_link = 'view_all_set.php?type=6&view_type=';
	} else {
		$f_switch_view_link = 'view_filters_page.php?view_type=';
	}

	$t_view_filters = config_get( 'view_filters' );
	if(( SIMPLE_ONLY != $t_view_filters ) && ( ADVANCED_ONLY != $t_view_filters ) ) {
		if( 'advanced' == $t_view_type ) {
			print_bracket_link( $f_switch_view_link . 'simple', lang_get( 'simple_filters' ) );
		} else {
			print_bracket_link( $f_switch_view_link . 'advanced', lang_get( 'advanced_filters' ) );
		}
	}

	if( access_has_project_level( config_get( 'create_permalink_threshold' ) ) ) {
		print_bracket_link( 'permalink_page.php?url=' . urlencode( filter_get_url( $t_filter ) ), lang_get( 'create_filter_link' ),

		/* new window = */
		true );
	}
	?>
			</td>
			<td class="right" colspan="4">
			<?php
			$t_stored_queries_arr = array();
	$t_stored_queries_arr = filter_db_get_available_queries();

	if( count( $t_stored_queries_arr ) > 0 ) {
		?>
					<form method="get" name="list_queries<?php echo $t_form_name_suffix;?>" action="view_all_set.php">
					<?php # CSRF protection not required here - form does not result in modifications ?>
					<input type="hidden" name="type" value="3" />
					<?php
					if( ON == config_get( 'use_javascript' ) ) {
			echo "<select name=\"source_query_id\" onchange=\"document.forms.list_queries$t_form_name_suffix.submit();\">";
		} else {
			echo '<select name="source_query_id">';
		}
		?>
					<option value="-1"><?php echo '[' . lang_get( 'reset_query' ) . ']'?></option>
					<option value="-1"></option>
					<?php
					$t_source_query_id = isset( $t_filter['_source_query_id'] ) ? (int)$t_filter['_source_query_id'] : -1;
					foreach( $t_stored_queries_arr as $t_query_id => $t_query_name ) {
						echo '<option value="' . $t_query_id . '" ';
						check_selected( $t_query_id, $t_source_query_id );
						echo '>' . string_display_line( $t_query_name ) . '</option>';
					}
		?>
					</select>
					<input type="submit" name="switch_to_query_button" class="button-small" value="<?php echo lang_get( 'use_query' )?>" />
					</form>
					<form method="post" name="open_queries" action="query_view_page.php">
					<?php # CSRF protection not required here - form does not result in modifications ?>
					<input type="submit" name="switch_to_query_button" class="button-small" value="<?php echo lang_get( 'open_queries' )?>" />
					</form>
				<?php
	} else {
		?>
					<form method="get" name="reset_query" action="view_all_set.php">
					<?php # CSRF protection not required here - form does not result in modifications ?>
					<input type="hidden" name="type" value="3" />
					<input type="hidden" name="source_query_id" value="-1" />
					<input type="submit" name="reset_query_button" class="button-small" value="<?php echo lang_get( 'reset_query' )?>" />
					</form>
				<?php
	}

	if( access_has_project_level( config_get( 'stored_query_create_threshold' ) ) ) {
		?>
					<form method="post" name="save_query" action="query_store_page.php">
					<?php # CSRF protection not required here - form does not result in modifications ?>
					<input type="submit" name="save_query_button" class="button-small" value="<?php echo lang_get( 'save_query' )?>" />
					</form>
			<?php
	}
	?>
			</td>
		</tr>
		</table>
<?php
}

/**
 	 * @internal The following functions each print out filter field inputs.
 *      They are derived from view_filters_page.php
 *      The functions follow a strict naming convention:
 *
 * 		print_filter_[filter_name]
 *
 *      Where [filter_name] is the same as the "name" of the form element for
 *      that filter. This naming convention is depended upon by the controller
 *      at the end of the script.
 *
 * @todo print functions should be abstracted.  Many of these functions
 *      are virtually identical except for the property name.
 *      Perhaps this code could be made simpler by refactoring into a
 *      class so as to avoid all those calls to global(which are pretty ugly)
 *      These functions could also be shared by view_filters_page.php
 */

/**
 *  Print the reporter field
 */
function print_filter_reporter_id() {
	global $t_select_modifier, $t_filter;
	?>
		<select <?php echo $t_select_modifier;?> name="reporter_id[]">
		<?php
	# if current user is a reporter, and limited reports set to ON, only display that name
	# @@@ thraxisp - access_has_project_level checks greater than or equal to,
	#   this assumed that there aren't any holes above REPORTER where the limit would apply
	#
	if(( ON === config_get( 'limit_reporters' ) ) && ( !access_has_project_level( REPORTER + 1 ) ) ) {
		$t_id = auth_get_current_user_id();
		$t_username = user_get_field( $t_id, 'username' );
		$t_realname = user_get_field( $t_id, 'realname' );
		$t_display_name = string_attribute( $t_username );
		if(( isset( $t_realname ) ) && ( $t_realname > '' ) && ( ON == config_get( 'show_realname' ) ) ) {
			$t_display_name = string_attribute( $t_realname );
		}
		echo '<option value="' . $t_id . '" selected="selected">' . $t_display_name . '</option>';
	} else {
		?>
		<option value="<?php echo META_FILTER_ANY?>" <?php check_selected( $t_filter[FILTER_PROPERTY_REPORTER_ID], META_FILTER_ANY );?>>[<?php echo lang_get( 'any' )?>]</option>
		<?php
			if( access_has_project_level( config_get( 'report_bug_threshold' ) ) ) {
				echo '<option value="' . META_FILTER_MYSELF . '" ';
				check_selected( $t_filter[FILTER_PROPERTY_REPORTER_ID], META_FILTER_MYSELF );
				echo '>[' . lang_get( 'myself' ) . ']</option>';
			}
		print_reporter_option_list( $t_filter[FILTER_PROPERTY_REPORTER_ID] );
	}?>
		</select>
		<?php
}

/**
 *  Print the user monitor field
 */
function print_filter_user_monitor() {
	global $t_select_modifier, $t_filter;
	?>
	<!-- Monitored by -->
		<select <?php echo $t_select_modifier;?> name="user_monitor[]">
			<option value="<?php echo META_FILTER_ANY?>" <?php check_selected( $t_filter[FILTER_PROPERTY_MONITOR_USER_ID], META_FILTER_ANY );?>>[<?php echo lang_get( 'any' )?>]</option>
			<?php
				if( access_has_project_level( config_get( 'monitor_bug_threshold' ) ) ) {
		echo '<option value="' . META_FILTER_MYSELF . '" ';
		check_selected( $t_filter[FILTER_PROPERTY_MONITOR_USER_ID], META_FILTER_MYSELF );
		echo '>[' . lang_get( 'myself' ) . ']</option>';
	}
	$t_threshold = config_get( 'show_monitor_list_threshold' );
	$t_has_project_level = access_has_project_level( $t_threshold );

	if( $t_has_project_level ) {
		print_reporter_option_list( $t_filter[FILTER_PROPERTY_MONITOR_USER_ID] );
	}
	?>
		</select>
		<?php
}

/**
 *  print the handler field
 */
function print_filter_handler_id() {
	global $t_select_modifier, $t_filter, $f_view_type;
	?>
		<!-- Handler -->
		<select <?php echo $t_select_modifier;?> name="handler_id[]">
			<option value="<?php echo META_FILTER_ANY?>" <?php check_selected( $t_filter[FILTER_PROPERTY_HANDLER_ID], META_FILTER_ANY );?>>[<?php echo lang_get( 'any' )?>]</option>
			<?php if( access_has_project_level( config_get( 'view_handler_threshold' ) ) ) {?>
			<option value="<?php echo META_FILTER_NONE?>" <?php check_selected( $t_filter[FILTER_PROPERTY_HANDLER_ID], META_FILTER_NONE );?>>[<?php echo lang_get( 'none' )?>]</option>
			<?php
				if( access_has_project_level( config_get( 'handle_bug_threshold' ) ) ) {
			echo '<option value="' . META_FILTER_MYSELF . '" ';
			check_selected( $t_filter[FILTER_PROPERTY_HANDLER_ID], META_FILTER_MYSELF );
			echo '>[' . lang_get( 'myself' ) . ']</option>';
		}

		print_assign_to_option_list( $t_filter[FILTER_PROPERTY_HANDLER_ID] );
	}?>
		</select>
		<?php
}

/**
 *  print the category field
 */
function print_filter_show_category() {
	global $t_select_modifier, $t_filter;
	?>
		<!-- Category -->
		<select <?php echo $t_select_modifier;?> name="<?php echo FILTER_PROPERTY_CATEGORY;?>[]">
			<option value="<?php echo META_FILTER_ANY?>" <?php check_selected( $t_filter[FILTER_PROPERTY_CATEGORY], META_FILTER_ANY );?>>[<?php echo lang_get( 'any' )?>]</option>
			<?php print_category_filter_option_list( $t_filter[FILTER_PROPERTY_CATEGORY] )?>
		</select>
		<?php
}

/**
 *  print the platform field
 */
function print_filter_platform() {
	global $t_select_modifier, $t_filter;

	?>
		<!-- Platform -->
		<select <?php echo $t_select_modifier;?> name="<?php echo FILTER_PROPERTY_PLATFORM;?>[]">
			<option value="<?php echo META_FILTER_ANY?>" <?php check_selected( $t_filter[FILTER_PROPERTY_PLATFORM], META_FILTER_ANY );?>>[<?php echo lang_get( 'any' )?>]</option>
			<?php
				log_event( LOG_FILTERING, 'Platform = ' . var_export( $t_filter[FILTER_PROPERTY_PLATFORM], true ) );
	print_platform_option_list( $t_filter[FILTER_PROPERTY_PLATFORM] );
	?>
		</select>
		<?php
}

/**
 *  print the os field
 */
function print_filter_os() {
	global $t_select_modifier, $t_filter;

	?>
		<!-- OS -->
		<select <?php echo $t_select_modifier;?> name="<?php echo FILTER_PROPERTY_OS;?>[]">
			<option value="<?php echo META_FILTER_ANY?>" <?php check_selected( $t_filter[FILTER_PROPERTY_OS], META_FILTER_ANY );?>>[<?php echo lang_get( 'any' )?>]</option>
			<?php print_os_option_list( $t_filter[FILTER_PROPERTY_OS] )?>
		</select>
		<?php
}

/**
 *  print the os build field
 */
function print_filter_os_build() {
	global $t_select_modifier, $t_filter;

	?>
		<!-- OS Build -->
		<select <?php echo $t_select_modifier;?> name="<?php echo FILTER_PROPERTY_OS_BUILD;?>[]">
			<option value="<?php echo META_FILTER_ANY?>" <?php check_selected( $t_filter[FILTER_PROPERTY_OS_BUILD], META_FILTER_ANY );?>>[<?php echo lang_get( 'any' )?>]</option>
			<?php print_os_build_option_list( $t_filter[FILTER_PROPERTY_OS_BUILD] )?>
		</select>
		<?php
}

/**
 *  print the severity field
 */
function print_filter_show_severity() {
	global $t_select_modifier, $t_filter;
	?><!-- Severity -->
			<select <?php echo $t_select_modifier;?> name="<?php echo FILTER_PROPERTY_SEVERITY_ID;?>[]">
				<option value="<?php echo META_FILTER_ANY?>" <?php check_selected( $t_filter[FILTER_PROPERTY_SEVERITY_ID], META_FILTER_ANY );?>>[<?php echo lang_get( 'any' )?>]</option>
				<?php print_enum_string_option_list( 'severity', $t_filter[FILTER_PROPERTY_SEVERITY_ID] )?>
			</select>
		<?php
}

/**
 *  print resolution field
 */
function print_filter_show_resolution() {
	global $t_select_modifier, $t_filter;
	?><!-- Resolution -->
			<select <?php echo $t_select_modifier;?> name="<?php echo FILTER_PROPERTY_RESOLUTION_ID;?>[]">
				<option value="<?php echo META_FILTER_ANY?>" <?php check_selected( $t_filter[FILTER_PROPERTY_RESOLUTION_ID], META_FILTER_ANY );?>>[<?php echo lang_get( 'any' )?>]</option>
				<?php print_enum_string_option_list( 'resolution', $t_filter[FILTER_PROPERTY_RESOLUTION_ID] )?>
			</select>
		<?php
}

/**
 *  print status field
 */
function print_filter_show_status() {
	global $t_select_modifier, $t_filter;
	?>	<!-- Status -->
			<select <?php echo $t_select_modifier;?> name="<?php echo FILTER_PROPERTY_STATUS_ID;?>[]">
				<option value="<?php echo META_FILTER_ANY?>" <?php check_selected( $t_filter[FILTER_PROPERTY_STATUS_ID], META_FILTER_ANY );?>>[<?php echo lang_get( 'any' )?>]</option>
				<?php print_enum_string_option_list( 'status', $t_filter[FILTER_PROPERTY_STATUS_ID] )?>
			</select>
		<?php
}

/**
 *  print hide status field
 */
function print_filter_hide_status() {
	global $t_select_modifier, $t_filter;
	?><!-- Hide Status -->
			<select <?php echo $t_select_modifier;?> name="<?php echo FILTER_PROPERTY_HIDE_STATUS_ID;?>[]">
				<option value="<?php echo META_FILTER_NONE?>">[<?php echo lang_get( 'none' )?>]</option>
				<?php print_enum_string_option_list( 'status', $t_filter[FILTER_PROPERTY_HIDE_STATUS_ID] )?>
			</select>
		<?php
}

/**
 *  print build field
 */
function print_filter_show_build() {
	global $t_select_modifier, $t_filter;
	?><!-- Build -->
		<select <?php echo $t_select_modifier;?> name="<?php echo FILTER_PROPERTY_PRODUCT_BUILD;?>[]">
			<option value="<?php echo META_FILTER_ANY?>" <?php check_selected( $t_filter[FILTER_PROPERTY_PRODUCT_BUILD], META_FILTER_ANY );?>>[<?php echo lang_get( 'any' )?>]</option>
			<option value="<?php echo META_FILTER_NONE?>" <?php check_selected( $t_filter[FILTER_PROPERTY_PRODUCT_BUILD], META_FILTER_NONE );?>>[<?php echo lang_get( 'none' )?>]</option>
			<?php print_build_option_list( $t_filter[FILTER_PROPERTY_PRODUCT_BUILD] )?>
		</select>
		<?php
}

/**
 *  print version field
 */
function print_filter_show_version() {
	global $t_select_modifier, $t_filter;
	?><!-- Version -->
		<select <?php echo $t_select_modifier;?> name="<?php echo FILTER_PROPERTY_PRODUCT_VERSION;?>[]">
			<option value="<?php echo META_FILTER_ANY?>" <?php check_selected( $t_filter[FILTER_PROPERTY_PRODUCT_VERSION], META_FILTER_ANY );?>>[<?php echo lang_get( 'any' )?>]</option>
			<option value="<?php echo META_FILTER_NONE?>" <?php check_selected( $t_filter[FILTER_PROPERTY_PRODUCT_VERSION], META_FILTER_NONE );?>>[<?php echo lang_get( 'none' )?>]</option>
			<?php print_version_option_list( $t_filter[FILTER_PROPERTY_PRODUCT_VERSION], /* projectId */ null, /* released */ VERSION_ALL, /* leadingBlank */ false, /* withSubs */ true )?>
		</select>
		<?php
}

/**
 * print fixed in version field
 */
function print_filter_show_fixed_in_version() {
	global $t_select_modifier, $t_filter;
	?><!-- Fixed in Version -->
		<select <?php echo $t_select_modifier;?> name="<?php echo FILTER_PROPERTY_FIXED_IN_VERSION;?>[]">
			<option value="<?php echo META_FILTER_ANY?>" <?php check_selected( $t_filter[FILTER_PROPERTY_FIXED_IN_VERSION], META_FILTER_ANY );?>>[<?php echo lang_get( 'any' )?>]</option>
			<option value="<?php echo META_FILTER_NONE?>" <?php check_selected( $t_filter[FILTER_PROPERTY_FIXED_IN_VERSION], META_FILTER_NONE );?>>[<?php echo lang_get( 'none' )?>]</option>
			<?php print_version_option_list( $t_filter[FILTER_PROPERTY_FIXED_IN_VERSION], /* projectId */ null, /* released */ VERSION_ALL, /* leadingBlank */ false, /* withSubs */ true )?>
		</select>
		<?php
}

/**
 *  print target version field
 */
function print_filter_show_target_version() {
	global $t_select_modifier, $t_filter;
	?><!-- Fixed in Version -->
		<select <?php echo $t_select_modifier;?> name="<?php echo FILTER_PROPERTY_TARGET_VERSION;?>[]">
			<option value="<?php echo META_FILTER_ANY?>" <?php check_selected( $t_filter[FILTER_PROPERTY_TARGET_VERSION], META_FILTER_ANY );?>>[<?php echo lang_get( 'any' )?>]</option>
			<option value="<?php echo META_FILTER_NONE?>" <?php check_selected( $t_filter[FILTER_PROPERTY_TARGET_VERSION], META_FILTER_NONE );?>>[<?php echo lang_get( 'none' )?>]</option>
			<?php print_version_option_list( $t_filter[FILTER_PROPERTY_TARGET_VERSION], /* projectId */ null, /* released */ VERSION_ALL, /* leadingBlank */ false, /* withSubs */ true )?>
		</select>
		<?php
}

/**
 *  print priority field
 */
function print_filter_show_priority() {
	global $t_select_modifier, $t_filter;
	?><!-- Priority -->
    <select <?php echo $t_select_modifier;?> name="<?php echo FILTER_PROPERTY_PRIORITY_ID;?>[]">
			<option value="<?php echo META_FILTER_ANY?>" <?php check_selected( $t_filter[FILTER_PROPERTY_PRIORITY_ID], META_FILTER_ANY );?>>[<?php echo lang_get( 'any' )?>]</option>
			<?php print_enum_string_option_list( 'priority', $t_filter[FILTER_PROPERTY_PRIORITY_ID] )?>
    </select>
		<?php
}

/**
 *  print profile field
 */
function print_filter_show_profile() {
	global $t_select_modifier, $t_filter;
	?><!-- Profile -->
		<select <?php echo $t_select_modifier;?> name="show_profile[]">
			<option value="<?php echo META_FILTER_ANY?>" <?php check_selected( $t_filter['show_profile'], META_FILTER_ANY );?>>[<?php echo lang_get( 'any' )?>]</option>
			<?php print_profile_option_list_for_project( helper_get_current_project(), $t_filter['show_profile'] );?>
		</select>
		<?php
}

/**
 *  print issues per page field
 */
function print_filter_per_page() {
	global $t_filter;
	?><!-- Number of bugs per page -->
		<input type="text" name="<?php echo FILTER_PROPERTY_ISSUES_PER_PAGE;?>" size="3" maxlength="7" value="<?php echo $t_filter[FILTER_PROPERTY_ISSUES_PER_PAGE]?>" />
		<?php
}

/**
 *  print view state field
 */
function print_filter_view_state() {
	global $t_select_modifier, $t_filter;
	?><!-- View Status -->
		<select name="<?php echo FILTER_PROPERTY_VIEW_STATE_ID;?>">
			<?php
			echo '<option value="' . META_FILTER_ANY . '" ';
	check_selected( $t_filter[FILTER_PROPERTY_VIEW_STATE_ID], META_FILTER_ANY );
	echo '>[' . lang_get( 'any' ) . ']</option>';
	echo '<option value="' . VS_PUBLIC . '" ';
	check_selected( $t_filter[FILTER_PROPERTY_VIEW_STATE_ID], VS_PUBLIC );
	echo '>' . lang_get( 'public' ) . '</option>';
	echo '<option value="' . VS_PRIVATE . '" ';
	check_selected( $t_filter[FILTER_PROPERTY_VIEW_STATE_ID], VS_PRIVATE );
	echo '>' . lang_get( 'private' ) . '</option>';
	?>
		</select>
		<?php
}

/**
 *  print sticky issues field
 */
function print_filter_sticky_issues() {
	global $t_filter;
	?><!-- Show or hide sticky bugs -->
			<input type="checkbox" name="<?php echo FILTER_PROPERTY_SHOW_STICKY_ISSUES;?>" <?php check_checked( gpc_string_to_bool( $t_filter[FILTER_PROPERTY_SHOW_STICKY_ISSUES] ), true );?> />
		<?php
}

/**
 *  print highlight changed field
 */
function print_filter_highlight_changed() {
	global $t_filter;
	?><!-- Highlight changed bugs -->
			<input type="text" name="<?php echo FILTER_PROPERTY_HIGHLIGHT_CHANGED;?>" size="3" maxlength="7" value="<?php echo $t_filter[FILTER_PROPERTY_HIGHLIGHT_CHANGED]?>" />
		<?php
}

/**
 *  print filter by date fields with javascript
 * @todo Javascript should be removed and added dynamically
 *      via external script
 */
function print_filter_do_filter_by_date( $p_hide_checkbox = false ) {
	global $t_filter;
	?>
		<table cellspacing="0" cellpadding="0">
		<?php if( !$p_hide_checkbox ) {
		?>
		<tr><td colspan="2">
			<input type="checkbox" name="<?php echo FILTER_PROPERTY_FILTER_BY_DATE;?>" <?php
				check_checked( $t_filter[FILTER_PROPERTY_FILTER_BY_DATE], 'on' );
		if( ON == config_get( 'use_javascript' ) ) {
			print "onclick=\"SwitchDateFields();\"";
		}?> />
			<?php echo lang_get( 'use_date_filters' )?>
		</td></tr>
		<?php
	}

	# Make sure the date selection controls are enabled by default
	# if we do not use javascript
	$t_menu_disabled =
		   !config_get( 'use_javascript' )
		|| 'on' == $t_filter[FILTER_PROPERTY_FILTER_BY_DATE]
		? ''
		: ' disabled ';
	?>

		<!-- Start date -->
		<tr>
			<td>
			<?php echo lang_get( 'start_date' )?>:
			</td>
			<td nowrap="nowrap">
			<?php
			$t_chars = preg_split( '//', config_get( 'short_date_format' ), -1, PREG_SPLIT_NO_EMPTY );
	foreach( $t_chars as $t_char ) {
		if( strcasecmp( $t_char, "M" ) == 0 ) {
			echo '<select name="', FILTER_PROPERTY_START_MONTH, '"', $t_menu_disabled, '>';
			print_month_option_list( $t_filter[FILTER_PROPERTY_START_MONTH] );
			print "</select>\n";
		}
		if( strcasecmp( $t_char, "D" ) == 0 ) {
			echo '<select name="', FILTER_PROPERTY_START_DAY, '"', $t_menu_disabled, '>';
			print_day_option_list( $t_filter[FILTER_PROPERTY_START_DAY] );
			print "</select>\n";
		}
		if( strcasecmp( $t_char, "Y" ) == 0 ) {
			echo '<select name="', FILTER_PROPERTY_START_YEAR, '"', $t_menu_disabled, '>';
			print_year_option_list( $t_filter[FILTER_PROPERTY_START_YEAR] );
			print "</select>\n";
		}
	}
	?>
			</td>
		</tr>
		<!-- End date -->
		<tr>
			<td>
			<?php echo lang_get( 'end_date' )?>:
			</td>
			<td>
			<?php
			$t_chars = preg_split( '//', config_get( 'short_date_format' ), -1, PREG_SPLIT_NO_EMPTY );
	foreach( $t_chars as $t_char ) {
		if( strcasecmp( $t_char, "M" ) == 0 ) {
			echo '<select name="', FILTER_PROPERTY_END_MONTH, '"', $t_menu_disabled, '>';
			print_month_option_list( $t_filter[FILTER_PROPERTY_END_MONTH] );
			print "</select>\n";
		}
		if( strcasecmp( $t_char, "D" ) == 0 ) {
			echo '<select name="', FILTER_PROPERTY_END_DAY, '"', $t_menu_disabled, '>';
			print_day_option_list( $t_filter[FILTER_PROPERTY_END_DAY] );
			print "</select>\n";
		}
		if( strcasecmp( $t_char, "Y" ) == 0 ) {
			echo '<select name="', FILTER_PROPERTY_END_YEAR, '"', $t_menu_disabled, '>';
			print_year_option_list( $t_filter[FILTER_PROPERTY_END_YEAR] );
			print "</select>\n";
		}
	}
	?>
			</td>
		</tr>
		</table>
		<?php
}

/**
 *  print relationship fields
 */
function print_filter_relationship_type() {
	global $t_filter;
	$c_reltype_value = $t_filter[FILTER_PROPERTY_RELATIONSHIP_TYPE];
	if( !$c_reltype_value ) {
		$c_reltype_value = -1;
	}
	relationship_list_box( $c_reltype_value, "relationship_type", true );
	echo '<input type="text" name="', FILTER_PROPERTY_RELATIONSHIP_BUG, '" size="5" maxlength="10" value="', $t_filter[FILTER_PROPERTY_RELATIONSHIP_BUG], '" />';
}

/**
 *  print tag fields
 */
function print_filter_tag_string() {
	if ( !access_has_global_level( config_get( 'tag_view_threshold' ) ) ) {
		return;
	}

	global $t_filter;
	$t_tag_string = $t_filter[FILTER_PROPERTY_TAG_STRING];
	if( $t_filter[FILTER_PROPERTY_TAG_SELECT] != 0 && tag_exists( $t_filter[FILTER_PROPERTY_TAG_SELECT] ) ) {
		$t_tag_string .= ( is_blank( $t_tag_string ) ? '' : config_get( 'tag_separator' ) );
		$t_tag_string .= tag_get_field( $t_filter[FILTER_PROPERTY_TAG_SELECT], 'name' );
	}
	?>
		<input type="hidden" id="tag_separator" value="<?php echo config_get( 'tag_separator' )?>" />
		<input type="text" name="<?php echo FILTER_PROPERTY_TAG_STRING;?>" id="<?php echo FILTER_PROPERTY_TAG_STRING;?>" size="40" value="<?php echo string_attribute( $t_tag_string )?>" />
		<select <?php echo helper_get_tab_index()?> name="<?php echo FILTER_PROPERTY_TAG_SELECT;?>" id="<?php echo FILTER_PROPERTY_TAG_SELECT;?>">
			<?php print_tag_option_list();?>
		</select>
		<?php
}

/**
 *  print note reporter field
 */
function print_filter_note_user_id() {
	global $t_select_modifier, $t_filter, $f_view_type;
	?>
        <!-- BUGNOTE REPORTER -->
        <select <?php echo $t_select_modifier;?> name="<?php echo FILTER_PROPERTY_NOTE_USER_ID;?>[]">
            <option value="<?php echo META_FILTER_ANY?>" <?php check_selected( $t_filter[FILTER_PROPERTY_NOTE_USER_ID], META_FILTER_ANY );?>>[<?php echo lang_get( 'any' )?>]</option>
            <?php if( access_has_project_level( config_get( 'view_handler_threshold' ) ) ) {?>
            <option value="<?php echo META_FILTER_NONE?>" <?php check_selected( $t_filter[FILTER_PROPERTY_NOTE_USER_ID], META_FILTER_NONE );?>>[<?php echo lang_get( 'none' )?>]</option>
            <?php
                if( access_has_project_level( config_get( 'handle_bug_threshold' ) ) ) {
					echo '<option value="' . META_FILTER_MYSELF . '" ';
					check_selected( $t_filter[FILTER_PROPERTY_NOTE_USER_ID], META_FILTER_MYSELF );
					echo '>[' . lang_get( 'myself' ) . ']</option>';
				}

				print_note_option_list( $t_filter[FILTER_PROPERTY_NOTE_USER_ID] );
			}
		?>
        </select>
        <?php
}


/**
 * Print plugin filter fields as defined by MantisFilter objects.
 * @param string Field name
 * @param object Filter object
 */
function print_filter_plugin_field( $p_field_name, $p_filter_object ) {
	global $t_select_modifier, $t_filter, $f_view_type;

	$t_size = (int)$p_filter_object->size;

	switch( $p_filter_object->type ) {
		case FILTER_TYPE_STRING:
			echo '<input name="', string_attribute( $p_field_name ), '"',
				( $t_size > 0 ? " size=\"$t_size\"" : '' ), ' value="',
				string_attribute( $t_filter[ $p_field_name ] ), '"/>';
			break;

		case FILTER_TYPE_INT:
			echo '<input name="', string_attribute( $p_field_name ), '"',
				( $t_size > 0 ? " size=\"$t_size\"" : '' ), ' value="',
				(int) $t_filter[ $p_field_name ], '"/>';
			break;

		case FILTER_TYPE_BOOLEAN:
			echo '<input name="', string_attribute( $p_field_name ), '" type="checkbox"',
				( $t_size > 0 ? " size=\"$t_size\"" : '' ), check_checked( (bool) $t_filter[ $p_field_name ] ) , '"/>';
			break;

		case FILTER_TYPE_MULTI_STRING:
			echo '<select ', $t_select_modifier, ( $t_size > 0 ? " size=\"$t_size\"" : '' ), ' name="',
				string_attribute( $p_field_name ), '[]">', '<option value="', META_FILTER_ANY, '" ',
				check_selected( $t_filter[ $p_field_name ], META_FILTER_ANY ), '>[', lang_get( 'any' ), ']</option>';

			foreach( $p_filter_object->options() as $t_option_value => $t_option_name ) {
				echo '<option value="', string_attribute( $t_option_value ), '" ',
					check_selected( $t_filter[ $p_field_name ], $t_option_value ), '>',
					string_display_line( $t_option_name ), '</option>';
			}

			echo '</select>';
			break;

		case FILTER_TYPE_MULTI_INT:
			echo '<select ', $t_select_modifier, ( $t_size > 0 ? " size=\"$t_size\"" : '' ), ' name="',
				string_attribute( $p_field_name ), '[]">', '<option value="', META_FILTER_ANY, '" ',
				check_selected( $t_filter[ $p_field_name ], META_FILTER_ANY ), '>[', lang_get( 'any' ), ']</option>';

			foreach( $p_filter_object->options() as $t_option_value => $t_option_name ) {
				echo '<option value="', (int)$t_option_value, '" ',
					check_selected( $t_filter[ $p_field_name ], (int)$t_option_value ), '>',
					string_display_line( $t_option_name ), '</option>';
			}

			echo '</select>';
			break;

	}
}

/**
 *  print custom fields
 * @param int $p_field_id
 */
function print_filter_custom_field( $p_field_id ) {
	global $t_filter, $t_accessible_custom_fields_names, $t_accessible_custom_fields_types, $t_accessible_custom_fields_values, $t_accessible_custom_fields_ids, $t_select_modifier;

	$j = array_search( $p_field_id, $t_accessible_custom_fields_ids );
	if( $j === null || $j === false ) {

		# Note: Prior to PHP 4.2.0, array_search() returns NULL on failure instead of FALSE.
		?>
			<span style="color:red;weight:bold;">
				unknown custom filter (custom <?php $p_field_id;?>)
			</span>
			<?php
	} else if( isset( $t_accessible_custom_fields_names[$j] ) ) {
		if( $t_accessible_custom_fields_types[$j] == CUSTOM_FIELD_TYPE_DATE ) {
			print_filter_custom_field_date( $j, $p_field_id );
#ODB Production - Text Area
		} else if( $t_accessible_custom_fields_types[$j] == CUSTOM_FIELD_TYPE_TEXTAREA ) {
			echo '<input type="text" name="custom_field_', $p_field_id, '" size="10" value="" />';
		} else {
			echo '<select ' . $t_select_modifier . ' name="custom_field_' . $p_field_id . '[]">';
			echo '<option value="' . META_FILTER_ANY . '" ';
			check_selected( $t_filter['custom_fields'][$p_field_id], META_FILTER_ANY );
			echo '>[' . lang_get( 'any' ) . ']</option>';

			# don't show META_FILTER_NONE for enumerated types as it's not possible for them to be blank
			if( !in_array( $t_accessible_custom_fields_types[$j], array( CUSTOM_FIELD_TYPE_ENUM, CUSTOM_FIELD_TYPE_LIST, CUSTOM_FIELD_TYPE_MULTILIST ) ) ) {
				echo '<option value="' . META_FILTER_NONE . '" ';
				check_selected( $t_filter['custom_fields'][$p_field_id], META_FILTER_NONE );
				echo '>[' . lang_get( 'none' ) . ']</option>';
			}
			if( is_array( $t_accessible_custom_fields_values[$j] ) ) {
				$t_max_length = config_get( 'max_dropdown_length' );
				foreach( $t_accessible_custom_fields_values[$j] as $t_item ) {
					if(( utf8_strtolower( $t_item ) !== META_FILTER_ANY ) && ( utf8_strtolower( $t_item ) !== META_FILTER_NONE ) ) {
						echo '<option value="' . string_attribute( $t_item ) . '" ';
						if( isset( $t_filter['custom_fields'][$p_field_id] ) ) {
							check_selected( $t_filter['custom_fields'][$p_field_id], $t_item );
						}
						echo '>' . string_attribute( string_shorten( $t_item, $t_max_length ) ) . '</option>' . "\n";
					}
				}
			}
			echo '</select>';
		}
	}
}

/**
 *  print sort fields
 */
function print_filter_show_sort() {
	global $t_filter;

	# get all of the displayed fields for sort, then drop ones that
	#  are not appropriate and translate the rest
	$t_fields = helper_get_columns_to_view();
	$t_n_fields = count( $t_fields );
	$t_shown_fields[''] = '';
	for( $i = 0;$i < $t_n_fields;$i++ ) {
		if( !in_array( $t_fields[$i], array( 'selection', 'edit', 'bugnotes_count', 'attachment_count' ) ) ) {
			if( strpos( $t_fields[$i], 'custom_' ) === 0 ) {
				$t_field_name = string_display( lang_get_defaulted( utf8_substr( $t_fields[$i], utf8_strlen( 'custom_' ) ) ) );
			} else {
				$t_field_name = string_get_field_name( $t_fields[$i] );
			}
			$t_shown_fields[$t_fields[$i]] = $t_field_name;
		}
	}
	$t_shown_dirs[''] = '';
	$t_shown_dirs['ASC'] = lang_get( 'bugnote_order_asc' );
	$t_shown_dirs['DESC'] = lang_get( 'bugnote_order_desc' );

	# get default values from filter structure
	$t_sort_fields = explode( ',', $t_filter[FILTER_PROPERTY_SORT_FIELD_NAME] );
	$t_dir_fields = explode( ',', $t_filter[FILTER_PROPERTY_SORT_DIRECTION] );
	if( !isset( $t_sort_fields[1] ) ) {
		$t_sort_fields[1] = '';
		$t_dir_fields[1] = '';
	}

	# if there are fields to display, show the dropdowns
	if( count( $t_fields ) > 0 ) {
		# display a primary and secondary sort fields
		echo '<select name="', FILTER_PROPERTY_SORT_FIELD_NAME, '_0">';
		foreach( $t_shown_fields as $key => $val ) {
			echo '<option value="' . $key . '"';
			check_selected( $key, $t_sort_fields[0] );
			echo '>' . $val . '</option>';
		}
		echo '</select>';

		echo '<select name="', FILTER_PROPERTY_SORT_DIRECTION, '_0">';
		foreach( $t_shown_dirs as $key => $val ) {
			echo '<option value="' . $key . '"';
			check_selected( $key, $t_dir_fields[0] );
			echo '>' . $val . '</option>';
		}
		echo '</select>';

		echo ', ';

		# for secondary sort
		echo '<select name="', FILTER_PROPERTY_SORT_FIELD_NAME, '_1">';
		foreach( $t_shown_fields as $key => $val ) {
			echo '<option value="' . $key . '"';
			check_selected( $key, $t_sort_fields[1] );
			echo '>' . $val . '</option>';
		}
		echo '</select>';
		echo '<select name="', FILTER_PROPERTY_SORT_DIRECTION, '_1">';
		foreach( $t_shown_dirs as $key => $val ) {
			echo '<option value="' . $key . '"';
			check_selected( $key, $t_dir_fields[1] );
			echo '>' . $val . '</option>';
		}
		echo '</select>';
	} else {
		echo lang_get_defaulted( 'last_updated' ) . lang_get( 'bugnote_order_desc' );
		echo '<input type="hidden" name="', FILTER_PROPERTY_SORT_FIELD_NAME, '_1" value="last_updated" />';
		echo '<input type="hidden" name="', FILTER_PROPERTY_SORT_DIRECTION, '_1" value="DESC" />';
	}
}

/**
 *  print custom field date fields
 * @param int $p_field_num
 * @param int $p_field_id
 */
function print_filter_custom_field_date( $p_field_num, $p_field_id ) {
	global $t_filter, $t_accessible_custom_fields_names, $t_accessible_custom_fields_types, $t_accessible_custom_fields_values, $t_accessible_custom_fields_ids, $t_select_modifier;

	$t_js_toggle_func = 'toggle_custom_date_field_' . $p_field_id . '_controls';

	# Resort the values so there ordered numerically, they are sorted as strings otherwise which
	# may be wrong for dates before early 2001.
	if( is_array( $t_accessible_custom_fields_values[$p_field_num] ) ) {
		array_multisort( $t_accessible_custom_fields_values[$p_field_num], SORT_NUMERIC, SORT_ASC );
	}

	$t_sel_start_year = null;
	$t_sel_end_year = null;
	if( isset( $t_accessible_custom_fields_values[$p_field_num][0] ) ) {
		$t_sel_start_year = date( 'Y', $t_accessible_custom_fields_values[$p_field_num][0] );
	}
	$t_count = count( $t_accessible_custom_fields_values[$p_field_num] );
	if( isset( $t_accessible_custom_fields_values[$p_field_num][$t_count - 1] ) ) {
		$t_sel_end_year = date( 'Y', $t_accessible_custom_fields_values[$p_field_num][$t_count - 1] );
	}

	$t_start = date( 'U' );

	# Default to today in filters..
	$t_end = $t_start;

	if( isset( $t_filter['custom_fields'][$p_field_id][1] ) ) {
		$t_start_time = $t_filter['custom_fields'][$p_field_id][1];
	} else {
		$t_start_time = 0;
	}

	if( isset( $t_filter['custom_fields'][$p_field_id][2] ) ) {
		$t_end_time = $t_filter['custom_fields'][$p_field_id][2];
	} else {
		$t_end_time = 0;
	}

	if( OFF == config_get( 'use_javascript' ) ) {
		$t_start_disable = false;
		$t_end_disable = false;
	} else {
		$t_start_disable = true;
		$t_end_disable = true;

		# if $t_filter['custom_fields'][$p_field_id][0] is not set (ie no filter),
		# we will drop through the following switch and use the default values
		# above, so no need to check if stuff is set or not.
		switch( $t_filter['custom_fields'][$p_field_id][0] ) {
			case CUSTOM_FIELD_DATE_ANY:
			case CUSTOM_FIELD_DATE_NONE:
				break;
			case CUSTOM_FIELD_DATE_BETWEEN:
				$t_start_disable = false;
				$t_end_disable = false;
				$t_start = $t_start_time;
				$t_end = $t_end_time;
				break;
			case CUSTOM_FIELD_DATE_ONORBEFORE:
				$t_start_disable = false;
				$t_start = $t_end_time;
				break;
			case CUSTOM_FIELD_DATE_BEFORE:
				$t_start_disable = false;
				$t_start = $t_end_time;
				break;
			case CUSTOM_FIELD_DATE_ON:
				$t_start_disable = false;
				$t_start = $t_start_time;
				break;
			case CUSTOM_FIELD_DATE_AFTER:
				$t_start_disable = false;
				$t_start = $t_start_time;
				break;
			case CUSTOM_FIELD_DATE_ONORAFTER:
				$t_start_disable = false;
				$t_start = $t_start_time;
				break;
		}
	}

	echo "\n<table cellspacing=\"0\" cellpadding=\"0\"><tr><td>\n";
	echo "<select size=\"1\" name=\"custom_field_" . $p_field_id . "_control\" OnChange=\"" . $t_js_toggle_func . "();\">\n";
	echo '<option value="' . CUSTOM_FIELD_DATE_ANY . '"';
	check_selected( $t_filter['custom_fields'][$p_field_id][0], CUSTOM_FIELD_DATE_ANY );
	echo '>' . lang_get( 'any' ) . '</option>' . "\n";
	echo '<option value="' . CUSTOM_FIELD_DATE_NONE . '"';
	check_selected( $t_filter['custom_fields'][$p_field_id][0], CUSTOM_FIELD_DATE_NONE );
	echo '>' . lang_get( 'none' ) . '</option>' . "\n";
	echo '<option value="' . CUSTOM_FIELD_DATE_BETWEEN . '"';
	check_selected( $t_filter['custom_fields'][$p_field_id][0], CUSTOM_FIELD_DATE_BETWEEN );
	echo '>' . lang_get( 'between_date' ) . '</option>' . "\n";
	echo '<option value="' . CUSTOM_FIELD_DATE_ONORBEFORE . '"';
	check_selected( $t_filter['custom_fields'][$p_field_id][0], CUSTOM_FIELD_DATE_ONORBEFORE );
	echo '>' . lang_get( 'on_or_before_date' ) . '</option>' . "\n";
	echo '<option value="' . CUSTOM_FIELD_DATE_BEFORE . '"';
	check_selected( $t_filter['custom_fields'][$p_field_id][0], CUSTOM_FIELD_DATE_BEFORE );
	echo '>' . lang_get( 'before_date' ) . '</option>' . "\n";
	echo '<option value="' . CUSTOM_FIELD_DATE_ON . '"';
	check_selected( $t_filter['custom_fields'][$p_field_id][0], CUSTOM_FIELD_DATE_ON );
	echo '>' . lang_get( 'on_date' ) . '</option>' . "\n";
	echo '<option value="' . CUSTOM_FIELD_DATE_AFTER . '"';
	check_selected( $t_filter['custom_fields'][$p_field_id][0], CUSTOM_FIELD_DATE_AFTER );
	echo '>' . lang_get( 'after_date' ) . '</option>' . "\n";
	echo '<option value="' . CUSTOM_FIELD_DATE_ONORAFTER . '"';
	check_selected( $t_filter['custom_fields'][$p_field_id][0], CUSTOM_FIELD_DATE_ONORAFTER );
	echo '>' . lang_get( 'on_or_after_date' ) . '</option>' . "\n";
	echo '</select>' . "\n";

	echo "</td></tr>\n<tr><td>";

	print_date_selection_set( 'custom_field_' . $p_field_id . '_start', config_get( 'short_date_format' ), $t_start, $t_start_disable, false, $t_sel_start_year, $t_sel_end_year );
	print "</td></tr>\n<tr><td>";
	print_date_selection_set( 'custom_field_' . $p_field_id . '_end', config_get( 'short_date_format' ), $t_end, $t_end_disable, false, $t_sel_start_year, $t_sel_end_year );
	print "</td></tr>\n</table>";
}

/**
 *  print project field
 */
function print_filter_project_id() {
	global $t_select_modifier, $t_filter, $f_view_type;
	?>
		<!-- Project -->
		<select <?php echo $t_select_modifier;?> name="<?php echo FILTER_PROPERTY_PROJECT_ID;?>[]">
			<option value="<?php echo META_FILTER_CURRENT?>" <?php check_selected( $t_filter[FILTER_PROPERTY_PROJECT_ID], META_FILTER_CURRENT );?>>[<?php echo lang_get( 'current' )?>]</option>
			<?php print_project_option_list( $t_filter[FILTER_PROPERTY_PROJECT_ID] )?>
		</select>
		<?php
}

function print_filter_match_type() {
	global $t_select_modifier, $t_filter, $f_view_type;
?>
		<!-- Project -->
		<select <?php echo $t_select_modifier;?> name="<?php echo FILTER_PROPERTY_MATCH_TYPE;?>">
			<option value="<?php echo FILTER_MATCH_ALL?>" <?php check_selected( $t_filter[FILTER_PROPERTY_MATCH_TYPE], FILTER_MATCH_ALL );?>>[<?php echo lang_get( 'filter_match_all' )?>]</option>
			<option value="<?php echo FILTER_MATCH_ANY?>" <?php check_selected( $t_filter[FILTER_PROPERTY_MATCH_TYPE], FILTER_MATCH_ANY );?>>[<?php echo lang_get( 'filter_match_any' )?>]</option>
		</select>
		<?php
}

/**
 *  Prints a multi-value filter field.
 * @param  string $p_field_name
 * @param mixed $p_field_value
 */
function print_multivalue_field( $p_field_name, $p_field_value ) {
	$t_output = '';
	$t_any_found = false;

	if( count( $p_field_value ) == 0 ) {
		echo lang_get( 'any' );
	} else {
		$t_first_flag = true;

		$t_field_value = is_array( $p_field_value ) ? $p_field_value : array( $p_field_value );

		foreach( $t_field_value as $t_current ) {
			$t_current = stripslashes( $t_current );
			?>
				<input type="hidden" name="<?php echo string_attribute( $p_field_name )?>[]" value="<?php echo string_attribute( $t_current );?>" />
				<?php
				$t_this_string = '';

			if((( $t_current == META_FILTER_ANY ) && ( is_numeric( $t_current ) ) ) || ( is_blank( $t_current ) ) ) {
				$t_any_found = true;
			} else {
				$t_this_string = string_display( $t_current );
			}

			if( $t_first_flag != true ) {
				$t_output .= '<br />';
			} else {
				$t_first_flag = false;
			}

			$t_output .= $t_this_string;
		}

		if( true == $t_any_found ) {
			echo lang_get( 'any' );
		} else {
			echo $t_output;
		}
	}
}

# ==========================================================================
# CACHING
# ==========================================================================
/**
 * @internal SECURITY NOTE: cache globals are initialized here to prevent them
 *      being spoofed if register_globals is turned on.
 * 	We cache filter requests to reduce the number of SQL queries
 * @global mixed $g_cache_filter
 * @global mixed $g_cache_filter_db_filters
 */
$g_cache_filter = array();
$g_cache_filter_db_filters = array();

/**
 *  Cache a filter row if necessary and return the cached copy
 *  If the second parameter is true (default), trigger an error
 *  if the filter can't be found.  If the second parameter is
 *  false, return false if the filter can't be found.
 * @param int $p_filter_id
 * @param bool $p_trigger_errors
 * @return mixed
 */
function filter_cache_row( $p_filter_id, $p_trigger_errors = true ) {
	global $g_cache_filter;

	$c_filter_id = db_prepare_int( $p_filter_id );

	$t_filters_table = db_get_table( 'mantis_filters_table' );

	if( isset( $g_cache_filter[$c_filter_id] ) ) {
		return $g_cache_filter[$c_filter_id];
	}

	$query = 'SELECT *
				  FROM ' . $t_filters_table . '
				  WHERE id=' . db_param();
	$result = db_query_bound( $query, Array( $c_filter_id ) );

	if( 0 == db_num_rows( $result ) ) {
		if( $p_trigger_errors ) {
			error_parameters( $p_filter_id );
			trigger_error( ERROR_FILTER_NOT_FOUND, ERROR );
		} else {
			return false;
		}
	}

	$row = db_fetch_array( $result );

	$g_cache_filter[$c_filter_id] = $row;

	return $row;
}

/**
 *  Clear the filter cache (or just the given id if specified)
 * @param int $p_filter_id
 * @return bool
 */
function filter_clear_cache( $p_filter_id = null ) {
	global $g_cache_filter;

	if( null === $p_filter_id ) {
		$g_cache_filter = array();
	} else {
		$c_filter_id = db_prepare_int( $p_filter_id );
		unset( $g_cache_filter[$c_filter_id] );
	}

	return true;
}

# ==========================================================================
# FILTER DB FUNCTIONS
# ==========================================================================
/**
 *  Add a filter to the database for the current user
 * @param int $p_project_id
 * @param bool $p_is_public
 * @param string $p_name
 * @param string $p_filter_string
 * @return int
 */
function filter_db_set_for_current_user( $p_project_id, $p_is_public, $p_name, $p_filter_string ) {
	$t_user_id = auth_get_current_user_id();
	$c_project_id = db_prepare_int( $p_project_id );
	$c_is_public = db_prepare_bool( $p_is_public );

	$t_filters_table = db_get_table( 'mantis_filters_table' );

	# check that the user can save non current filters (if required)
	if(( ALL_PROJECTS <= $c_project_id ) && ( !is_blank( $p_name ) ) && ( !access_has_project_level( config_get( 'stored_query_create_threshold' ) ) ) ) {
		return -1;
	}

	# ensure that we're not making this filter public if we're not allowed
	if( !access_has_project_level( config_get( 'stored_query_create_shared_threshold' ) ) ) {
		$c_is_public = db_prepare_bool( false );
	}

	# Do I need to update or insert this value?
	$query = "SELECT id FROM $t_filters_table
					WHERE user_id=" . db_param() . "
					AND project_id=" . db_param() . "
					AND name=" . db_param();
	$result = db_query_bound( $query, Array( $t_user_id, $c_project_id, $p_name ) );

	if( db_num_rows( $result ) > 0 ) {
		$row = db_fetch_array( $result );

		$query = "UPDATE $t_filters_table
					  SET is_public=" . db_param() . ",
						filter_string=" . db_param() . "
					  WHERE id=" . db_param();
		db_query_bound( $query, Array( $c_is_public, $p_filter_string, $row['id'] ) );

		return $row['id'];
	} else {
		$query = "INSERT INTO $t_filters_table
						( user_id, project_id, is_public, name, filter_string )
					  VALUES
						( " . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ' )';
		db_query_bound( $query, Array( $t_user_id, $c_project_id, $c_is_public, $p_name, $p_filter_string ) );

		# Recall the query, we want the filter ID
		$query = "SELECT id
						FROM $t_filters_table
						WHERE user_id=" . db_param() . "
						AND project_id=" . db_param() . "
						AND name=" . db_param();
		$result = db_query_bound( $query, Array( $t_user_id, $c_project_id, $p_name ) );

		if( db_num_rows( $result ) > 0 ) {
			$row = db_fetch_array( $result );
			return $row['id'];
		}

		return -1;
	}
}

/**
 *  This function returns the filter string that is
 *  tied to the unique id parameter. If the user doesn't
 *  have permission to see this filter, the function
 *  returns null
 * @param int $p_filter_id
 * @param int $p_user_id
 * @return mixed
 */
function filter_db_get_filter( $p_filter_id, $p_user_id = null ) {
	global $g_cache_filter_db_filters;
	$t_filters_table = db_get_table( 'mantis_filters_table' );
	$c_filter_id = db_prepare_int( $p_filter_id );

	if( isset( $g_cache_filter_db_filters[$p_filter_id] ) ) {
		if( $g_cache_filter_db_filters[$p_filter_id] === false ) {
			return null;
		}
		return $g_cache_filter_db_filters[$p_filter_id];
	}

	if( null === $p_user_id ) {
		$t_user_id = auth_get_current_user_id();
	} else {
		$t_user_id = $p_user_id;
	}

	$query = 'SELECT * FROM ' . $t_filters_table . ' WHERE id=' . db_param();
	$result = db_query_bound( $query, Array( $c_filter_id ) );

	if( db_num_rows( $result ) > 0 ) {
		$row = db_fetch_array( $result );

		if( $row['user_id'] != $t_user_id ) {
			if( $row['is_public'] != true ) {
				return null;
			}
		}

		# check that the user has access to non current filters
		if(( ALL_PROJECTS <= $row['project_id'] ) && ( !is_blank( $row['name'] ) ) && ( !access_has_project_level( config_get( 'stored_query_use_threshold', null, $t_user_id, $row['project_id'] ) ) ) ) {
			return null;
		}

		$g_cache_filter_db_filters[$p_filter_id] = $row['filter_string'];
		return $row['filter_string'];
	} else {
		$g_cache_filter_db_filters[$p_filter_id] = false;
		return false;
	}
}

/**
 * @param int $p_project_id
 * @param int $p_user_id
 * @return int
 */
function filter_db_get_project_current( $p_project_id, $p_user_id = null ) {
	$t_filters_table = db_get_table( 'mantis_filters_table' );
	$c_project_id = db_prepare_int( $p_project_id );
	$c_project_id = $c_project_id * -1;

	if( null === $p_user_id ) {
		$c_user_id = auth_get_current_user_id();
	} else {
		$c_user_id = db_prepare_int( $p_user_id );
	}

	# we store current filters for each project with a special project index
	$query = "SELECT *
				  FROM $t_filters_table
				  WHERE user_id=" . db_param() . "
					AND project_id=" . db_param() . "
					AND name=" . db_param();
	$result = db_query_bound( $query, Array( $c_user_id, $c_project_id, '' ) );

	if( db_num_rows( $result ) > 0 ) {
		$row = db_fetch_array( $result );
		return $row['id'];
	}

	return null;
}

/**
 *  Query for the filter name using the filter id
 * @param int $p_filter_id
 * @return string
 */
function filter_db_get_name( $p_filter_id ) {
	$t_filters_table = db_get_table( 'mantis_filters_table' );
	$c_filter_id = db_prepare_int( $p_filter_id );

	$query = 'SELECT * FROM ' . $t_filters_table . ' WHERE id=' . db_param();
	$result = db_query_bound( $query, Array( $c_filter_id ) );

	if( db_num_rows( $result ) > 0 ) {
		$row = db_fetch_array( $result );

		if( $row['user_id'] != auth_get_current_user_id() ) {
			if( $row['is_public'] != true ) {
				return null;
			}
		}

		return $row['name'];
	}

	return null;
}

/**
 *  Check if the current user has permissions to delete the stored query
 * @param $p_filter_id
 * @return bool
 */
function filter_db_can_delete_filter( $p_filter_id ) {
	$t_filters_table = db_get_table( 'mantis_filters_table' );
	$c_filter_id = db_prepare_int( $p_filter_id );
	$t_user_id = auth_get_current_user_id();

	# Administrators can delete any filter
	if( user_is_administrator( $t_user_id ) ) {
		return true;
	}

	$query = "SELECT id
				  FROM $t_filters_table
				  WHERE id=" . db_param() . "
				  AND user_id=" . db_param() . "
				  AND project_id!=" . db_param();

	$result = db_query_bound( $query, Array( $c_filter_id, $t_user_id, -1 ) );

	if( db_num_rows( $result ) > 0 ) {
		return true;
	}

	return false;
}

/**
 *  Delete the filter specified by $p_filter_id
 * @param $p_filter_id
 * @return bool
 */
function filter_db_delete_filter( $p_filter_id ) {
	$t_filters_table = db_get_table( 'mantis_filters_table' );
	$c_filter_id = db_prepare_int( $p_filter_id );
	$t_user_id = auth_get_current_user_id();

	if( !filter_db_can_delete_filter( $c_filter_id ) ) {
		return false;
	}

	$query = 'DELETE FROM ' . $t_filters_table . ' WHERE id=' . db_param();
	$result = db_query_bound( $query, Array( $c_filter_id ) );

	if( db_affected_rows( $result ) > 0 ) {
		return true;
	}

	return false;
}

/**
 *  Delete all the unnamed filters
 */
function filter_db_delete_current_filters() {
	$t_filters_table = db_get_table( 'mantis_filters_table' );
	$t_all_id = ALL_PROJECTS;

	$query = "DELETE FROM $t_filters_table
					WHERE project_id<=" . db_param() . "
					AND name=" . db_param();
	$result = db_query_bound( $query, Array( $t_all_id, '' ) );
}

/**
 * Note: any changes made in this function should be reflected in
 * mci_filter_db_get_available_queries())
 * @param int $p_project_id
 * @param int $p_user_id
 * @return mixed
 */
function filter_db_get_available_queries( $p_project_id = null, $p_user_id = null ) {
	$t_filters_table = db_get_table( 'mantis_filters_table' );
	$t_overall_query_arr = array();

	if( null === $p_project_id ) {
		$t_project_id = helper_get_current_project();
	} else {
		$t_project_id = db_prepare_int( $p_project_id );
	}

	if( null === $p_user_id ) {
		$t_user_id = auth_get_current_user_id();
	} else {
		$t_user_id = db_prepare_int( $p_user_id );
	}

	# If the user doesn't have access rights to stored queries, just return
	if( !access_has_project_level( config_get( 'stored_query_use_threshold' ) ) ) {
		return $t_overall_query_arr;
	}

	# Get the list of available queries. By sorting such that public queries are
	# first, we can override any query that has the same name as a private query
	# with that private one
	$query = "SELECT * FROM $t_filters_table
					WHERE (project_id=" . db_param() . "
						OR project_id=0)
					AND name!=''
					AND (is_public = " . db_prepare_bool(true) . "
						OR user_id = " . db_param() . ")
					ORDER BY is_public DESC, name ASC";
	$result = db_query_bound( $query, Array( $t_project_id, $t_user_id ) );
	$query_count = db_num_rows( $result );

	for( $i = 0;$i < $query_count;$i++ ) {
		$row = db_fetch_array( $result );
		$t_overall_query_arr[$row['id']] = $row['name'];
	}

	$t_overall_query_arr = array_unique( $t_overall_query_arr );
	asort( $t_overall_query_arr );

	return $t_overall_query_arr;
}

/**
 * @param str $p_name
 * @return bool true when under max_length (64) and false when over
 */
function filter_name_valid_length( $p_name ) {
	if( utf8_strlen( $p_name ) > 64 ) {
		return false;
	} else {
		return true;
	}
}

/**
 * Create a filter for getting issues assigned to the specified project and user that
 * are not yet resolved.
 *
 * @param $p_project_id the project id or ALL_PROJECTS.
 * @param $p_user_id the user id or 0 to get unassigned issues.
 * @return a valid filter.
 */
function filter_create_assigned_to_unresolved( $p_project_id, $p_user_id ) {
	$t_filter = filter_get_default();

	if ( $p_user_id == 0 ) {
		$t_filter[FILTER_PROPERTY_HANDLER_ID] = array( '0' => META_FILTER_NONE );
	} else {
		$t_filter[FILTER_PROPERTY_HANDLER_ID] = array( '0' => $p_user_id );
	}

	$t_bug_resolved_status_threshold = config_get( 'bug_resolved_status_threshold', /* default */ null, $p_user_id, $p_project_id );
	$t_filter[FILTER_PROPERTY_HIDE_STATUS_ID] = array( '0' => $t_bug_resolved_status_threshold );

	if ( $p_project_id != ALL_PROJECTS ) {
		$t_filter[FILTER_PROPERTY_PROJECT_ID] = array( '0' => $p_project_id );
	}

	return filter_ensure_valid_filter( $t_filter );
}

/**
 * Create a filter for getting issues reported by the specified project and user.
 * @param $p_project_id the project id or ALL_PROJECTS.
 * @param $p_user_id the user id.
 * @return a valid filter.
 */
function filter_create_reported_by( $p_project_id, $p_user_id ) {
	$t_filter = filter_get_default();
	$t_filter[FILTER_PROPERTY_REPORTER_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 );
}

/**
 * Create a filter for getting issues monitored by the specified project and user.
 * @param $p_project_id the project id or ALL_PROJECTS.
 * @param $p_user_id the user id.
 * @return 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 );
}
filter_api.php (184,241 bytes)   
strings_english.txt (75,182 bytes)   
<?php
/** MantisBT - a php based bugtracking system
 *
 * Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
 * Copyright (C) 2002 - 2014  MantisBT Team - mantisbt-dev@lists.sourceforge.net
 *
 * MantisBT is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * MantisBT is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.
 */

/** English (English)
 *
 * See the qqq 'language' for message documentation incl. usage of parameters
 * To improve a translation please visit http://translatewiki.net
 *
 * @ingroup Language
 * @file
 *
 * @author Kenzaburo Ito, kenito@300baud.org
 * @author various developers
 */

# Script directionality (currently supported: ltr and rtl)
$s_directionality = 'ltr';

# Group commands menuitems
$s_actiongroup_menu_move = 'Move';
$s_actiongroup_menu_copy = 'Copy';
$s_actiongroup_menu_assign = 'Assign';
$s_actiongroup_menu_close = 'Close';
$s_actiongroup_menu_delete = 'Delete';
$s_actiongroup_menu_resolve = 'Resolve';
$s_actiongroup_menu_update_priority = 'Update Priority';
$s_actiongroup_menu_update_status = 'Update Status';
$s_actiongroup_menu_update_severity = 'Update Severity';
$s_actiongroup_menu_update_view_status = 'Update View Status';
$s_actiongroup_menu_update_category = 'Update Category';
$s_actiongroup_menu_set_sticky = 'Set/Unset Sticky';
$s_actiongroup_menu_update_field = 'Update %1$s';
$s_actiongroup_menu_update_target_version = 'Update Target Version';
$s_actiongroup_menu_update_fixed_in_version = 'Update Fixed in Version';
$s_actiongroup_menu_update_product_build = 'Update Product Build';
$s_actiongroup_menu_add_note = 'Add Note';
$s_actiongroup_menu_attach_tags = 'Attach Tags';
$s_actiongroup_bugs = 'Selected Issues';
$s_actiongroup_error_issue_is_readonly = 'Issue is readonly.';

# new strings:
$s_all_projects = 'All Projects';
$s_move_bugs = 'Move Issues';
$s_operation_successful = 'Operation successful.';
$s_date_order = 'Date Order';
$s_print_all_bug_page_link = 'Print Reports';
$s_csv_export = 'CSV Export';
$s_excel_export = 'Excel Export';
$s_login_anonymously = 'Login Anonymously';
$s_anonymous = 'Anonymous';
$s_jump_to_bugnotes = 'Jump to Notes';
$s_public_project_msg = 'This project is public. All users have access.';
$s_private_project_msg = 'This project is private. Only administrators and manually added users have access.';
$s_access_level_project = 'Project Access Level';
$s_view_submitted_bug_link = 'View Submitted Issue %1$s';
$s_assigned_projects = 'Assigned Projects';
$s_unassigned_projects = 'Unassigned Projects';
$s_print = 'Print';
$s_jump = 'Jump';
$s_copy_users = 'Copy Users';
$s_copy_categories_from = 'Copy Categories From';
$s_copy_categories_to = 'Copy Categories To';
$s_copy_versions_from = 'Copy Versions From';
$s_copy_versions_to = 'Copy Versions To';
$s_copy_users_from = 'Copy Users From';
$s_copy_users_to = 'Copy Users To';
$s_bug_history = 'Issue History';
$s_field = 'Field';
$s_old_value = 'Old Value';
$s_new_value = 'New Value';
$s_date_modified = 'Date Modified';
$s_bugnote = 'Note';
$s_change = 'Change';
$s_bugnote_view_state = 'Note View State';
$s_bug_monitor = 'Issue Monitored';
$s_bug_end_monitor = 'Issue End Monitor';
$s_announcement = 'Announcement';
$s_stays_on_top = 'Stays on Top';
$s_bugnote_link_title = 'Direct link to note';
$s_delete_bugnote_button = 'Delete Note';
$s_delete_bugnote_sure_msg = 'Are you sure you wish to delete this note?';
$s_bug_relationships = 'Relationships';
$s_empty_password_sure_msg = 'The user has an empty password. Are you sure that is what you want?';
$s_empty_password_button = 'Use Empty Password';
$s_reauthenticate_title = 'Authenticate';
$s_reauthenticate_message = 'You are visiting a secure page, and your secure session has expired. Please authenticate yourself to continue.';

$s_no_category = '(No Category)';
$s_global_categories = 'Global Categories';
$s_inherit = 'Inherit Categories';
$s_inherit_global = 'Inherit Global Categories';
$s_inherit_parent = 'Inherit Parent Categories';
$s_update_subproject_inheritance = 'Update Subproject Inheritance';

$s_duplicate_of = 'duplicate of';
$s_has_duplicate = 'has duplicate';
$s_related_to = 'related to';
$s_dependant_on = 'parent of';
$s_blocks = 'child of';

$s_new_bug = 'New Issue';
$s_bugnote_added = 'Note Added';
$s_bugnote_edited = 'Note Edited';
$s_bugnote_deleted = 'Note Deleted';
$s_summary_updated = 'Summary Updated';
$s_description_updated = 'Description Updated';
$s_additional_information_updated = 'Additional Information Updated';
$s_steps_to_reproduce_updated = 'Steps to Reproduce Updated';
$s_file_added = 'File Added';
$s_file_deleted = 'File Deleted';
$s_bug_deleted = 'Issue Deleted';

$s_make_private = 'Make Private';
$s_make_public = 'Make Public';

$s_create_new_project_link = 'Create New Project';

$s_login_link = 'Login';
$s_select_option = '(select)'; # comboboxes default to this to instruct user to explicitly select an entry.

# bug_actiongroup_page.php : mass treatment
$s_bug_actiongroup_access = 'You did not have appropriate permissions to perform that action.';
$s_bug_actiongroup_status = 'This issue cannot be changed to the requested status';
$s_bug_actiongroup_category = 'This issue cannot be changed to the requested category';
$s_bug_actiongroup_handler = 'The requested user is not allowed to handle this issue';
$s_bug_actiongroup_version = 'The requested version does not exist in this issue\'s project';
$s_close_bugs_conf_msg = 'Are you sure you wish to close these issues?';
$s_delete_bugs_conf_msg = 'Are you sure you wish to delete these issues?';
$s_move_bugs_conf_msg = 'Move issues to';
$s_copy_bugs_conf_msg = 'Copy issues to';
$s_assign_bugs_conf_msg = 'Assign issues to';
$s_resolve_bugs_conf_msg = 'Choose issues resolution';
$s_priority_bugs_conf_msg = 'Choose issues priority';
$s_status_bugs_conf_msg = 'Choose issues status';
$s_view_status_bugs_conf_msg = 'Choose issues view status';
$s_category_bugs_conf_msg = 'Choose issues category';
$s_set_sticky_bugs_conf_msg = 'Are you sure you wish to set/unset these issues sticky?';
$s_fixed_in_version_bugs_conf_msg = 'Update Fixed in Version to';
$s_target_version_bugs_conf_msg = 'Update Target Version to';
$s_close_group_bugs_button = 'Close Issues';
$s_delete_group_bugs_button = 'Delete Issues';
$s_move_group_bugs_button = 'Move Issues';
$s_copy_group_bugs_button = 'Copy Issues';
$s_assign_group_bugs_button = 'Assign Issues';
$s_resolve_group_bugs_button = 'Resolve Issues';
$s_priority_group_bugs_button = 'Update Priority';
$s_status_group_bugs_button = 'Update Status';
$s_category_group_bugs_button = 'Update Category';
$s_view_status_group_bugs_button = 'Update View Status';
$s_set_sticky_group_bugs_button = 'Set/Unset Sticky';
$s_fixed_in_version_group_bugs_button = 'Update Fixed in Version';
$s_target_version_group_bugs_button = 'Update Target Version';
$s_update_severity_title = 'Update Severity';
$s_update_severity_msg = 'Choose issue severity';
$s_update_severity_button = 'Update Severity';

# print_all_bug_page.php : display selected issues
$s_hide_button = 'Display selected only';

# print_all_bug_options.php : printing preferences
$s_printing_preferences_title = 'Choose fields to print';
$s_printing_options_link = 'Printing Options';

# word and excel export
$s_bugnote_title = 'Note handler';
$s_bugnote_date = 'Date of note';
$s_bugnote_description = 'Note description';

$s_error_no_proceed = 'Please use the "Back" button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section.';

# ERROR strings
$MANTIS_ERROR[ERROR_GENERIC] = 'An error occurred during this action. You may wish to report this error to your local administrator.';
$MANTIS_ERROR[ERROR_SQL] = 'SQL error detected.';
$MANTIS_ERROR[ERROR_REPORT] = 'There was an error in your report.';
$MANTIS_ERROR[ERROR_NO_FILE_SPECIFIED] = 'No file specified.';
$MANTIS_ERROR[ERROR_FILE_DISALLOWED] = 'The file type is disallowed.';
$MANTIS_ERROR[ERROR_NO_DIRECTORY] = 'The directory does not exist. Please check the project settings.';
$MANTIS_ERROR[ERROR_DUPLICATE_PROJECT] = 'A project with that name already exists.';
$MANTIS_ERROR[ERROR_EMPTY_FIELD] = 'A necessary field "%1$s" was empty. Please recheck your inputs.';
$MANTIS_ERROR[ERROR_PROTECTED_ACCOUNT] = 'This account is protected. You are not allowed to access this until the account protection is lifted.';
$MANTIS_ERROR[ERROR_ACCESS_DENIED] = 'Access Denied.';
$MANTIS_ERROR[ERROR_UPLOAD_FAILURE] = 'File upload failed. File is not readable by MantisBT. Please check the project settings.';
$MANTIS_ERROR[ERROR_FILE_TOO_BIG] = 'File upload failed. This is likely because the filesize was larger than is currently allowed by this PHP installation.';
$MANTIS_ERROR[ERROR_GPC_VAR_NOT_FOUND] = 'A required parameter to this page (%1$s) was not found.';
$MANTIS_ERROR[ERROR_USER_NAME_NOT_UNIQUE] = 'That username is already being used. Please go back and select another one.';
$MANTIS_ERROR[ERROR_CONFIG_OPT_NOT_FOUND] = 'Configuration option "%1$s" not found.';
$MANTIS_ERROR[ERROR_CONFIG_OPT_CANT_BE_SET_IN_DB] = 'Configuration option "%1$s" can not be set in the database. It must be set in config_inc.php.';
$MANTIS_ERROR[ERROR_LANG_STRING_NOT_FOUND] = 'String "%1$s" not found.';
$MANTIS_ERROR[ERROR_BUGNOTE_NOT_FOUND] = 'Note not found.';
$MANTIS_ERROR[ERROR_PROJECT_NOT_FOUND] = 'Project "%1$d" not found.';
$MANTIS_ERROR[ERROR_DB_FIELD_NOT_FOUND] = 'Database field "%1$s" not found.';
$MANTIS_ERROR[ERROR_FTP_CONNECT_ERROR] = 'Unable to connect to FTP server.';
$MANTIS_ERROR[ERROR_HANDLER_ACCESS_TOO_LOW] = 'Issue handler does not have sufficient access rights to handle issue at this status.';
$MANTIS_ERROR[ERROR_PROJECT_NAME_NOT_UNIQUE] = 'A project with that name already exists. Please go back and enter a different name.';
$MANTIS_ERROR[ERROR_PROJECT_NAME_INVALID] = 'Invalid project name specified. Project names cannot be blank.';
$MANTIS_ERROR[ERROR_USER_BY_NAME_NOT_FOUND] = 'User with name "%1$s" not found.';
$MANTIS_ERROR[ERROR_USER_BY_ID_NOT_FOUND] = 'User with id "%1$d" not found.';
$MANTIS_ERROR[ERROR_AUTH_INVALID_COOKIE] = 'The login information stored by your browser is invalid. Perhaps your account was deleted?';
$MANTIS_ERROR[ERROR_USER_PREFS_NOT_FOUND] = 'Preferences could not be found for this user.';
$MANTIS_ERROR[ERROR_NEWS_NOT_FOUND] = 'News item not found.';
$MANTIS_ERROR[ERROR_USER_CREATE_PASSWORD_MISMATCH] = 'Password does not match verification.';
$MANTIS_ERROR[ERROR_GPC_ARRAY_EXPECTED] = 'An array was expected but a string was received for %1$s.';
$MANTIS_ERROR[ERROR_GPC_ARRAY_UNEXPECTED] = 'A string was expected but an array was received for %1$s.';
$MANTIS_ERROR[ERROR_GPC_NOT_NUMBER] = 'A number was expected for %1$s.';
$MANTIS_ERROR[ERROR_BUG_NOT_FOUND] = 'Issue %1$d not found.';
$MANTIS_ERROR[ERROR_FILTER_NOT_FOUND] = 'Filter %1$s not found.';
$MANTIS_ERROR[ERROR_FILTER_TOO_OLD] = 'The filter you are trying to use is too old to be upgraded. Please re-create it.';
$MANTIS_ERROR[ERROR_EMAIL_INVALID] = 'Invalid e-mail address.';
$MANTIS_ERROR[ERROR_EMAIL_DISPOSABLE] = 'It is not allowed to use disposable e-mail addresses.';
$MANTIS_ERROR[ERROR_USER_PROFILE_NOT_FOUND] = 'Profile not found.';
$MANTIS_ERROR[ERROR_FILE_NOT_ALLOWED] = 'File type not allowed for uploads.';
$MANTIS_ERROR[ERROR_FILE_DUPLICATE] = 'This is a duplicate file. Please delete the file first.';
$MANTIS_ERROR[ERROR_FILE_INVALID_UPLOAD_PATH] = 'Invalid upload path. Directory either does not exist or not writable to webserver.';
$MANTIS_ERROR[ERROR_FILE_NO_UPLOAD_FAILURE] = 'No file was uploaded. Please go back and Choose a file before pressing Upload.';
$MANTIS_ERROR[ERROR_FILE_MOVE_FAILED] = 'Uploaded file could not be moved to the file storage directory. Directory either does not exist or not writable to webserver.';
$MANTIS_ERROR[ERROR_BUG_DUPLICATE_SELF] = 'You cannot set an issue as a duplicate of itself.';
$MANTIS_ERROR[ERROR_BUG_REVISION_NOT_FOUND] = 'Issue revision not found.';
$MANTIS_ERROR[ERROR_CUSTOM_FIELD_NOT_FOUND] = 'Custom field not found.';
$MANTIS_ERROR[ERROR_CUSTOM_FIELD_NAME_NOT_UNIQUE] = 'This is a duplicate name.';
$MANTIS_ERROR[ERROR_CUSTOM_FIELD_IN_USE] = 'At least one project still uses this field.';
$MANTIS_ERROR[ERROR_CUSTOM_FIELD_INVALID_VALUE] = 'Invalid value for field "%1$s".';
$MANTIS_ERROR[ERROR_CUSTOM_FIELD_INVALID_DEFINITION] = 'Invalid custom field definition.';
$MANTIS_ERROR[ERROR_CUSTOM_FIELD_INVALID_PROPERTY] = 'Invalid custom field property (%1$s).';
$MANTIS_ERROR[ERROR_LDAP_AUTH_FAILED] = 'LDAP Authentication Failed.';
$MANTIS_ERROR[ERROR_LDAP_SERVER_CONNECT_FAILED] = 'LDAP Server Connection Failed.';
$MANTIS_ERROR[ERROR_LDAP_UPDATE_FAILED] = 'LDAP Record Update has failed.';
$MANTIS_ERROR[ERROR_LDAP_USER_NOT_FOUND] = 'LDAP User Record Not Found.';
$MANTIS_ERROR[ERROR_LDAP_EXTENSION_NOT_LOADED] = 'LDAP Extension Not Loaded.';
$MANTIS_ERROR[ERROR_DB_CONNECT_FAILED] = 'Database connection failed. Error received from database was #%1$d: %2$s.';
$MANTIS_ERROR[ERROR_DB_QUERY_FAILED] = 'Database query failed. Error received from database was #%1$d: %2$s for the query: %3$s.';
$MANTIS_ERROR[ERROR_DB_SELECT_FAILED] = 'Database selection failed. Error received from database was #%1$d: %2$s.';
$MANTIS_ERROR[ERROR_CATEGORY_DUPLICATE] = 'A category with that name already exists.';
$MANTIS_ERROR[ERROR_CATEGORY_NO_ACTION] = 'No copy action was specified.';
$MANTIS_ERROR[ERROR_CATEGORY_NOT_FOUND] = 'Category not found.';
$MANTIS_ERROR[ERROR_CATEGORY_NOT_FOUND_FOR_PROJECT] = 'Category "%1$s" not found for project "%2$s".';
$MANTIS_ERROR[ERROR_CATEGORY_CANNOT_DELETE_DEFAULT] = 'This Category cannot be deleted, because it is defined as "Default Category For Moves".';
$MANTIS_ERROR[ERROR_VERSION_DUPLICATE] = 'A version with that name already exists.';
$MANTIS_ERROR[ERROR_VERSION_NOT_FOUND] = 'Version "%1$s" not found.';
$MANTIS_ERROR[ERROR_USER_NAME_INVALID] = 'The username is invalid. Usernames may only contain Latin letters, numbers, spaces, hyphens, dots, plus signs and underscores.';
$MANTIS_ERROR[ERROR_USER_REAL_NAME_INVALID] = 'The user real name is invalid.';
$MANTIS_ERROR[ERROR_USER_DOES_NOT_HAVE_REQ_ACCESS] = 'User does not have required access level.';
$MANTIS_ERROR[ERROR_USER_REAL_MATCH_USER] = 'The "Real Name" chosen matches another user\'s login name. Please choose another.';
$MANTIS_ERROR[ERROR_SPONSORSHIP_NOT_ENABLED] = 'Sponsorship support not enabled.';
$MANTIS_ERROR[ERROR_SPONSORSHIP_NOT_FOUND] = 'Sponsorship %1$d not found.';
$MANTIS_ERROR[ERROR_SPONSORSHIP_AMOUNT_TOO_LOW] = 'Sponsorship (%1$s) is below minimum amount (%2$s).';
$MANTIS_ERROR[ERROR_SPONSORSHIP_HANDLER_ACCESS_LEVEL_TOO_LOW] = 'Handler does not have the required access level to handle sponsored issues.';
$MANTIS_ERROR[ERROR_SPONSORSHIP_ASSIGNER_ACCESS_LEVEL_TOO_LOW] = 'Access Denied: Assigning sponsored issues requires higher access level.';
$MANTIS_ERROR[ERROR_SPONSORSHIP_SPONSOR_NO_EMAIL] = 'Sponsor has not provided an e-mail address. Please update your profile.';
$MANTIS_ERROR[ERROR_CONFIG_OPT_INVALID] = 'Configuration option "%1$s" has invalid value "%2$s".';
$MANTIS_ERROR[ERROR_BUG_READ_ONLY_ACTION_DENIED] = 'The action cannot be performed because issue "%1$d" is read-only.';
$MANTIS_ERROR[ERROR_RELATIONSHIP_ALREADY_EXISTS] = 'There is already a relationship between these two issues.';
$MANTIS_ERROR[ERROR_RELATIONSHIP_NOT_FOUND] = 'Relationship not found.';
$MANTIS_ERROR[ERROR_RELATIONSHIP_ACCESS_LEVEL_TO_DEST_BUG_TOO_LOW] = 'Access denied: The issue %1$d requires higher access level.';
$MANTIS_ERROR[ERROR_RELATIONSHIP_SAME_BUG] = 'An issue cannot be related to itself.';
$MANTIS_ERROR[ERROR_SIGNUP_NOT_MATCHING_CAPTCHA] = 'Confirmation hash does not match. Please retry.';
$MANTIS_ERROR[ERROR_LOST_PASSWORD_NOT_ENABLED] = 'The "lost your password" feature is not available.';
$MANTIS_ERROR[ERROR_LOST_PASSWORD_NO_EMAIL_SPECIFIED] = 'You must provide an e-mail address in order to reset the password.';
$MANTIS_ERROR[ERROR_LOST_PASSWORD_NOT_MATCHING_DATA] = 'The provided information does not match any registered account!';
$MANTIS_ERROR[ERROR_LOST_PASSWORD_CONFIRM_HASH_INVALID] = 'The confirmation URL is invalid or has already been used. Please signup again.';
$MANTIS_ERROR[ERROR_LOST_PASSWORD_MAX_IN_PROGRESS_ATTEMPTS_REACHED] = 'Maximum number of in-progress requests reached. Please contact the system administrator.';
$MANTIS_ERROR[ERROR_PROJECT_RECURSIVE_HIERARCHY] = 'That operation would create a loop in the subproject hierarchy.';
$MANTIS_ERROR[ERROR_USER_CHANGE_LAST_ADMIN] = 'You cannot remove or demote the last administrator account. To perform the action you requested, you first need to create another administrator account.';
$MANTIS_ERROR[ERROR_PAGE_REDIRECTION] = 'Page redirection error, ensure that there are no spaces outside the PHP block (&lt;?php ?&gt;) in config_inc.php or custom_*.php files.';
$MANTIS_ERROR[ERROR_TWITTER_NO_CURL_EXT] = 'Twitter integration requires PHP cURL extension which is not installed.';
$MANTIS_ERROR[ERROR_TAG_NOT_FOUND] = 'Could not find a tag with that name.';
$MANTIS_ERROR[ERROR_TAG_DUPLICATE] = 'A tag already exists with that name.';
$MANTIS_ERROR[ERROR_TAG_NAME_INVALID] = 'That tag name is invalid.';
$MANTIS_ERROR[ERROR_TAG_NOT_ATTACHED] = 'That tag is not attached to that issue.';
$MANTIS_ERROR[ERROR_TAG_ALREADY_ATTACHED] = 'That tag already attached to that issue.';
$MANTIS_ERROR[ERROR_TOKEN_NOT_FOUND] = 'Token could not be found.';
$MANTIS_ERROR[ERROR_EVENT_UNDECLARED] = 'Event "%1$s" has not yet been declared.';
$MANTIS_ERROR[ERROR_PLUGIN_NOT_REGISTERED] = 'Plugin is not registered with MantisBT.';
$MANTIS_ERROR[ERROR_PLUGIN_ALREADY_INSTALLED] = 'Plugin is already installed.';
$MANTIS_ERROR[ERROR_PLUGIN_PAGE_NOT_FOUND] = 'Plugin page not found.';
$MANTIS_ERROR[ERROR_PLUGIN_INSTALL_FAILED] = 'Plugin installation failed: %1$s.';
$MANTIS_ERROR[ERROR_PLUGIN_UPGRADE_FAILED] = 'Upgrading the plugin schema failed in block #%1$s.';
$MANTIS_ERROR[ERROR_PLUGIN_UPGRADE_NEEDED] = 'The "%1$s" plugin needs to be upgraded before you can access this page.';
$MANTIS_ERROR[ERROR_PLUGIN_GENERIC] = 'There was an unknown error "%1$s" during execution of the "%2$s" plugin.';
$MANTIS_ERROR[ERROR_COLUMNS_DUPLICATE] = 'Field "%1$s" contains duplicate column "%2$s".';
$MANTIS_ERROR[ERROR_COLUMNS_INVALID] = 'Field "%1$s" contains invalid field "%2$s".';
$MANTIS_ERROR[ERROR_SESSION_HANDLER_INVALID] = 'Invalid session handler.';
$MANTIS_ERROR[ERROR_SESSION_VAR_NOT_FOUND] = 'Session variable "%1$s" not found.';
$MANTIS_ERROR[ERROR_SESSION_NOT_VALID] = 'Your session has become invalidated.';
$MANTIS_ERROR[ERROR_FORM_TOKEN_INVALID] = 'Invalid form security token. This could be caused by a session timeout, or accidentally submitting the form twice.';
$MANTIS_ERROR[ERROR_INVALID_REQUEST_METHOD] = 'This page cannot be accessed using this method.';
$MANTIS_ERROR[ERROR_INVALID_SORT_FIELD] = 'Invalid sort field.';
$MANTIS_ERROR[ERROR_INVALID_DATE_FORMAT] = 'Invalid date format.';
$MANTIS_ERROR[ERROR_UPDATING_TIMEZONE] = 'Unable to update timezone.';

$s_login_error = 'Your account may be disabled or blocked or the username/password you entered is incorrect.';
$s_login_cookies_disabled = 'Your browser either does not know how to handle cookies, or refuses to handle them.';

# General Strings
$s_go_back = 'Go Back';
$s_proceed = 'Proceed';

$s_switch = 'Switch';
$s_logged_in_as = 'Logged in as';

$s_prefix_for_deleted_users = 'user';

$s_administrator = 'administrator';
$s_myself = 'Myself';
$s_default_access_level = 'Default access level';

$s_issue_status_percentage = 'Issue Status Percentage';

# Enum Strings
$s_access_levels_enum_string = '10:viewer,25:reporter,40:updater,55:developer,70:manager,90:administrator';
$s_project_status_enum_string = '10:development,30:release,50:stable,70:obsolete';
$s_project_view_state_enum_string = '10:public,50:private';
$s_view_state_enum_string = '10:public,50:private';

$s_priority_enum_string = '10:none,20:low,30:normal,40:high,50:urgent,60:immediate';
$s_severity_enum_string = '10:feature,20:trivial,30:text,40:tweak,50:minor,60:major,70:crash,80:block';
$s_reproducibility_enum_string = '10:always,30:sometimes,50:random,70:have not tried,90:unable to reproduce,100:N/A';
$s_status_enum_string = '10:new,20:feedback,30:acknowledged,40:confirmed,50:assigned,80:resolved,90:closed';
$s_resolution_enum_string = '10:open,20:fixed,30:reopened,40:unable to reproduce,50:not fixable,60:duplicate,70:no change required,80:suspended,90:won\'t fix';
$s_projection_enum_string = '10:none,30:tweak,50:minor fix,70:major rework,90:redesign';
$s_eta_enum_string = '10:none,20:< 1 day,30:2-3 days,40:< 1 week,50:< 1 month,60:> 1 month';
$s_sponsorship_enum_string = '0:Unpaid,1:Requested,2:Paid';

# E-mail Strings
$s_new_account_subject = 'Account registration';
$s_new_account_greeting = 'Thank you for registering. You have an account with username "%1$s". In order to complete your registration, visit the following URL (make sure it is entered as the single line) and set your own access password:';
$s_new_account_greeting_admincreated = 'The user %1$s has created an account for you with username "%2$s". In order to complete your registration, visit the following URL (make sure it is entered as the single line) and set your own access password:';
$s_new_account_username = 'Username:';
$s_new_account_message = 'If you did not request any registration, ignore this message and nothing will happen.';
$s_new_account_do_not_reply = 'Do not reply to this message';
$s_new_account_email = 'E-mail:';
$s_new_account_IP = 'Remote IP address:';
$s_new_account_signup_msg = 'The following account has been created:';

$s_reset_request_msg = 'Someone (presumably you) requested a password change through e-mail verification. If this was not you, ignore this message and nothing will happen.

If you requested this verification, visit the following URL to change your password:';
$s_reset_request_in_progress_msg = 'If you supplied the correct username and e-mail address for your account, we will now have sent a confirmation message to that e-mail address. Once the message has been received, follow the instructions provided to change the password on your account.';

$s_email_notification_title_for_status_bug_new = 'The following issue is now in status NEW (again)';
$s_email_notification_title_for_status_bug_feedback = 'The following issue requires your FEEDBACK.';
$s_email_notification_title_for_status_bug_acknowledged = 'The following issue has been ACKNOWLEDGED.';
$s_email_notification_title_for_status_bug_confirmed = 'The following issue has been CONFIRMED.';
$s_email_notification_title_for_status_bug_assigned = 'The following issue has been ASSIGNED.';
$s_email_notification_title_for_status_bug_resolved = 'The following issue has been RESOLVED.';
$s_email_notification_title_for_status_bug_closed = 'The following issue has been CLOSED';

$s_email_notification_title_for_action_bug_submitted = 'The following issue has been SUBMITTED.';
$s_email_notification_title_for_action_bug_assigned = 'The following issue has been ASSIGNED.';
$s_email_notification_title_for_action_bug_reopened = 'The following issue has been REOPENED.';
$s_email_notification_title_for_action_bug_deleted = 'The following issue has been DELETED.';
$s_email_notification_title_for_action_bug_updated = 'The following issue has been UPDATED.';
$s_email_notification_title_for_action_sponsorship_added = 'The following issue has been SPONSORED.';
$s_email_notification_title_for_action_sponsorship_updated = 'A sponsorship of the following issue was modified.';
$s_email_notification_title_for_action_sponsorship_deleted = 'A sponsorship of the following issue was withdrawn.';

$s_email_notification_title_for_action_bugnote_submitted = 'A NOTE has been added to this issue.';
$s_email_notification_title_for_action_duplicate_of_relationship_added = 'The following issue has been set as DUPLICATE OF issue %1$s.';
$s_email_notification_title_for_action_has_duplicate_relationship_added = 'The issue %1$s has been set as DUPLICATE OF the following issue.';
$s_email_notification_title_for_action_related_to_relationship_added = 'The following issue has been set as RELATED TO issue %1$s.';
$s_email_notification_title_for_action_dependant_on_relationship_added = 'The following issue has been set PARENT OF issue %1$s.';
$s_email_notification_title_for_action_blocks_relationship_added = 'The following issue has been set CHILD OF issue %1$s.';
$s_email_notification_title_for_action_duplicate_of_relationship_deleted = 'The following issue has been UNset as DUPLICATE OF issue %1$s.';
$s_email_notification_title_for_action_has_duplicate_relationship_deleted = 'The issue %1$s has been removed as a DUPLICATE OF the following issue.';
$s_email_notification_title_for_action_related_to_relationship_deleted = 'The following issue has been marked as UNRELATED TO issue %1$s.';
$s_email_notification_title_for_action_dependant_on_relationship_deleted = 'The following issue has been removed as the PARENT OF issue %1$s.';
$s_email_notification_title_for_action_blocks_relationship_deleted = 'The following issue has been removed as the CHILD OF issue %1$s.';
$s_email_notification_title_for_action_relationship_child_resolved = 'The RELATED issue %1$s has been RESOLVED.';
$s_email_notification_title_for_action_relationship_child_closed = 'The RELATED issue %1$s has been CLOSED.';
$s_email_notification_title_for_action_monitor = 'Issue %1$s is now monitored by user %2$s.';

$s_email_reporter = 'Reported By';
$s_email_handler = 'Assigned To';
$s_email_project = 'Project';
$s_email_bug = 'Issue ID';
$s_email_category = 'Category';
$s_email_reproducibility = 'Reproducibility';
$s_email_severity = 'Severity';
$s_email_priority = 'Priority';
$s_email_status = 'Status';
$s_email_resolution = 'Resolution';
$s_email_duplicate = 'Duplicate';
$s_email_fixed_in_version = 'Fixed in Version';
$s_email_target_version = 'Target Version';
$s_email_date_submitted = 'Date Submitted';
$s_email_last_modified = 'Last Modified';
$s_email_summary = 'Summary';
$s_email_description = 'Description';
$s_email_additional_information = 'Additional Information';
$s_email_steps_to_reproduce = 'Steps to Reproduce';

# account_delete.php
$s_account_protected_msg = 'Account protected. Cannot change settings...';
$s_account_removed_msg = 'Your account has been removed...';

# account_delete_page.php
$s_confirm_delete_msg = 'Are you sure you wish to delete your account?';
$s_delete_account_button = 'Delete Account';

# account_page.php
$s_manage_profiles_link = 'Profiles';
$s_change_preferences_link = 'Preferences';
$s_edit_account_title = 'Edit Account';
$s_username = 'Username';
$s_realname = 'Real Name';
$s_email = 'E-mail';
$s_password = 'Password';
$s_no_password_change = 'The password is controlled by another system, hence cannot be edited here.';
$s_confirm_password = 'Confirm Password';
$s_access_level = 'Access Level';
$s_update_user_button = 'Update User';
$s_verify_warning = 'Your account information has been verified. The account confirmation message you have received is now invalid.';
$s_verify_change_password = 'You must set a password here to allow you to log in again.';

# account_prefs_page.php
$s_default_account_preferences_title = 'Account Preferences';
$s_default_project = 'Default Project';
$s_refresh_delay = 'Refresh Delay';
$s_minutes = 'minutes';
$s_redirect_delay = 'Redirect Delay';
$s_seconds = 'seconds';
$s_with_minimum_severity = 'With Minimum Severity of';
$s_bugnote_order = 'Notes Sort Order';
$s_bugnote_order_asc = 'Ascending';
$s_bugnote_order_desc = 'Descending';
$s_email_on_new = 'E-mail on New';
$s_email_on_assigned = 'E-mail on Change of Handler';
$s_email_on_feedback = 'E-mail on Feedback';
$s_email_on_resolved = 'E-mail on Resolved';
$s_email_on_closed = 'E-mail on Closed';
$s_email_on_reopened = 'E-mail on Reopened';
$s_email_on_bugnote_added = 'E-mail on Note Added';
$s_email_on_status_change = 'E-mail on Status Change';
$s_email_on_priority_change = 'E-mail on Priority Change';
$s_email_bugnote_limit = 'E-mail Notes Limit';
$s_language = 'Language';
$s_update_prefs_button = 'Update Prefs';
$s_reset_prefs_button = 'Reset Prefs';
$s_timezone = 'Time Zone';

# account_prefs_reset.php
$s_prefs_reset_msg = 'Preferences have been reset...';

# account_prefs_update.php
$s_prefs_updated_msg = 'Preferences have been updated...';

# account_profile_add.php
$s_profile_added_msg = 'Profile added...';

# account_profile_delete.php
$s_profile_deleted_msg = 'Deleted profile...';

# account_profile_edit_page.php
$s_edit_profile_title = 'Edit Profile';
$s_platform = 'Platform';
$s_operating_system = 'Operating System';
$s_additional_description = 'Additional Description';
$s_update_profile_button = 'Update Profile';

# account_profile_make_default.php
$s_profile_defaulted_msg = 'Default profile updated...';

# account_profile_manage_page.php
$s_add_profile_title = 'Add Profile';
$s_add_profile_button = 'Add Profile';
$s_edit_or_delete_profiles_title = 'Edit or Delete Profiles';
$s_edit_profile = 'Edit Profile';
$s_make_default = 'Make Default';
$s_delete_profile = 'Delete Profile';
$s_select_profile = 'Select Profile';
$s_submit_button = 'Submit';

# account_profile_update.php
$s_profile_updated_msg = 'Profile updated...';

# account_sponsor_page.php
$s_my_sponsorship = 'My Sponsorships';
$s_update_sponsorship_button = 'Change Payment Status';
$s_no_sponsored = 'No sponsored issues Assigned To yourself were found.';
$s_own_sponsored = 'Issues You have Sponsored:';
$s_issues_handled = 'Sponsored Issues You Have Been Assigned To:';
$s_no_own_sponsored = 'You have not sponsored any issues.';
$s_sponsor = 'Sponsor'; # like in 'The sponsor of...'
$s_sponsor_verb = 'Sponsor'; # like in 'Sponsor it!'
$s_amount = 'Amount';
$s_total_owing = 'Total Owing';
$s_total_paid = 'Total Paid';
$s_sponsor_hide = 'Hide Resolved and Paid';
$s_sponsor_show = 'Show All';

# account_sponsor_update.php
$s_payment_updated = 'Payment information updated.';

# account_update.php
$s_account_updated_msg = 'Your account has been successfully updated...';
$s_email_updated = 'E-mail address successfully updated';
$s_realname_duplicated = 'Real name is used by another user';
$s_realname_updated = 'Real name successfully updated';
$s_password_updated = 'Password successfully updated';

# adm_permission_report.php

# bug_action_group_page
$s_multiple_projects = 'The issues you have selected are from different projects. The parameters below reflect the settings for all projects. If this is incorrect, please retry your change with a smaller number of issues selected.';

# bug_assign.php
$s_bug_assign_msg = 'Issue has been successfully assigned...';

# bug_change_status_page.php
$s_new_bug_title = 'New Issue';
$s_feedback_bug_title = 'Request Feedback on Issue';
$s_acknowledged_bug_title = 'Acknowledge Issue';
$s_confirmed_bug_title = 'Confirm Issue';
$s_assigned_bug_title = 'Assign Issue';
$s_new_bug_button = 'New Issue';
$s_feedback_bug_button = 'Request Feedback';
$s_acknowledged_bug_button = 'Acknowledge Issue';
$s_confirmed_bug_button = 'Confirm Issue';
$s_assigned_bug_button = 'Assign Issue';

# bug_close.php
$s_bug_close_msg = 'Issue has been closed...';
$s_close_immediately = 'Close immediately:';

# bug_close_page.php
$s_closed_bug_title = 'Close Issue';

# bug_delete.php
$s_bug_deleted_msg = 'Issue has been deleted...';

# bug_delete_page.php
$s_delete_bug_sure_msg = 'Are you sure you wish to delete this issue?';
$s_delete_bug_button = 'Delete';

# bug_monitor_add.php
$s_monitor_bug_button = 'Monitor';

# bug_monitor_delete.php
$s_unmonitor_bug_button = 'End Monitoring';

# bug_file_add.php
$s_file_upload_msg = 'File upload successful.';

# bug_file_upload_inc.php
$s_upload_file = 'Upload File';
$s_upload_files = 'Upload Files';
$s_select_file = 'Select File';
$s_select_files = 'Select Files';
$s_upload_file_button = 'Upload File';
$s_upload_files_button = 'Upload Files';
$s_max_file_size = 'Maximum size';

# bug_reopen.php
$s_bug_reopened_msg = 'Issue has been reopened...';
$s_reopen_add_bugnote_title = 'Add Note Reason For Reopening Issue';
$s_bugnote_add_reopen_button = 'Add Note and Reopen Issue';

# bug_resolve_page.php
$s_resolved_bug_title = 'Resolve Issue';
$s_resolved_bug_button = 'Resolve Issue';

# bug_resolve_page2.php
$s_bug_resolved_msg = 'Issue has been resolved. Enter note below...';
$s_resolve_add_bugnote_title = 'Add Note Reason For Resolving Issue';
$s_bugnote_add_resolve_button = 'Add Note';

# bug_reminder_page.php
$s_from = 'From';
$s_to = 'To';
$s_sent_you_this_reminder_about = 'sent you this reminder about';
$s_bug_reminder = 'Send a reminder';
$s_reminder_sent_to = 'Reminder sent to';
$s_reminder_sent_none = 'No reminders could be sent';
$s_reminder_list_truncated = 'recipients list truncated';
$s_bug_send_button = 'Send';
$s_reminder = 'Reminder';
$s_reminder_explain = 'This note will be sent to the recipients listed requesting feedback on this issue.';
$s_reminder_monitor = 'These recipients will also begin monitoring the issue. They can unsubscribe using the Unmonitor button.';
$s_reminder_store = 'This note will be stored with the issue.';

# bug_set_sponsorship.php
$s_confirm_sponsorship = 'Please confirm you want to sponsor issue %1$d for %2$s.';

# bug_stick.php
$s_stick_bug_button = 'Stick';
$s_unstick_bug_button = 'Unstick';

# bug_update.php
$s_bug_updated_msg = 'Issue has been successfully updated...';

# bug_update_advanced_page.php
$s_back_to_bug_link = 'Back To Issue';
$s_update_simple_link = 'Update Simple';
$s_updating_bug_advanced_title = 'Updating Issue Information';
$s_id = 'ID';
$s_category = 'Category';
$s_severity = 'Severity';
$s_reproducibility = 'Reproducibility';
$s_date_submitted = 'Date Submitted';
$s_last_update = 'Last Update';
$s_reporter = 'Reporter';
$s_assigned_to = 'Assigned To';
$s_priority = 'Priority';
$s_resolution = 'Resolution';
$s_status = 'Status';
$s_duplicate_id = 'Duplicate ID';
$s_os = 'OS';
$s_projection = 'Projection';
$s_os_version = 'OS Version';
$s_eta = 'ETA';
$s_product_version = 'Product Version';
$s_build = 'Build';
$s_fixed_in_version = 'Fixed in Version';
$s_target_version = 'Target Version';
$s_votes = 'Votes';
$s_summary = 'Summary';
$s_description = 'Description';
$s_steps_to_reproduce = 'Steps To Reproduce';
$s_update_information_button = 'Update Information';
$s_sticky_issue = 'Sticky Issue';
$s_profile = 'Profile';

# bug_update_page.php
$s_updating_bug_simple_title = 'Updating Issue Information';

# bug_view*
$s_view_revisions = 'View Revisions';
$s_revision = 'Revision';
$s_revision_by = '%1$s by %2$s';
$s_revision_drop = 'Drop';
$s_bug_revision_dropped_history = 'Bug Revision Dropped';
$s_bugnote_revision_dropped_history = 'Note Revision Dropped';
$s_all_revisions = 'All Revisions';
$s_back_to_issue = 'Back to Issue';
$s_confirm_revision_drop = 'Are you sure you want to drop this issue revision?';

# bug_vote_add.php
$s_vote_added_msg = 'Vote has been added...';

# bugnote_add.php
$s_bugnote_added_msg = 'Note added...';

# bugnote_delete.php
$s_bugnote_deleted_msg = 'Note has been successfully deleted...';
$s_bug_notes_title = 'Notes';

# bugnote_edit_page.php
$s_edit_bugnote_title = 'Edit Note';

# bugnote_inc.php
$s_no_bugnotes_msg = 'There are no notes attached to this issue.';
$s_delete_link = 'Delete';
$s_add_bugnote_title = 'Add Note';
$s_add_bugnote_button = 'Add Note';
$s_bugnote_edit_link = 'Edit';
$s_closed_bug_button = 'Close Issue';

# bugnote_update.php
$s_bugnote_updated_msg = 'Note has been successfully updated...';
$s_edited_on = 'edited on:';

# file_api.php
$s_hide_content = 'Hide Content';
$s_show_content = 'Show Content';

# html_api.php
$s_total_queries_executed = '%1$d total queries executed.';
$s_unique_queries_executed = '%1$d unique queries executed.';
$s_memory_usage_in_kb = 'memory usage: %1$s KB';

# print_api.php
$s_please_report = 'Please report this to the %1$s.';

# index.php
$s_click_to_login = 'Login';

# login.php
$s_warning_plain_password_authentication = '<strong>Warning:</strong> Plain password authentication is used, this will expose your passwords to administrators.';
$s_warning_default_administrator_account_present = '<strong>Warning:</strong> You should disable the default \'administrator\' account or change its password.';
$s_warning_admin_directory_present = '<strong>Warning:</strong> Admin directory should be removed.';
$s_error_database_version_out_of_date_1 = '<strong>Error:</strong> The database structure appears to be out of date (config(databaseversion) is 0 and old upgrade tables exist). Version 1.x of MantisBT introduced a new upgrade process. You appear to be upgrading from a 0.XX Release. Please upgrade to 1.0.8 or 1.1.X, then upgrade to 1.2.';
$s_error_database_no_schema_version = '<strong>Error:</strong> The database structure appears to be out of date (config(databaseversion) is 0 and old upgrade tables do not exist). Please check that your database is running - we can not retrieve the database schema version. Config Table did not return a valid database schema version - please ask for support on the mantis-help mailing list if required.';
$s_error_database_version_out_of_date_2 = '<strong>Warning:</strong> The database structure may be out of date. Please upgrade <a href="admin/install.php">here</a> before logging in.';
$s_error_code_version_out_of_date = '<strong>Warning:</strong> The database structure is more up-to-date than the code installed. Please upgrade the code.';

# login_page.php
#@@@ should the following string be related to $g_window_title?
$s_login_page_info = 'Welcome to the Issue Tracker.';
$s_login_title = 'Login';
$s_save_login = 'Remember my login in this browser';
$s_secure_session = 'Secure Session';
$s_secure_session_long = 'Only allow your session to be used from this IP address.';
$s_choose_project = 'Choose Project';
$s_login_button = 'Login';
$s_signup_link = 'Signup for a new account';
$s_lost_password_link = 'Lost your password?';

# login_select_proj_page.php
$s_select_project_button = 'Select Project';

# lost_pwd_page.php
$s_lost_password_title = 'Password Reset';
$s_lost_password_done_title = 'Password Message Sent';
$s_lost_password_subject = 'Password Reset';
$s_lost_password_info = 'To reinstate your lost password, please supply the name and e-mail address for the account.<br /><br />If the data corresponds to a valid account, you will be sent a special URL via e-mail that contains a validation code for your account. Please follow this link to change your password.';
$s_lost_password_confirm_hash_OK = 'Your confirmation has been accepted. Please update your password.';

# main_page.php
$s_open_and_assigned_to_me = 'Open and assigned to me';
$s_open_and_reported_to_me = 'Open and reported by me';
$s_newer_news_link = 'Newer News';
$s_older_news_link = 'Older News';
$s_archives = 'Archives';
$s_rss = 'RSS';

# manage_overview_page
$s_site_information = 'Site Information';
$s_mantis_version = 'MantisBT Version';
$s_schema_version = 'Schema Version';
$s_site_path = 'Site Path';
$s_core_path = 'Core Path';
$s_plugin_path = 'Plugin Path';

# manage_create_new_user.php
$s_created_user_part1 = 'Created user';
$s_created_user_part2 = 'with an access level of';

# manage_create_user_page.php
$s_create_new_account_title = 'Create New Account';
$s_verify_password = 'Verify Password';
$s_enabled = 'Enabled';
$s_protected = 'Protected';
$s_create_user_button = 'Create User';

# manage_page.php
$s_hide_disabled = 'Hide Disabled';
$s_filter_button = 'Apply Filter';
$s_default_filter = 'Default Filter';
$s_create_filter_link = 'Create Permalink'; # Permalink = Permanent Link
$s_create_short_link = 'Create Short Link';
$s_filter_permalink = 'Following is a permanent link to the currently configured filter:';
$s_manage_users_link = 'Manage Users';
$s_manage_projects_link = 'Manage Projects';
$s_manage_custom_field_link = 'Manage Custom Fields';
$s_manage_global_profiles_link = 'Manage Global Profiles';
$s_manage_plugin_link = 'Manage Plugins';
$s_permissions_summary_report = 'Permissions Report';
$s_manage_config_link = 'Manage Configuration';
$s_manage_threshold_config = 'Workflow Thresholds';
$s_manage_email_config = 'E-mail Notifications';
$s_manage_workflow_config = 'Workflow Transitions';
$s_manage_tags_link = 'Manage Tags';
$s_create_new_account_link = 'Create New Account';
$s_projects_link = 'Projects';
$s_documentation_link = 'Documentation';
$s_new_accounts_title = 'New Accounts';
$s_1_week_title = '1 Week';
$s_never_logged_in_title = 'Never Logged In';
$s_prune_accounts = 'Prune Accounts';
$s_hide_inactive = 'Hide Inactive';
$s_show_disabled = 'Show Disabled';
$s_manage_accounts_title = 'Manage Accounts';
$s_p = 'p';
$s_date_created = 'Date Created';
$s_last_visit = 'Last Visit';
$s_edit_user_link = 'Edit User';

# manage_config_email_page
$s_config_all_projects = 'Note: These configurations affect all projects, unless overridden at the project level.';
$s_config_project = 'Note: These configurations affect only the %1$s project.';
$s_colour_coding = 'In the table below, the following color code applies:';
$s_colour_project = 'Project setting overrides others.';
$s_colour_global = 'All Project settings override default configuration.';
$s_issue_reporter = 'User who reported issue';
$s_issue_handler = 'User who is handling the issue';
$s_users_added_bugnote = 'Users who added Issue Notes';
$s_change_configuration = 'Update Configuration';
$s_message = 'Message';
$s_default_notify = 'Setting default notification flags to';
$s_action_notify = 'Setting action notification flags to';
$s_notify_defaults_change_access = 'Who can change notification defaults';
$s_notify_actions_change_access = 'Who can change notifications:';
$s_revert_to_system = 'Delete All Projects Settings';
$s_revert_to_all_project = 'Delete Project Specific Settings';

# manage_config_workflow_page
$s_non_existent = 'non-existent';
$s_current_status = 'Current Status';
$s_next_status = 'Next Status';
$s_workflow = 'Workflow';
$s_workflow_thresholds = 'Thresholds that Affect Workflow';
$s_threshold = 'Threshold';
$s_status_level = 'Status';
$s_alter_level = 'Who can alter this value';
$s_validation = 'Workflow Validation';
$s_comment = 'Validation Comment';
$s_superfluous = 'Arc from status to itself is implied, and need not be given explicitly';
$s_unreachable = 'You cannot move an issue into this status';
$s_no_exit = 'You cannot move an issue out of this status';
$s_access_levels = 'Access Levels';
$s_access_change = 'Minimum Access Level to Change to this Status';
$s_desc_bug_submit_status = 'Status to which a new issue is set';
$s_desc_bug_reopen_status = 'Status to which reopened issues are set';
$s_desc_bug_resolved_status_threshold = 'Status where an issue is considered resolved';
$s_desc_bug_closed_status_threshold = 'Status where an issue is considered closed';
$s_workflow_change_access = 'Who can change workflow';
$s_access_change_access = 'Who can change access levels';

# manage_config_workflow_set
$s_default_not_in_flow = 'The default status of %1$s is not selected in the next statuses for %2$s. It will be ignored.';

# manage_config_work_threshold_page
$s_assign_issue = 'Assign an issue';
$s_allow_close_immediate = 'Allow issue to be closed on Resolve';
$s_allow_reporter_close = 'Allow Reporter to close Issue';
$s_allow_reporter_reopen = 'Allow Reporter to re-open Issue';
$s_set_status_assigned = 'Set status on assignment of Handler';
$s_allow_user_edit = 'Allow user to edit their own issue notes';
$s_limit_access = 'Limit reporter\'s access to their own issues';
$s_submit_status = 'Status to which a new issue is set';
$s_assigned_status = 'Status to set auto-assigned issues to';
$s_resolved_status = 'Status where an issue is considered resolved';
$s_readonly_status = 'Status where an issue becomes read only';
$s_reopen_status = 'Status to which a reopened issue is set';
$s_reopen_resolution = 'Resolution to which a reopened issue is set';

# manage_config_revert_page
$s_config_delete_sure = 'Are you sure you want to delete the settings for:';
$s_in_project = 'in project';
$s_delete_config_button = 'Delete Settings';

# adm_config_report.php
$s_configuration_report = 'Configuration Report';
$s_database_configuration = 'Database Configuration';
$s_configuration_option = 'Configuration Option';
$s_configuration_option_type = 'Type';
$s_configuration_option_value = 'Value';
$s_all_users = 'All Users';
$s_set_configuration_option = 'Set Configuration Option';
$s_delete_config_sure_msg = 'Are you sure you wish to delete this configuration option?';
$s_configuration_corrupted = 'The configuration in the database is corrupted.';

# manage_plugin_page.php
$s_plugin = 'Plugin';
$s_plugins_installed = 'Installed Plugins';
$s_plugins_available = 'Available Plugins';
$s_plugin_description = 'Description';
$s_plugin_author = 'Author: %1$s';
$s_plugin_url = 'Website:';
$s_plugin_depends = 'Dependencies';
$s_plugin_no_depends = 'No dependencies';
$s_plugin_priority = 'Priority';
$s_plugin_protected = 'Protected';
$s_plugin_update = 'Update';
$s_plugin_actions = 'Actions';
$s_plugin_install = 'Install';
$s_plugin_upgrade = 'Upgrade';
$s_plugin_uninstall = 'Uninstall';
$s_plugin_uninstall_message = 'Are you sure you want to uninstall the "%1$s" plugin?';
$s_plugin_key = 'Key';
$s_plugin_key_met = 'plugin ready';
$s_plugin_key_unmet = 'unmet dependencies';
$s_plugin_key_dated = 'outdated dependencies';
$s_plugin_key_upgrade = 'upgrade needed';

# manage_proj_add.php
$s_project_added_msg = 'Project has been successfully added...';

# manage_proj_category_add.php
$s_category_added_msg = 'Category has been successfully added...';

# manage_proj_category_delete.php
$s_category_deleted_msg = 'Category has been successfully deleted...';

# manage_proj_category_delete_page.php
$s_category_delete_sure_msg = 'Are you sure you want to delete this category?<br />Category "%1$s" contains %2$d issues.';
$s_delete_category_button = 'Delete Category';

# manage_proj_category_edit_page.php
$s_edit_project_category_title = 'Edit Project Category';
$s_update_category_button = 'Update Category';

# manage_proj_category_update.php
$s_category_updated_msg = 'Category has been successfully updated...';

# manage_proj_create_page.php
$s_add_subproject_title = 'Add Subproject';

# manage_proj_delete.php
$s_project_deleted_msg = 'Project successfully removed...';

# manage_proj_delete_page.php
$s_project_delete_msg = 'Are you sure you want to delete this project and all attached issue reports?';
$s_project_delete_button = 'Delete Project';

# manage_proj_edit_page.php
$s_edit_project_title = 'Edit Project';
$s_project_name = 'Project Name';
$s_view_status = 'View Status';
$s_public = 'public';
$s_private = 'private';
$s_update_project_button = 'Update Project';
$s_delete_project_button = 'Delete Project';
$s_copy_from = 'Copy From';
$s_copy_to = 'Copy To';
$s_categories_and_version_title = 'Categories and Versions';
$s_categories = 'Categories';
$s_add_category_button = 'Add Category';
$s_versions = 'Versions';
$s_add_version_button = 'Add Version';
$s_add_and_edit_version_button = 'Add and Edit Version';
$s_edit_link = 'Edit';
$s_actions = 'Actions';
$s_version = 'Version';
$s_timestamp = 'Timestamp';
$s_update = 'Update';
$s_subprojects = 'Subprojects';
$s_add_subproject = 'Add as Subproject';
$s_create_new_subproject_link = 'Create New Subproject';
$s_unlink_link = 'Unlink';
$s_show_global_users = 'Show Users with Global Access';
$s_hide_global_users = 'Hide Users with Global Access';

# manage_proj_menu_page.php
$s_add_project_title = 'Add Project';
$s_upload_file_path = 'Upload File Path';
$s_add_project_button = 'Add Project';
$s_projects_title = 'Projects';
$s_name = 'Name';

# manage_proj_update.php
$s_project_updated_msg = 'Project has been successfully updated...';

# manage_proj_version_add.php
$s_version_added_msg = 'Version has been successfully added...';

# manage_proj_version_delete.php
$s_version_deleted_msg = 'Version has been successfully deleted...';

# manage_proj_version_delete_page.php
$s_version_delete_sure = 'Are you sure you want to delete this version?';
$s_delete_version_button = 'Delete Version';

# manage_proj_version_edit_page.php
$s_edit_project_version_title = 'Edit Project Version';
$s_update_version_button = 'Update Version';
$s_released = 'Released';
$s_not_released = 'Not Yet Released';
$s_scheduled_release = 'Scheduled For Release';
$s_obsolete = 'Obsolete';

# manage_proj_version_update.php
$s_version_updated_msg = 'Version has been successfully updated...';

# manage_user_delete.php
$s_account_delete_protected_msg = 'Account protected. Cannot delete this account.';
$s_account_deleted_msg = 'Account deleted...';

# manage_user_delete_page.php
$s_delete_account_sure_msg = 'Are you sure you wish to delete this account?';

# manage_user_edit_page.php
$s_notify_user = 'Notify User';

# manage_user_prune.php
$s_accounts_pruned_msg = 'All accounts that have never logged in and are older than 1 week have been removed';
$s_prune_accounts_button = 'Prune';
$s_confirm_account_pruning = 'Are you sure you want to delete old accounts that have never logged in?';

# manage_user_page.php
$s_edit_user_title = 'Edit User';
$s_account_unlock_button = 'Unlock Account';
$s_reset_password_button = 'Reset Password';
$s_delete_user_button = 'Delete User';
$s_reset_password_msg = 'Reset Password sends the confirmation URL via e-mail.';
$s_reset_password_msg2 = 'Reset Password resets the password to be blank.';
$s_show_all_users = 'All';
$s_users_unused = 'Unused';
$s_users_new = 'New';

# manage_user_reset.php
$s_account_reset_protected_msg = 'Account protected. Cannot reset the password.';
$s_account_reset_msg = 'A confirmation request has been sent to the selected user\'s e-mail address. Using this, the user will be able to change their password.';
$s_account_reset_msg2 = 'Account password has been set to blank...';
$s_account_unlock_msg = 'The account has been unlocked.';

# manage_user_update.php
$s_manage_user_protected_msg = 'Account protected; the \'Access Level\' and \'Enabled\' fields cannot be modified. Other fields were successfully updated.';
$s_manage_user_updated_msg = 'Account successfully updated...';
$s_email_user_updated_subject = 'Account updated';
$s_email_user_updated_msg = 'Your account has been updated by an administrator. A list of these changes is provided below. You can update your account details and preferences at any time by visiting the following URL:';

# menu_inc.php
$s_main_link = 'Main';
$s_view_bugs_link = 'View Issues';
$s_report_bug_link = 'Report Issue';
$s_changelog_link = 'Change Log';
$s_roadmap_link = 'Roadmap';
$s_summary_link = 'Summary';
$s_account_link = 'My Account';
$s_users_link = 'Users';
$s_manage_link = 'Manage';
$s_edit_news_link = 'Edit News';
$s_docs_link = 'Docs';
$s_logout_link = 'Logout';
$s_my_view_link = 'My View';

# meta_inc.php

# my_view_page.php
$s_my_view_title_unassigned = 'Unassigned';
$s_my_view_title_recent_mod = 'Recently Modified';
$s_my_view_title_reported = 'Reported by Me';
$s_my_view_title_assigned = 'Assigned to Me (Unresolved)';
$s_my_view_title_resolved = 'Resolved';
$s_my_view_title_monitored = 'Monitored by Me';
$s_my_view_title_feedback = 'Awaiting Feedback from Me';
$s_my_view_title_verify = 'Awaiting Confirmation of Resolution from Me';
$s_my_view_title_my_comments = 'Issues I Have Commented On';

# news_add.php
$s_news_added_msg = 'News item added...';

# news_delete.php
$s_news_deleted_msg = 'Deleted news item...';

# news_delete_page.php
$s_delete_news_sure_msg = 'Are you sure you wish to delete this news item?';
$s_delete_news_item_button = 'Delete News Item';

# news_edit_page.php
$s_edit_news_title = 'Edit News';
$s_headline = 'Headline';
$s_body = 'Body';
$s_update_news_button = 'Update News';

# news_menu_page.php
$s_add_news_title = 'Add News';
$s_post_to = 'Post to';
$s_post_news_button = 'Post News';
$s_edit_or_delete_news_title = 'Edit or Delete News';
$s_edit_post = 'Edit Post';
$s_delete_post = 'Delete Post';
$s_select_post = 'Select Post';

# news_update.php
$s_news_updated_msg = 'News item updated...';

# news_view_page.php
$s_back_link = 'Back';

# proj_doc_add.php
$s_file_uploaded_msg = 'File upload successful.';

# proj_doc_add_page.php
$s_upload_file_title = 'Upload File';
$s_title = 'Title';

# proj_doc_delete.php
$s_project_file_deleted_msg = 'Project file deleted.';

# proj_doc_delete_page.php
$s_confirm_file_delete_msg = 'Are you sure you wish to delete this file?';

# proj_doc_edit_page.php
$s_filename = 'Filename';
$s_file_update_button = 'Update File';
$s_file_delete_button = 'Delete File';

# proj_doc_page.php
$s_project_documentation_title = 'Project Documentation';
$s_user_documentation = 'User Documentation';
$s_project_documentation = 'Project Documentation';
$s_add_file = 'Add File';

# proj_doc_update.php
$s_project_document_updated = 'Project update successful.';

# proj_user_add.php
$s_project_user_added_msg = 'Successfully added user to project.';

# proj_user_delete.php
$s_project_removed_user_msg = 'Successfully removed user from project.';

# manage_user_proj_delete.php
$s_remove_user_sure_msg = 'Are you sure you wish to remove this user?';
$s_remove_user_from_project_button = 'Remove User from Project %s';
$s_remove_all_users_sure_msg = 'Are you sure you wish to remove all the users of this project?';
$s_remove_all_users_button = 'Remove All Users';

# proj_user_menu_page.php
$s_add_user_title = 'Add user to project';
$s_add_user_button = 'Add User';
$s_project_selection_title = 'Project Selection';
$s_remove_link = 'Remove';
$s_remove_all_link = 'Remove all';

# proj_user_update.php
$s_updated_user_msg = 'Successfully updated user.';

# report_add.php
$s_must_enter_category = 'You must select a category.';
$s_must_enter_severity = 'You must select a severity.';
$s_must_enter_reproducibility = 'You must select a reproducibility.';
$s_must_enter_summary = 'You must enter a summary.';
$s_must_enter_description = 'You must enter a description.';
$s_report_more_bugs = 'Report More Issues';
$s_submission_thanks_msg = 'Thank you for your submission.';

# report_bug_advanced_page.php
$s_simple_report_link = 'Simple Report';
$s_enter_report_details_title = 'Enter Report Details';
$s_required = 'required';
$s_select_category = 'Select Category';
$s_select_reproducibility = 'Select Reproducibility';
$s_select_severity = 'Select Severity';
$s_or_fill_in = 'Or Fill In';
$s_assign_to = 'Assign To';
$s_additional_information = 'Additional Information';
$s_submit_report_button = 'Submit Report';
$s_check_report_more_bugs = 'check to report more issues';

# report_bug_page.php
$s_report_stay = 'Report Stay';

# set_project.php
$s_selected_project = 'Selected project';
$s_valid_project_msg = 'You must choose a valid project.';

# signup.php
$s_signup_done_title = 'Account registration processed.';
$s_password_emailed_msg = 'Congratulations. You have registered successfully. You are now being sent a confirmation e-mail to verify your e-mail address. Visiting the link sent to you in this e-mail will activate your account.';
$s_no_reponse_msg = 'You will have seven days to complete the account confirmation process; if you fail to complete account confirmation within seven days, this newly-registered account may be purged.';

# signup_page.php
$s_signup_captcha_request = 'Enter the code as it is shown in the box on the right.';
$s_signup_info = 'On completion of this form and verification of your answers, you will be sent a confirmation e-mail to the e-mail address you specified.<br />Using the confirmation e-mail, you will be able to activate your account. If you fail to activate your account within seven days, it will be purged.<br />You must specify a valid e-mail address in order to receive the account confirmation e-mail.';
$s_signup_title = 'Signup';
$s_signup_button = 'Signup';
$s_no_password_request = 'Your password is managed by another system. Please contact your system administrator.';

# site_settings_edit_page.php
$s_edit_site_settings_title = 'Edit Site Settings';
$s_save_settings_button = 'Save Settings';

# site_settings_page.php
$s_site_settings_title = 'Site Settings';
$s_system_info_link = 'System Info';
$s_site_settings_link = 'Site Settings';

# site_settings_update.php
$s_site_settings_updated_msg = 'Site settings have been updated';

# summary_page.php
$s_summary_title = 'Summary';
$s_summary_advanced_link = 'Advanced summary';
$s_by_project = 'By Project';
$s_by_status = 'By Status';
$s_by_date = 'By Date (days)';
$s_by_severity = 'By Severity';
$s_by_resolution = 'By Resolution';
$s_by_category = 'By Category';
$s_by_priority = 'By Priority';
$s_by_developer = 'By Developer';
$s_by_reporter = 'By Reporter';
$s_reporter_by_resolution = 'Reporter By Resolution';
$s_reporter_effectiveness = 'Reporter Effectiveness';
$s_developer_by_resolution = 'Developer By Resolution';
$s_percentage_fixed = '% Fixed';
$s_percentage_errors = '% False';
$s_errors = 'False';
$s_opened = 'Opened';
$s_resolved = 'Resolved';
$s_total = 'Total';
$s_balance = 'Balance';
$s_most_active = 'Most Active';
$s_score = 'Score';
$s_days = 'Days';
$s_time_stats = 'Time Stats For Resolved Issues (days)';
$s_longest_open_bug = 'Longest open issue';
$s_longest_open = 'Longest open';
$s_average_time = 'Average time';
$s_total_time = 'Total time';
$s_developer_stats = 'Developer Stats';
$s_reporter_stats = 'Reporter Stats';
$s_orct = '(open/resolved/closed/total)';

# view_all_bug_page.php
$s_any = 'any';
$s_all = 'all';
$s_show = 'Show';
$s_changed = 'Changed(hrs)';
$s_viewing_bugs_title = 'Viewing Issues';
$s_updated = 'Updated';
$s_sticky = 'Show Sticky Issues';
$s_sort = 'Sort by';
$s_issue_id = 'Issue #';
$s_recently_visited = 'Recently Visited';
$s_priority_abbreviation = 'P';
$s_note_user_id = 'Note By';
$s_filter_match_type = 'Match Type';
$s_filter_match_all = 'All Conditions';
$s_filter_match_any = 'Any Condition';

# view_all_inc.php
$s_none = 'none';
$s_current = 'current';
$s_search = 'Search';
$s_view_prev_link = 'View Prev';
$s_view_next_link = 'View Next';
$s_prev = 'Prev';
$s_next = 'Next';
$s_first = 'First';
$s_last = 'Last';
$s_start_date = 'Start Date';
$s_end_date = 'End Date';
$s_use_date_filters = 'Use Date Filters';
$s_yes = 'Yes';
$s_no = 'No';
$s_open_filters = 'Change Filter';
$s_or_unassigned = 'Or Unassigned';
$s_ok = 'OK';
$s_select_all = 'Select All';

# stored query strings
$s_use_query = 'Use Filter';
$s_delete_query = 'Delete Filter';
$s_query_deleted = 'Filter Deleted';
$s_save_query = 'Save Current Filter';
$s_reset_query = 'Reset Filter';
$s_query_name = 'Filter Name';
$s_query_exists = 'This particular filter appears to already exist.';
$s_query_dupe_name = 'Another filter already has this name. Please choose a different name for this filter.';
$s_query_blank_name = 'You cannot store a filter without a name. Please give this filter a name before saving it.';
$s_query_name_too_long = 'You cannot store a filter name with more than 64 characters. Please give this filter a shorter name.';
$s_query_store_error = 'There was an error saving this filter.';
$s_open_queries = 'Manage Filters';
$s_query_delete_msg = 'Are you sure you wish to delete this filter?';

# bug_view_advanced_page.php
$s_view_simple_link = 'View Simple';
$s_product_build = 'Product Build';
$s_system_profile = 'System Description';
$s_update_bug_button = 'Edit';
$s_bug_assign_to_button = 'Assign To:';
$s_bug_status_to_button = 'Change Status To:';
$s_reopen_bug_button = 'Reopen';
$s_close_bug_button = 'Close';
$s_move_bug_button = 'Move';
$s_attached_files = 'Attached Files';
$s_publish = 'Publish';
$s_cached = 'Cached';
$s_add_user_to_monitor = 'Add';

# view_bug_inc.php

# view_bug_page.php
# print_all_bug_page_word.php
$s_bug_view_title = 'View Issue Details';

# bug_monitor_list_view_inc.php
$s_no_users_monitoring_bug = 'There are no users monitoring this issue.';
$s_users_monitoring_bug = 'Users monitoring this issue';
$s_monitoring_user_list = 'User List';

# bug_sponsorship_list_view_inc.php
$s_no_users_sponsoring_bug = 'There are no users sponsoring this issue.';
$s_users_sponsoring_bug = 'Users sponsoring this issue';
$s_sponsors_list = 'Sponsors List';
$s_total_sponsorship_amount = 'Total Sponsorship = %1$s';

# custom field strings
$s_add_custom_field_button = 'New Custom Field';
$s_delete_custom_field_button = 'Delete Custom Field';
$s_delete_custom_field_everywhere = 'Delete Custom Field Everywhere';
$s_update_custom_field_button = 'Update Custom Field';
$s_add_existing_custom_field = 'Add This Existing Custom Field';
$s_edit_custom_field_title = 'Edit custom field';
$s_custom_field = 'Field';
$s_custom_fields_setup = 'Custom Fields';
$s_custom_field_name = 'Name';
$s_custom_field_project_count = 'Project Count';
$s_custom_field_type = 'Type';
$s_custom_field_possible_values = 'Possible Values';
$s_custom_field_default_value = 'Default Value';
$s_custom_field_valid_regexp = 'Regular Expression';
$s_custom_field_access_level_r = 'Read Access';
$s_custom_field_access_level_rw = 'Write Access';
$s_custom_field_length_min = 'Min. Length';
$s_custom_field_length_max = 'Max. Length';
$s_custom_field_filter_by = 'Add to Filter';
$s_custom_field_display_report = 'Display When Reporting Issues';
$s_custom_field_display_update = 'Display When Updating Issues';
$s_custom_field_display_resolved = 'Display When Resolving Issues';
$s_custom_field_display_closed = 'Display When Closing Issues';
$s_custom_field_require_report = 'Required On Report';
$s_custom_field_require_update = 'Required On Update';
$s_custom_field_require_resolved = 'Required On Resolve';
$s_custom_field_require_closed = 'Required On Close';
$s_link_custom_field_to_project_title = 'Link custom field to project';
$s_link_custom_field_to_project_button = 'Link Custom Field';
$s_linked_projects = 'Linked Projects';

$s_custom_field_sequence = 'Sequence';
# ODB Production Changed to add text area $s_custom_field_type_enum_string = '0:String,1:Numeric,2:Float,3:Enumeration,4:E-mail,5:Checkbox,6:List,7:Multiselection list,8:Date,9:Radio';
$s_custom_field_type_enum_string = '0:String,1:Numeric,2:Float,3:Enumeration,4:E-mail,5:Checkbox,6:List,7:Multiselection list,8:Date,9:Radio,10:Textarea';
$s_confirm_used_custom_field_deletion = 'This field is currently linked to at least one project. If you continue all values for this field will be permanently deleted. This action cannot be undone. If you do not want to delete this field, hit the Back button in your browser. To proceed, click the button below';
$s_confirm_custom_field_deletion = 'Are you sure you want to delete this custom field and all associated values?';
$s_field_delete_button = 'Delete Field';

$s_confirm_custom_field_unlinking = 'Are you sure you want to unlink this custom field from the project? The values will not be deleted as long as the custom field itself is not deleted.';
$s_field_remove_button = 'Remove Field';

$s_hide_status = 'Hide Status';
$s_filter_closed = 'Closed';
$s_filter_resolved = 'Resolved';
$s_hide_closed = 'Hide Closed';
$s_hide_resolved = 'Hide Resolved';
$s_and_above = 'And Above';
$s_advanced_filters = 'Advanced Filters';
$s_simple_filters = 'Simple Filters';
$s_monitored_by = 'Monitored By';

$s_attachments = 'attachment(s)';
$s_bytes = 'bytes';
$s_attachment_missing = 'Attachment missing';
$s_attachment_count = 'Attachment count';
$s_view_attachments_for_issue = 'View %1$d attachment(s) for issue #%2$d';

# PHPMailer
$s_phpmailer_language = 'en';

# Sponsorship Strings
$s_sponsors = '%1$d sponsor(s)';
$s_sponsorship_added = 'Sponsorship Added';
$s_sponsorship_updated = 'Sponsorship Updated';
$s_sponsorship_deleted = 'Sponsorship Deleted';
$s_sponsorship_paid = 'Sponsorship Paid';
$s_sponsorship_more_info = 'More information about sponsorship';
$s_sponsorship_total = 'Sponsorship Total';

# URL explaining the process of sponsoring an issue. This is defined here rather than
# in the config to allow for a URL per language. This can be set to an empty string if there
# is not need to provide such process information.
$s_sponsorship_process_url = '';

# Changelog
$s_changelog = 'Change Log';
$s_changelog_empty = 'No Change Log information available';

# Roadmap
$s_roadmap = 'Roadmap';
$s_resolved_progress = '%1$d of %2$d issue(s) resolved. Progress (%3$d%%).';

# Http auth
$s_http_auth_realm = 'MantisBT Login';

$s_bug = 'issue';
$s_bugs = 'issues';
$s_add_new_relationship = 'New relationship';
$s_add_new_relationship_button = 'Add';
$s_this_bug = 'Current issue';
$s_relationship_added = 'Relationship added';
$s_relationship_deleted = 'Relationship deleted';
$s_no_relationship = 'no relationship';
$s_relationship_replaced = 'Relationship replaced';
$s_replace_relationship_button = 'Replace';
$s_replace_relationship_sure_msg = 'There is already a relationship between the two issues. Are you sure you want to replace it?';
$s_relationship_with_parent = 'Relationship with the parent issue';
$s_delete_relationship_button = 'Delete';
$s_delete_relationship_sure_msg = 'Are you sure you wish to delete this relationship?';
$s_relationship_warning_blocking_bugs_not_resolved = 'Not all the children of this issue are yet resolved or closed.';
$s_relationship_warning_blocking_bugs_not_resolved_2 = '<b>Attention:</b> Not all the children of this issue are yet resolved or closed.<br />Before <b>resolving/closing</b> a parent issue, all the issues related as child with this one should be resolved or closed.';
$s_create_child_bug_button = 'Clone';
$s_bug_cloned_to = 'Issue cloned';
$s_bug_created_from = 'Issue generated from';
$s_copy_from_parent = 'Copy extended data from parent issue';
$s_copy_notes_from_parent = 'Copy bug notes';
$s_copy_attachments_from_parent = 'Copy attachments';

# Relationship Graphs
$s_viewing_bug_relationship_graph_title = 'Relationship Graph';
$s_viewing_bug_dependency_graph_title = 'Dependency Graph';
$s_relation_graph = 'Relation Graph';
$s_dependency_graph = 'Dependency Graph';
$s_vertical = 'Vertical';
$s_horizontal = 'Horizontal';
$s_view_issue = 'View Issue';

# Source Control Integration
$s_checkin = 'Checkin';

# Pemissions report
$s_perm_rpt_capability = 'Capability';
$s_view = 'View';
$s_issues = 'Issues';
$s_report_issue = 'Report an issue';
$s_update_issue = 'Update an issue';
$s_monitor_issue = 'Monitor an issue';
$s_handle_issue = 'Handle an issue';
$s_move_issue = 'Move an issue';
$s_delete_issue = 'Delete an issue';
$s_reopen_issue = 'Reopen an issue';
$s_view_private_issues = 'View private issues';
$s_update_readonly_issues = 'Update readonly issues';
$s_update_issue_status = 'Update issue status';
$s_set_view_status = 'Set view status (public vs private)';
$s_update_view_status = 'Update view status (public vs private)';
$s_show_list_of_users_monitoring_issue = 'Show list of users monitoring issue';
$s_notes = 'Notes';
$s_add_notes = 'Add notes';
$s_update_notes = 'Update notes';
$s_delete_note = 'Delete note';
$s_view_private_notes = 'View private notes';
$s_news = 'News';
$s_view_private_news = 'View private news';
$s_manage_news = 'Manage news';
$s_view_list_of_attachments = 'View list of attachments';
$s_download_attachments = 'Download attachments';
$s_delete_attachments = 'Delete attachments';
$s_delete_attachment_button = 'Delete';
$s_delete_attachment_sure_msg = 'Are you sure you wish to delete this attachment?';
$s_upload_issue_attachments = 'Upload issue attachments';
$s_filters = 'Filters';
$s_save_filters = 'Save filters';
$s_save_filters_as_shared = 'Save filters as shared';
$s_use_saved_filters = 'Use saved filters';
$s_create_project = 'Create project';
$s_delete_project = 'Delete project';
$s_manage_project = 'Manage project';
$s_manage_user_access_to_project = 'Manage user access to a project';
$s_automatically_included_in_private_projects = 'Automatically included in private projects';
$s_project_documents = 'Project Documents';
$s_view_project_documents = 'View project documents';
$s_upload_project_documents = 'Upload project documents';
$s_link_custom_fields_to_projects = 'Link custom fields to projects';
$s_sponsorships = 'Sponsorships';
$s_view_sponsorship_details = 'View sponsorship details';
$s_view_sponsorship_total = 'View sponsorship total';
$s_sponsor_issue = 'Sponsor issue';
$s_assign_sponsored_issue = 'Assign sponsored issue';
$s_handle_sponsored_issue = 'Handle sponsored issue';
$s_others = 'Others';
$s_see_email_addresses_of_other_users = 'See e-mail addresses of other users';
$s_send_reminders = 'Send reminders';
$s_receive_reminders = 'Receive reminders';
$s_add_profiles = 'Add profiles';
$s_notify_of_new_user_created = 'Notify of new user created';
$s_email_notification = 'E-mail notification';
$s_status_changed_to = 'Status changes to';
$s_email_on_deleted = 'E-mail on Deleted';
$s_email_on_sponsorship_changed = 'E-mail on Sponsorship changed';
$s_email_on_relationship_changed = 'E-mail on Relationship changed';

# DHTML filters
$s_loading = 'Loading...';

# filter_api.php
$s_between_date = 'Between';
$s_on_or_before_date = 'On Or Before';
$s_before_date = 'Before';
$s_after_date = 'After';
$s_on_or_after_date = 'On Or After';

# Date constants
$s_from_date = 'From';
$s_to_date = 'To';
$s_on_date = 'On';

# Switch constants
$s_on = 'On';
$s_off = 'Off';

# wiki related strings
$s_wiki = 'Wiki';

# Tagging
$s_tags = 'Tags';
$s_tag_details = 'Tag Details: %1$s';
$s_tag_id = 'Tag ID';
$s_tag_name = 'Name';
$s_tag_creator = 'Creator';
$s_tag_created = 'Date Created';
$s_tag_updated = 'Last Updated';
$s_tag_description = 'Tag Description';
$s_tag_statistics = 'Usage Statistics';
$s_tag_update = 'Update Tag: %1$s';
$s_tag_update_return = 'Back to Tag';
$s_tag_update_button = 'Update Tag';
$s_tag_delete_button = 'Delete Tag';
$s_tag_delete_message = 'Are you sure you wish to delete this tag?';
$s_tag_existing = 'Existing tags';
$s_tag_none_attached = 'No tags attached.';
$s_tag_attach = 'Attach';
$s_tag_attach_long = 'Attach Tags';
$s_tag_attach_failed = 'Tag attachment failed.';
$s_tag_detach = 'Detach "%1$s"';
$s_tag_separate_by = '(Separate by "%1$s")';
$s_tag_invalid_name = 'Invalid tag name.';
$s_tag_create_denied = 'Create permission denied.';
$s_tag_filter_default = 'Attached Issues (%1$s)';
$s_tag_history_attached = 'Tag Attached';
$s_tag_history_detached = 'Tag Detached';
$s_tag_history_renamed = 'Tag Renamed';
$s_tag_related = 'Related Tags';
$s_tag_related_issues = 'Shared Issues (%1$s)';
$s_tag_stats_attached = 'Issues attached: %1$s';
$s_tag_create = 'Create Tag';
$s_show_all_tags = 'All';

# Time Tracking
$s_time_tracking_billing_link = 'Time Tracking';
$s_time_tracking = 'Time tracking';
$s_time_tracking_time_spent = 'Time spent:';
$s_time_tracking_get_info_button = 'Get Time Tracking Information';
$s_time_tracking_cost_per_hour = 'Cost / Hour';
$s_time_tracking_cost = 'Cost';
$s_total_time_for_issue = 'Total time for issue = %1$s';
$s_time_tracking_stopwatch_start = 'Start';
$s_time_tracking_stopwatch_stop = 'Stop';
$s_time_tracking_stopwatch_reset = 'Reset';

$s_access_denied = 'Access Denied.';

# Twitter Integration
$s_twitter_resolved = '%1$d: [%2$s] %3$s (resolved by %4$s in %5$s)';
$s_twitter_resolved_no_version = '%1$d: [%2$s] %3$s (resolved by %4$s)';

# Project Page
$s_development_team = 'Development Team';

# manage columns page
$s_manage_columns_config = 'Manage Columns';
$s_all_columns_title = 'All Available Columns';
$s_csv_columns_title = 'CSV Columns';
$s_view_issues_columns_title = 'View Issues Columns';
$s_print_issues_columns_title = 'Print Issues Columns';
$s_excel_columns_title = 'Excel Columns';
$s_update_columns_as_global_default = 'Update Columns as Global Default for All Projects';
$s_update_columns_for_current_project = 'Update Columns For Current Project';
$s_update_columns_as_my_default = 'Update Columns as Default for All Projects';
$s_reset_columns_configuration = 'Reset Columns Configuration';
$s_copy_columns_from = 'Copy Columns From';
$s_copy_columns_to = 'Copy Columns To';

# due date
$s_due_date = 'Due Date';
$s_overdue = 'Overdue';

#account_view_page.php
$s_view_account_title = 'User Information';

# view_user_page.php
$s_manage_user = 'Manage User';

# separators
$s_word_separator = '&#32;';

# admin pages
$s_install_information = 'MantisBT Installation Information';
$s_database_information = 'MantisBT Database Information';
$s_path_information = 'MantisBT Path Information';

# months
$s_month_january = 'January';
$s_month_february = 'February';
$s_month_march = 'March';
$s_month_april = 'April';
$s_month_may = 'May';
$s_month_june = 'June';
$s_month_july = 'July';
$s_month_august = 'August';
$s_month_september = 'September';
$s_month_october = 'October';
$s_month_november = 'November';
$s_month_december = 'December';
strings_english.txt (75,182 bytes)   
my_view_inc.php (12,297 bytes)   
<?php
# Mantis - a php based bugtracking system

# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
# Copyright (C) 2002 - 2007  Mantis Team   - mantisbt-dev@lists.sourceforge.net

# Mantis is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Mantis is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Mantis.  If not, see <http://www.gnu.org/licenses/>.

	# --------------------------------------------------------
	# $Id: my_view_inc.php,v 1.18.2.2 2007-10-13 22:35:34 giallu Exp $
	# --------------------------------------------------------
?>
<?php
	$t_core_path = config_get( 'core_path' );

	require_once( $t_core_path . 'current_user_api.php' );
	require_once( $t_core_path . 'bug_api.php' );
	require_once( $t_core_path . 'string_api.php' );
	require_once( $t_core_path . 'date_api.php' );
	require_once( $t_core_path . 'icon_api.php' );
?>
<?php
	$t_filter = current_user_get_bug_filter();

	if ( $t_filter === false ) {
		$t_filter = filter_get_default();
	}

	$t_sort = $t_filter['sort'];
	$t_dir = $t_filter['dir'];

	$t_checkboxes_exist = false;

	$t_icon_path = config_get( 'icon_path' );
	$t_update_bug_threshold = config_get( 'update_bug_threshold' );
	$t_bug_resolved_status_threshold = config_get( 'bug_resolved_status_threshold' );
	$t_hide_status_default = config_get( 'hide_status_default' );
	$t_default_show_changed = config_get( 'default_show_changed' );
?>

<?php
	$c_filter['assigned'] = array(
		'show_category'		=> Array ( '0' => META_FILTER_ANY ),
		'show_severity'		=> Array ( '0' => META_FILTER_ANY ),
		'show_status'		=> Array ( '0' => META_FILTER_ANY ),
		'highlight_changed'	=> $t_default_show_changed,
		'reporter_id'		=> Array ( '0' => META_FILTER_ANY ),
		'handler_id'		=> Array ( '0' => $t_current_user_id ),
		'show_resolution'	=> Array ( '0' => META_FILTER_ANY ),
		'show_build'		=> Array ( '0' => META_FILTER_ANY ),
		'show_version'		=> Array ( '0' => META_FILTER_ANY ),
		'hide_status'		=> Array ( '0' => $t_bug_resolved_status_threshold ),
		'user_monitor'		=> Array ( '0' => META_FILTER_ANY )
	);
	$url_link_parameters['assigned'] = 'handler_id=' . $t_current_user_id . '&amp;hide_status=' . $t_bug_resolved_status_threshold;

	$c_filter['recent_mod'] = array(
		'show_category'		=> Array ( '0' => META_FILTER_ANY ),
		'show_severity'		=> Array ( '0' => META_FILTER_ANY ),
		'show_status'		=> Array ( '0' => META_FILTER_ANY ),
		'highlight_changed'	=> $t_default_show_changed,
		'reporter_id'		=> Array ( '0' => META_FILTER_ANY ),
		'handler_id'		=> Array ( '0' => META_FILTER_ANY ),
		'show_resolution'	=> Array ( '0' => META_FILTER_ANY ),
		'show_build'		=> Array ( '0' => META_FILTER_ANY ),
		'show_version'		=> Array ( '0' => META_FILTER_ANY ),
		'hide_status'		=> Array ( '0' => META_FILTER_NONE ),
		'user_monitor'		=> Array ( '0' => META_FILTER_ANY )
	);
	$url_link_parameters['recent_mod'] = 'hide_status=none';

	$c_filter['reported'] = array(
		'show_category'		=> Array ( '0' => META_FILTER_ANY ),
		'show_severity'		=> Array ( '0' => META_FILTER_ANY ),
		'show_status'		=> Array ( '0' => META_FILTER_ANY ),
		'highlight_changed'	=> $t_default_show_changed,
		'reporter_id'		=> Array ( '0' => $t_current_user_id ),
		'handler_id'		=> Array ( '0' => META_FILTER_ANY ),
		'sort'			=> 'last_updated',
		'show_resolution'	=> Array ( '0' => META_FILTER_ANY ),
		'show_build'		=> Array ( '0' => META_FILTER_ANY ),
		'show_version'		=> Array ( '0' => META_FILTER_ANY ),
		'hide_status'		=> Array ( '0' => $t_hide_status_default ),
		'user_monitor'		=> Array ( '0' => META_FILTER_ANY )
	);
	$url_link_parameters['reported'] = 'reporter_id=' . $t_current_user_id . '&amp;hide_status=' . $t_hide_status_default;

	$c_filter['resolved'] = array(
		'show_category'		=> Array ( '0' => META_FILTER_ANY ),
		'show_severity'		=> Array ( '0' => META_FILTER_ANY ),
		'show_status'		=> Array ( '0' => $t_bug_resolved_status_threshold ),
		'highlight_changed'	=> $t_default_show_changed,
		'reporter_id'		=> Array ( '0' => META_FILTER_ANY ),
		'handler_id'		=> Array ( '0' => META_FILTER_ANY ),
		'show_resolution'	=> Array ( '0' => META_FILTER_ANY ),
		'show_build'		=> Array ( '0' => META_FILTER_ANY ),
		'show_version'		=> Array ( '0' => META_FILTER_ANY ),
		'hide_status'		=> Array ( '0' => $t_hide_status_default ),
		'user_monitor'		=> Array ( '0' => META_FILTER_ANY )
	);
	$url_link_parameters['resolved'] = 'show_status=' . $t_bug_resolved_status_threshold . '&amp;hide_status=' . $t_bug_resolved_status_threshold;

	$c_filter['unassigned'] = array(
		'show_category'		=> Array ( '0' => META_FILTER_ANY ),
		'show_severity'		=> Array ( '0' => META_FILTER_ANY ),
		'show_status'		=> Array ( '0' => META_FILTER_ANY ),
		'highlight_changed'	=> $t_default_show_changed,
		'reporter_id'		=> Array ( '0' => META_FILTER_ANY ),
		'handler_id'		=> Array ( '0' => META_FILTER_NONE ),
		'show_resolution'	=> Array ( '0' => META_FILTER_ANY ),
		'show_build'		=> Array ( '0' => META_FILTER_ANY ),
		'show_version'		=> Array ( '0' => META_FILTER_ANY ),
		'hide_status'		=> Array ( '0' => $t_hide_status_default ),
		'user_monitor'		=> Array ( '0' => META_FILTER_ANY )
	);
	$url_link_parameters['unassigned'] = 'handler_id=[none]' . '&amp;hide_status=' . $t_hide_status_default;

	$c_filter['monitored'] = array(
		'show_category'		=> Array ( '0' => META_FILTER_ANY ),
		'show_severity'		=> Array ( '0' => META_FILTER_ANY ),
		'show_status'		=> Array ( '0' => META_FILTER_ANY ),
		'highlight_changed'	=> $t_default_show_changed,
		'reporter_id'		=> Array ( '0' => META_FILTER_ANY ),
		'handler_id'		=> Array ( '0' => META_FILTER_ANY ),
		'show_resolution'	=> Array ( '0' => META_FILTER_ANY ),
		'show_build'		=> Array ( '0' => META_FILTER_ANY ),
		'show_version'		=> Array ( '0' => META_FILTER_ANY ),
		'hide_status'		=> Array ( '0' => $t_hide_status_default ),
		'user_monitor'		=> Array ( '0' => $t_current_user_id )
	);
	$url_link_parameters['monitored'] = 'user_monitor=' . $t_current_user_id . '&amp;hide_status=' . $t_hide_status_default;


	$c_filter['feedback'] = array(
		'show_category'		=> Array ( '0' => META_FILTER_ANY ),
		'show_severity'		=> Array ( '0' => META_FILTER_ANY ),
		'show_status'		=> Array ( '0' => FEEDBACK ),
		'highlight_changed'	=> $t_default_show_changed,
		'reporter_id'		=> Array ( '0' => $t_current_user_id ),
		'handler_id'		=> Array ( '0' => META_FILTER_ANY ),
		'show_resolution'	=> Array ( '0' => META_FILTER_ANY ),
		'show_build'		=> Array ( '0' => META_FILTER_ANY ),
		'show_version'		=> Array ( '0' => META_FILTER_ANY ),
		'hide_status'		=> Array ( '0' => $t_hide_status_default ),
		'user_monitor'		=> Array ( '0' => META_FILTER_ANY )
	);
	$url_link_parameters['feedback'] = 'reporter_id=' . $t_current_user_id . '&amp;show_status=' . FEEDBACK . '&amp;hide_status=' . $t_hide_status_default;

	$c_filter['verify'] = array(
		'show_category'		=> Array ( '0' => META_FILTER_ANY ),
		'show_severity'		=> Array ( '0' => META_FILTER_ANY ),
		'show_status'		=> Array ( '0' => $t_bug_resolved_status_threshold ),
		'highlight_changed'	=> $t_default_show_changed,
		'reporter_id'		=> Array ( '0' => $t_current_user_id ),
		'handler_id'		=> Array ( '0' => META_FILTER_ANY ),
		'show_resolution'	=> Array ( '0' => META_FILTER_ANY ),
		'show_build'		=> Array ( '0' => META_FILTER_ANY ),
		'show_version'		=> Array ( '0' => META_FILTER_ANY ),
		'hide_status'		=> Array ( '0' => $t_hide_status_default ),
		'user_monitor'		=> Array ( '0' => META_FILTER_ANY )
	);
	$url_link_parameters['verify'] = 'reporter_id=' . $t_current_user_id . '&amp;show_status=' . $t_bug_resolved_status_threshold;

        $rows = filter_get_bug_rows ( $f_page_number, $t_per_page, $t_page_count, $t_bug_count, $c_filter[$t_box_title]  );
		$t_filter = array_merge( $c_filter[$t_box_title], $t_filter );

        $box_title = lang_get( 'my_view_title_' . $t_box_title );
?>


<?php # -- ====================== BUG LIST ========================= -- ?>

<table class="width100" cellspacing="1">
<?php # -- Navigation header row -- ?>
<tr>
	<?php # -- Viewing range info -- ?>
	<td class="form-title" colspan="2">
		<?php
			echo '<a class="subtle" href="view_all_set.php?type=1&amp;temporary=y&amp;' . $url_link_parameters[$t_box_title] . '">';
			echo $box_title;
			echo '</a>';
			echo ' [';
			echo '<a class="subtle" href="view_all_set.php?type=1&amp;temporary=y&amp;' . $url_link_parameters[$t_box_title] . '" target="_blank">';
			echo '^';
			echo '</a>]';
		?>
		<?php
			if ( sizeof( $rows ) > 0 ) {
				$v_start = $t_filter['per_page'] * ($f_page_number-1) +1;
				$v_end   = $v_start + sizeof( $rows ) -1;
			} else {
				$v_start = 0;
				$v_end   = 0;
			}
			echo "($v_start - $v_end / $t_bug_count)";
		?>
	</td>
</tr>

<?php mark_time( 'begin loop' ); ?>
<?php # -- Loop over bug rows and create $v_* variables -- ?>
<?php
	for($i=0; $i < sizeof( $rows ); $i++) {
		# prefix bug data with v_

		extract( $rows[$i], EXTR_PREFIX_ALL, 'v' );

		$t_summary = string_attribute( $v_summary );
		$t_last_updated = date( config_get( 'normal_date_format' ), $v_last_updated );

		# choose color based on status
		$status_color = get_status_color( $v_status );

		# grab the bugnote count
		# @@@ thraxisp - not used???
#		$bugnote_info = bug_get_bugnote_stats( $v_id );

		# Check for attachments
		$t_attachment_count = 0;
		if (  ( file_can_view_bug_attachments( $v_id ) ) ) {
		   $t_attachment_count = file_bug_attachment_count( $v_id );
		}

		# grab the project name
		$project_name = project_get_field( $v_project_id, 'name' );
?>

<tr bgcolor="<?php echo $status_color ?>">
	<?php # -- Bug ID and details link + Pencil shortcut -- ?>
	<td class="center" valign="top" width ="0" nowrap>
		<span class="small">
		<?php
			print_bug_link( $v_id );

			echo '<br />';

			if ( !bug_is_readonly( $v_id ) && access_has_bug_level( $t_update_bug_threshold, $v_id ) ) {
				echo '<a href="' . string_get_bug_update_url( $v_id ) . '"><img border="0" src="' . $t_icon_path . 'update.png' . '" alt="' . lang_get( 'update_bug_button' ) . '" /></a>';
			}

			if ( ON == config_get( 'show_priority_text' ) ) {
				print_formatted_priority_string( $v_status, $v_priority );
			} else {
				print_status_icon( $v_priority );
			}

			if ( 0 < $t_attachment_count ) {
				echo '<a href="' . string_get_bug_view_url( $v_id ) . '#attachments">';
				echo '<img border="0" src="' . $t_icon_path . 'attachment.png' . '"';
				echo ' alt="' . lang_get( 'attachment_alt' ) . '"';
				echo ' title="' . $t_attachment_count . ' ' . lang_get( 'attachments' ) . '"';
				echo ' />';
				echo '</a>';
			}
			if ( VS_PRIVATE == $v_view_state ) {
				echo '<img src="' . $t_icon_path . 'protected.gif" width="8" height="15" alt="' . lang_get( 'private' ) . '" />';
			}
		?>
		</span>
	</td>

	<?php # -- Summary -- ?>
	<td class="left" valign="top" width="100%">
		<span class="small">
		<?php
			echo $t_summary;
		?>
		<br />
		<?php
			# type project name if viewing 'all projects' or bug is in subproject
			if ( ON == config_get( 'show_bug_project_links' ) &&
				helper_get_current_project() != $v_project_id ) {
				echo '[';
				print( $project_name );
				echo '] ';
			}
			echo string_display( $v_category );

			if ( $v_last_updated > strtotime( '-'.$t_filter['highlight_changed'].' hours' ) ) {
				echo ' - <b>' . $t_last_updated . '</b>';
			} else {
				echo ' - ' . $t_last_updated;
			}
		?>
		</span>
	</td>
</tr>
<?php # -- end of Repeating bug row -- ?>
<?php
	}
?>
<?php # -- ====================== end of BUG LIST ========================= -- ?>

</table>

<?php mark_time( 'end loop' ); ?>
my_view_inc.php (12,297 bytes)   

Activities

joel_li

joel_li

2015-01-19 22:29

reporter   ~0042210

Hi,
Have uploaded the files I have changes to allow textarea custom fields.

Regards,
Joel

dregad

dregad

2015-01-20 03:45

developer   ~0042214

I am unable to get issues under My Views page to be displayed.
There is no error but they do not show up.

What does the page actually display ?

FYI, customised the Mantis 1.2.18 version with the textarea patch from this helpdesk.

Does it work if you disable / remove these customizations ?

joel_li

joel_li

2015-01-20 23:58

reporter   ~0042220

Hi Dregad,

I have removed the text area patch and still am unable to view the issues on the My View Page.

To note, I upgraded my old 1.1.x mantis to this latest 1.2.18.

Regards,
Joel Li

dregad

dregad

2015-01-21 09:12

developer   ~0042225

The provided information is not sufficient to provide any help in resolving the issue. A complete and detailed description is required to get a clear understanding of the problem.

Please explain what you actually get when you open the my view page (a screenshot may help).

In addition to the 'textarea patch' are there other customizations ?

  • Relevant customizations (e.g. changes in config_inc.php, etc)
  • Installed plugins or custom functions ?
  • Was the MantisBT source code modified in any way ?
  • are there any errors in the server logs ?
joel_li

joel_li

2015-01-22 01:53

reporter   ~0042233

Hi Dregad,
I troublehhoot and found that it is this file in the core folder that was the my_view_inc.php file causing the problem.

The previous installation was done 4~5 years ago and I am unsure if the my_view_inc.php file is an additional file my organisation added or part of the old mantis 1.1.x file.

All I know is that once I removed it, the My View page works again.

I have attached the file.

Regards,
Joel Li

joel_li

joel_li

2015-01-22 01:55

reporter   ~0042234

  • Relevant customizations (e.g. changes in config_inc.php, etc)
    We customs the Categories, Status and Type Dropdown fields. But even when I removed them, the issue remained.

  • Installed plugins or custom functions ?
    No additional plugins were installed. But we carried over the old plugins from mantis 1.1.x.

  • Was the MantisBT source code modified in any way ?
    No, unless it was an old file copied over from the old Mantis 1.1.x. In the end the error was due to a my_view_inc.php file.

  • are there any errors in the server logs ?
    No error in the server log.

atrol

atrol

2015-01-22 03:01

developer   ~0042235

This is how to upgrade from 1.1.x to 1.2.x
https://www.mantisbt.org/docs/master-1.2.x/en/administration_guide.html#ADMIN.INSTALL.UPGRADE
Don't replace any files of 1.2.x by older versions from 1.1.x!

But we carried over the old plugins from mantis 1.1.x.
What exactly does this mean?
The original MantisBT 1.1.x did not offer plugins.
It seems you used an unsupported 3rd party plugin system.

dregad

dregad

2015-01-22 03:09

developer   ~0042236

Joel,

The my_view_inc.php file still exists in 1.2.18, but the file you uploaded is indeed an old version of it, and looking at the $Id in the header, I don't find a trace of it in the repository.

The existence of an old file leads me to believe that you did not exactly follow the upgrade process outlined in the admin guide, namely step 3 of pre-install/upgrade tasks [1] - you should not perform the upgrade "in place", but rather install the new version in a separate directory and copy the existing and relevant configs to the new location.

With regards to plugins, please note that 1.1.x plugin system is incompatible with Mantis 1.2, and unsupported. I strongly recommend you remove that and look for alternatives.

[1] http://mantisbt.org/docs/master-1.2.x/en/administration_guide/admin.install.preinstall.html

dregad

dregad

2015-01-22 03:09

developer   ~0042237

XPOST !!!

joel_li

joel_li

2015-01-22 03:17

reporter   ~0042239

Thanks for your help.

Please close the issue.

I will start again and follow the installation steps mentioned in the url above and port the database across.

Thanks and Regards,
Joel Li