Issue #10730: Use crypto_api for generating nonces and improve hashing
[mantis/radio.git] / bug_actiongroup_ext.php
blob1e047e612f0371a0b227b960ae495517c3d61c3b
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 - 2010 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 require_once( 'core.php' );
38 require_api( 'authentication_api.php' );
39 require_api( 'bug_api.php' );
40 require_api( 'bug_group_action_api.php' );
41 require_api( 'config_api.php' );
42 require_api( 'form_api.php' );
43 require_api( 'gpc_api.php' );
44 require_api( 'helper_api.php' );
45 require_api( 'html_api.php' );
46 require_api( 'lang_api.php' );
47 require_api( 'print_api.php' );
48 require_api( 'string_api.php' );
50 auth_ensure_user_authenticated();
52 helper_begin_long_process();
54 $f_action = gpc_get_string( 'action' );
55 $f_bug_arr = gpc_get_int_array( 'bug_arr', array() );
57 $t_action_include_file = 'bug_actiongroup_' . $f_action . '_inc.php';
58 $t_form_name = 'bug_actiongroup_' . $f_action;
60 form_security_validate( $t_form_name );
62 require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . $t_action_include_file );
64 # group bugs by project
65 $t_projects_bugs = array();
66 foreach( $f_bug_arr as $t_bug_id ) {
67 bug_ensure_exists( $t_bug_id );
68 $t_bug = bug_get( $t_bug_id, true );
70 if ( isset( $t_projects_bugs[$t_bug->project_id] ) ) {
71 $t_projects_bugs[$t_bug->project_id][] = $t_bug_id;
72 } else {
73 $t_projects_bugs[$t_bug->project_id] = array( $t_bug_id );
77 $t_failed_ids = array();
79 # validate all bugs before we start the processing, we may fail the whole action
80 # group, or some of the bugs.
81 foreach( $t_projects_bugs as $t_project_id => $t_bug_ids ) {
82 if ( $t_bug->project_id != helper_get_current_project() ) {
83 # in case the current project is not the same project of the bug we are viewing...
84 # ... override the current project. This to avoid problems with categories and handlers lists etc.
85 $g_project_override = $t_bug->project_id;
86 /** @todo (thraxisp) the next line goes away if the cache was smarter and used project */
87 config_flush_cache(); # flush the config cache so that configs are refetched
90 foreach( $t_bug_ids as $t_bug_id ) {
91 $t_result = bug_group_action_validate( $f_action, $t_bug_id );
92 if ( $t_result !== true ) {
93 foreach( $t_result as $t_key => $t_value ) {
94 $t_failed_ids[$t_key] = $t_value;
100 // process bugs that are not already failed by validation.
101 foreach( $t_projects_bugs as $t_project_id => $t_bug_ids ) {
102 if ( $t_bug->project_id != helper_get_current_project() ) {
103 // in case the current project is not the same project of the bug we are viewing...
104 // ... override the current project. This to avoid problems with categories and handlers lists etc.
105 $g_project_override = $t_bug->project_id;
106 /** @todo (thraxisp) the next line goes away if the cache was smarter and used project */
107 config_flush_cache(); // flush the config cache so that configs are refetched
110 foreach( $t_bug_ids as $t_bug_id ) {
111 # do not process this bug if validation failed for it.
112 if ( !isset( $t_failed_ids[$t_bug_id] ) ) {
113 $t_result = bug_group_action_process( $f_action, $t_bug_id );
114 if ( $t_result !== true ) {
115 $t_failed_ids[] = $t_result;
121 form_security_purge( $t_form_name );
123 if ( count( $t_failed_ids ) > 0 ) {
124 html_page_top();
126 echo '<div align="center">';
128 $separator = lang_get( 'word_separator' );
129 foreach( $t_failed_ids as $t_id => $t_reason ) {
130 $label = sprintf( lang_get( 'label' ), string_get_bug_view_link( $t_id ) ) . $sepatator;
131 printf("<p>%s%s</p>\n", $label, $t_reason );
134 print_bracket_link( 'view_all_bug_page.php', lang_get( 'proceed' ) );
135 echo '</div>';
137 html_page_bottom();
138 } else {
139 print_header_redirect( 'view_all_bug_page.php' );