/
print_all_bug_options_inc.php
185 lines (159 loc) · 5.15 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
<?php
# Mantis - a php based bugtracking system
# Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
# Copyright (C) 2002 - 2003 Mantis Team - mantisbt-dev@lists.sourceforge.net
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details
?>
<?php
require_once( 'core.php' );
require_once( $g_core_path . 'current_user_api.php' );
?>
<?php
# this function only gets the field names, by appending strings
function get_field_names()
{
global $s_printing_preferences_title,
$s_id, $s_category, $s_severity, $s_reproducibility,
$s_date_submitted, $s_last_update, $s_reporter, $s_assigned_to,
$s_priority, $s_resolution, $s_status, $s_duplicate_id,
$s_os, $s_projection, $s_os_version, $s_eta, $s_product_version,
$s_build, $s_summary, $s_description,
$s_steps_to_reproduce, $s_additional, $s_information,
$s_platform, $s_attached_files, $s_bugnote_title,
$s_bugnote_date, $s_bugnote_description ;
#currently 27 fields
return $t_arr = array ( $s_id,
$s_category,
$s_severity,
$s_reproducibility,
$s_date_submitted,
$s_last_update,
$s_reporter,
$s_assigned_to,
$s_priority,
$s_status,
$s_build,
$s_projection,
$s_eta,
$s_platform,
$s_os,
$s_os_version,
$s_product_version,
$s_resolution,
$s_duplicate_id,
$s_summary,
$s_description,
$s_steps_to_reproduce,
$s_additional.'_'.$s_information,
$s_attached_files,
$s_bugnote_title,
$s_bugnote_date,
$s_bugnote_description) ;
}
function edit_printing_prefs($p_user_id = 0, $p_error_if_protected = true, $p_redirect_url = '')
{
global $g_mantis_user_print_pref_table, $g_default_advanced_report,
$g_default_advanced_view,
$g_enable_email_notification,
$s_printing_preferences_title,
$s_id, $s_category, $s_severity, $s_reproducibility,
$s_date_submitted, $s_last_update, $s_reporter, $s_assigned_to,
$s_priority, $s_resolution, $s_status, $s_duplicate_id,
$s_os, $s_projection, $s_os_version, $s_eta, $s_product_version,
$s_build, $s_summary, $s_description,
$s_steps_to_reproduce, $s_additional, $s_information,
$s_platform, $s_attached_files, $s_update_prefs_button, $s_reset_prefs_button;
$c_user_id = (integer)$p_user_id;
if ($c_user_id == 0) {
$c_user_id = current_user_get_field( 'id' );
}
$t_redirect_url = $p_redirect_url;
if ( strlen ($t_redirect_url)== 0 ) {
$t_redirect_url = 'print_all_bug_page.php';
}
# protected account check
if ( $p_error_if_protected ) {
user_ensure_unprotected( $p_user_id );
}
# 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 $g_mantis_user_print_pref_table
WHERE user_id='$c_user_id'";
$result = db_query($query);
## 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 $g_mantis_user_print_pref_table
(user_id, print_pref)
VALUES
('$c_user_id','$t_default')";
$result = db_query($query);
# Rerun select query
$query = "SELECT print_pref
FROM $g_mantis_user_print_pref_table
WHERE user_id='$c_user_id'";
$result = db_query($query);
}
# putting the query result into an array with the same size as $t_fields_arr
$row = db_fetch_array($result);
$t_prefs = $row[0];
?>
<?php # Account Preferences Form BEGIN ?>
<?php $t_index_count=0; ?>
<br />
<div align="center">
<form method="post" action="print_all_bug_options_update.php">
<input type="hidden" name="user_id" value="<?php echo $c_user_id ?>" />
<input type="hidden" name="redirect_url" value="<?php echo $t_redirect_url ?>" />
<table class="width75" cellspacing="1">
<tr>
<td class="form-title">
<?php echo $s_printing_preferences_title ?>
</td>
<td class="right">
</td>
</tr>
<?php # display the checkboxes
for ($i=0 ; $i <$field_name_count ; $i++) {
$row_color = $i%2+1;
PRINT "<tr class=\"row-($row_color)\">";
?>
<td class="category">
<?php echo $t_field_name_arr[$i] ?>
</td>
<td>
<?php # @@@ REWORK Code should not span two lines except in extreme cases. Build this into a variable then print it out. ?>
<?php //echo 'print_'.strtolower(str_replace(' ','_', $t_field_name_arr[$i])); ?>
<input type="checkbox" name="<?php echo 'print_'.strtolower(str_replace(' ','_', $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" value="<?php echo $s_update_prefs_button ?>" />
</td>
</tr>
</table>
</form>
</div>
<br />
<div class="border-center">
<form method="post" action="print_all_bug_options_reset.php">
<input type="submit" value="<?php echo $s_reset_prefs_button ?>" />
</form>
</div>
<?php } # end of edit_printing_prefs() ?>