diff options
author | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-06-23 17:43:23 +0000 |
---|---|---|
committer | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-06-23 17:43:23 +0000 |
commit | ee25c76e0bab45893a9d52a3820a16be2d481010 (patch) | |
tree | 63792d4a58d56953ede040831e18b176107d23a1 /engine/lib/statistics.php | |
parent | 317d14bba5d58975446ecd9ab1b37a89c647fc1b (diff) | |
download | elgg-ee25c76e0bab45893a9d52a3820a16be2d481010.tar.gz elgg-ee25c76e0bab45893a9d52a3820a16be2d481010.tar.bz2 |
Refs #76: User settings page (to Elgg Classic standard). Committing some work before shutting down for the day.
git-svn-id: https://code.elgg.org/elgg/trunk@1078 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/statistics.php')
-rw-r--r-- | engine/lib/statistics.php | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/engine/lib/statistics.php b/engine/lib/statistics.php index 8744db4ab..73c424433 100644 --- a/engine/lib/statistics.php +++ b/engine/lib/statistics.php @@ -12,32 +12,35 @@ * @copyright Curverider Ltd 2008 * @link http://elgg.org/ */ - - - // 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. * + * @param int $owner_guid Optional owner of the statistics * @return array */ - function get_entity_statistics() + function get_entity_statistics($owner_guid = 0) { global $CONFIG; $entity_stats = array(); + $owner_guid = (int)$owner_guid; + + $query = "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"; + $owner_query = ""; + if ($owner_guid) { + $query .= " where owner_guid=$owner_guid"; + $owner_query = "and owner_guid=$owner_guid "; + } // 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"); + + $types = get_data($query); 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}'"; + $query = "SELECT count(*) as count from {$CONFIG->dbprefix}entities where type='{$type->type}' $owner_query"; if ($type->subtype) $query.= " and subtype={$type->subtype_id}"; $subtype_cnt = get_data_row($query); @@ -69,16 +72,6 @@ } /** - * 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, rendered as a view. */ function get_online_users() @@ -99,6 +92,10 @@ extend_elgg_admin_page('admin/statistics_opt/basic', 'admin/statistics'); extend_elgg_admin_page('admin/statistics_opt/numentities', 'admin/statistics'); extend_elgg_admin_page('admin/statistics_opt/online', 'admin/statistics'); + + + + extend_elgg_admin_page('usersettings/statistics_opt/numentities', 'usersettings/statistics'); } /// Register init function |