From 7ddd9521b3f3a397da3b0a6b56238d31414eb4be Mon Sep 17 00:00:00 2001 From: brettp Date: Thu, 28 Oct 2010 19:17:36 +0000 Subject: Standardized code in all of core, not including language files, tests, or core mods. git-svn-id: http://code.elgg.org/elgg/trunk@7124 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/statistics.php | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'engine/lib/statistics.php') diff --git a/engine/lib/statistics.php b/engine/lib/statistics.php index 91fea1257..0067f3672 100644 --- a/engine/lib/statistics.php +++ b/engine/lib/statistics.php @@ -1,18 +1,20 @@ dbprefix}entities e left join {$CONFIG->dbprefix}entity_subtypes s on e.subtype=s.id"; + $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"; @@ -37,9 +42,11 @@ function get_entity_statistics($owner_guid = 0) { $entity_stats[$type->type] = array(); } - $query = "SELECT count(*) as count from {$CONFIG->dbprefix}entities where type='{$type->type}' $owner_query"; + $query = "SELECT count(*) as count + from {$CONFIG->dbprefix}entities where type='{$type->type}' $owner_query"; + if ($type->subtype) { - $query.= " and subtype={$type->subtype_id}"; + $query .= " and subtype={$type->subtype_id}"; } $subtype_cnt = get_data_row($query); @@ -57,7 +64,8 @@ function get_entity_statistics($owner_guid = 0) { /** * Return the number of users registered in the system. * - * @param bool $show_deactivated + * @param bool $show_deactivated Count not enabled users? + * * @return int */ function get_number_users($show_deactivated = false) { @@ -69,7 +77,10 @@ function get_number_users($show_deactivated = false) { $access = "and " . get_access_sql_suffix(); } - $result = get_data_row("SELECT count(*) as count from {$CONFIG->dbprefix}entities where type='user' $access"); + $query = "SELECT count(*) as count + from {$CONFIG->dbprefix}entities where type='user' $access"; + + $result = get_data_row($query); if ($result) { return $result->count; @@ -80,6 +91,8 @@ function get_number_users($show_deactivated = false) { /** * Return a list of how many users are currently online, rendered as a view. + * + * @return string */ function get_online_users() { $offset = get_input('offset', 0); @@ -87,12 +100,14 @@ function get_online_users() { $objects = find_active_users(600, 10, $offset); if ($objects) { - return elgg_view_entity_list($objects, $count,$offset,10,false); + return elgg_view_entity_list($objects, $count, $offset, 10, false); } } /** * Initialise the statistics admin page. + * + * @return void */ function statistics_init() { extend_elgg_admin_page('admin/statistics_opt/basic', 'admin/statistics'); @@ -104,4 +119,4 @@ function statistics_init() { } /// Register init function -register_elgg_event_handler('init','system','statistics_init'); \ No newline at end of file +register_elgg_event_handler('init', 'system', 'statistics_init'); \ No newline at end of file -- cgit v1.2.3