From 7a22e49e052395c765bdd59643419ca809b121e1 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Wed, 19 Jul 2017 12:08:17 +0800 Subject: [PATCH 1/3] MDL-59436 admin: Add city and country to $CFG->showuseridentity --- admin/settings/users.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/admin/settings/users.php b/admin/settings/users.php index 950c2aa1826..a82d5d6bf93 100644 --- a/admin/settings/users.php +++ b/admin/settings/users.php @@ -189,6 +189,8 @@ if ($hassiteconfig 'phone2' => new lang_string('phone2'), 'department' => new lang_string('department'), 'institution' => new lang_string('institution'), + 'city' => new lang_string('city'), + 'country' => new lang_string('country'), ))); $setting = new admin_setting_configtext('fullnamedisplay', new lang_string('fullnamedisplay', 'admin'), new lang_string('configfullnamedisplay', 'admin'), 'language', PARAM_TEXT, 50); From a9991533fa93e25fbbf04ad629c8311219afa7e8 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Wed, 19 Jul 2017 13:31:43 +0800 Subject: [PATCH 2/3] MDL-59436 user: Render city and country based on $CFG->showuseridentity * I also fixed the redundant generation of query fields in user_get_participants_sql(). --- user/classes/participants_table.php | 18 ------------------ user/lib.php | 9 ++++----- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/user/classes/participants_table.php b/user/classes/participants_table.php index 2def8e50260..e93c844cfef 100644 --- a/user/classes/participants_table.php +++ b/user/classes/participants_table.php @@ -146,14 +146,6 @@ class participants_table extends \table_sql { } // Do not show the columns if it exists in the hiddenfields array. - if (!isset($hiddenfields['city'])) { - $headers[] = get_string('city'); - $columns[] = 'city'; - } - if (!isset($hiddenfields['country'])) { - $headers[] = get_string('country'); - $columns[] = 'country'; - } if (!isset($hiddenfields['lastaccess'])) { if ($courseid == SITEID) { $headers[] = get_string('lastsiteaccess'); @@ -228,16 +220,6 @@ class participants_table extends \table_sql { return $OUTPUT->render_from_template('core/inplace_editable', $editable->export_for_template($OUTPUT)); } - /** - * Generate the city column. - * - * @param \stdClass $data - * @return string - */ - public function col_city($data) { - return $data->city; - } - /** * Generate the country column. * diff --git a/user/lib.php b/user/lib.php index feccd711191..e1f9ec719be 100644 --- a/user/lib.php +++ b/user/lib.php @@ -1239,18 +1239,17 @@ function user_get_participants_sql($courseid, $groupid = 0, $accesssince = 0, $r $joins = array('FROM {user} u'); $wheres = array(); - $userfields = array('username', 'email', 'city', 'country', 'lang', 'timezone', 'maildisplay'); - $mainuserfields = user_picture::fields('u', $userfields); - $extrasql = get_extra_user_fields_sql($context, 'u', '', $userfields); + $userfields = get_extra_user_fields($context, array('username', 'lang', 'timezone', 'maildisplay')); + $userfieldssql = user_picture::fields('u', $userfields); if ($isfrontpage) { - $select = "SELECT $mainuserfields, u.lastaccess$extrasql"; + $select = "SELECT $userfieldssql, u.lastaccess"; $joins[] = "JOIN ($esql) e ON e.id = u.id"; // Everybody on the frontpage usually. if ($accesssince) { $wheres[] = user_get_user_lastaccess_sql($accesssince); } } else { - $select = "SELECT $mainuserfields, COALESCE(ul.timeaccess, 0) AS lastaccess$extrasql"; + $select = "SELECT $userfieldssql, COALESCE(ul.timeaccess, 0) AS lastaccess"; $joins[] = "JOIN ($esql) e ON e.id = u.id"; // Course enrolled users only. // Not everybody has accessed the course yet. $joins[] = 'LEFT JOIN {user_lastaccess} ul ON (ul.userid = u.id AND ul.courseid = :courseid)'; From f7cd3bc0e1e1e2685ad418c23398aafdfea00dd6 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Fri, 21 Jul 2017 08:49:18 +0800 Subject: [PATCH 3/3] MDL-59436 user: Apply default sorting for participants table --- user/classes/participants_table.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/user/classes/participants_table.php b/user/classes/participants_table.php index e93c844cfef..08ba8ccdebe 100644 --- a/user/classes/participants_table.php +++ b/user/classes/participants_table.php @@ -158,6 +158,9 @@ class participants_table extends \table_sql { $this->define_columns($columns); $this->define_headers($headers); + // Make this table sorted by first name by default. + $this->sortable(true, 'firstname'); + $this->no_sorting('select'); $this->set_attribute('id', 'participants');