Fix bug when user not in ldap
[mantis.git] / bug_actiongroup_ext.php
blobfd52436541fcb36d426431f10354b1a9605a24f3
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 * @package MantisBT
19 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
20 * @copyright Copyright (C) 2002 - 2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net
21 * @link http://www.mantisbt.org
23 * @uses core.php
24 * @uses authentication_api.php
25 * @uses bug_api.php
26 * @uses bug_group_action_api.php
27 * @uses config_api.php
28 * @uses form_api.php
29 * @uses gpc_api.php
30 * @uses helper_api.php
31 * @uses html_api.php
32 * @uses lang_api.php
33 * @uses print_api.php
34 * @uses string_api.php
37 /**
38 * MantisBT Core API's
40 require_once( 'core.php' );
41 require_api( 'authentication_api.php' );
42 require_api( 'bug_api.php' );
43 require_api( 'bug_group_action_api.php' );
44 require_api( 'config_api.php' );
45 require_api( 'form_api.php' );
46 require_api( 'gpc_api.php' );
47 require_api( 'helper_api.php' );
48 require_api( 'html_api.php' );
49 require_api( 'lang_api.php' );
50 require_api( 'print_api.php' );
51 require_api( 'string_api.php' );
53 auth_ensure_user_authenticated();
55 helper_begin_long_process();
57 $f_action = gpc_get_string( 'action' );
58 $f_bug_arr = gpc_get_int_array( 'bug_arr', array() );
60 $t_action_include_file = 'bug_actiongroup_' . $f_action . '_inc.php';
61 $t_form_name = 'bug_actiongroup_' . $f_action;
63 form_security_validate( $t_form_name );
65 require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . $t_action_include_file );
67 # group bugs by project
68 $t_projects_bugs = array();
69 foreach( $f_bug_arr as $t_bug_id ) {
70 bug_ensure_exists( $t_bug_id );
71 $t_bug = bug_get( $t_bug_id, true );
73 if ( isset( $t_projects_bugs[$t_bug->project_id] ) ) {
74 $t_projects_bugs[$t_bug->project_id][] = $t_bug_id;
75 } else {
76 $t_projects_bugs[$t_bug->project_id] = array( $t_bug_id );
80 $t_failed_ids = array();
82 foreach( $t_projects_bugs as $t_project_id => $t_bugs ) {
83 $g_project_override = $t_project_id;
84 foreach( $t_bugs as $t_bug_id ) {
85 $t_fail_reason = bug_group_action_validate( $f_action, $t_bug_id );
86 if( $t_fail_reason !== null ) {
87 $t_failed_ids[$t_bug_id] = $t_fail_reason;
89 if( !isset( $t_failed_ids[$t_bug_id] ) ) {
90 $t_fail_reason = bug_group_action_process( $f_action, $t_bug_id );
91 if( $t_fail_reason !== null ) {
92 $t_failed_ids[$t_bug_id] = $t_fail_reason;
98 $g_project_override = null;
100 form_security_purge( $t_form_name );
102 if ( count( $t_failed_ids ) > 0 ) {
103 html_page_top();
105 echo '<div>';
107 $t_word_separator = lang_get( 'word_separator' );
108 foreach( $t_failed_ids as $t_id => $t_reason ) {
109 $label = sprintf( lang_get( 'label' ), string_get_bug_view_link( $t_id ) ) . $t_word_separator;
110 printf("<p>%s%s</p>\n", $label, $t_reason );
113 print_bracket_link( 'view_all_bug_page.php', lang_get( 'proceed' ) );
114 echo '</div>';
116 html_page_bottom();
117 } else {
118 print_header_redirect( 'view_all_bug_page.php' );