public function findActive(array $options = [])
{
$options = array_merge(array('seconds' => 600, 'limit' => $this->config->get('default_limit')), $options);
// cast options we're sending to hook
foreach (array('seconds', 'limit', 'offset') as $key) {
$options[$key] = (int) $options[$key];
}
$options['count'] = (bool) $options['count'];
// allow plugins to override
$params = array('seconds' => $options['seconds'], 'limit' => $options['limit'], 'offset' => $options['offset'], 'count' => $options['count'], 'options' => $options);
$data = _elgg_services()->hooks->trigger('find_active_users', 'system', $params, null);
// check null because the handler could legitimately return falsey values.
if ($data !== null) {
return $data;
}
$dbprefix = $this->config->get('dbprefix');
$time = $this->getCurrentTime()->getTimestamp() - $options['seconds'];
return elgg_get_entities(array('type' => 'user', 'limit' => $options['limit'], 'offset' => $options['offset'], 'count' => $options['count'], 'joins' => array("join {$dbprefix}users_entity u on e.guid = u.guid"), 'wheres' => array("u.last_action >= {$time}"), 'order_by' => "u.last_action desc"));
}