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 - 2011 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
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;
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;
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 );
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'] );
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';
126 $t_form_name = 'bug_actiongroup_' . $f_action;
128 switch ( $f_action ) {
129 # Use a simple confirmation page, if close or delete...
132 $t_question_title = lang_get( 'close_bugs_conf_msg' );
133 $t_button_title = lang_get( 'close_group_bugs_button' );
139 $t_question_title = lang_get( 'delete_bugs_conf_msg' );
140 $t_button_title = lang_get( 'delete_group_bugs_button' );
145 $t_question_title = lang_get( 'set_sticky_bugs_conf_msg' );
146 $t_button_title = lang_get( 'set_sticky_group_bugs_button' );
149 # ...else we define the variables used in the form
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';
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';
163 $t_question_title = lang_get( 'assign_bugs_conf_msg' );
164 $t_button_title = lang_get( 'assign_group_bugs_button' );
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';
180 $t_question_title = lang_get( 'priority_bugs_conf_msg' );
181 $t_button_title = lang_get( 'priority_group_bugs_button' );
182 $t_form = 'priority';
186 $t_question_title = lang_get( 'status_bugs_conf_msg' );
187 $t_button_title = lang_get( 'status_group_bugs_button' );
193 $t_question_title = lang_get( 'category_bugs_conf_msg' );
194 $t_button_title = lang_get( 'category_group_bugs_button' );
195 $t_form = 'category';
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';
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';
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';
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";
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>';
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 ) ?>" />
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">
249 if ( !$t_finished ) {
252 <th
class="category">
253 <?php
echo $t_question_title ?
>
257 if ( $f_action === 'CUSTOM' ) {
258 $t_custom_field_def = custom_field_get_definition( $t_custom_field_id );
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 );
270 echo "<select name=\"$t_form\">";
272 switch ( $f_action ) {
275 print_project_option_list( null, false );
278 print_assign_to_option_list( 0, $t_project_id );
281 print_enum_string_option_list( 'resolution', config_get( 'bug_resolution_fixed_threshold' ) );
284 print_enum_string_option_list( 'priority', config_get( 'default_bug_priority' ) );
287 print_enum_string_option_list( 'status', config_get( 'bug_submit_status' ) );
290 print_category_option_list();
293 print_enum_string_option_list( 'view_state', config_get( 'default_bug_view_status' ) );
295 case 'UP_TARGET_VERSION':
296 case 'UP_FIXED_IN_VERSION':
297 print_version_option_list( '', $t_project_id, VERSION_ALL
);
307 if ( isset( $t_question_title2 ) ) {
308 switch ( $f_action ) {
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 ) {
316 <th
class="category">
317 <?php
echo $t_question_title2 ?
>
320 <select name
="<?php echo $t_form2 ?>">
321 <?php
print_version_option_list( '', null, VERSION_ALL
);?
>
336 <th
class="category" colspan
="2">
337 <?php
echo $t_question_title; ?
>
348 <th
class="category">
349 <?php
echo lang_get( 'add_bugnote_title' ); ?
>
352 <textarea name
="bugnote_text" cols
="80" rows
="10"></textarea
>
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' ) ?
>
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
); ?
> />
367 echo lang_get( 'private' );
369 echo get_enum_element( 'project_view_state', $t_default_bugnote_view_status );
380 <td
class="center" colspan
="2">
381 <input type
="submit" class="button" value
="<?php echo $t_button_title ?>" />
388 bug_group_action_print_bug_list( $f_bug_arr );
394 bug_group_action_print_bottom();