aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/statistics.php42
1 files changed, 40 insertions, 2 deletions
diff --git a/engine/lib/statistics.php b/engine/lib/statistics.php
index 3adebd0b6..85a59b0af 100644
--- a/engine/lib/statistics.php
+++ b/engine/lib/statistics.php
@@ -1,7 +1,8 @@
<?php
/**
* Elgg statistics library.
- * This file contains updated
+ * This file contains a number of functions for obtaining statistics about the running system.
+ * These statistics are mainly used by the administration pages.
*
* @package Elgg
* @subpackage Core
@@ -10,4 +11,41 @@
* @copyright Curverider Ltd 2008
* @link http://elgg.org/
*/
-?> \ No newline at end of file
+
+
+ // number of users
+
+ // Number of objects broken down into type
+
+ // who's online now
+
+ /**
+ * Return an array reporting the number of various entities in the system.
+ *
+ * @return array
+ */
+ function get_entity_statistics()
+ {
+ global $CONFIG;
+
+ $entity_stats = array();
+
+ // Get a list of major types
+ $types = get_data("SELECT distinct e.type,s.subtype,e.subtype as subtype_id from {$CONFIG->dbprefix}entities e left join {$CONFIG->dbprefix}entity_subtypes s on e.subtype=s.id");
+ foreach ($types as $type) {
+ if (!is_array($entity_stats[$type->type]))
+ $entity_stats[$type->type] = array(); // assume there are subtypes for now
+
+ $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);
+
+ if ($type->subtype)
+ $entity_stats[$type->type][$type->subtype] = $subtype_cnt->count;
+ else
+ $entity_stats[$type->type]['__base__'] = $subtype_cnt->count;
+ }
+
+ return $entity_stats;
+ }
+?>