aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-12 21:12:52 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-12 21:12:52 +0000
commit6584bc4ec2de3b1c377baf763ef5b0ac1e6c807a (patch)
treee827ceb550d4035515bc394b89e94ca7a07cae9d /engine/lib
parentdb557a6331d2be1496d22627b3de61575567ad1a (diff)
downloadelgg-6584bc4ec2de3b1c377baf763ef5b0ac1e6c807a.tar.gz
elgg-6584bc4ec2de3b1c377baf763ef5b0ac1e6c807a.tar.bz2
Marcus Povey <marcus@elgg.com>
* Some basic statistics committed after a fruitless day fighting with Eclipse. git-svn-id: https://code.elgg.org/elgg/trunk@904 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/admin.php4
-rw-r--r--engine/lib/statistics.php40
2 files changed, 41 insertions, 3 deletions
diff --git a/engine/lib/admin.php b/engine/lib/admin.php
index 10ab87cd7..f1e088eca 100644
--- a/engine/lib/admin.php
+++ b/engine/lib/admin.php
@@ -42,7 +42,7 @@
global $CONFIG;
// Add plugin main menu option (last)
- extend_elgg_admin_page('admin/statistics', 'admin/main');
+ extend_elgg_admin_page('admin/main_opt/statistics', 'admin/main');
extend_elgg_admin_page('admin/main_opt/site', 'admin/main');
extend_elgg_admin_page('admin/main_opt/user', 'admin/main');
extend_elgg_admin_page('admin/main_opt/plugins', 'admin/main', 999); // Always last
@@ -74,4 +74,4 @@
// Register a plugin hook for permissions
register_plugin_hook('permissions_check','all','admin_permissions');
-?> \ No newline at end of file
+?>
diff --git a/engine/lib/statistics.php b/engine/lib/statistics.php
index ce601e7b4..f5bf23250 100644
--- a/engine/lib/statistics.php
+++ b/engine/lib/statistics.php
@@ -38,7 +38,8 @@
$query = "SELECT count(*) as count from {$CONFIG->dbprefix}entities where type='{$type->type}'";
if ($type->subtype) $query.= " and subtype={$type->subtype_id}";
- $subtype_cnt = get_data($query);
+
+ $subtype_cnt = get_data_row($query);
if ($type->subtype)
$entity_stats[$type->type][$type->subtype] = $subtype_cnt->count;
@@ -48,4 +49,41 @@
return $entity_stats;
}
+
+ /**
+ * Return the number of users registered in the system.
+ *
+ * @return int
+ */
+ function get_number_users()
+ {
+ global $CONFIG;
+
+ $result = get_data_row("SELECT count(*) as count from {$CONFIG->dbprefix}entities where type='user'");
+
+ if ($result)
+ return $result->count;
+
+ return false;
+ }
+
+ /**
+ * Report how many users are currently online
+ *
+ * @return int
+ */
+ function get_number_online()
+ {
+ // TODO: get logged in users somehow
+ }
+
+ /**
+ * Return a list of how many users are currently online.
+ *
+ * @param int $limit Number of users to return
+ */
+ function get_online_users($limit = 10)
+ {
+ // TODO: Writeme
+ }
?>