Skip to content

Commit

Permalink
Fix adm_config_report user list
Browse files Browse the repository at this point in the history
The code to build the user dropdown list have some issues:
- Missing db_param_push()
- Calls to get user names are not cached generating a lot of separate
  queries for individual user ids
- User names are not properly ordered in the dropdown list, as it's
  sorting with a case sensitive mode.

Fixes: #25454, #25455, #25456
  • Loading branch information
cproensa authored and vboctor committed Feb 24, 2019
1 parent 5ee508f commit f0d4f66
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions adm_config_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,21 @@ function check_config_value( $p_config ) {
# Apply filters

# Get users in db having specific configs
$t_query = 'SELECT DISTINCT user_id FROM {config} WHERE user_id <> ' . db_param() ;
$t_result = db_query( $t_query, array( ALL_USERS ) );
$t_query = new DbQuery( 'SELECT DISTINCT user_id FROM {config} WHERE user_id <> :all_users',
array( 'all_users' => ALL_USERS ) );
# build result as: array( [id]=>id, ... )
$t_user_ids = array_column( $t_query->fetch_all(), 'user_id', 'user_id' );

if( $t_filter_user_value != META_FILTER_NONE && $t_filter_user_value != ALL_USERS ) {
# Make sure the filter value exists in the list
$t_users_list[$t_filter_user_value] = user_get_name( $t_filter_user_value );
} else {
$t_users_list = array();
}
while( $t_row = db_fetch_array( $t_result ) ) {
$t_user_id = $t_row['user_id'];
$t_users_list[$t_user_id] = user_get_name( $t_user_id );
$t_user_ids[$t_filter_user_value] = $t_filter_user_value;
}
asort( $t_users_list );
user_cache_array_rows( $t_user_ids );

# build array for user names
$t_users_list = array_map( 'user_get_name', $t_user_ids );
asort( $t_users_list, SORT_NATURAL | SORT_FLAG_CASE );

# Prepend '[any]' and 'All Users' to the list
$t_users_list = array(
META_FILTER_NONE => '[' . lang_get( 'any' ) . ']',
Expand Down

0 comments on commit f0d4f66

Please sign in to comment.