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/>.
18 * This page allows actions to be performed on an array of bugs
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
26 * @uses access_api.php
27 * @uses authentication_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
35 * @uses helper_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;
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;
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 );
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'] );
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';
123 $t_form_name = 'bug_actiongroup_' . $f_action;
125 switch ( $f_action ) {
126 # Use a simple confirmation page, if close or delete...
129 $t_question_title = lang_get( 'close_bugs_conf_msg' );
130 $t_button_title = lang_get( 'close_group_bugs_button' );
136 $t_question_title = lang_get( 'delete_bugs_conf_msg' );
137 $t_button_title = lang_get( 'delete_group_bugs_button' );
142 $t_question_title = lang_get( 'set_sticky_bugs_conf_msg' );
143 $t_button_title = lang_get( 'set_sticky_group_bugs_button' );
146 # ...else we define the variables used in the form
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';
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';
160 $t_question_title = lang_get( 'assign_bugs_conf_msg' );
161 $t_button_title = lang_get( 'assign_group_bugs_button' );
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';
177 $t_question_title = lang_get( 'priority_bugs_conf_msg' );
178 $t_button_title = lang_get( 'priority_group_bugs_button' );
179 $t_form = 'priority';
183 $t_question_title = lang_get( 'status_bugs_conf_msg' );
184 $t_button_title = lang_get( 'status_group_bugs_button' );
190 $t_question_title = lang_get( 'category_bugs_conf_msg' );
191 $t_button_title = lang_get( 'category_group_bugs_button' );
192 $t_form = 'category';
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';
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';
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';
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";
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>';
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 ) ?>" />
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">
246 if ( !$t_finished ) {
249 <td
class="category">
250 <?php
echo $t_question_title ?
>
254 if ( $f_action === 'CUSTOM' ) {
255 $t_custom_field_def = custom_field_get_definition( $t_custom_field_id );
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 );
267 echo "<select name=\"$t_form\">";
269 switch ( $f_action ) {
272 print_project_option_list( null, false );
275 print_assign_to_option_list( 0, $t_project_id );
278 print_enum_string_option_list( 'resolution', config_get( 'bug_resolution_fixed_threshold' ) );
281 print_enum_string_option_list( 'priority', config_get( 'default_bug_priority' ) );
284 print_enum_string_option_list( 'status', config_get( 'bug_submit_status' ) );
287 print_category_option_list();
290 print_enum_string_option_list( 'view_state', config_get( 'default_bug_view_status' ) );
292 case 'UP_TARGET_VERSION':
293 case 'UP_FIXED_IN_VERSION':
294 print_version_option_list( '', $t_project_id, VERSION_ALL
);
304 if ( isset( $t_question_title2 ) ) {
305 switch ( $f_action ) {
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 ) {
313 <td
class="category">
314 <?php
echo $t_question_title2 ?
>
317 <select name
="<?php echo $t_form2 ?>">
318 <?php
print_version_option_list( '', null, VERSION_ALL
);?
>
333 <td
class="category" colspan
="2">
334 <?php
echo $t_question_title; ?
>
345 <td
class="category">
346 <?php
echo lang_get( 'add_bugnote_title' ); ?
>
349 <textarea name
="bugnote_text" cols
="80" rows
="10"></textarea
>
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' ) ?
>
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
); ?
> />
364 echo lang_get( 'private' );
366 echo get_enum_element( 'project_view_state', $t_default_bugnote_view_status );
377 <td
class="center" colspan
="2">
378 <input type
="submit" class="button" value
="<?php echo $t_button_title ?>" />
385 bug_group_action_print_bug_list( $f_bug_arr );
391 bug_group_action_print_bottom();