mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
MDL-59293 block_onlineusers: Check whether current user can view online users
- Removed block from site admin. - Blocked guest from viewuserlist cap
This commit is contained in:
parent
5db1ed89b9
commit
33d6017287
@ -88,14 +88,23 @@ class block_online_users extends block_base {
|
||||
|
||||
$this->content->text = '<div class="info">'.$usercount.' ('.$periodminutes.')</div>';
|
||||
|
||||
// Verify if we can see the list of users, if not just print number of users
|
||||
if (!has_capability('block/online_users:viewlist', $this->page->context)) {
|
||||
// Verify if we can see the list of users, if not just print number of users.
|
||||
// If the current user is not logged in OR it's a guest then don't show any users.
|
||||
if (!has_capability('block/online_users:viewlist', $this->page->context)
|
||||
|| isguestuser() || !isloggedin()) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$userlimit = 50; // We'll just take the most recent 50 maximum.
|
||||
$initialcount = 0;
|
||||
if ($users = $onlineusers->get_users($userlimit)) {
|
||||
require_once($CFG->dirroot . '/user/lib.php');
|
||||
$initialcount = count($users);
|
||||
foreach ($users as $user) {
|
||||
if (!user_can_view_profile($user)) {
|
||||
unset($users[$user->id]);
|
||||
continue;
|
||||
}
|
||||
$users[$user->id]->fullname = fullname($user);
|
||||
}
|
||||
} else {
|
||||
@ -153,6 +162,14 @@ class block_online_users extends block_base {
|
||||
}
|
||||
$this->content->text .= "</li>\n";
|
||||
}
|
||||
if ($initialcount - count($users) > 0) {
|
||||
$this->content->text .= '<li class="listentry"><div class="otherusers">';
|
||||
$this->content->text .= html_writer::span(
|
||||
get_string('otherusers', 'block_online_users', $initialcount - count($users))
|
||||
);
|
||||
$this->content->text .= "</div>";
|
||||
$this->content->text .= "</li>\n";
|
||||
}
|
||||
$this->content->text .= '</ul><div class="clearer"><!-- --></div>';
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ class fetcher {
|
||||
}
|
||||
$params = array();
|
||||
|
||||
$userfields = \user_picture::fields('u', array('username'));
|
||||
$userfields = \user_picture::fields('u', array('username', 'deleted'));
|
||||
|
||||
// Add this to the SQL to show only group users.
|
||||
if ($currentgroup !== null) {
|
||||
|
@ -55,7 +55,7 @@ $capabilities = array(
|
||||
'contextlevel' => CONTEXT_BLOCK,
|
||||
'archetypes' => array(
|
||||
'user' => CAP_ALLOW,
|
||||
'guest' => CAP_ALLOW,
|
||||
'guest' => CAP_PREVENT,
|
||||
'student' => CAP_ALLOW,
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
|
@ -23,6 +23,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['otherusers'] = 'Other Users ({$a})';
|
||||
$string['onlinestatushiding_desc'] = 'If enabled, users have the option to hide their online status from other users.';
|
||||
$string['configtimetosee'] = 'Number of minutes determining the period of inactivity after which a user is no longer considered to be online.';
|
||||
$string['onlinestatushiding'] = 'Online status hiding';
|
||||
|
@ -7,6 +7,10 @@
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.block_online_users .content .list li.listentry .otherusers {
|
||||
margin-left: 1.5rem;
|
||||
}
|
||||
|
||||
.block_online_users .content .list li.listentry .user .userpicture {
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
|
@ -24,6 +24,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2021052500; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2021052501; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2021052500; // Requires this Moodle version
|
||||
$plugin->component = 'block_online_users'; // Full name of the plugin (used for diagnostics)
|
||||
|
Loading…
x
Reference in New Issue
Block a user