-
Notifications
You must be signed in to change notification settings - Fork 719
/
manage_config_work_threshold_set.php
246 lines (217 loc) · 8.75 KB
/
manage_config_work_threshold_set.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<?php
# MantisBT - A PHP based bugtracking system
# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
/**
* Workflow Threshold Configuration
*
* @package MantisBT
* @copyright Copyright 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
* @copyright Copyright 2002 MantisBT Team - mantisbt-dev@lists.sourceforge.net
* @link http://www.mantisbt.org
*
* @uses core.php
* @uses authentication_api.php
* @uses config_api.php
* @uses constant_inc.php
* @uses current_user_api.php
* @uses form_api.php
* @uses gpc_api.php
* @uses helper_api.php
* @uses html_api.php
* @uses lang_api.php
* @uses print_api.php
*/
require_once( 'core.php' );
require_api( 'authentication_api.php' );
require_api( 'config_api.php' );
require_api( 'constant_inc.php' );
require_api( 'current_user_api.php' );
require_api( 'form_api.php' );
require_api( 'gpc_api.php' );
require_api( 'helper_api.php' );
require_api( 'html_api.php' );
require_api( 'lang_api.php' );
require_api( 'print_api.php' );
form_security_validate( 'manage_config_work_threshold_set' );
auth_reauthenticate();
$t_redirect_url = 'manage_config_work_threshold_page.php';
layout_page_header( lang_get( 'manage_threshold_config' ), $t_redirect_url );
layout_page_begin();
$g_access = current_user_get_access_level();
$g_project = helper_get_current_project();
/**
* set row
* @param string $p_threshold Threshold.
* @param boolean $p_all_projects_only All projects only.
* @return void
*/
function set_capability_row( $p_threshold, $p_all_projects_only = false ) {
global $g_access, $g_project;
if( ( $g_access >= config_get_access( $p_threshold ) )
&& ( ( ALL_PROJECTS == $g_project ) || !$p_all_projects_only ) ) {
$f_threshold = gpc_get_int_array( 'flag_thres_' . $p_threshold, array() );
$f_access = gpc_get_int( 'access_' . $p_threshold );
# @@debug @@ echo "<br />for $p_threshold "; var_dump($f_threshold, $f_access); echo '<br />';
$t_access_levels = MantisEnum::getAssocArrayIndexedByValues( config_get( 'access_levels_enum_string' ) );
ksort( $t_access_levels );
reset( $t_access_levels );
$t_lower_threshold = NOBODY;
$t_array_threshold = array();
foreach( $t_access_levels as $t_access_level => $t_level_name ) {
if( in_array( $t_access_level, $f_threshold ) ) {
if( NOBODY == $t_lower_threshold ) {
$t_lower_threshold = $t_access_level;
}
$t_array_threshold[] = $t_access_level;
} else {
if( NOBODY <> $t_lower_threshold ) {
$t_lower_threshold = -1;
}
}
# @@debug @@ var_dump($$t_access_level, $t_lower_threshold, $t_array_threshold); echo '<br />';
}
$t_existing_threshold = config_get( $p_threshold );
$t_existing_access = config_get_access( $p_threshold );
if( -1 == $t_lower_threshold ) {
if( ( $t_existing_threshold != $t_array_threshold )
|| ( $t_existing_access != $f_access ) ) {
config_set( $p_threshold, $t_array_threshold, NO_USER, $g_project, $f_access );
}
} else {
if( ( $t_existing_threshold != $t_lower_threshold )
|| ( $t_existing_access != $f_access ) ) {
config_set( $p_threshold, $t_lower_threshold, NO_USER, $g_project, $f_access );
}
}
}
}
/**
* Get capability boolean
* @param string $p_threshold Threshold.
* @param boolean $p_all_projects_only All projects only.
* @return void
*/
function set_capability_boolean( $p_threshold, $p_all_projects_only = false ) {
global $g_access, $g_project;
if( ( $g_access >= config_get_access( $p_threshold ) )
&& ( ( ALL_PROJECTS == $g_project ) || !$p_all_projects_only ) ) {
$f_flag = gpc_get( 'flag_' . $p_threshold, OFF );
$f_access = gpc_get_int( 'access_' . $p_threshold );
$f_flag = ( OFF == $f_flag ) ? OFF : ON;
# @@debug @@ echo "<br />for $p_threshold "; var_dump($f_flag, $f_access); echo '<br />';
if( ( $f_flag != config_get( $p_threshold ) ) || ( $f_access != config_get_access( $p_threshold ) ) ) {
config_set( $p_threshold, $f_flag, NO_USER, $g_project, $f_access );
}
}
}
/**
* Set capability enum
* @param string $p_threshold Threshold.
* @param boolean $p_all_projects_only All projects only.
* @return void
*/
function set_capability_enum( $p_threshold, $p_all_projects_only = false ) {
global $g_access, $g_project;
if( ( $g_access >= config_get_access( $p_threshold ) )
&& ( ( ALL_PROJECTS == $g_project ) || !$p_all_projects_only ) ) {
$f_flag = gpc_get( 'flag_' . $p_threshold );
$f_access = gpc_get_int( 'access_' . $p_threshold );
if( ( $f_flag != config_get( $p_threshold ) ) || ( $f_access != config_get_access( $p_threshold ) ) ) {
config_set( $p_threshold, $f_flag, NO_USER, $g_project, $f_access );
}
}
}
/**
* Check if a configuration option, of those rendered as checkbox inputs, was present
* in the form. This only applies to threshold and boolean config options.
*
* Usually, when a checkbox input is submitted unchecked, there is no value in the
* receiving post data, so we can't know if the input was present or not.
* Those config options add a special hidden input when rendered in the form, so
* we can check its existence with this function.
*
* @param string $p_name Configuration option name
* @return boolean Whether the option was present in the form.
*/
function capability_exists( $p_name ) {
$t_flag = 'flag_exists_' . $p_name;
return gpc_isset( $t_flag );
}
# Issues
set_capability_row( 'report_bug_threshold' );
set_capability_enum( 'bug_submit_status' );
set_capability_row( 'update_bug_threshold' );
set_capability_boolean( 'allow_reporter_close' );
set_capability_row( 'monitor_bug_threshold' );
set_capability_row( 'handle_bug_threshold' );
set_capability_row( 'update_bug_assign_threshold' );
set_capability_row( 'move_bug_threshold', true );
set_capability_row( 'delete_bug_threshold' );
set_capability_row( 'reopen_bug_threshold' );
set_capability_boolean( 'allow_reporter_reopen' );
set_capability_enum( 'bug_reopen_status' );
set_capability_enum( 'bug_reopen_resolution' );
set_capability_enum( 'bug_resolved_status_threshold' );
set_capability_enum( 'bug_readonly_status_threshold' );
set_capability_row( 'private_bug_threshold' );
set_capability_row( 'update_readonly_bug_threshold' );
set_capability_row( 'update_bug_status_threshold' );
set_capability_row( 'set_view_status_threshold' );
set_capability_row( 'change_view_status_threshold' );
set_capability_row( 'set_bug_sticky_threshold' );
set_capability_row( 'show_monitor_list_threshold' );
set_capability_row( 'monitor_add_others_bug_threshold' );
set_capability_row( 'monitor_delete_others_bug_threshold' );
set_capability_boolean( 'auto_set_status_to_assigned' );
set_capability_enum( 'bug_assigned_status' );
if( capability_exists( 'limit_reporters' ) ) {
set_capability_boolean( 'limit_reporters', true );
}
if( capability_exists( 'limit_view_unless_threshold' ) ) {
set_capability_row( 'limit_view_unless_threshold' );
}
# Notes
set_capability_row( 'add_bugnote_threshold' );
set_capability_row( 'update_bugnote_threshold' );
set_capability_row( 'bugnote_user_edit_threshold' );
set_capability_row( 'delete_bugnote_threshold' );
set_capability_row( 'bugnote_user_delete_threshold' );
set_capability_row( 'private_bugnote_threshold' );
set_capability_row( 'bugnote_user_change_view_state_threshold' );
# Tags
set_capability_row( 'tag_view_threshold' );
set_capability_row( 'tag_attach_threshold' );
set_capability_row( 'tag_detach_threshold' );
set_capability_row( 'tag_detach_own_threshold' );
set_capability_row( 'tag_create_threshold' );
set_capability_row( 'tag_edit_threshold' );
set_capability_row( 'tag_edit_own_threshold' );
# Attachments
if( config_get( 'allow_file_upload' ) == ON ) {
set_capability_row( 'view_attachments_threshold' );
set_capability_row( 'download_attachments_threshold' );
set_capability_row( 'delete_attachments_threshold' );
set_capability_row( 'upload_bug_file_threshold' );
}
# Others
set_capability_row( 'view_changelog_threshold' );
set_capability_row( 'roadmap_view_threshold' );
set_capability_row( 'view_summary_threshold' );
set_capability_row( 'view_handler_threshold' );
set_capability_row( 'view_history_threshold' );
set_capability_row( 'bug_reminder_threshold' );
set_capability_row( 'reminder_receive_threshold' );
form_security_purge( 'manage_config_work_threshold_set' );
html_operation_successful( $t_redirect_url );
layout_page_end();