.
/**
* @package MantisBT
* @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
*/
require_once( 'current_user_api.php' );
# this function only gets the field names, by appending strings
function get_field_names()
{
#currently 27 fields
return $t_arr = array (
'id',
'category',
'severity',
'reproducibility',
'date_submitted',
'last_update',
'reporter',
'assigned_to',
'priority',
'status',
'build',
'projection',
'eta',
'platform',
'os',
'os_version',
'product_version',
'resolution',
'duplicate_id',
'summary',
'description',
'steps_to_reproduce',
'additional_information',
'attached_files',
'bugnote_title',
'bugnote_date',
'bugnote_description',
'time_tracking' );
}
function edit_printing_prefs( $p_user_id = null, $p_error_if_protected = true, $p_redirect_url = '' )
{
if ( null === $p_user_id ) {
$p_user_id = auth_get_current_user_id();
}
$c_user_id = db_prepare_int( $p_user_id );
# protected account check
if ( $p_error_if_protected ) {
user_ensure_unprotected( $p_user_id );
}
$t_user_print_pref_table = db_get_table( 'mantis_user_print_pref_table' );
if ( is_blank( $p_redirect_url ) ) {
$p_redirect_url = 'print_all_bug_page.php';
}
# get the fields list
$t_field_name_arr = get_field_names();
$field_name_count = count( $t_field_name_arr );
# Grab the data
$query = "SELECT print_pref
FROM $t_user_print_pref_table
WHERE user_id=" . db_param();
$result = db_query_bound( $query, Array( $c_user_id ) );
## OOPS, No entry in the database yet. Lets make one
if ( 0 == db_num_rows( $result ) ) {
# create a default array, same size than $t_field_name
for ($i=0 ; $i<$field_name_count ; $i++) {
$t_default_arr[$i] = 1 ;
}
$t_default = implode( '', $t_default_arr ) ;
# all fields are added by default
$query = "INSERT
INTO $t_user_print_pref_table
(user_id, print_pref)
VALUES
(" . db_param() . "," . db_param() . ")";
$result = db_query_bound( $query, Array( $c_user_id, $t_default ) );
# Rerun select query
$query = "SELECT print_pref
FROM $t_user_print_pref_table
WHERE user_id=" . db_param();
$result = db_query_bound( $query, Array( $c_user_id ) );
}
# putting the query result into an array with the same size as $t_fields_arr
$row = db_fetch_array( $result );
$t_prefs = $row['print_pref'];
# Account Preferences Form BEGIN
$t_index_count=0;
?>