aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/users.php
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-19 14:15:58 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-19 14:15:58 +0000
commit8b7cf8710c8cbb5e6db2bc57e05dffc7bfcf0681 (patch)
tree9a2a1056775b0a6aa43c188ca81678ae5ba5c038 /engine/lib/users.php
parentb54981abca82d285403c05101cb03573d5590dab (diff)
downloadelgg-8b7cf8710c8cbb5e6db2bc57e05dffc7bfcf0681.tar.gz
elgg-8b7cf8710c8cbb5e6db2bc57e05dffc7bfcf0681.tar.bz2
Fixes #55 : "Users online now" function
git-svn-id: https://code.elgg.org/elgg/trunk@998 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/users.php')
-rw-r--r--engine/lib/users.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 51cb748c5..3bd87dbff 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -726,6 +726,29 @@
}
return false;
}
+
+ /**
+ * A function that returns a maximum of $limit users who have done something within the last
+ * $seconds seconds.
+ *
+ * @param int $seconds Number of seconds (default 600 = 10min)
+ * @param int $limit Limit, default 10.
+ * @param int $offset Offset, defualt 0.
+ */
+ function find_active_users($seconds = 600, $limit = 10, $offset = 0)
+ {
+ global $CONFIG;
+
+ $seconds = (int)$seconds;
+ $limit = (int)$limit;
+ $offset = (int)$offset;
+
+ $time = time() - $seconds;
+
+ $query = "SELECT * from {$CONFIG->dbprefix}entities where type='user' and time_updated>=$time order by time_updated desc limit $offset, $limit";
+
+ return get_data($query, "entity_row_to_elggstar");
+ }
/**
* Registers a user, returning false if the username already exists