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/>.
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
24 * @uses authentication_api.php
25 * @uses config_api.php
26 * @uses constant_inc.php
27 * @uses current_user_api.php
30 * @uses helper_api.php
39 require_once( 'core.php' );
40 require_api( 'authentication_api.php' );
41 require_api( 'config_api.php' );
42 require_api( 'constant_inc.php' );
43 require_api( 'current_user_api.php' );
44 require_api( 'form_api.php' );
45 require_api( 'gpc_api.php' );
46 require_api( 'helper_api.php' );
47 require_api( 'html_api.php' );
48 require_api( 'lang_api.php' );
49 require_api( 'print_api.php' );
51 form_security_validate( 'manage_config_work_threshold_set' );
53 auth_reauthenticate();
55 $t_redirect_url = 'manage_config_work_threshold_page.php';
56 $t_project = helper_get_current_project();
58 html_page_top( lang_get( 'manage_threshold_config' ), $t_redirect_url );
60 $t_access = current_user_get_access_level();
62 function set_capability_row( $p_threshold, $p_all_projects_only=false ) {
63 global $t_access, $t_project;
65 if ( ( $t_access >= config_get_access( $p_threshold ) )
66 && ( ( ALL_PROJECTS
== $t_project ) ||
!$p_all_projects_only ) ) {
67 $f_threshold = gpc_get_int_array( 'flag_thres_' . $p_threshold, array() );
68 $f_access = gpc_get_int( 'access_' . $p_threshold );
69 # @@debug @@ echo "<br />for $p_threshold "; var_dump($f_threshold, $f_access); echo '<br />';
70 $t_access_levels = MantisEnum
::getAssocArrayIndexedByValues( config_get( 'access_levels_enum_string' ) );
71 ksort( $t_access_levels );
72 reset( $t_access_levels );
74 $t_lower_threshold = NOBODY
;
75 $t_array_threshold = array();
77 foreach( $t_access_levels as $t_access_level => $t_level_name ) {
78 if ( in_array( $t_access_level, $f_threshold ) ) {
79 if ( NOBODY
== $t_lower_threshold ) {
80 $t_lower_threshold = $t_access_level;
82 $t_array_threshold[] = $t_access_level;
84 if ( NOBODY
<> $t_lower_threshold ) {
85 $t_lower_threshold = -1;
88 # @@debug @@ var_dump($$t_access_level, $t_lower_threshold, $t_array_threshold); echo '<br />';
90 $t_existing_threshold = config_get( $p_threshold );
91 $t_existing_access = config_get_access( $p_threshold );
92 if ( -1 == $t_lower_threshold ) {
93 if ( ( $t_existing_threshold != $t_array_threshold )
94 ||
( $t_existing_access != $f_access ) ) {
95 config_set( $p_threshold, $t_array_threshold, NO_USER
, $t_project, $f_access );
98 if ( ( $t_existing_threshold != $t_lower_threshold )
99 ||
( $t_existing_access != $f_access ) ) {
100 config_set( $p_threshold, $t_lower_threshold, NO_USER
, $t_project, $f_access );
106 function set_capability_boolean( $p_threshold, $p_all_projects_only=false ) {
107 global $t_access, $t_project;
109 if ( ( $t_access >= config_get_access( $p_threshold ) )
110 && ( ( ALL_PROJECTS
== $t_project ) ||
!$p_all_projects_only ) ) {
111 $f_flag = gpc_get( 'flag_' . $p_threshold, OFF
);
112 $f_access = gpc_get_int( 'access_' . $p_threshold );
113 $f_flag = ( OFF
== $f_flag ) ? OFF
: ON
;
114 # @@debug @@ echo "<br />for $p_threshold "; var_dump($f_flag, $f_access); echo '<br />';
116 if ( ( $f_flag != config_get( $p_threshold ) ) ||
( $f_access != config_get_access( $p_threshold ) ) ) {
117 config_set( $p_threshold, $f_flag, NO_USER
, $t_project, $f_access );
122 function set_capability_enum( $p_threshold, $p_all_projects_only=false ) {
123 global $t_access, $t_project;
125 if ( ( $t_access >= config_get_access( $p_threshold ) )
126 && ( ( ALL_PROJECTS
== $t_project ) ||
!$p_all_projects_only ) ) {
127 $f_flag = gpc_get( 'flag_' . $p_threshold );
128 $f_access = gpc_get_int( 'access_' . $p_threshold );
129 # @@debug @@ echo "<br />for $p_threshold "; var_dump($f_flag, $f_access); echo '<br />';
131 if ( ( $f_flag != config_get( $p_threshold ) ) ||
( $f_access != config_get_access( $p_threshold ) ) ) {
132 config_set( $p_threshold, $f_flag, NO_USER
, $t_project, $f_access );
139 set_capability_row( 'report_bug_threshold' );
140 set_capability_enum( 'bug_submit_status' );
141 set_capability_row( 'update_bug_threshold' );
142 set_capability_boolean( 'allow_reporter_close' );
143 set_capability_row( 'monitor_bug_threshold' );
144 set_capability_row( 'handle_bug_threshold' );
145 set_capability_row( 'update_bug_assign_threshold' );
146 set_capability_row( 'move_bug_threshold', true );
147 set_capability_row( 'delete_bug_threshold' );
148 set_capability_row( 'reopen_bug_threshold' );
149 set_capability_boolean( 'allow_reporter_reopen' );
150 set_capability_enum( 'bug_reopen_status' );
151 set_capability_enum( 'bug_reopen_resolution' );
152 set_capability_enum( 'bug_resolved_status_threshold' );
153 set_capability_enum( 'bug_readonly_status_threshold' );
154 set_capability_row( 'private_bug_threshold' );
155 set_capability_row( 'update_readonly_bug_threshold' );
156 set_capability_row( 'update_bug_status_threshold' );
157 set_capability_row( 'set_view_status_threshold' );
158 set_capability_row( 'change_view_status_threshold' );
159 set_capability_row( 'show_monitor_list_threshold' );
160 set_capability_boolean( 'auto_set_status_to_assigned' );
161 set_capability_enum( 'bug_assigned_status' );
162 set_capability_boolean( 'limit_reporters', true );
165 set_capability_row( 'add_bugnote_threshold' );
166 set_capability_row( 'update_bugnote_threshold' );
167 set_capability_row( 'bugnote_user_edit_threshold' );
168 set_capability_row( 'delete_bugnote_threshold' );
169 set_capability_row( 'bugnote_user_delete_threshold' );
170 set_capability_row( 'private_bugnote_threshold' );
171 set_capability_row( 'bugnote_user_change_view_state_threshold' );
174 set_capability_row( 'view_changelog_threshold' );
175 set_capability_row( 'view_handler_threshold' );
176 set_capability_row( 'view_history_threshold' );
177 set_capability_row( 'bug_reminder_threshold' );
179 form_security_purge( 'manage_config_work_threshold_set' );
185 echo lang_get( 'operation_successful' ) . '<br />';
186 print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );