Permalink
Browse files

MDL-26647 (4) Support showuseridentity on Participants page

  • Loading branch information...
1 parent 1fdc0c6 commit 43aa295b959ef4212535a569972dee52c474bdb5 @sammarshallou sammarshallou committed Apr 13, 2011
Showing with 30 additions and 5 deletions.
  1. +30 −5 user/index.php
View
@@ -318,7 +318,14 @@
/// Define a table showing a list of users in the current role selection
$tablecolumns = array('userpic', 'fullname');
+ $extrafields = get_extra_user_fields($context);
$tableheaders = array(get_string('userpic'), get_string('fullnameuser'));
+ if ($mode === MODE_BRIEF) {
+ foreach ($extrafields as $field) {
+ $tablecolumns[] = $field;
+ $tableheaders[] = get_user_field_name($field);
+ }
+ }
if ($mode === MODE_BRIEF && !isset($hiddenfields['city'])) {
$tablecolumns[] = 'city';
$tableheaders[] = get_string('city');
@@ -338,7 +345,6 @@
}
$table = new flexible_table('user-index-participants-'.$course->id);
-
$table->define_columns($tablecolumns);
$table->define_headers($tableheaders);
$table->define_baseurl($baseurl->out());
@@ -373,11 +379,15 @@
$joins = array("FROM {user} u");
$wheres = array();
+ $extrasql = get_extra_user_fields_sql($context, 'u', '', array(
+ 'id', 'username', 'firstname', 'lastname', 'email', 'city', 'country',
+ 'picture', 'lang', 'timezone', 'maildisplay', 'imagealt', 'lastaccess'));
+
if ($isfrontpage) {
$select = "SELECT u.id, u.username, u.firstname, u.lastname,
u.email, u.city, u.country, u.picture,
u.lang, u.timezone, u.maildisplay, u.imagealt,
- u.lastaccess";
+ u.lastaccess$extrasql";
$joins[] = "JOIN ($esql) e ON e.id = u.id"; // everybody on the frontpage usually
if ($accesssince) {
$wheres[] = get_user_lastaccess_sql($accesssince);
@@ -387,7 +397,7 @@
$select = "SELECT u.id, u.username, u.firstname, u.lastname,
u.email, u.city, u.country, u.picture,
u.lang, u.timezone, u.maildisplay, u.imagealt,
- COALESCE(ul.timeaccess, 0) AS lastaccess";
+ COALESCE(ul.timeaccess, 0) AS lastaccess$extrasql";
$joins[] = "JOIN ($esql) e ON e.id = u.id"; // course enrolled users only
$joins[] = "LEFT JOIN {user_lastaccess} ul ON (ul.userid = u.id AND ul.courseid = :courseid)"; // not everybody accessed course yet
$params['courseid'] = $course->id;
@@ -607,9 +617,20 @@
$row->cells[1]->text .= get_string('role').get_string('labelsep', 'langconfig').$user->role.'<br />';
}
if ($user->maildisplay == 1 or ($user->maildisplay == 2 and ($course->id != SITEID) and !isguestuser()) or
- has_capability('moodle/course:viewhiddenuserfields', $context)) {
+ has_capability('moodle/course:viewhiddenuserfields', $context) or
+ in_array('email', $extrafields)) {
$row->cells[1]->text .= get_string('email').get_string('labelsep', 'langconfig').html_writer::link("mailto:$user->email", $user->email) . '<br />';
}
+ foreach ($extrafields as $field) {
+ if ($field === 'email') {
+ // Skip email because it was displayed with different
+ // logic above (because this page is intended for
+ // students too)
+ continue;
+ }
+ $row->cells[1]->text .= get_user_field_name($field) .
+ get_string('labelsep', 'langconfig') . s($user->{$field}) . '<br />';
+ }
if (($user->city or $user->country) and (!isset($hiddenfields['city']) or !isset($hiddenfields['country']))) {
$row->cells[1]->text .= get_string('city').get_string('labelsep', 'langconfig');
if ($user->city && !isset($hiddenfields['city'])) {
@@ -717,6 +738,11 @@
$data = array ($OUTPUT->user_picture($user, array('size' => 35, 'courseid'=>$course->id)), $profilelink);
+ if ($mode === MODE_BRIEF) {
+ foreach ($extrafields as $field) {
+ $data[] = $user->{$field};
+ }
+ }
if ($mode === MODE_BRIEF && !isset($hiddenfields['city'])) {
$data[] = $user->city;
}
@@ -752,7 +778,6 @@
$data[] = '<input type="checkbox" class="usercheckbox" name="user'.$user->id.'" />';
}
$table->add_data($data);
-
}
}

0 comments on commit 43aa295

Please sign in to comment.