Fix #11417: Allow EVENT_MENU_MAIN plugin events to return null
[mantis/radio.git] / adm_config_report.php
blobd407a670c09c13cc499135d6566566abc475fd89
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 database_api.php
29 * @uses form_api.php
30 * @uses helper_api.php
31 * @uses html_api.php
32 * @uses lang_api.php
33 * @uses print_api.php
34 * @uses project_api.php
35 * @uses string_api.php
36 * @uses user_api.php
39 require_once( 'core.php' );
40 require_api( 'access_api.php' );
41 require_api( 'authentication_api.php' );
42 require_api( 'config_api.php' );
43 require_api( 'constant_inc.php' );
44 require_api( 'database_api.php' );
45 require_api( 'form_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' );
50 require_api( 'project_api.php' );
51 require_api( 'string_api.php' );
52 require_api( 'user_api.php' );
54 access_ensure_global_level( config_get( 'view_configuration_threshold' ) );
56 $t_read_write_access = access_has_global_level( config_get('set_configuration_threshold' ) );
58 html_page_top( lang_get( 'configuration_report' ) );
60 print_manage_menu( 'adm_config_report.php' );
61 print_manage_config_menu( 'adm_config_report.php' );
63 function get_config_type( $p_type ) {
64 switch( $p_type ) {
65 case CONFIG_TYPE_INT:
66 return "integer";
67 case CONFIG_TYPE_FLOAT:
68 return "float";
69 case CONFIG_TYPE_COMPLEX:
70 return "complex";
71 case CONFIG_TYPE_STRING:
72 default:
73 return "string";
77 function print_config_value_as_string( $p_type, $p_value ) {
78 $t_corrupted = false;
80 switch( $p_type ) {
81 case CONFIG_TYPE_FLOAT:
82 $t_value = (float)$p_value;
83 echo $t_value;
84 return;
85 case CONFIG_TYPE_INT:
86 $t_value = (integer)$p_value;
87 echo $t_value;
88 return;
89 case CONFIG_TYPE_STRING:
90 $t_value = config_eval( $p_value );
91 echo string_nl2br( string_html_specialchars( "'$t_value'" ) );
92 return;
93 case CONFIG_TYPE_COMPLEX:
94 $t_value = @unserialize( $p_value );
95 if ( $t_value === false ) {
96 $t_corrupted = true;
98 break;
99 default:
100 $t_value = config_eval( $p_value );
101 break;
104 echo '<pre>';
106 if ( $t_corrupted ) {
107 echo lang_get( 'configuration_corrupted' );
108 } else {
109 if ( function_exists( 'var_export' ) ) {
110 var_export( $t_value );
111 } else {
112 print_r( $t_value );
116 echo '</pre>';
119 $t_config_table = db_get_table( 'config' );
120 $query = "SELECT config_id, user_id, project_id, type, value, access_reqd FROM $t_config_table ORDER BY user_id, project_id, config_id";
121 $result = db_query_bound( $query );
123 <br />
124 <div align="center">
125 <table class="width100" cellspacing="1">
127 <!-- Title -->
128 <tr>
129 <td class="form-title" colspan="7">
130 <?php echo lang_get( 'database_configuration' ) ?>
131 </td>
132 </tr>
133 <tr class="row-category">
134 <td class="center">
135 <?php echo lang_get( 'username' ) ?>
136 </td>
137 <td class="center">
138 <?php echo lang_get( 'project_name' ) ?>
139 </td>
140 <td>
141 <?php echo lang_get( 'configuration_option' ) ?>
142 </td>
143 <td class="center">
144 <?php echo lang_get( 'configuration_option_type' ) ?>
145 </td>
146 <td class="center">
147 <?php echo lang_get( 'configuration_option_value' ) ?>
148 </td>
149 <td class="center">
150 <?php echo lang_get( 'access_level' ) ?>
151 </td>
152 <?php if ( $t_read_write_access ): ?>
153 <td class="center">
154 <?php echo lang_get( 'actions' ) ?>
155 </td>
156 <?php endif; ?>
157 </tr>
158 <?php
159 while ( $row = db_fetch_array( $result ) ) {
160 extract( $row, EXTR_PREFIX_ALL, 'v' );
163 <!-- Repeated Info Rows -->
164 <tr <?php echo helper_alternate_class() ?> valign="top">
165 <td class="center">
166 <?php echo ($v_user_id == 0) ? lang_get( 'all_users' ) : string_display_line( user_get_name( $v_user_id ) ) ?>
167 </td>
168 <td class="center">
169 <?php echo string_display_line( project_get_name( $v_project_id ) ) ?>
170 </td>
171 <td>
172 <?php echo string_display_line( $v_config_id ) ?>
173 </td>
174 <td class="center">
175 <?php echo string_display_line( get_config_type( $v_type ) ) ?>
176 </td>
177 <td class="left">
178 <?php print_config_value_as_string( $v_type, $v_value ) ?>
179 </td>
180 <td class="center">
181 <?php echo get_enum_element( 'access_levels', $v_access_reqd ) ?>
182 </td>
183 <?php if ( $t_read_write_access ): ?>
184 <td class="center">
185 <?php
186 if ( config_can_delete( $v_config_id ) ) {
187 print_button( "adm_config_delete.php?user_id=$v_user_id&project_id=$v_project_id&config_option=$v_config_id", lang_get( 'delete_link' ) );
188 } else {
189 echo '&nbsp;';
192 </td>
193 <?php endif; ?>
194 </tr>
195 <?php
196 } # end for loop
198 </table>
199 <?php
200 if ( $t_read_write_access ) {
202 <br />
203 <!-- Config Set Form -->
204 <form method="post" action="adm_config_set.php">
205 <?php echo form_security_field( 'adm_config_set' ) ?>
206 <table class="width100" cellspacing="1">
208 <!-- Title -->
209 <tr>
210 <td class="form-title" colspan="2">
211 <?php echo lang_get( 'set_configuration_option' ) ?>
212 </td>
213 </tr>
214 <tr <?php echo helper_alternate_class() ?> valign="top">
215 <td>
216 <?php echo lang_get( 'username' ) ?>
217 </td>
218 <td>
219 <select name="user_id">
220 <option value="0" selected="selected"><?php echo lang_get( 'all_users' ); ?></option>
221 <?php print_user_option_list( auth_get_current_user_id() ) ?>
222 </select>
223 </td>
224 </tr>
225 <tr <?php echo helper_alternate_class() ?> valign="top">
226 <td>
227 <?php echo lang_get( 'project_name' ) ?>
228 </td>
229 <td>
230 <select name="project_id">
231 <option value="0" selected="selected"><?php echo lang_get( 'all_projects' ); ?></option>
232 <?php print_project_option_list( ALL_PROJECTS, false ) ?>
233 </select>
234 </td>
235 </tr>
236 <tr <?php echo helper_alternate_class() ?> valign="top">
237 <td>
238 <?php echo lang_get( 'configuration_option' ) ?>
239 </td>
240 <td>
241 <input type="text" name="config_option" value="" size="64" maxlength="64" />
242 </td>
243 </tr>
244 <tr <?php echo helper_alternate_class() ?> valign="top">
245 <td>
246 <?php echo lang_get( 'configuration_option_type' ) ?>
247 </td>
248 <td>
249 <select name="type">
250 <option value="default" selected="selected">default</option>
251 <option value="string">string</option>
252 <option value="integer">integer</option>
253 <option value="complex">complex</option>
254 </select>
255 </td>
256 </tr>
257 <tr <?php echo helper_alternate_class() ?> valign="top">
258 <td>
259 <?php echo lang_get( 'configuration_option_value' ) ?>
260 </td>
261 <td>
262 <textarea name="value" cols="80" rows="10"></textarea>
263 </td>
264 </tr>
265 <tr>
266 <td colspan="2">
267 <input type="submit" name="config_set" class="button" value="<?php echo lang_get( 'set_configuration_option' ) ?>" />
268 </td>
269 </tr>
270 </table>
271 </form>
272 <?php
273 } # end user can change config
275 </div>
276 <?php
277 html_page_bottom();