SOAP API: do not try to unserialize an invalid filter
[mantis.git] / bug_actiongroup_page.php
blobddeaa190cf8dd66c2f99bfb398b6d4822212363f
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 - 2011 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 /**
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( 'bug_group_action_api.php' );
51 require_api( 'config_api.php' );
52 require_api( 'constant_inc.php' );
53 require_api( 'custom_field_api.php' );
54 require_api( 'form_api.php' );
55 require_api( 'gpc_api.php' );
56 require_api( 'helper_api.php' );
57 require_api( 'lang_api.php' );
58 require_api( 'print_api.php' );
59 require_api( 'string_api.php' );
60 require_api( 'utility_api.php' );
61 require_api( 'version_api.php' );
63 auth_ensure_user_authenticated();
65 $f_action = gpc_get_string( 'action', '' );
66 $f_bug_arr = gpc_get_int_array( 'bug_arr', array() );
68 # redirects to all_bug_page if nothing is selected
69 if ( is_blank( $f_action ) || ( 0 == count( $f_bug_arr ) ) ) {
70 print_header_redirect( 'view_all_bug_page.php' );
73 # run through the issues to see if they are all from one project
74 $t_project_id = ALL_PROJECTS;
75 $t_multiple_projects = false;
77 bug_cache_array_rows( $f_bug_arr );
79 foreach( $f_bug_arr as $t_bug_id ) {
80 $t_bug = bug_get( $t_bug_id );
81 if ( $t_project_id != $t_bug->project_id ) {
82 if ( ( $t_project_id != ALL_PROJECTS ) && !$t_multiple_projects ) {
83 $t_multiple_projects = true;
84 } else {
85 $t_project_id = $t_bug->project_id;
89 if ( $t_multiple_projects ) {
90 $t_project_id = ALL_PROJECTS;
92 # override the project if necessary
93 if( $t_project_id != helper_get_current_project() ) {
94 # in case the current project is not the same project of the bug we are viewing...
95 # ... override the current project. This to avoid problems with categories and handlers lists etc.
96 $g_project_override = $t_project_id;
99 $t_finished = false;
100 $t_bugnote = false;
102 $t_external_action_prefix = 'EXT_';
103 if ( strpos( $f_action, $t_external_action_prefix ) === 0 ) {
104 $t_form_page = 'bug_actiongroup_ext_page.php';
105 require_once( $t_form_page );
106 exit;
109 $t_custom_group_actions = config_get( 'custom_group_actions' );
111 foreach( $t_custom_group_actions as $t_custom_group_action ) {
112 if ( $f_action == $t_custom_group_action['action'] ) {
113 require_once( $t_custom_group_action['form_page'] );
114 exit;
118 # Check if user selected to update a custom field.
119 $t_custom_fields_prefix = 'custom_field_';
120 if ( strpos( $f_action, $t_custom_fields_prefix ) === 0 ) {
121 $t_custom_field_id = (int)substr( $f_action, utf8_strlen( $t_custom_fields_prefix ) );
122 $f_action = 'CUSTOM';
125 # Form name
126 $t_form_name = 'bug_actiongroup_' . $f_action;
128 switch ( $f_action ) {
129 # Use a simple confirmation page, if close or delete...
130 case 'CLOSE' :
131 $t_finished = true;
132 $t_question_title = lang_get( 'close_bugs_conf_msg' );
133 $t_button_title = lang_get( 'close_group_bugs_button' );
134 $t_bugnote = true;
135 break;
137 case 'DELETE' :
138 $t_finished = true;
139 $t_question_title = lang_get( 'delete_bugs_conf_msg' );
140 $t_button_title = lang_get( 'delete_group_bugs_button' );
141 break;
143 case 'SET_STICKY' :
144 $t_finished = true;
145 $t_question_title = lang_get( 'set_sticky_bugs_conf_msg' );
146 $t_button_title = lang_get( 'set_sticky_group_bugs_button' );
147 break;
149 # ...else we define the variables used in the form
150 case 'MOVE' :
151 $t_question_title = lang_get( 'move_bugs_conf_msg' );
152 $t_button_title = lang_get( 'move_group_bugs_button' );
153 $t_form = 'project_id';
154 break;
156 case 'COPY' :
157 $t_question_title = lang_get( 'copy_bugs_conf_msg' );
158 $t_button_title = lang_get( 'copy_group_bugs_button' );
159 $t_form = 'project_id';
160 break;
162 case 'ASSIGN' :
163 $t_question_title = lang_get( 'assign_bugs_conf_msg' );
164 $t_button_title = lang_get( 'assign_group_bugs_button' );
165 $t_form = 'assign';
166 break;
168 case 'RESOLVE' :
169 $t_question_title = lang_get( 'resolve_bugs_conf_msg' );
170 $t_button_title = lang_get( 'resolve_group_bugs_button' );
171 $t_form = 'resolution';
172 if ( ALL_PROJECTS != $t_project_id ) {
173 $t_question_title2 = lang_get( 'fixed_in_version' );
174 $t_form2 = 'fixed_in_version';
176 $t_bugnote = true;
177 break;
179 case 'UP_PRIOR' :
180 $t_question_title = lang_get( 'priority_bugs_conf_msg' );
181 $t_button_title = lang_get( 'priority_group_bugs_button' );
182 $t_form = 'priority';
183 break;
185 case 'UP_STATUS' :
186 $t_question_title = lang_get( 'status_bugs_conf_msg' );
187 $t_button_title = lang_get( 'status_group_bugs_button' );
188 $t_form = 'status';
189 $t_bugnote = true;
190 break;
192 case 'UP_CATEGORY' :
193 $t_question_title = lang_get( 'category_bugs_conf_msg' );
194 $t_button_title = lang_get( 'category_group_bugs_button' );
195 $t_form = 'category';
196 break;
198 case 'VIEW_STATUS' :
199 $t_question_title = lang_get( 'view_status_bugs_conf_msg' );
200 $t_button_title = lang_get( 'view_status_group_bugs_button' );
201 $t_form = 'view_status';
202 break;
204 case 'UP_FIXED_IN_VERSION':
205 $t_question_title = lang_get( 'fixed_in_version_bugs_conf_msg' );
206 $t_button_title = lang_get( 'fixed_in_version_group_bugs_button' );
207 $t_form = 'fixed_in_version';
208 break;
210 case 'UP_TARGET_VERSION':
211 $t_question_title = lang_get( 'target_version_bugs_conf_msg' );
212 $t_button_title = lang_get( 'target_version_group_bugs_button' );
213 $t_form = 'target_version';
214 break;
216 case 'CUSTOM' :
217 $t_custom_field_def = custom_field_get_definition( $t_custom_field_id );
218 $t_question_title = sprintf( lang_get( 'actiongroup_menu_update_field' ), lang_get_defaulted( $t_custom_field_def['name'] ) );
219 $t_button_title = $t_question_title;
220 $t_form = "custom_field_$t_custom_field_id";
221 break;
223 default:
224 trigger_error( ERROR_GENERIC, ERROR );
227 bug_group_action_print_top();
229 if ( $t_multiple_projects ) {
230 echo '<p class="bold">' . lang_get( 'multiple_projects' ) . '</p>';
234 <br />
236 <div>
237 <form method="post" action="bug_actiongroup.php">
238 <?php echo form_security_field( $t_form_name ); ?>
239 <input type="hidden" name="action" value="<?php echo string_attribute( $f_action ) ?>" />
240 <?php
241 bug_group_action_print_hidden_fields( $f_bug_arr );
243 if ( $f_action === 'CUSTOM' ) {
244 echo "<input type=\"hidden\" name=\"custom_field_id\" value=\"$t_custom_field_id\" />";
247 <table class="width75" cellspacing="1">
248 <?php
249 if ( !$t_finished ) {
251 <tr class="row-1">
252 <th class="category">
253 <?php echo $t_question_title ?>
254 </th>
255 <td>
256 <?php
257 if ( $f_action === 'CUSTOM' ) {
258 $t_custom_field_def = custom_field_get_definition( $t_custom_field_id );
260 $t_bug_id = null;
262 # if there is only one issue, use its current value as default, otherwise,
263 # use the default value specified in custom field definition.
264 if ( count( $f_bug_arr ) == 1 ) {
265 $t_bug_id = $f_bug_arr[0];
268 print_custom_field_input( $t_custom_field_def, $t_bug_id );
269 } else {
270 echo "<select name=\"$t_form\">";
272 switch ( $f_action ) {
273 case 'COPY':
274 case 'MOVE':
275 print_project_option_list( null, false );
276 break;
277 case 'ASSIGN':
278 print_assign_to_option_list( 0, $t_project_id );
279 break;
280 case 'RESOLVE':
281 print_enum_string_option_list( 'resolution', config_get( 'bug_resolution_fixed_threshold' ) );
282 break;
283 case 'UP_PRIOR':
284 print_enum_string_option_list( 'priority', config_get( 'default_bug_priority' ) );
285 break;
286 case 'UP_STATUS':
287 print_enum_string_option_list( 'status', config_get( 'bug_submit_status' ) );
288 break;
289 case 'UP_CATEGORY':
290 print_category_option_list();
291 break;
292 case 'VIEW_STATUS':
293 print_enum_string_option_list( 'view_state', config_get( 'default_bug_view_status' ) );
294 break;
295 case 'UP_TARGET_VERSION':
296 case 'UP_FIXED_IN_VERSION':
297 print_version_option_list( '', $t_project_id, VERSION_ALL );
298 break;
301 echo '</select>';
304 </td>
305 </tr>
306 <?php
307 if ( isset( $t_question_title2 ) ) {
308 switch ( $f_action ) {
309 case 'RESOLVE':
310 $t_show_product_version = ( ON == config_get( 'show_product_version' ) )
311 || ( ( AUTO == config_get( 'show_product_version' ) )
312 && ( count( version_get_all_rows( $t_project_id ) ) > 0 ) );
313 if ( $t_show_product_version ) {
315 <tr class="row-2">
316 <th class="category">
317 <?php echo $t_question_title2 ?>
318 </th>
319 <td>
320 <select name="<?php echo $t_form2 ?>">
321 <?php print_version_option_list( '', null, VERSION_ALL );?>
322 </select>
323 </td>
324 </tr>
325 <?php
327 break;
331 <?php
332 } else {
335 <tr class="row-1">
336 <th class="category" colspan="2">
337 <?php echo $t_question_title; ?>
338 </th>
339 </tr>
340 <?php
344 <?php
345 if( $t_bugnote ) {
347 <tr class="row-1">
348 <th class="category">
349 <?php echo lang_get( 'add_bugnote_title' ); ?>
350 </th>
351 <td>
352 <textarea name="bugnote_text" cols="80" rows="10"></textarea>
353 </td>
354 </tr>
355 <?php if ( access_has_project_level( config_get( 'private_bugnote_threshold' ), $t_project_id ) ) { ?>
356 <tr <?php echo helper_alternate_class() ?>>
357 <th class="category">
358 <?php echo lang_get( 'view_status' ) ?>
359 </th>
360 <td>
361 <?php
362 $t_default_bugnote_view_status = config_get( 'default_bugnote_view_status' );
363 if ( access_has_project_level( config_get( 'set_view_status_threshold' ), $t_project_id ) ) {
365 <input type="checkbox" name="private" <?php check_checked( $t_default_bugnote_view_status, VS_PRIVATE ); ?> />
366 <?php
367 echo lang_get( 'private' );
368 } else {
369 echo get_enum_element( 'project_view_state', $t_default_bugnote_view_status );
372 </td>
373 </tr>
374 <?php } ?>
376 <?php
379 <tr>
380 <td class="center" colspan="2">
381 <input type="submit" class="button" value="<?php echo $t_button_title ?>" />
382 </td>
383 </tr>
384 </table>
385 <br />
387 <?php
388 bug_group_action_print_bug_list( $f_bug_arr );
390 </form>
391 </div>
393 <?php
394 bug_group_action_print_bottom();