aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/users.php
diff options
context:
space:
mode:
authorbenbro <ben.browitt@gmail.com>2011-06-20 08:43:09 +0300
committerCash Costello <cash.costello@gmail.com>2011-06-24 08:00:20 -0400
commite29500440b1848f192bc56a1bad89eac69408e7b (patch)
tree12759fd85035296bcc3018f923e2bd50562669f7 /engine/lib/users.php
parent8edfc55bc7ee99955b3c82a59312df8c9d840bb7 (diff)
downloadelgg-e29500440b1848f192bc56a1bad89eac69408e7b.tar.gz
elgg-e29500440b1848f192bc56a1bad89eac69408e7b.tar.bz2
added find_active_users hook
Diffstat (limited to 'engine/lib/users.php')
-rw-r--r--engine/lib/users.php34
1 files changed, 20 insertions, 14 deletions
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 59bfa1259..e7e1a57f0 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -625,31 +625,37 @@ function get_user_by_email($email) {
/**
* A function that returns a maximum of $limit users who have done something within the last
- * $seconds seconds.
+ * $seconds seconds or the total count of active users.
*
* @param int $seconds Number of seconds (default 600 = 10min)
* @param int $limit Limit, default 10.
- * @param int $offset Offset, defualt 0.
+ * @param int $offset Offset, default 0.
+ * @param bool $count Count, default false.
*
* @return mixed
*/
-function find_active_users($seconds = 600, $limit = 10, $offset = 0) {
- global $CONFIG;
-
+function find_active_users($seconds = 600, $limit = 10, $offset = 0, $count = false) {
$seconds = (int)$seconds;
$limit = (int)$limit;
$offset = (int)$offset;
+ $params = array('seconds' => $seconds, 'limit' => $limit, 'offset' => $offset, 'count' => $count);
+ $data = elgg_trigger_plugin_hook('find_active_users', 'system', $params, NULL);
+ if (!$data) {
+ global $CONFIG;
- $time = time() - $seconds;
-
- $access = get_access_sql_suffix("e");
-
- $query = "SELECT distinct e.* from {$CONFIG->dbprefix}entities e
- join {$CONFIG->dbprefix}users_entity u on e.guid = u.guid
- where u.last_action >= {$time} and $access
- order by u.last_action desc limit {$offset}, {$limit}";
+ $time = time() - $seconds;
- return get_data($query, "entity_row_to_elggstar");
+ $data = elgg_get_entities(array(
+ 'type' => 'user',
+ 'limit' => $limit,
+ 'offset' => $offset,
+ 'count' => $count,
+ 'joins' => array("join {$CONFIG->dbprefix}users_entity u on e.guid = u.guid"),
+ 'wheres' => array("u.last_action >= {$time}"),
+ 'order_by' => "u.last_action desc"
+ ));
+ }
+ return $data;
}
/**