SOAP API: do not try to unserialize an invalid filter
[mantis.git] / bug_change_status_page.php
blob25bc3aec1bf5ee596d492cacc83a42192ec5a1b2
1 <?php
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/>.
17 /**
18 * @package MantisBT
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 core.php
24 * @uses access_api.php
25 * @uses authentication_api.php
26 * @uses bug_api.php
27 * @uses config_api.php
28 * @uses constant_inc.php
29 * @uses custom_field_api.php
30 * @uses date_api.php
31 * @uses event_api.php
32 * @uses form_api.php
33 * @uses gpc_api.php
34 * @uses helper_api.php
35 * @uses html_api.php
36 * @uses lang_api.php
37 * @uses print_api.php
38 * @uses relationship_api.php
39 * @uses sponsorship_api.php
40 * @uses version_api.php
43 /**
44 * MantisBT Core API's
46 require_once( 'core.php' );
47 require_api( 'access_api.php' );
48 require_api( 'authentication_api.php' );
49 require_api( 'bug_api.php' );
50 require_api( 'config_api.php' );
51 require_api( 'constant_inc.php' );
52 require_api( 'custom_field_api.php' );
53 require_api( 'date_api.php' );
54 require_api( 'event_api.php' );
55 require_api( 'form_api.php' );
56 require_api( 'gpc_api.php' );
57 require_api( 'helper_api.php' );
58 require_api( 'html_api.php' );
59 require_api( 'lang_api.php' );
60 require_api( 'print_api.php' );
61 require_api( 'relationship_api.php' );
62 require_api( 'sponsorship_api.php' );
63 require_api( 'version_api.php' );
65 $g_allow_browser_cache = 1;
67 $f_bug_id = gpc_get_int( 'id' );
68 $t_bug = bug_get( $f_bug_id );
70 $tpl_file = __FILE__;
71 $tpl_mantis_dir = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
72 $tpl_show_page_header = false;
73 $tpl_force_readonly = true;
74 $tpl_fields_config_option = 'bug_change_status_page_fields';
76 if( $t_bug->project_id != helper_get_current_project() ) {
77 # in case the current project is not the same project of the bug we are viewing...
78 # ... override the current project. This to avoid problems with categories and handlers lists etc.
79 $g_project_override = $t_bug->project_id;
82 $f_new_status = gpc_get_int( 'new_status' );
83 $f_reopen_flag = gpc_get_int( 'reopen_flag', OFF );
85 $t_current_user_id = auth_get_current_user_id();
87 if ( !( ( access_has_bug_level( access_get_status_threshold( $f_new_status, bug_get_field( $f_bug_id, 'project_id' ) ), $f_bug_id ) ) ||
88 ( ( bug_get_field( $f_bug_id, 'reporter_id' ) == $t_current_user_id ) &&
89 ( ( ON == config_get( 'allow_reporter_reopen' ) ) ||
90 ( ON == config_get( 'allow_reporter_close' ) ) ) ) ||
91 ( ( ON == $f_reopen_flag ) && ( access_has_bug_level( config_get( 'reopen_bug_threshold' ), $f_bug_id ) ) )
92 ) ) {
93 access_denied();
96 $t_can_update_due_date = access_has_bug_level( config_get( 'due_date_update_threshold' ), $f_bug_id );
97 if ( $t_can_update_due_date ) {
98 require_js( 'jscalendar/calendar.js' );
99 require_js( 'jscalendar/lang/calendar-en.js' );
100 require_js( 'jscalendar/calendar-setup.js' );
101 require_css( 'calendar-blue.css' );
104 # get new issue handler if set, otherwise default to original handler
105 $f_handler_id = gpc_get_int( 'handler_id', bug_get_field( $f_bug_id, 'handler_id' ) );
107 if ( config_get( 'bug_assigned_status' ) == $f_new_status ) {
108 $t_bug_sponsored = sponsorship_get_amount( sponsorship_get_all_ids( $f_bug_id ) ) > 0;
109 if ( $t_bug_sponsored ) {
110 if ( !access_has_bug_level( config_get( 'assign_sponsored_bugs_threshold' ), $f_bug_id ) ) {
111 trigger_error( ERROR_SPONSORSHIP_ASSIGNER_ACCESS_LEVEL_TOO_LOW, ERROR );
115 if ( $f_handler_id != NO_USER ) {
116 if ( !access_has_bug_level( config_get( 'handle_bug_threshold' ), $f_bug_id, $f_handler_id ) ) {
117 trigger_error( ERROR_HANDLER_ACCESS_TOO_LOW, ERROR );
120 if ( $t_bug_sponsored ) {
121 if ( !access_has_bug_level( config_get( 'handle_sponsored_bugs_threshold' ), $f_bug_id, $f_handler_id ) ) {
122 trigger_error( ERROR_SPONSORSHIP_HANDLER_ACCESS_LEVEL_TOO_LOW, ERROR );
128 $t_status_label = str_replace( " ", "_", MantisEnum::getLabel( config_get( 'status_enum_string' ), $f_new_status ) );
129 $t_resolved = config_get( 'bug_resolved_status_threshold' );
130 $t_closed = config_get( 'bug_closed_status_threshold' );
132 $t_bug = bug_get( $f_bug_id );
134 html_page_top( bug_format_summary( $f_bug_id, SUMMARY_CAPTION ) );
136 print_recently_visited();
139 <br />
140 <div>
141 <form id="bug-change-status-form" name="bug_change_status_form" method="post" action="bug_update.php">
142 <?php echo form_security_field( 'bug_update' ) ?>
143 <table class="width75" cellspacing="1">
145 <!-- Title -->
146 <tr>
147 <td class="form-title" colspan="2">
148 <input type="hidden" name="bug_id" value="<?php echo $f_bug_id ?>" />
149 <input type="hidden" name="status" value="<?php echo $f_new_status ?>" />
150 <?php echo lang_get( $t_status_label . '_bug_title' ) ?>
151 </td>
152 </tr>
154 <?php
155 if ( $f_new_status >= $t_resolved ) {
156 if ( relationship_can_resolve_bug( $f_bug_id ) == false ) {
157 echo "<tr><td colspan=\"2\">" . lang_get( 'relationship_warning_blocking_bugs_not_resolved_2' ) . "</td></tr>";
162 <?php
163 $t_current_resolution = $t_bug->resolution;
164 $t_bug_is_open = $t_current_resolution < $t_resolved;
165 if ( ( $f_new_status >= $t_resolved ) && ( ( $f_new_status < $t_closed ) || ( $t_bug_is_open ) ) ) { ?>
166 <!-- Resolution -->
167 <tr <?php echo helper_alternate_class() ?>>
168 <th class="category">
169 <?php echo lang_get( 'resolution' ) ?>
170 </th>
171 <td>
172 <select name="resolution">
173 <?php
174 $t_resolution = $t_bug_is_open ? config_get( 'bug_resolution_fixed_threshold' ) : $t_current_resolution;
176 $t_relationships = relationship_get_all_src( $f_bug_id );
177 foreach( $t_relationships as $t_relationship ) {
178 if ( $t_relationship->type == BUG_DUPLICATE ) {
179 $t_resolution = config_get( 'bug_duplicate_resolution' );
180 break;
184 print_enum_string_option_list( 'resolution', $t_resolution );
186 </select>
187 </td>
188 </tr>
189 <?php } ?>
191 <?php
192 if ( $f_new_status >= $t_resolved
193 && $f_new_status < $t_closed
194 && $t_resolution != config_get( 'bug_duplicate_resolution' ) ) { ?>
195 <!-- Duplicate ID -->
196 <tr <?php echo helper_alternate_class() ?>>
197 <th class="category">
198 <?php echo lang_get( 'duplicate_id' ) ?>
199 </th>
200 <td>
201 <input type="text" name="duplicate_id" maxlength="10" />
202 </td>
203 </tr>
204 <?php } ?>
206 <?php
207 if ( access_has_bug_level( config_get( 'update_bug_assign_threshold', config_get( 'update_bug_threshold' ) ), $f_bug_id ) ) {
208 $t_suggested_handler_id = $t_bug->handler_id;
210 if ( $t_suggested_handler_id == NO_USER && access_has_bug_level( config_get( 'handle_bug_threshold' ), $f_bug_id ) ) {
211 $t_suggested_handler_id = $t_current_user_id;
214 <!-- Assigned To -->
215 <tr <?php echo helper_alternate_class() ?>>
216 <th class="category">
217 <?php echo lang_get( 'assigned_to' ) ?>
218 </th>
219 <td>
220 <select name="handler_id">
221 <option value="0"></option>
222 <?php print_assign_to_option_list( $t_suggested_handler_id, $t_bug->project_id ) ?>
223 </select>
224 </td>
225 </tr>
226 <?php } ?>
228 <!-- Due date -->
229 <?php if ( $t_can_update_due_date ) {
230 $t_date_to_display = '';
231 if ( !date_is_null( $t_bug->due_date ) ) {
232 $t_date_to_display = date( config_get( 'calendar_date_format' ), $t_bug->due_date );
235 <tr <?php echo helper_alternate_class() ?>>
236 <th class="category">
237 <?php print_documentation_link( 'due_date' ) ?>
238 </th>
239 <td>
240 <?php echo "<input " . helper_get_tab_index() . " type=\"text\" id=\"due_date\" name=\"due_date\" class=\"datetime\" size=\"20\" maxlength=\"16\" value=\"" . $t_date_to_display . "\" />" ?>
241 </td>
242 </tr>
243 <?php } ?>
245 <!-- Custom Fields -->
246 <?php
247 /** @todo thraxisp - I undid part of the change for #5068 for #5527
248 * We really need to say what fields are shown in which statusses. For now,
249 * this page will show required custom fields in update mode, or
250 * display or required fields on resolve or close
252 $t_custom_status_label = "update"; # Don't show custom fields by default
253 if ( ( $f_new_status == $t_resolved ) &&
254 ( $f_new_status < $t_closed ) ) {
255 $t_custom_status_label = "resolved";
257 if ( $t_closed == $f_new_status ) {
258 $t_custom_status_label = "closed";
261 $t_related_custom_field_ids = custom_field_get_linked_ids( bug_get_field( $f_bug_id, 'project_id' ) );
263 foreach( $t_related_custom_field_ids as $t_id ) {
264 $t_def = custom_field_get_definition( $t_id );
265 $t_display = $t_def['display_' . $t_custom_status_label];
266 $t_require = $t_def['require_' . $t_custom_status_label];
268 if ( ( "update" == $t_custom_status_label ) && ( !$t_require ) ) {
269 continue;
271 if ( in_array( $t_custom_status_label, array( "resolved", "closed" ) ) && !( $t_display || $t_require ) ) {
272 continue;
274 if ( custom_field_has_write_access( $t_id, $f_bug_id ) ) {
276 <tr <?php echo helper_alternate_class() ?>>
277 <th class="category">
278 <?php if ( $t_require ) {?><span class="required">*</span><?php } echo lang_get_defaulted( $t_def['name'] ) ?>
279 </th>
280 <td>
281 <?php
282 print_custom_field_input( $t_def, $f_bug_id );
284 </td>
285 </tr>
286 <?php
287 } # custom_field_has_write_access( $t_id, $f_bug_id ) )
288 else if ( custom_field_has_read_access( $t_id, $f_bug_id ) ) {
290 <tr <?php echo helper_alternate_class() ?>>
291 <th class="category">
292 <?php echo lang_get_defaulted( $t_def['name'] ) ?>
293 </th>
294 <td>
295 <?php print_custom_field_value( $t_def, $t_id, $f_bug_id ); ?>
296 </td>
297 </tr>
298 <?php
299 } # custom_field_has_read_access( $t_id, $f_bug_id ) )
300 } # foreach( $t_related_custom_field_ids as $t_id )
303 <?php
304 if ( ( $t_resolved <= $f_new_status ) ) {
305 $t_show_product_version = ( ON == config_get( 'show_product_version' ) )
306 || ( ( AUTO == config_get( 'show_product_version' ) )
307 && ( count( version_get_all_rows( $t_bug->project_id ) ) > 0 ) );
308 if ( $t_show_product_version ) {
310 <!-- Fixed in Version -->
311 <tr <?php echo helper_alternate_class() ?>>
312 <th class="category">
313 <?php echo lang_get( 'fixed_in_version' ) ?>
314 </th>
315 <td>
316 <select name="fixed_in_version">
317 <?php print_version_option_list( bug_get_field( $f_bug_id, 'fixed_in_version' ),
318 bug_get_field( $f_bug_id, 'project_id' ), VERSION_ALL ) ?>
319 </select>
320 </td>
321 </tr>
322 <?php }
323 } ?>
325 <?php event_signal( 'EVENT_BUG_CHANGE_STATUS_FORM', array( $f_bug_id ) ); ?>
327 <!-- Bugnote -->
328 <tr id="bug-change-status-note" <?php echo helper_alternate_class() ?>>
329 <th class="category">
330 <?php echo lang_get( 'add_bugnote_title' ) ?>
331 </th>
332 <td class="center">
333 <textarea name="bugnote_text" cols="80" rows="10"></textarea>
334 </td>
335 </tr>
336 <?php if ( access_has_bug_level( config_get( 'private_bugnote_threshold' ), $f_bug_id ) ) { ?>
337 <tr <?php echo helper_alternate_class() ?>>
338 <th class="category">
339 <?php echo lang_get( 'view_status' ) ?>
340 </th>
341 <td>
342 <?php
343 $t_default_bugnote_view_status = config_get( 'default_bugnote_view_status' );
344 if ( access_has_bug_level( config_get( 'set_view_status_threshold' ), $f_bug_id ) ) {
346 <input type="checkbox" name="private" <?php check_checked( $t_default_bugnote_view_status, VS_PRIVATE ); ?> />
347 <?php
348 echo lang_get( 'private' );
349 } else {
350 echo get_enum_element( 'project_view_state', $t_default_bugnote_view_status );
353 </td>
354 </tr>
355 <?php } ?>
357 <?php if ( config_get('time_tracking_enabled') ) { ?>
358 <?php if ( access_has_bug_level( config_get( 'private_bugnote_threshold' ), $f_bug_id ) ) { ?>
359 <?php if ( access_has_bug_level( config_get( 'time_tracking_edit_threshold' ), $f_bug_id ) ) { ?>
360 <tr <?php echo helper_alternate_class() ?>>
361 <th class="category">
362 <?php echo lang_get( 'time_tracking' ) ?>
363 </th>
364 <td>
365 <input type="text" name="time_tracking" size="5" value="hh:mm" />
366 </td>
367 </tr>
368 <?php } ?>
369 <?php } ?>
370 <?php } ?>
372 <?php event_signal( 'EVENT_BUGNOTE_ADD_FORM', array( $f_bug_id ) ); ?>
374 <!-- Submit Button -->
375 <tr>
376 <td class="center" colspan="2">
377 <input type="submit" class="button" value="<?php echo lang_get( $t_status_label . '_bug_button' ) ?>" />
378 </td>
379 </tr>
382 </table>
383 </form>
384 </div>
385 <br />
386 <?php
387 define( 'BUG_VIEW_INC_ALLOW', true );
388 include( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'bug_view_inc.php' );