Fix #11417: Allow EVENT_MENU_MAIN plugin events to return null
[mantis/radio.git] / bug_actiongroup_page.php
blobfe5305ecb8f1746c51e88fec8f98c1e8cf5fd236
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 * This page allows actions to be performed on an array of bugs
20 * @package MantisBT
21 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
22 * @copyright Copyright (C) 2002 - 2010 MantisBT Team - mantisbt-dev@lists.sourceforge.net
23 * @link http://www.mantisbt.org
25 * @uses core.php
26 * @uses access_api.php
27 * @uses authentication_api.php
28 * @uses bug_api.php
29 * @uses bug_group_action_api.php
30 * @uses config_api.php
31 * @uses constant_inc.php
32 * @uses custom_field_api.php
33 * @uses form_api.php
34 * @uses gpc_api.php
35 * @uses helper_api.php
36 * @uses lang_api.php
37 * @uses print_api.php
38 * @uses string_api.php
39 * @uses utility_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( 'bug_group_action_api.php' );
48 require_api( 'config_api.php' );
49 require_api( 'constant_inc.php' );
50 require_api( 'custom_field_api.php' );
51 require_api( 'form_api.php' );
52 require_api( 'gpc_api.php' );
53 require_api( 'helper_api.php' );
54 require_api( 'lang_api.php' );
55 require_api( 'print_api.php' );
56 require_api( 'string_api.php' );
57 require_api( 'utility_api.php' );
58 require_api( 'version_api.php' );
60 auth_ensure_user_authenticated();
62 $f_action = gpc_get_string( 'action', '' );
63 $f_bug_arr = gpc_get_int_array( 'bug_arr', array() );
65 # redirects to all_bug_page if nothing is selected
66 if ( is_blank( $f_action ) || ( 0 == count( $f_bug_arr ) ) ) {
67 print_header_redirect( 'view_all_bug_page.php' );
70 # run through the issues to see if they are all from one project
71 $t_project_id = ALL_PROJECTS;
72 $t_multiple_projects = false;
74 bug_cache_array_rows( $f_bug_arr );
76 foreach( $f_bug_arr as $t_bug_id ) {
77 $t_bug = bug_get( $t_bug_id );
78 if ( $t_project_id != $t_bug->project_id ) {
79 if ( ( $t_project_id != ALL_PROJECTS ) && !$t_multiple_projects ) {
80 $t_multiple_projects = true;
81 } else {
82 $t_project_id = $t_bug->project_id;
86 if ( $t_multiple_projects ) {
87 $t_project_id = ALL_PROJECTS;
89 # override the project if necessary
90 if( $t_project_id != helper_get_current_project() ) {
91 # in case the current project is not the same project of the bug we are viewing...
92 # ... override the current project. This to avoid problems with categories and handlers lists etc.
93 $g_project_override = $t_project_id;
96 $t_finished = false;
97 $t_bugnote = false;
99 $t_external_action_prefix = 'EXT_';
100 if ( strpos( $f_action, $t_external_action_prefix ) === 0 ) {
101 $t_form_page = 'bug_actiongroup_ext_page.php';
102 require_once( $t_form_page );
103 exit;
106 $t_custom_group_actions = config_get( 'custom_group_actions' );
108 foreach( $t_custom_group_actions as $t_custom_group_action ) {
109 if ( $f_action == $t_custom_group_action['action'] ) {
110 require_once( $t_custom_group_action['form_page'] );
111 exit;
115 # Check if user selected to update a custom field.
116 $t_custom_fields_prefix = 'custom_field_';
117 if ( strpos( $f_action, $t_custom_fields_prefix ) === 0 ) {
118 $t_custom_field_id = (int)substr( $f_action, utf8_strlen( $t_custom_fields_prefix ) );
119 $f_action = 'CUSTOM';
122 # Form name
123 $t_form_name = 'bug_actiongroup_' . $f_action;
125 switch ( $f_action ) {
126 # Use a simple confirmation page, if close or delete...
127 case 'CLOSE' :
128 $t_finished = true;
129 $t_question_title = lang_get( 'close_bugs_conf_msg' );
130 $t_button_title = lang_get( 'close_group_bugs_button' );
131 $t_bugnote = true;
132 break;
134 case 'DELETE' :
135 $t_finished = true;
136 $t_question_title = lang_get( 'delete_bugs_conf_msg' );
137 $t_button_title = lang_get( 'delete_group_bugs_button' );
138 break;
140 case 'SET_STICKY' :
141 $t_finished = true;
142 $t_question_title = lang_get( 'set_sticky_bugs_conf_msg' );
143 $t_button_title = lang_get( 'set_sticky_group_bugs_button' );
144 break;
146 # ...else we define the variables used in the form
147 case 'MOVE' :
148 $t_question_title = lang_get( 'move_bugs_conf_msg' );
149 $t_button_title = lang_get( 'move_group_bugs_button' );
150 $t_form = 'project_id';
151 break;
153 case 'COPY' :
154 $t_question_title = lang_get( 'copy_bugs_conf_msg' );
155 $t_button_title = lang_get( 'copy_group_bugs_button' );
156 $t_form = 'project_id';
157 break;
159 case 'ASSIGN' :
160 $t_question_title = lang_get( 'assign_bugs_conf_msg' );
161 $t_button_title = lang_get( 'assign_group_bugs_button' );
162 $t_form = 'assign';
163 break;
165 case 'RESOLVE' :
166 $t_question_title = lang_get( 'resolve_bugs_conf_msg' );
167 $t_button_title = lang_get( 'resolve_group_bugs_button' );
168 $t_form = 'resolution';
169 if ( ALL_PROJECTS != $t_project_id ) {
170 $t_question_title2 = lang_get( 'fixed_in_version' );
171 $t_form2 = 'fixed_in_version';
173 $t_bugnote = true;
174 break;
176 case 'UP_PRIOR' :
177 $t_question_title = lang_get( 'priority_bugs_conf_msg' );
178 $t_button_title = lang_get( 'priority_group_bugs_button' );
179 $t_form = 'priority';
180 break;
182 case 'UP_STATUS' :
183 $t_question_title = lang_get( 'status_bugs_conf_msg' );
184 $t_button_title = lang_get( 'status_group_bugs_button' );
185 $t_form = 'status';
186 $t_bugnote = true;
187 break;
189 case 'UP_CATEGORY' :
190 $t_question_title = lang_get( 'category_bugs_conf_msg' );
191 $t_button_title = lang_get( 'category_group_bugs_button' );
192 $t_form = 'category';
193 break;
195 case 'VIEW_STATUS' :
196 $t_question_title = lang_get( 'view_status_bugs_conf_msg' );
197 $t_button_title = lang_get( 'view_status_group_bugs_button' );
198 $t_form = 'view_status';
199 break;
201 case 'UP_FIXED_IN_VERSION':
202 $t_question_title = lang_get( 'fixed_in_version_bugs_conf_msg' );
203 $t_button_title = lang_get( 'fixed_in_version_group_bugs_button' );
204 $t_form = 'fixed_in_version';
205 break;
207 case 'UP_TARGET_VERSION':
208 $t_question_title = lang_get( 'target_version_bugs_conf_msg' );
209 $t_button_title = lang_get( 'target_version_group_bugs_button' );
210 $t_form = 'target_version';
211 break;
213 case 'CUSTOM' :
214 $t_custom_field_def = custom_field_get_definition( $t_custom_field_id );
215 $t_question_title = sprintf( lang_get( 'actiongroup_menu_update_field' ), lang_get_defaulted( $t_custom_field_def['name'] ) );
216 $t_button_title = $t_question_title;
217 $t_form = "custom_field_$t_custom_field_id";
218 break;
220 default:
221 trigger_error( ERROR_GENERIC, ERROR );
224 bug_group_action_print_top();
226 if ( $t_multiple_projects ) {
227 echo '<p class="bold">' . lang_get( 'multiple_projects' ) . '</p>';
231 <br />
233 <div align="center">
234 <form method="post" action="bug_actiongroup.php">
235 <?php echo form_security_field( $t_form_name ); ?>
236 <input type="hidden" name="action" value="<?php echo string_attribute( $f_action ) ?>" />
237 <?php
238 bug_group_action_print_hidden_fields( $f_bug_arr );
240 if ( $f_action === 'CUSTOM' ) {
241 echo "<input type=\"hidden\" name=\"custom_field_id\" value=\"$t_custom_field_id\" />";
244 <table class="width75" cellspacing="1">
245 <?php
246 if ( !$t_finished ) {
248 <tr class="row-1">
249 <td class="category">
250 <?php echo $t_question_title ?>
251 </td>
252 <td>
253 <?php
254 if ( $f_action === 'CUSTOM' ) {
255 $t_custom_field_def = custom_field_get_definition( $t_custom_field_id );
257 $t_bug_id = null;
259 # if there is only one issue, use its current value as default, otherwise,
260 # use the default value specified in custom field definition.
261 if ( count( $f_bug_arr ) == 1 ) {
262 $t_bug_id = $f_bug_arr[0];
265 print_custom_field_input( $t_custom_field_def, $t_bug_id );
266 } else {
267 echo "<select name=\"$t_form\">";
269 switch ( $f_action ) {
270 case 'COPY':
271 case 'MOVE':
272 print_project_option_list( null, false );
273 break;
274 case 'ASSIGN':
275 print_assign_to_option_list( 0, $t_project_id );
276 break;
277 case 'RESOLVE':
278 print_enum_string_option_list( 'resolution', config_get( 'bug_resolution_fixed_threshold' ) );
279 break;
280 case 'UP_PRIOR':
281 print_enum_string_option_list( 'priority', config_get( 'default_bug_priority' ) );
282 break;
283 case 'UP_STATUS':
284 print_enum_string_option_list( 'status', config_get( 'bug_submit_status' ) );
285 break;
286 case 'UP_CATEGORY':
287 print_category_option_list();
288 break;
289 case 'VIEW_STATUS':
290 print_enum_string_option_list( 'view_state', config_get( 'default_bug_view_status' ) );
291 break;
292 case 'UP_TARGET_VERSION':
293 case 'UP_FIXED_IN_VERSION':
294 print_version_option_list( '', $t_project_id, VERSION_ALL );
295 break;
298 echo '</select>';
301 </td>
302 </tr>
303 <?php
304 if ( isset( $t_question_title2 ) ) {
305 switch ( $f_action ) {
306 case 'RESOLVE':
307 $t_show_product_version = ( ON == config_get( 'show_product_version' ) )
308 || ( ( AUTO == config_get( 'show_product_version' ) )
309 && ( count( version_get_all_rows( $t_project_id ) ) > 0 ) );
310 if ( $t_show_product_version ) {
312 <tr class="row-2">
313 <td class="category">
314 <?php echo $t_question_title2 ?>
315 </td>
316 <td>
317 <select name="<?php echo $t_form2 ?>">
318 <?php print_version_option_list( '', null, VERSION_ALL );?>
319 </select>
320 </td>
321 </tr>
322 <?php
324 break;
328 <?php
329 } else {
332 <tr class="row-1">
333 <td class="category" colspan="2">
334 <?php echo $t_question_title; ?>
335 </td>
336 </tr>
337 <?php
341 <?php
342 if( $t_bugnote ) {
344 <tr class="row-1">
345 <td class="category">
346 <?php echo lang_get( 'add_bugnote_title' ); ?>
347 </td>
348 <td>
349 <textarea name="bugnote_text" cols="80" rows="10"></textarea>
350 </td>
351 </tr>
352 <?php if ( access_has_project_level( config_get( 'private_bugnote_threshold' ), $t_project_id ) ) { ?>
353 <tr <?php echo helper_alternate_class() ?>>
354 <td class="category">
355 <?php echo lang_get( 'view_status' ) ?>
356 </td>
357 <td>
358 <?php
359 $t_default_bugnote_view_status = config_get( 'default_bugnote_view_status' );
360 if ( access_has_project_level( config_get( 'set_view_status_threshold' ), $t_project_id ) ) {
362 <input type="checkbox" name="private" <?php check_checked( $t_default_bugnote_view_status, VS_PRIVATE ); ?> />
363 <?php
364 echo lang_get( 'private' );
365 } else {
366 echo get_enum_element( 'project_view_state', $t_default_bugnote_view_status );
369 </td>
370 </tr>
371 <?php } ?>
373 <?php
376 <tr>
377 <td class="center" colspan="2">
378 <input type="submit" class="button" value="<?php echo $t_button_title ?>" />
379 </td>
380 </tr>
381 </table>
382 <br />
384 <?php
385 bug_group_action_print_bug_list( $f_bug_arr );
387 </form>
388 </div>
390 <?php
391 bug_group_action_print_bottom();