diff --git a/blocks/online_users/block_online_users.php b/blocks/online_users/block_online_users.php
index 7c65c47732a..5d2a5c6b820 100644
--- a/blocks/online_users/block_online_users.php
+++ b/blocks/online_users/block_online_users.php
@@ -140,6 +140,12 @@ class block_online_users extends block_base {
//Accessibility: Don't want 'Alt' text for the user picture; DO want it for the envelope/message link (existing lang string).
//Accessibility: Converted
to
, inherit existing classes & styles.
$this->content->text .= "\n";
+ if (!empty($USER->id) && has_capability('moodle/site:sendmessage', $context)
+ && !empty($CFG->messaging) && !isguest()) {
+ $canshowicon = true;
+ } else {
+ $canshowicon = false;
+ }
foreach ($users as $user) {
$this->content->text .= '- ';
$timeago = format_time(time() - $user->lastaccess); //bruno to calculate correctly on frontpage
@@ -152,9 +158,7 @@ class block_online_users extends block_base {
$this->content->text .= print_user_picture($user->id, $COURSE->id, $user->picture, 16, true, false, '', false);
$this->content->text .= $user->fullname.'
';
}
- if (!empty($USER->id) and ($USER->id != $user->id) and !empty($CFG->messaging) and
- has_capability('moodle/site:sendmessage', $context) and
- !isguest() and $user->username != 'guest') { // Only when logged in and messaging active etc
+ if ($canshowicon and ($USER->id != $user->id) and $user->username != 'guest') { // Only when logged in and messaging active etc
$this->content->text .= '';
}