Fix #11417: Allow EVENT_MENU_MAIN plugin events to return null
[mantis/radio.git] / manage_config_workflow_set.php
blob9ea3e90532bb3854158f04dc7a17b17c29481021
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 access_api.php
25 * @uses authentication_api.php
26 * @uses config_api.php
27 * @uses constant_inc.php
28 * @uses current_user_api.php
29 * @uses form_api.php
30 * @uses gpc_api.php
31 * @uses helper_api.php
32 * @uses html_api.php
33 * @uses lang_api.php
34 * @uses print_api.php
37 require_once( 'core.php' );
38 require_api( 'access_api.php' );
39 require_api( 'authentication_api.php' );
40 require_api( 'config_api.php' );
41 require_api( 'constant_inc.php' );
42 require_api( 'current_user_api.php' );
43 require_api( 'form_api.php' );
44 require_api( 'gpc_api.php' );
45 require_api( 'helper_api.php' );
46 require_api( 'html_api.php' );
47 require_api( 'lang_api.php' );
48 require_api( 'print_api.php' );
50 form_security_validate( 'manage_config_workflow_set' );
52 auth_reauthenticate();
54 $t_can_change_level = min( config_get_access( 'notify_flags' ), config_get_access( 'default_notify_flags' ) );
55 access_ensure_project_level( $t_can_change_level );
57 $t_redirect_url = 'manage_config_workflow_page.php';
58 $t_project = helper_get_current_project();
59 $t_access = current_user_get_access_level();
61 html_page_top( lang_get( 'manage_workflow_config' ), $t_redirect_url );
63 # process the changes to threshold values
64 $t_valid_thresholds = array( 'bug_submit_status', 'bug_resolved_status_threshold', 'bug_reopen_status' );
66 foreach( $t_valid_thresholds as $t_threshold ) {
67 if( config_get_access( $t_threshold ) <= $t_access ) {
68 $f_value = gpc_get( 'threshold_' . $t_threshold );
69 $f_access = gpc_get( 'access_' . $t_threshold );
70 if ( ( $f_value != config_get( $t_threshold ) )
71 || ( $f_access != config_get_access( $t_threshold ) ) ) {
72 config_set( $t_threshold, $f_value, NO_USER, $t_project, $f_access );
77 # process the workflow by reversing the flags to a matrix and creating the appropriate string
78 if( config_get_access( 'status_enum_workflow' ) <= $t_access ) {
79 $f_value = gpc_get( 'flag', array() );
80 $f_access = gpc_get( 'workflow_access' );
81 $t_matrix = array();
83 foreach( $f_value as $t_transition ) {
84 list( $t_from, $t_to ) = explode( ':', $t_transition );
85 $t_matrix[$t_from][$t_to] = '';
87 $t_statuses = MantisEnum::getAssocArrayIndexedByValues( config_get( 'status_enum_string' ) );
88 foreach( $t_statuses as $t_state => $t_label) {
89 $t_workflow_row = '';
90 $t_default = gpc_get_int( 'default_' . $t_state );
91 if ( isset( $t_matrix[$t_state] ) && isset( $t_matrix[$t_state][$t_default] ) ) {
92 $t_workflow_row .= $t_default . ':' . get_enum_element( 'status', $t_default );
93 unset( $t_matrix[$t_state][$t_default] );
94 $t_first = false;
95 } else {
96 # error default state isn't in the matrix
97 echo '<p>' . sprintf( lang_get( 'default_not_in_flow' ), get_enum_element( 'status', $t_default ), get_enum_element( 'status', $t_state ) ) . '</p>';
98 $t_first = true;
100 if ( isset( $t_matrix[$t_state] ) ) {
101 foreach ( $t_matrix[$t_state] as $t_next_state => $t_junk ) {
102 if ( false == $t_first ) {
103 $t_workflow_row .= ',';
105 $t_workflow_row .= $t_next_state . ':' . get_enum_element( 'status', $t_next_state );
106 $t_first = false;
109 if ( '' <> $t_workflow_row ) {
110 $t_workflow[$t_state] = $t_workflow_row;
113 if ( ( $t_workflow != config_get( 'status_enum_workflow' ) )
114 || ( $f_access != config_get_access( 'status_enum_workflow' ) ) ) {
115 config_set( 'status_enum_workflow', $t_workflow, NO_USER, $t_project, $f_access );
119 # process the access level changes
120 if( config_get_access( 'status_enum_workflow' ) <= $t_access ) {
121 # get changes to access level to change these values
122 $f_access = gpc_get( 'status_access' );
124 # walk through the status labels to set the status threshold
125 $t_enum_status = explode( ',', config_get( 'status_enum_string' ) );
126 $t_set_status = array();
127 foreach( $t_statuses as $t_status_id => $t_status_label) {
128 $f_level = gpc_get( 'access_change_' . $t_status_id );
129 if ( config_get( 'bug_submit_status' ) == $t_status_id ) {
130 if ( (int)$f_level != config_get( 'report_bug_threshold' ) ) {
131 config_set( 'report_bug_threshold', (int)$f_level, ALL_USERS, $t_project, $f_access );
133 } else {
134 $t_set_status[$t_status_id] = (int)$f_level;
138 if ( ( $t_set_status != config_get( 'set_status_threshold' ) )
139 || ( $f_access != config_get_access( 'status_enum_workflow' ) ) ) {
140 config_set( 'set_status_threshold', $t_set_status, ALL_USERS, $t_project, $f_access );
144 form_security_purge( 'manage_config_workflow_set' );
147 <br />
148 <div align="center">
149 <?php
150 echo lang_get( 'operation_successful' ) . '<br />';
151 print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
153 </div>
155 <?php
156 html_page_bottom();