From a20a2ac7040283370d8202442d66054a73865eb4 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Thu, 22 Mar 2018 13:43:07 +0800 Subject: [PATCH] MDL-61718 admin: Make sure city and country columns are not duplicated * Since City/town and Country have been added in $CFG->showuseridentity since 3.4, we need to exclude the required city and country columns when fetching the extra columns using get_extra_user_fields(). --- admin/user.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/admin/user.php b/admin/user.php index ac0f5f94cb6..8ed2aebf809 100644 --- a/admin/user.php +++ b/admin/user.php @@ -160,10 +160,13 @@ // Carry on with the user listing $context = context_system::instance(); - $extracolumns = get_extra_user_fields($context); + // These columns are always shown in the users list. + $requiredcolumns = array('city', 'country', 'lastaccess'); + // Extra columns containing the extra user fields, excluding the required columns (city and country, to be specific). + $extracolumns = get_extra_user_fields($context, $requiredcolumns); // Get all user name fields as an array. $allusernamefields = get_all_user_name_fields(false, null, null, null, true); - $columns = array_merge($allusernamefields, $extracolumns, array('city', 'country', 'lastaccess')); + $columns = array_merge($allusernamefields, $extracolumns, $requiredcolumns); foreach ($columns as $column) { $string[$column] = get_user_field_name($column);