2 # MantisBT - A PHP based bugtracking system
4 # MantisBT is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 2 of the License, or
7 # (at your option) any later version.
9 # MantisBT is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
19 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
20 * @copyright Copyright (C) 2002 - 2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net
21 * @link http://www.mantisbt.org
23 * @uses authentication_api.php
24 * @uses database_api.php
26 * @uses helper_api.php
28 * @uses string_api.php
30 * @uses utility_api.php
33 if ( !defined( 'PRINT_ALL_BUG_OPTIONS_INC_ALLOW' ) ) {
37 require_api( 'authentication_api.php' );
38 require_api( 'database_api.php' );
39 require_api( 'form_api.php' );
40 require_api( 'helper_api.php' );
41 require_api( 'lang_api.php' );
42 require_api( 'string_api.php' );
43 require_api( 'user_api.php' );
44 require_api( 'utility_api.php' );
46 # this function only gets the field names, by appending strings
47 function get_field_names()
50 return $t_arr = array (
73 'additional_information',
77 'bugnote_description',
82 function edit_printing_prefs( $p_user_id = null, $p_error_if_protected = true, $p_redirect_url = '' )
84 if ( null === $p_user_id ) {
85 $p_user_id = auth_get_current_user_id();
88 $c_user_id = db_prepare_int( $p_user_id );
90 # protected account check
91 if ( $p_error_if_protected ) {
92 user_ensure_unprotected( $p_user_id );
95 $t_user_print_pref_table = db_get_table( 'user_print_pref' );
97 if ( is_blank( $p_redirect_url ) ) {
98 $p_redirect_url = 'print_all_bug_page.php';
101 # get the fields list
102 $t_field_name_arr = get_field_names();
103 $field_name_count = count( $t_field_name_arr );
106 $query = "SELECT print_pref
107 FROM $t_user_print_pref_table
108 WHERE user_id=" . db_param();
109 $result = db_query_bound( $query, Array( $c_user_id ) );
111 ## OOPS, No entry in the database yet. Lets make one
112 if ( 0 == db_num_rows( $result ) ) {
114 # create a default array, same size than $t_field_name
115 for ($i=0 ; $i<$field_name_count ; $i++
) {
116 $t_default_arr[$i] = 1 ;
118 $t_default = implode( '', $t_default_arr ) ;
120 # all fields are added by default
122 INTO $t_user_print_pref_table
123 (user_id, print_pref)
125 (" . db_param() . "," . db_param() . ")";
127 $result = db_query_bound( $query, Array( $c_user_id, $t_default ) );
130 $query = "SELECT print_pref
131 FROM $t_user_print_pref_table
132 WHERE user_id=" . db_param();
133 $result = db_query_bound( $query, Array( $c_user_id ) );
136 # putting the query result into an array with the same size as $t_fields_arr
137 $row = db_fetch_array( $result );
138 $t_prefs = $row['print_pref'];
140 # Account Preferences Form BEGIN
145 <form method
="post" action
="print_all_bug_options_update.php">
146 <?php
echo form_security_field( 'print_all_bug_options_update' ) ?
>
147 <input type
="hidden" name
="user_id" value
="<?php echo $p_user_id ?>" />
148 <input type
="hidden" name
="redirect_url" value
="<?php echo string_attribute( $p_redirect_url ) ?>" />
149 <table
class="width75" cellspacing
="1">
151 <td
class="form-title">
152 <?php
echo lang_get( 'printing_preferences_title' ) ?
>
159 <?php
# display the checkboxes
160 for ($i=0 ; $i <$field_name_count ; $i++
) {
162 printf ( '<tr %s>', helper_alternate_class( $i ) );
165 <th
class="category">
166 <?php
echo lang_get( $t_field_name_arr[$i] ) ?
>
169 <input type
="checkbox" name
="<?php echo 'print_' . $t_field_name_arr[$i]; ?>"
170 <?php
if ( isset( $t_prefs[$i] ) && ( $t_prefs[$i]==1 ) ) echo 'checked="checked"' ?
> />
180 <input type
="submit" class="button" value
="<?php echo lang_get( 'update_prefs_button' ) ?>" />
189 <div
class="border center">
190 <form method
="post" action
="print_all_bug_options_reset.php">
191 <?php
echo form_security_field( 'print_all_bug_options_reset' ) ?
>
192 <input type
="submit" class="button" value
="<?php echo lang_get( 'reset_prefs_button' ) ?>" />