Fix #11417: Allow EVENT_MENU_MAIN plugin events to return null
[mantis/radio.git] / bug_change_status_page.php
blob0a57d90a838835e6b843a88baa3e497009d2e055
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 - 2010 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 require_once( 'core.php' );
44 require_api( 'access_api.php' );
45 require_api( 'authentication_api.php' );
46 require_api( 'bug_api.php' );
47 require_api( 'config_api.php' );
48 require_api( 'constant_inc.php' );
49 require_api( 'custom_field_api.php' );
50 require_api( 'date_api.php' );
51 require_api( 'event_api.php' );
52 require_api( 'form_api.php' );
53 require_api( 'gpc_api.php' );
54 require_api( 'helper_api.php' );
55 require_api( 'html_api.php' );
56 require_api( 'lang_api.php' );
57 require_api( 'print_api.php' );
58 require_api( 'relationship_api.php' );
59 require_api( 'sponsorship_api.php' );
60 require_api( 'version_api.php' );
62 $g_allow_browser_cache = 1;
64 define ( 'BUG_VIEW_INC_ALLOW', true );
66 $f_bug_id = gpc_get_int( 'id' );
67 $t_bug = bug_get( $f_bug_id );
69 $tpl_file = __FILE__;
70 $tpl_mantis_dir = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
71 $tpl_show_page_header = false;
72 $tpl_force_readonly = true;
73 $tpl_fields_config_option = 'bug_change_status_page_fields';
75 if( $t_bug->project_id != helper_get_current_project() ) {
76 # in case the current project is not the same project of the bug we are viewing...
77 # ... override the current project. This to avoid problems with categories and handlers lists etc.
78 $g_project_override = $t_bug->project_id;
81 $f_new_status = gpc_get_int( 'new_status' );
82 $f_reopen_flag = gpc_get_int( 'reopen_flag', OFF );
84 $t_current_user_id = auth_get_current_user_id();
86 if ( !( ( access_has_bug_level( access_get_status_threshold( $f_new_status, bug_get_field( $f_bug_id, 'project_id' ) ), $f_bug_id ) ) ||
87 ( ( bug_get_field( $f_bug_id, 'reporter_id' ) == $t_current_user_id ) &&
88 ( ( ON == config_get( 'allow_reporter_reopen' ) ) ||
89 ( ON == config_get( 'allow_reporter_close' ) ) ) ) ||
90 ( ( ON == $f_reopen_flag ) && ( access_has_bug_level( config_get( 'reopen_bug_threshold' ), $f_bug_id ) ) )
91 ) ) {
92 access_denied();
94 $t_can_update_due_date = access_has_bug_level( config_get( 'due_date_update_threshold' ), $f_bug_id );
95 # get new issue handler if set, otherwise default to original handler
96 $f_handler_id = gpc_get_int( 'handler_id', bug_get_field( $f_bug_id, 'handler_id' ) );
98 if ( config_get( 'bug_assigned_status' ) == $f_new_status ) {
99 $t_bug_sponsored = sponsorship_get_amount( sponsorship_get_all_ids( $f_bug_id ) ) > 0;
100 if ( $t_bug_sponsored ) {
101 if ( !access_has_bug_level( config_get( 'assign_sponsored_bugs_threshold' ), $f_bug_id ) ) {
102 trigger_error( ERROR_SPONSORSHIP_ASSIGNER_ACCESS_LEVEL_TOO_LOW, ERROR );
106 if ( $f_handler_id != NO_USER ) {
107 if ( !access_has_bug_level( config_get( 'handle_bug_threshold' ), $f_bug_id, $f_handler_id ) ) {
108 trigger_error( ERROR_HANDLER_ACCESS_TOO_LOW, ERROR );
111 if ( $t_bug_sponsored ) {
112 if ( !access_has_bug_level( config_get( 'handle_sponsored_bugs_threshold' ), $f_bug_id, $f_handler_id ) ) {
113 trigger_error( ERROR_SPONSORSHIP_HANDLER_ACCESS_LEVEL_TOO_LOW, ERROR );
119 $t_status_label = str_replace( " ", "_", MantisEnum::getLabel( config_get( 'status_enum_string' ), $f_new_status ) );
120 $t_resolved = config_get( 'bug_resolved_status_threshold' );
121 $t_closed = config_get( 'bug_closed_status_threshold' );
123 $t_bug = bug_get( $f_bug_id );
125 html_page_top( bug_format_summary( $f_bug_id, SUMMARY_CAPTION ) );
127 print_recently_visited();
130 <br />
131 <div align="center">
132 <form method="post" action="bug_update.php">
133 <?php echo form_security_field( 'bug_update' ) ?>
134 <table class="width75" cellspacing="1">
136 <!-- Title -->
137 <tr>
138 <td class="form-title" colspan="2">
139 <input type="hidden" name="bug_id" value="<?php echo $f_bug_id ?>" />
140 <input type="hidden" name="status" value="<?php echo $f_new_status ?>" />
141 <?php echo lang_get( $t_status_label . '_bug_title' ) ?>
142 </td>
143 </tr>
145 <?php
146 if ( $f_new_status >= $t_resolved ) {
147 if ( relationship_can_resolve_bug( $f_bug_id ) == false ) {
148 echo "<tr><td colspan=\"2\">" . lang_get( 'relationship_warning_blocking_bugs_not_resolved_2' ) . "</td></tr>";
153 <?php
154 $t_current_resolution = $t_bug->resolution;
155 $t_bug_is_open = in_array( $t_current_resolution, array( config_get( 'default_bug_resolution' ), config_get( 'bug_reopen_resolution' ) ) );
156 if ( ( $f_new_status >= $t_resolved ) && ( ( $f_new_status < $t_closed ) || ( $t_bug_is_open ) ) ) { ?>
157 <!-- Resolution -->
158 <tr <?php echo helper_alternate_class() ?>>
159 <td class="category">
160 <?php echo lang_get( 'resolution' ) ?>
161 </td>
162 <td>
163 <select name="resolution">
164 <?php
165 $t_resolution = $t_bug_is_open ? config_get( 'bug_resolution_fixed_threshold' ) : $t_current_resolution;
166 print_enum_string_option_list( "resolution", $t_resolution );
168 </select>
169 </td>
170 </tr>
171 <?php } ?>
173 <?php
174 if ( ( $f_new_status >= $t_resolved ) && ( $f_new_status < $t_closed ) ) { ?>
175 <!-- Duplicate ID -->
176 <tr <?php echo helper_alternate_class() ?>>
177 <td class="category">
178 <?php echo lang_get( 'duplicate_id' ) ?>
179 </td>
180 <td>
181 <input type="text" name="duplicate_id" maxlength="10" />
182 </td>
183 </tr>
184 <?php } ?>
186 <?php
187 if ( access_has_bug_level( config_get( 'update_bug_assign_threshold', config_get( 'update_bug_threshold' ) ), $f_bug_id ) ) {
188 $t_suggested_handler_id = $t_bug->handler_id;
190 if ( $t_suggested_handler_id == NO_USER && access_has_bug_level( config_get( 'handle_bug_threshold' ), $f_bug_id ) ) {
191 $t_suggested_handler_id = $t_current_user_id;
194 <!-- Assigned To -->
195 <tr <?php echo helper_alternate_class() ?>>
196 <td class="category">
197 <?php echo lang_get( 'assigned_to' ) ?>
198 </td>
199 <td>
200 <select name="handler_id">
201 <option value="0"></option>
202 <?php print_assign_to_option_list( $t_suggested_handler_id, $t_bug->project_id ) ?>
203 </select>
204 </td>
205 </tr>
206 <?php } ?>
208 <!-- Due date -->
209 <?php if ( $t_can_update_due_date ) {
210 $t_date_to_display = '';
211 if ( !date_is_null( $t_bug->due_date ) ) {
212 $t_date_to_display = date( config_get( 'calendar_date_format' ), $t_bug->due_date );
215 <tr <?php echo helper_alternate_class() ?>>
216 <td class="category">
217 <?php print_documentation_link( 'due_date' ) ?>
218 </td>
219 <td>
220 <?php
221 print "<input ".helper_get_tab_index()." type=\"text\" id=\"due_date\" name=\"due_date\" size=\"20\" maxlength=\"10\" value=\"".$t_date_to_display."\" />";
222 date_print_calendar();
224 </td>
225 </tr>
226 <?php } ?>
228 <!-- Custom Fields -->
229 <?php
230 /** @todo thraxisp - I undid part of the change for #5068 for #5527
231 * We really need to say what fields are shown in which statusses. For now,
232 * this page will show required custom fields in update mode, or
233 * display or required fields on resolve or close
235 $t_custom_status_label = "update"; # Don't show custom fields by default
236 if ( ( $f_new_status == $t_resolved ) &&
237 ( $f_new_status < $t_closed ) ) {
238 $t_custom_status_label = "resolved";
240 if ( $t_closed == $f_new_status ) {
241 $t_custom_status_label = "closed";
244 $t_related_custom_field_ids = custom_field_get_linked_ids( bug_get_field( $f_bug_id, 'project_id' ) );
246 foreach( $t_related_custom_field_ids as $t_id ) {
247 $t_def = custom_field_get_definition( $t_id );
248 $t_display = $t_def['display_' . $t_custom_status_label];
249 $t_require = $t_def['require_' . $t_custom_status_label];
251 if ( ( "update" == $t_custom_status_label ) && ( !$t_require ) ) {
252 continue;
254 if ( in_array( $t_custom_status_label, array( "resolved", "closed" ) ) && !( $t_display || $t_require ) ) {
255 continue;
257 if ( custom_field_has_write_access( $t_id, $f_bug_id ) ) {
259 <tr <?php echo helper_alternate_class() ?>>
260 <td class="category">
261 <?php if ( $t_require ) {?><span class="required">*</span><?php } echo lang_get_defaulted( $t_def['name'] ) ?>
262 </td>
263 <td>
264 <?php
265 print_custom_field_input( $t_def, $f_bug_id );
267 </td>
268 </tr>
269 <?php
270 } # custom_field_has_write_access( $t_id, $f_bug_id ) )
271 else if ( custom_field_has_read_access( $t_id, $f_bug_id ) ) {
273 <tr <?php echo helper_alternate_class() ?>>
274 <td class="category">
275 <?php echo lang_get_defaulted( $t_def['name'] ) ?>
276 </td>
277 <td>
278 <?php print_custom_field_value( $t_def, $t_id, $f_bug_id ); ?>
279 </td>
280 </tr>
281 <?php
282 } # custom_field_has_read_access( $t_id, $f_bug_id ) )
283 } # foreach( $t_related_custom_field_ids as $t_id )
286 <?php
287 if ( ( $t_resolved <= $f_new_status ) ) {
288 $t_show_product_version = ( ON == config_get( 'show_product_version' ) )
289 || ( ( AUTO == config_get( 'show_product_version' ) )
290 && ( count( version_get_all_rows( $t_bug->project_id ) ) > 0 ) );
291 if ( $t_show_product_version ) {
293 <!-- Fixed in Version -->
294 <tr <?php echo helper_alternate_class() ?>>
295 <td class="category">
296 <?php echo lang_get( 'fixed_in_version' ) ?>
297 </td>
298 <td>
299 <select name="fixed_in_version">
300 <?php print_version_option_list( bug_get_field( $f_bug_id, 'fixed_in_version' ),
301 bug_get_field( $f_bug_id, 'project_id' ), VERSION_ALL ) ?>
302 </select>
303 </td>
304 </tr>
305 <?php }
306 } ?>
308 <?php
309 if ( ( $t_resolved <= $f_new_status ) && ( $f_new_status < $t_closed ) ) { ?>
310 <!-- Close Immediately (if enabled) -->
311 <?php if ( ( ON == config_get( 'allow_close_immediately' ) )
312 && ( access_has_bug_level( access_get_status_threshold( $t_closed ), $f_bug_id ) ) ) { ?>
313 <tr <?php echo helper_alternate_class() ?>>
314 <td class="category">
315 <?php echo lang_get( 'close_immediately' ) ?>
316 </td>
317 <td>
318 <input type="checkbox" name="close_now" />
319 </td>
320 </tr>
321 <?php } ?>
322 <?php } ?>
324 <?php
325 if ( ON == $f_reopen_flag ) {
326 # bug was re-opened
327 printf(" <input type=\"hidden\" name=\"resolution\" value=\"%s\" />\n", config_get( 'bug_reopen_resolution' ) );
331 <!-- Bugnote -->
332 <tr <?php echo helper_alternate_class() ?>>
333 <td class="category">
334 <?php echo lang_get( 'add_bugnote_title' ) ?>
335 </td>
336 <td class="center">
337 <textarea name="bugnote_text" cols="80" rows="10"></textarea>
338 </td>
339 </tr>
340 <?php if ( access_has_bug_level( config_get( 'private_bugnote_threshold' ), $f_bug_id ) ) { ?>
341 <tr <?php echo helper_alternate_class() ?>>
342 <td class="category">
343 <?php echo lang_get( 'view_status' ) ?>
344 </td>
345 <td>
346 <?php
347 $t_default_bugnote_view_status = config_get( 'default_bugnote_view_status' );
348 if ( access_has_bug_level( config_get( 'set_view_status_threshold' ), $f_bug_id ) ) {
350 <input type="checkbox" name="private" <?php check_checked( $t_default_bugnote_view_status, VS_PRIVATE ); ?> />
351 <?php
352 echo lang_get( 'private' );
353 } else {
354 echo get_enum_element( 'project_view_state', $t_default_bugnote_view_status );
357 </td>
358 </tr>
359 <?php } ?>
361 <?php if ( config_get('time_tracking_enabled') ) { ?>
362 <?php if ( access_has_bug_level( config_get( 'private_bugnote_threshold' ), $f_bug_id ) ) { ?>
363 <?php if ( access_has_bug_level( config_get( 'time_tracking_edit_threshold' ), $f_bug_id ) ) { ?>
364 <tr <?php echo helper_alternate_class() ?>>
365 <td class="category">
366 <?php echo lang_get( 'time_tracking' ) ?> (HH:MM)
367 </td>
368 <td>
369 <input type="text" name="time_tracking" size="5" value="0:00" />
370 </td>
371 </tr>
372 <?php } ?>
373 <?php } ?>
374 <?php } ?>
376 <?php event_signal( 'EVENT_BUGNOTE_ADD_FORM', array( $f_bug_id ) ); ?>
378 <!-- Submit Button -->
379 <tr>
380 <td class="center" colspan="2">
381 <input type="submit" class="button" value="<?php echo lang_get( $t_status_label . '_bug_button' ) ?>" />
382 </td>
383 </tr>
386 </table>
387 </form>
388 </div>
390 <?php
391 if ( $t_can_update_due_date ) {
392 date_finish_calendar( 'due_date', 'trigger');
395 echo '<br />';
397 include( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'bug_view_inc.php' );