Fix #11417: Allow EVENT_MENU_MAIN plugin events to return null
[mantis/radio.git] / manage_config_work_threshold_page.php
blob70d25642bb452b746f34151b9a8d2ece0d3cdc82
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 form_api.php
29 * @uses helper_api.php
30 * @uses html_api.php
31 * @uses lang_api.php
32 * @uses print_api.php
33 * @uses project_api.php
34 * @uses string_api.php
35 * @uses user_api.php
38 require_once( 'core.php' );
39 require_api( 'access_api.php' );
40 require_api( 'authentication_api.php' );
41 require_api( 'config_api.php' );
42 require_api( 'constant_inc.php' );
43 require_api( 'form_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( 'project_api.php' );
49 require_api( 'string_api.php' );
50 require_api( 'user_api.php' );
52 auth_reauthenticate();
54 html_page_top( lang_get( 'manage_threshold_config' ) );
56 print_manage_menu( 'adm_permissions_report.php' );
57 print_manage_config_menu( 'manage_config_work_threshold_page.php' );
59 $t_user = auth_get_current_user_id();
60 $t_project_id = helper_get_current_project();
61 $t_access = user_get_access_level( $t_user, $t_project_id );
62 $t_show_submit = false;
64 $t_access_levels = MantisEnum::getAssocArrayIndexedByValues( config_get( 'access_levels_enum_string' ) );
66 $t_overrides = array();
67 function set_overrides( $p_config ) {
68 global $t_overrides;
69 if ( !in_array( $p_config, $t_overrides ) ) {
70 $t_overrides[] = $p_config;
74 function get_section_begin_mcwt( $p_section_name ) {
75 global $t_access_levels;
77 echo '<table class="width100">';
78 echo '<tr><td class="form-title" colspan="' . ( count( $t_access_levels ) + 2 ) . '">' . $p_section_name . '</td></tr>' . "\n";
79 echo '<tr><td class="form-title" width="40%" rowspan="2">' . lang_get( 'perm_rpt_capability' ) . '</td>';
80 echo '<td class="form-title"style="text-align:center" width="40%" colspan="' . count( $t_access_levels ) . '">' . lang_get( 'access_levels' ) . '</td>';
81 echo '<td class="form-title" style="text-align:center" rowspan="2">&nbsp;' . lang_get( 'alter_level' ) . '&nbsp;</td></tr><tr>';
82 foreach( $t_access_levels as $t_access_level => $t_access_label ) {
83 echo '<td class="form-title" style="text-align:center">&nbsp;' . MantisEnum::getLabel( lang_get( 'access_levels_enum_string' ), $t_access_level ) . '&nbsp;</td>';
85 echo '</tr>' . "\n";
88 function get_capability_row( $p_caption, $p_threshold, $p_all_projects_only=false ) {
89 global $t_user, $t_project_id, $t_show_submit, $t_access_levels, $t_colour_project, $t_colour_global;
91 $t_file = config_get_global( $p_threshold );
92 if ( !is_array( $t_file ) ) {
93 $t_file_exp = array();
94 foreach( $t_access_levels as $t_access_level => $t_label ) {
95 if ( $t_access_level >= $t_file ) {
96 $t_file_exp[] = $t_access_level;
99 } else {
100 $t_file_exp = $t_file;
103 $t_global = config_get( $p_threshold, null, null, ALL_PROJECTS );
104 if ( !is_array( $t_global ) ) {
105 $t_global_exp = array();
106 foreach( $t_access_levels as $t_access_level => $t_label ) {
107 if ( $t_access_level >= $t_global ) {
108 $t_global_exp[] = $t_access_level;
111 } else {
112 $t_global_exp = $t_global;
115 $t_project = config_get( $p_threshold );
116 if ( !is_array( $t_project ) ) {
117 $t_project_exp = array();
118 foreach( $t_access_levels as $t_access_level => $t_label ) {
119 if ( $t_access_level >= $t_project ) {
120 $t_project_exp[] = $t_access_level;
123 } else {
124 $t_project_exp = $t_project;
127 $t_can_change = access_has_project_level( config_get_access( $p_threshold ), $t_project_id, $t_user )
128 && ( ( ALL_PROJECTS == $t_project_id ) || !$p_all_projects_only );
130 echo '<tr ' . helper_alternate_class() . '><td>' . string_display( $p_caption ) . '</td>';
131 foreach( $t_access_levels as $t_access_level => $t_access_label ) {
132 $t_file = in_array( $t_access_level, $t_file_exp );
133 $t_global = in_array( $t_access_level, $t_global_exp );
134 $t_project = in_array( $t_access_level, $t_project_exp ) ;
136 $t_colour = '';
137 if ( $t_global != $t_file ) {
138 $t_colour = ' bgcolor="' . $t_colour_global . '" '; # all projects override
139 if ( $t_can_change ) {
140 set_overrides( $p_threshold );
143 if ( $t_project != $t_global ) {
144 $t_colour = ' bgcolor="' . $t_colour_project . '" '; # project overrides
145 if ( $t_can_change ) {
146 set_overrides( $p_threshold );
150 if ( $t_can_change ) {
151 $t_checked = $t_project ? "checked=\"checked\"" : "";
152 $t_value = "<input type=\"checkbox\" name=\"flag_thres_" . $p_threshold . "[]\" value=\"$t_access_level\" $t_checked />";
153 $t_show_submit = true;
154 } else {
155 if ( $t_project ) {
156 $t_value = '<img src="images/ok.gif" width="20" height="15" alt="X" title="X" />';
157 } else {
158 $t_value = '&nbsp;';
161 echo '<td class="center"' . $t_colour . '>' . $t_value . '</td>';
163 if ( $t_can_change ) {
164 echo '<td> <select name="access_' . $p_threshold . '">';
165 print_enum_string_option_list( 'access_levels', config_get_access( $p_threshold ) );
166 echo '</select> </td>';
167 } else {
168 echo '<td>' . MantisEnum::getLabel( lang_get( 'access_levels_enum_string' ), config_get_access( $p_threshold ) ) . '&nbsp;</td>';
171 echo '</tr>' . "\n";
174 function get_capability_boolean( $p_caption, $p_threshold, $p_all_projects_only=false ) {
175 global $t_user, $t_project_id, $t_show_submit, $t_access_levels, $t_colour_project, $t_colour_global;
177 $t_file = config_get_global( $p_threshold );
178 $t_global = config_get( $p_threshold, null, null, ALL_PROJECTS );
179 $t_project = config_get( $p_threshold );
181 $t_can_change = access_has_project_level( config_get_access( $p_threshold ), $t_project_id, $t_user )
182 && ( ( ALL_PROJECTS == $t_project_id ) || !$p_all_projects_only );
184 $t_colour = '';
185 if ( $t_global != $t_file ) {
186 $t_colour = ' bgcolor="' . $t_colour_global . '" '; # all projects override
187 if ( $t_can_change ) {
188 set_overrides( $p_threshold );
191 if ( $t_project != $t_global ) {
192 $t_colour = ' bgcolor="' . $t_colour_project . '" '; # project overrides
193 if ( $t_can_change ) {
194 set_overrides( $p_threshold );
198 echo '<tr ' . helper_alternate_class() . '><td>' . string_display( $p_caption ) . '</td>';
199 if ( $t_can_change ) {
200 $t_checked = ( ON == config_get( $p_threshold ) ) ? "checked=\"checked\"" : "";
201 $t_value = "<input type=\"checkbox\" name=\"flag_" . $p_threshold . "\" value=\"1\" $t_checked />";
202 $t_show_submit = true;
203 } else {
204 if ( ON == config_get( $p_threshold ) ) {
205 $t_value = '<img src="images/ok.gif" width="20" height="15" title="X" alt="X" />';
206 } else {
207 $t_value = '&nbsp;';
210 echo '<td' . $t_colour . '>' . $t_value . '</td><td class="left" colspan="' . ( count( $t_access_levels ) - 1 ). '"></td>';
212 if ( $t_can_change ) {
213 echo '<td><select name="access_' . $p_threshold . '">';
214 print_enum_string_option_list( 'access_levels', config_get_access( $p_threshold ) );
215 echo '</select> </td>';
216 } else {
217 echo '<td>' . MantisEnum::getLabel( lang_get( 'access_levels_enum_string' ), config_get_access( $p_threshold ) ) . '&nbsp;</td>';
220 echo '</tr>' . "\n";
223 function get_capability_enum( $p_caption, $p_threshold, $p_enum, $p_all_projects_only=false ) {
224 global $t_user, $t_project_id, $t_show_submit, $t_access_levels, $t_colour_project, $t_colour_global;
226 $t_file = config_get_global( $p_threshold );
227 $t_global = config_get( $p_threshold, null, null, ALL_PROJECTS );
228 $t_project = config_get( $p_threshold );
230 $t_can_change = access_has_project_level( config_get_access( $p_threshold ), $t_project_id, $t_user )
231 && ( ( ALL_PROJECTS == $t_project_id ) || !$p_all_projects_only );
233 $t_colour = '';
234 if ( $t_global != $t_file ) {
235 $t_colour = ' bgcolor="' . $t_colour_global . '" '; # all projects override
236 if ( $t_can_change ) {
237 set_overrides( $p_threshold );
240 if ( $t_project != $t_global ) {
241 $t_colour = ' bgcolor="' . $t_colour_project . '" '; # project overrides
242 if ( $t_can_change ) {
243 set_overrides( $p_threshold );
247 echo '<tr ' . helper_alternate_class() . '><td>' . string_display( $p_caption ) . '</td>';
248 if ( $t_can_change ) {
249 echo '<td class="left" colspan="3"' . $t_colour . '><select name="flag_' . $p_threshold . '">';
250 print_enum_string_option_list( $p_enum, config_get( $p_threshold ) );
251 echo '</select></td><td colspan="' . ( count( $t_access_levels ) - 3 ) . '"></td>';
252 $t_show_submit = true;
253 } else {
254 $t_value = MantisEnum::getLabel( lang_get( $p_enum . '_enum_string' ), config_get( $p_threshold ) ) . '&nbsp;';
255 echo '<td class="left" colspan="3"' . $t_colour . '>' . $t_value . '</td><td colspan="' . ( count( $t_access_levels ) - 3 ) . '"></td>';
258 if ( $t_can_change ) {
259 echo '<td><select name="access_' . $p_threshold . '">';
260 print_enum_string_option_list( 'access_levels', config_get_access( $p_threshold ) );
261 echo '</select> </td>';
262 } else {
263 echo '<td>' . MantisEnum::getLabel( lang_get( 'access_levels_enum_string' ), config_get_access( $p_threshold ) ) . '&nbsp;</td>';
266 echo '</tr>' . "\n";
269 function get_section_end() {
270 echo '</table><br />' . "\n";
273 $t_colour_project = config_get( 'colour_project');
274 $t_colour_global = config_get( 'colour_global');
276 echo "<br /><br />\n";
278 if ( ALL_PROJECTS == $t_project_id ) {
279 $t_project_title = lang_get( 'config_all_projects' );
280 } else {
281 $t_project_title = sprintf( lang_get( 'config_project' ) , string_display( project_get_name( $t_project_id ) ) );
283 echo '<p class="bold">' . $t_project_title . '</p>' . "\n";
284 echo '<p>' . lang_get( 'colour_coding' ) . '<br />';
285 if ( ALL_PROJECTS <> $t_project_id ) {
286 echo '<span style="background-color:' . $t_colour_project . '">' . lang_get( 'colour_project' ) .'</span><br />';
288 echo '<span style="background-color:' . $t_colour_global . '">' . lang_get( 'colour_global' ) . '</span></p>';
290 echo "<form name=\"mail_config_action\" method=\"post\" action=\"manage_config_work_threshold_set.php\">\n";
291 echo form_security_field( 'manage_config_work_threshold_set' );
293 # Issues
294 get_section_begin_mcwt( lang_get( 'issues' ) );
295 get_capability_row( lang_get( 'report_issue' ), 'report_bug_threshold' );
296 get_capability_enum( lang_get( 'submit_status' ), 'bug_submit_status', 'status' );
297 get_capability_row( lang_get( 'update_issue' ), 'update_bug_threshold' );
298 get_capability_boolean( lang_get( 'allow_close_immediate' ), 'allow_close_immediately' );
299 get_capability_boolean( lang_get( 'allow_reporter_close' ), 'allow_reporter_close' );
300 get_capability_row( lang_get( 'monitor_issue' ), 'monitor_bug_threshold' );
301 get_capability_row( lang_get( 'handle_issue' ), 'handle_bug_threshold' );
302 get_capability_row( lang_get( 'assign_issue' ), 'update_bug_assign_threshold' );
303 get_capability_row( lang_get( 'move_issue' ), 'move_bug_threshold', true );
304 get_capability_row( lang_get( 'delete_issue' ), 'delete_bug_threshold' );
305 get_capability_row( lang_get( 'reopen_issue' ), 'reopen_bug_threshold' );
306 get_capability_boolean( lang_get( 'allow_reporter_reopen' ), 'allow_reporter_reopen' );
307 get_capability_enum( lang_get( 'reopen_status' ), 'bug_reopen_status', 'status' );
308 get_capability_enum( lang_get( 'reopen_resolution' ), 'bug_reopen_resolution', 'resolution' );
309 get_capability_enum( lang_get( 'resolved_status' ), 'bug_resolved_status_threshold', 'status' );
310 get_capability_enum( lang_get( 'readonly_status' ), 'bug_readonly_status_threshold', 'status' );
311 get_capability_row( lang_get( 'update_readonly_issues' ), 'update_readonly_bug_threshold' );
312 get_capability_row( lang_get( 'update_issue_status' ), 'update_bug_status_threshold' );
313 get_capability_row( lang_get( 'view_private_issues' ), 'private_bug_threshold' );
314 get_capability_row( lang_get( 'set_view_status' ), 'set_view_status_threshold' );
315 get_capability_row( lang_get( 'update_view_status' ), 'change_view_status_threshold' );
316 get_capability_row( lang_get( 'show_list_of_users_monitoring_issue' ), 'show_monitor_list_threshold' );
317 get_capability_boolean( lang_get( 'set_status_assigned' ), 'auto_set_status_to_assigned' );
318 get_capability_enum( lang_get( 'assigned_status' ), 'bug_assigned_status', 'status' );
319 get_capability_boolean( lang_get( 'limit_access' ), 'limit_reporters', true );
320 get_section_end();
322 # Notes
323 get_section_begin_mcwt( lang_get( 'notes' ) );
324 get_capability_row( lang_get( 'add_notes' ), 'add_bugnote_threshold' );
325 get_capability_row( lang_get( 'edit_others_bugnotes' ), 'update_bugnote_threshold' );
326 get_capability_row( lang_get( 'edit_own_bugnotes' ), 'bugnote_user_edit_threshold' );
327 get_capability_row( lang_get( 'delete_others_bugnotes' ), 'delete_bugnote_threshold' );
328 get_capability_row( lang_get( 'delete_own_bugnotes' ), 'bugnote_user_delete_threshold' );
329 get_capability_row( lang_get( 'view_private_notes' ), 'private_bugnote_threshold' );
330 get_capability_row( lang_get( 'change_view_state_own_bugnotes' ), 'bugnote_user_change_view_state_threshold' );
331 get_section_end();
333 # Others
334 get_section_begin_mcwt( lang_get('others' ) );
335 get_capability_row( lang_get( 'view' ) . ' ' . lang_get( 'changelog_link' ), 'view_changelog_threshold' );
336 get_capability_row( lang_get( 'view' ) . ' ' . lang_get( 'assigned_to' ), 'view_handler_threshold' );
337 get_capability_row( lang_get( 'view' ) . ' ' . lang_get( 'bug_history' ), 'view_history_threshold' );
338 get_capability_row( lang_get( 'send_reminders' ), 'bug_reminder_threshold' );
339 get_section_end();
342 if ( $t_show_submit ) {
343 echo "<input type=\"submit\" class=\"button\" value=\"" . lang_get( 'change_configuration' ) . "\" />\n";
346 echo "</form>\n";
348 if ( $t_show_submit && ( 0 < count( $t_overrides ) ) ) {
349 echo "<div class=\"right\"><form name=\"threshold_config_action\" method=\"post\" action=\"manage_config_revert.php\">\n";
350 echo form_security_field( 'manage_config_revert' );
351 echo "<input name=\"revert\" type=\"hidden\" value=\"" . implode( ',', $t_overrides ) . "\"></input>";
352 echo "<input name=\"project\" type=\"hidden\" value=\"$t_project_id\"></input>";
353 echo "<input name=\"return\" type=\"hidden\" value=\"" . string_sanitize_url( $_SERVER['SCRIPT_NAME'] ) ."\"></input>";
354 echo "<input type=\"submit\" class=\"button\" value=\"";
355 if ( ALL_PROJECTS == $t_project_id ) {
356 echo lang_get( 'revert_to_system' );
357 } else {
358 echo lang_get( 'revert_to_all_project' );
360 echo "\" />\n";
361 echo "</form></div>\n";
364 html_page_bottom();