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().
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
+4
-5
@@ -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)';
|
||||
|
||||
Reference in New Issue
Block a user