MDL-87649 user: Add suspended label to participants page

This commit is contained in:
Brendan Heywood
2026-03-15 00:21:47 +11:00
parent 31f361c73f
commit 6caa1d26bc
4 changed files with 29 additions and 5 deletions
+12 -1
View File
@@ -2384,7 +2384,18 @@ class core_renderer extends renderer_base {
$this->add_action_handler(new popup_action('click', $url), $id);
}
return html_writer::tag('a', $output, $attributes);
$output = html_writer::tag('a', $output, $attributes);
// Show suspended label if needed.
if ( $userpicture->showsuspended && property_exists($user, 'suspended') && $user->suspended) {
$output .= html_writer::tag(
'span',
get_string('suspended'),
['class' => 'badge text-bg-warning ms-1']
);
}
return $output;
}
/**
@@ -81,6 +81,11 @@ class user_picture implements renderable {
*/
public $includefullname = false;
/**
* @var bool Whether to include the suspended label.
*/
public $showsuspended = false;
/**
* @var mixed Include user authentication token. True indicates to generate a token for current user, and integer value
* indicates to generate a token for the user whose id is the value indicated.
+10 -2
View File
@@ -250,8 +250,16 @@ class participants extends \table_sql implements dynamic_table {
*/
public function col_fullname($data) {
global $OUTPUT;
return $OUTPUT->render(\core_user::get_profile_picture($data, null,
['courseid' => $this->course->id, 'includefullname' => true]));
return $OUTPUT->render(\core_user::get_profile_picture(
$data,
null,
[
'courseid' => $this->course->id,
'includefullname' => true,
'showsuspended' => true,
]
));
}
/**
@@ -235,12 +235,12 @@ class participants_search {
}
if ($isfrontpage) {
$outerselect = "SELECT u.lastaccess $userfieldssql";
$outerselect = "SELECT u.lastaccess, u.suspended $userfieldssql";
if ($accesssince) {
$wheres[] = user_get_user_lastaccess_sql($accesssince, 'u', $matchaccesssince);
}
} else {
$outerselect = "SELECT COALESCE(ul.timeaccess, 0) AS lastaccess $userfieldssql";
$outerselect = "SELECT COALESCE(ul.timeaccess, 0) AS lastaccess, u.suspended $userfieldssql";
// Not everybody has accessed the course yet.
$outerjoins[] = 'LEFT JOIN {user_lastaccess} ul ON (ul.userid = u.id AND ul.courseid = :courseid2)';
$params['courseid2'] = $this->course->id;