aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/statistics.php
diff options
context:
space:
mode:
authoricewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-12 13:48:42 +0000
committericewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-12 13:48:42 +0000
commit504e579f97b601634015172bb0ed01fd08578ee7 (patch)
tree5f30b47b893748ef5581f206614a95372c62a758 /engine/lib/statistics.php
parent497cf702144ab6da884cdc3199667517f0dee2dc (diff)
downloadelgg-504e579f97b601634015172bb0ed01fd08578ee7.tar.gz
elgg-504e579f97b601634015172bb0ed01fd08578ee7.tar.bz2
Last commit for now
git-svn-id: https://code.elgg.org/elgg/trunk@892 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/statistics.php')
-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;
+ }
+?>