Fix #11417: Allow EVENT_MENU_MAIN plugin events to return null
[mantis/radio.git] / manage_config_work_threshold_set.php
blob38d34476ddac6d3d138a4027697f6192dc4b3e5d
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 config_api.php
26 * @uses constant_inc.php
27 * @uses current_user_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
36 require_once( 'core.php' );
37 require_api( 'authentication_api.php' );
38 require_api( 'config_api.php' );
39 require_api( 'constant_inc.php' );
40 require_api( 'current_user_api.php' );
41 require_api( 'form_api.php' );
42 require_api( 'gpc_api.php' );
43 require_api( 'helper_api.php' );
44 require_api( 'html_api.php' );
45 require_api( 'lang_api.php' );
46 require_api( 'print_api.php' );
48 form_security_validate( 'manage_config_work_threshold_set' );
50 auth_reauthenticate();
52 $t_redirect_url = 'manage_config_work_threshold_page.php';
53 $t_project = helper_get_current_project();
55 html_page_top( lang_get( 'manage_threshold_config' ), $t_redirect_url );
57 $t_access = current_user_get_access_level();
59 function set_capability_row( $p_threshold, $p_all_projects_only=false ) {
60 global $t_access, $t_project;
62 if ( ( $t_access >= config_get_access( $p_threshold ) )
63 && ( ( ALL_PROJECTS == $t_project ) || !$p_all_projects_only ) ) {
64 $f_threshold = gpc_get_int_array( 'flag_thres_' . $p_threshold, array() );
65 $f_access = gpc_get_int( 'access_' . $p_threshold );
66 # @@debug @@ echo "<br />for $p_threshold "; var_dump($f_threshold, $f_access); echo '<br />';
67 $t_access_levels = MantisEnum::getAssocArrayIndexedByValues( config_get( 'access_levels_enum_string' ) );
68 ksort( $t_access_levels );
69 reset( $t_access_levels );
71 $t_lower_threshold = NOBODY;
72 $t_array_threshold = array();
74 foreach( $t_access_levels as $t_access_level => $t_level_name ) {
75 if ( in_array( $t_access_level, $f_threshold ) ) {
76 if ( NOBODY == $t_lower_threshold ) {
77 $t_lower_threshold = $t_access_level;
79 $t_array_threshold[] = $t_access_level;
80 } else {
81 if ( NOBODY <> $t_lower_threshold ) {
82 $t_lower_threshold = -1;
85 # @@debug @@ var_dump($$t_access_level, $t_lower_threshold, $t_array_threshold); echo '<br />';
87 $t_existing_threshold = config_get( $p_threshold );
88 $t_existing_access = config_get_access( $p_threshold );
89 if ( -1 == $t_lower_threshold ) {
90 if ( ( $t_existing_threshold != $t_array_threshold )
91 || ( $t_existing_access != $f_access ) ) {
92 config_set( $p_threshold, $t_array_threshold, NO_USER, $t_project, $f_access );
94 } else {
95 if ( ( $t_existing_threshold != $t_lower_threshold )
96 || ( $t_existing_access != $f_access ) ) {
97 config_set( $p_threshold, $t_lower_threshold, NO_USER, $t_project, $f_access );
103 function set_capability_boolean( $p_threshold, $p_all_projects_only=false ) {
104 global $t_access, $t_project;
106 if ( ( $t_access >= config_get_access( $p_threshold ) )
107 && ( ( ALL_PROJECTS == $t_project ) || !$p_all_projects_only ) ) {
108 $f_flag = gpc_get( 'flag_' . $p_threshold, OFF );
109 $f_access = gpc_get_int( 'access_' . $p_threshold );
110 $f_flag = ( OFF == $f_flag ) ? OFF : ON;
111 # @@debug @@ echo "<br />for $p_threshold "; var_dump($f_flag, $f_access); echo '<br />';
113 if ( ( $f_flag != config_get( $p_threshold ) ) || ( $f_access != config_get_access( $p_threshold ) ) ) {
114 config_set( $p_threshold, $f_flag, NO_USER, $t_project, $f_access );
119 function set_capability_enum( $p_threshold, $p_all_projects_only=false ) {
120 global $t_access, $t_project;
122 if ( ( $t_access >= config_get_access( $p_threshold ) )
123 && ( ( ALL_PROJECTS == $t_project ) || !$p_all_projects_only ) ) {
124 $f_flag = gpc_get( 'flag_' . $p_threshold );
125 $f_access = gpc_get_int( 'access_' . $p_threshold );
126 # @@debug @@ echo "<br />for $p_threshold "; var_dump($f_flag, $f_access); echo '<br />';
128 if ( ( $f_flag != config_get( $p_threshold ) ) || ( $f_access != config_get_access( $p_threshold ) ) ) {
129 config_set( $p_threshold, $f_flag, NO_USER, $t_project, $f_access );
135 # Issues
136 set_capability_row( 'report_bug_threshold' );
137 set_capability_enum( 'bug_submit_status' );
138 set_capability_row( 'update_bug_threshold' );
139 set_capability_boolean( 'allow_close_immediately' );
140 set_capability_boolean( 'allow_reporter_close' );
141 set_capability_row( 'monitor_bug_threshold' );
142 set_capability_row( 'handle_bug_threshold' );
143 set_capability_row( 'update_bug_assign_threshold' );
144 set_capability_row( 'move_bug_threshold', true );
145 set_capability_row( 'delete_bug_threshold' );
146 set_capability_row( 'reopen_bug_threshold' );
147 set_capability_boolean( 'allow_reporter_reopen' );
148 set_capability_enum( 'bug_reopen_status' );
149 set_capability_enum( 'bug_reopen_resolution' );
150 set_capability_enum( 'bug_resolved_status_threshold' );
151 set_capability_enum( 'bug_readonly_status_threshold' );
152 set_capability_row( 'private_bug_threshold' );
153 set_capability_row( 'update_readonly_bug_threshold' );
154 set_capability_row( 'update_bug_status_threshold' );
155 set_capability_row( 'set_view_status_threshold' );
156 set_capability_row( 'change_view_status_threshold' );
157 set_capability_row( 'show_monitor_list_threshold' );
158 set_capability_boolean( 'auto_set_status_to_assigned' );
159 set_capability_enum( 'bug_assigned_status' );
160 set_capability_boolean( 'limit_reporters', true );
162 # Notes
163 set_capability_row( 'add_bugnote_threshold' );
164 set_capability_row( 'update_bugnote_threshold' );
165 set_capability_row( 'bugnote_user_edit_threshold' );
166 set_capability_row( 'delete_bugnote_threshold' );
167 set_capability_row( 'bugnote_user_delete_threshold' );
168 set_capability_row( 'private_bugnote_threshold' );
169 set_capability_row( 'bugnote_user_change_view_state_threshold' );
171 # Others
172 set_capability_row( 'view_changelog_threshold' );
173 set_capability_row( 'view_handler_threshold' );
174 set_capability_row( 'view_history_threshold' );
175 set_capability_row( 'bug_reminder_threshold' );
177 form_security_purge( 'manage_config_work_threshold_set' );
180 <br />
181 <div align="center">
182 <?php
183 echo lang_get( 'operation_successful' ) . '<br />';
184 print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
186 </div>
188 <?php
189 html_page_bottom();