/
print_all_bug_options_inc.php
201 lines (176 loc) · 5.09 KB
/
print_all_bug_options_inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?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/>.
/**
* Print all bug options include file
* @package MantisBT
* @copyright Copyright 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
* @copyright Copyright 2002 MantisBT Team - mantisbt-dev@lists.sourceforge.net
* @link http://www.mantisbt.org
*
* @uses authentication_api.php
* @uses database_api.php
* @uses form_api.php
* @uses helper_api.php
* @uses lang_api.php
* @uses string_api.php
* @uses user_api.php
* @uses utility_api.php
*/
if( !defined( 'PRINT_ALL_BUG_OPTIONS_INC_ALLOW' ) ) {
return;
}
require_api( 'authentication_api.php' );
require_api( 'database_api.php' );
require_api( 'form_api.php' );
require_api( 'helper_api.php' );
require_api( 'lang_api.php' );
require_api( 'string_api.php' );
require_api( 'user_api.php' );
require_api( 'utility_api.php' );
/**
* this function only gets the field names, by appending strings
* @return array
*/
function get_field_names() {
return array (
'id',
'category',
'severity',
'reproducibility',
'date_submitted',
'last_update',
'reporter',
'assigned_to',
'priority',
'status',
'build',
'projection',
'eta',
'platform',
'os',
'os_build',
'product_version',
'resolution',
'duplicate_id',
'summary',
'description',
'steps_to_reproduce',
'additional_information',
'attached_files',
'bugnote_title',
'bugnote_date',
'bugnote_description',
'time_tracking' );
}
/**
* Edit Printing preferences
* @param integer $p_user_id A valid user identifier.
* @param boolean $p_error_if_protected Error if account protected.
* @param string $p_redirect_url Redirect URL.
* @return void
*/
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();
}
# protected account check
if( $p_error_if_protected ) {
user_ensure_unprotected( $p_user_id );
}
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();
$t_field_name_count = count( $t_field_name_arr );
# Grab the data
$t_query = 'SELECT print_pref FROM {user_print_pref} WHERE user_id=' . db_param();
$t_result = db_query( $t_query, array( $p_user_id ) );
$t_row = db_fetch_array( $t_result );
## OOPS, No entry in the database yet. Lets make one
if( !$t_row ) {
# create a default array, same size than $t_field_name
for( $i=0; $i<$t_field_name_count; $i++ ) {
$t_default_arr[$i] = 1 ;
}
$t_default = implode( '', $t_default_arr ) ;
# all fields are added by default
$t_query = 'INSERT
INTO {user_print_pref}
(user_id, print_pref)
VALUES
(' . db_param() . ',' . db_param() . ')';
db_query( $t_query, array( $p_user_id, $t_default ) );
# Rerun select query
$t_query = 'SELECT print_pref FROM {user_print_pref} WHERE user_id=' . db_param();
$t_result = db_query( $t_query, array( $p_user_id ) );
$t_row = db_fetch_array( $t_result );
}
# putting the query result into an array with the same size as $t_fields_arr
$t_prefs = $t_row['print_pref'];
# Account Preferences Form BEGIN
?>
<br />
<div>
<form method="post" action="print_all_bug_options_update.php">
<?php echo form_security_field( 'print_all_bug_options_update' ) ?>
<input type="hidden" name="user_id" value="<?php echo $p_user_id ?>" />
<input type="hidden" name="redirect_url" value="<?php echo string_attribute( $p_redirect_url ) ?>" />
<table class="width75" cellspacing="1">
<tr>
<td class="bold">
<?php echo lang_get( 'printing_preferences_title' ) ?>
</td>
<td class="pull-right">
</td>
</tr>
<?php # display the checkboxes
for( $i=0; $i <$t_field_name_count; $i++ ) {
echo '<tr>';
?>
<th class="category">
<?php echo lang_get( $t_field_name_arr[$i] ) ?>
</th>
<td>
<input type="checkbox" name="<?php echo 'print_' . $t_field_name_arr[$i]; ?>"
<?php
if( isset( $t_prefs[$i] ) && ( $t_prefs[$i]==1 ) ) {
echo 'checked="checked"';
}
?>
/>
</td>
</tr>
<?php
}
?>
<tr>
<td> </td>
<td>
<input type="submit" class="button" value="<?php echo lang_get( 'update_prefs_button' ) ?>" />
</td>
</tr>
</table>
</form>
</div>
<br />
<div class="border center">
<form method="post" action="print_all_bug_options_reset.php">
<?php echo form_security_field( 'print_all_bug_options_reset' ) ?>
<input type="submit" class="button" value="<?php echo lang_get( 'reset_prefs_button' ) ?>" />
</form>
</div>
<?php
}