1<?php 2# MantisBT - A PHP based bugtracking system 3 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. 8# 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. 13# 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/>. 16 17/** 18 * Bug action group additional actions 19 * 20 * @package MantisBT 21 * @copyright Copyright 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 22 * @copyright Copyright 2002 MantisBT Team - mantisbt-dev@lists.sourceforge.net 23 * @link http://www.mantisbt.org 24 * 25 * @uses core.php 26 * @uses authentication_api.php 27 * @uses bug_api.php 28 * @uses bug_group_action_api.php 29 * @uses config_api.php 30 * @uses form_api.php 31 * @uses gpc_api.php 32 * @uses helper_api.php 33 * @uses html_api.php 34 * @uses lang_api.php 35 * @uses print_api.php 36 * @uses string_api.php 37 */ 38 39require_once( 'core.php' ); 40require_api( 'authentication_api.php' ); 41require_api( 'bug_api.php' ); 42require_api( 'bug_group_action_api.php' ); 43require_api( 'config_api.php' ); 44require_api( 'form_api.php' ); 45require_api( 'gpc_api.php' ); 46require_api( 'helper_api.php' ); 47require_api( 'html_api.php' ); 48require_api( 'lang_api.php' ); 49require_api( 'print_api.php' ); 50require_api( 'string_api.php' ); 51 52auth_ensure_user_authenticated(); 53 54helper_begin_long_process(); 55 56$f_action = gpc_get_string( 'action' ); 57$f_bug_arr = gpc_get_int_array( 'bug_arr', array() ); 58 59$t_form_name = 'bug_actiongroup_' . $f_action; 60 61form_security_validate( $t_form_name ); 62 63bug_group_action_init( $f_action ); 64 65# group bugs by project 66$t_projects_bugs = array(); 67foreach( $f_bug_arr as $t_bug_id ) { 68 bug_ensure_exists( $t_bug_id ); 69 $t_bug = bug_get( $t_bug_id, true ); 70 71 if( isset( $t_projects_bugs[$t_bug->project_id] ) ) { 72 $t_projects_bugs[$t_bug->project_id][] = $t_bug_id; 73 } else { 74 $t_projects_bugs[$t_bug->project_id] = array( $t_bug_id ); 75 } 76} 77 78$t_failed_ids = array(); 79 80foreach( $t_projects_bugs as $t_project_id => $t_bugs ) { 81 $g_project_override = $t_project_id; 82 foreach( $t_bugs as $t_bug_id ) { 83 $t_fail_reason = bug_group_action_validate( $f_action, $t_bug_id ); 84 if( $t_fail_reason !== null ) { 85 $t_failed_ids[$t_bug_id] = $t_fail_reason; 86 } 87 if( !isset( $t_failed_ids[$t_bug_id] ) ) { 88 $t_fail_reason = bug_group_action_process( $f_action, $t_bug_id ); 89 if( $t_fail_reason !== null ) { 90 $t_failed_ids[$t_bug_id] = $t_fail_reason; 91 } 92 } 93 } 94} 95 96$g_project_override = null; 97 98form_security_purge( $t_form_name ); 99 100if( count( $t_failed_ids ) > 0 ) { 101 bug_group_action_print_top(); 102 bug_group_action_print_results( $t_failed_ids ); 103 bug_group_action_print_bottom(); 104} else { 105 print_header_redirect( 'view_all_bug_page.php' ); 106} 107