Skip to content

Commit

Permalink
Code cleanup: align adm_config_report.php with 1.3 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
dregad committed Mar 27, 2013
1 parent 840b55f commit 0acb11b
Showing 1 changed file with 52 additions and 47 deletions.
99 changes: 52 additions & 47 deletions adm_config_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

access_ensure_project_level( config_get( 'view_configuration_threshold' ) );

$t_read_write_access = access_has_global_level( config_get('set_configuration_threshold' ) );

html_page_top( lang_get( 'configuration_report' ) );

print_manage_menu( 'adm_config_report.php' );
Expand Down Expand Up @@ -63,11 +65,11 @@ function print_config_value_as_string( $p_type, $p_value, $p_for_display = true
echo (integer)$p_value;
return;
case CONFIG_TYPE_STRING:
$t_value = config_eval( $p_value );
$t_value = string_nl2br( string_html_specialchars( config_eval( $p_value ) ) );
if( $p_for_display ) {
$t_value = "'$t_value'";
}
echo string_nl2br( string_html_specialchars( $t_value ) );
echo $t_value;
return;
case CONFIG_TYPE_COMPLEX:
$t_value = @unserialize( $p_value );
Expand Down Expand Up @@ -97,10 +99,11 @@ function print_option_list_from_array( $p_array, $p_filter_value ) {
foreach( $p_array as $t_key => $t_value ) {
echo "<option value='$t_key'";
check_selected( $p_filter_value, $t_key );
echo ">" . string_attribute( $t_value ) . "</option>\n";
echo '>' . string_attribute( $t_value ) . "</option>\n";
}
}


# Get filter values
$t_filter_save = gpc_get_bool( 'save' );
$t_filter_default = gpc_get_bool( 'default_filter_button', false );
Expand Down Expand Up @@ -234,9 +237,10 @@ function print_option_list_from_array( $p_array, $p_filter_value ) {
?>

<br />
<div align="center">

<!-- FILTER FORM -->
<div align="center">

<form id="filter_form" method="post">
<?php # CSRF protection not required here - form does not result in modifications ?>
<input type="hidden" name="save" value="1" />
Expand Down Expand Up @@ -324,10 +328,13 @@ function print_option_list_from_array( $p_array, $p_filter_value ) {
<td class="center">
<?php echo lang_get( 'access_level' ) ?>
</td>
<?php if( $t_read_write_access ) { ?>
<td class="center">
<?php echo lang_get( 'actions' ) ?>
</td>
<?php } ?>
</tr>

<?php
# Pre-generate a form security token to avoid performance issues when the
# db contains a large number of configurations
Expand Down Expand Up @@ -357,52 +364,55 @@ function print_option_list_from_array( $p_array, $p_filter_value ) {
<td class="center">
<?php echo get_enum_element( 'access_levels', $v_access_reqd ) ?>
</td>
<?php
if( $t_read_write_access ) {
?>
<td class="center">
<?php
if (
config_can_delete( $v_config_id )
&& access_has_global_level( config_get( 'set_configuration_threshold' ) )
) {
# Update button (will populate edit form at page bottom)
print_button(
'#config_set_form',
lang_get( 'edit_link' ),
array(
'user_id' => $v_user_id,
'project_id' => $v_project_id,
'config_option' => $v_config_id,
'type' => $v_type,
'value' => $v_value,
),
OFF
);

# Delete button
print_button(
'adm_config_delete.php',
lang_get( 'delete_link' ),
array(
'user_id' => $v_user_id,
'project_id' => $v_project_id,
'config_option' => $v_config_id,
),
$t_form_security_token
);
} else {
echo '&#160;';
}
?>
<?php
if( config_can_delete( $v_config_id ) ) {
# Update button (will populate edit form at page bottom)
print_button(
'#config_set_form',
lang_get( 'edit_link' ),
array(
'user_id' => $v_user_id,
'project_id' => $v_project_id,
'config_option' => $v_config_id,
'type' => $v_type,
'value' => $v_value,
),
OFF
);

# Delete button
print_button(
'adm_config_delete.php',
lang_get( 'delete_link' ),
array(
'user_id' => $v_user_id,
'project_id' => $v_project_id,
'config_option' => $v_config_id,
),
$t_form_security_token
);
} else {
echo '&#160;';
}
?>
</td>
<?php
} # end if config_can_delete
?>
</tr>
<?php
} # end for loop
} # end while loop
?>
</table>


<?php
# Only display the edit form if user is authorized to change configuration
if ( access_has_global_level( config_get( 'set_configuration_threshold' ) ) ) {
if( $t_read_write_access ) {
?>
<br />

Expand Down Expand Up @@ -470,13 +480,7 @@ function print_option_list_from_array( $p_array, $p_filter_value ) {
</td>
<td>
<select name="type">
<?php
foreach( $t_config_types as $t_key => $t_type ) {
echo '<option value="' . $t_key . '" ';
check_selected( $t_key, $t_edit_type );
echo ">$t_type</option>";
}
?>
<?php print_option_list_from_array( $t_config_types, $t_edit_type ); ?>
</select>
</td>
</tr>
Expand All @@ -493,6 +497,7 @@ function print_option_list_from_array( $p_array, $p_filter_value ) {
</td>
</tr>

<!-- Submit button -->
<tr>
<td colspan="2">
<input type="submit" name="config_set" class="button" value="<?php echo lang_get( 'set_configuration_option' ) ?>" />
Expand Down

0 comments on commit 0acb11b

Please sign in to comment.