aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/statistics.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-10-28 19:17:36 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-10-28 19:17:36 +0000
commit7ddd9521b3f3a397da3b0a6b56238d31414eb4be (patch)
tree6eb6a9a51db5fa0f5d3cc2ec6de29b9e258b12a1 /engine/lib/statistics.php
parentbd3484417d170e62bc94e9db81d4ad37e8ddee6a (diff)
downloadelgg-7ddd9521b3f3a397da3b0a6b56238d31414eb4be.tar.gz
elgg-7ddd9521b3f3a397da3b0a6b56238d31414eb4be.tar.bz2
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
Diffstat (limited to 'engine/lib/statistics.php')
-rw-r--r--engine/lib/statistics.php37
1 files changed, 26 insertions, 11 deletions
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 @@
<?php
/**
* Elgg statistics library.
+ *
* This file contains a number of functions for obtaining statistics about the running system.
- * These statistics are mainly used by the administration pages, and is also where the basic views for statistics
- * are added.
+ * These statistics are mainly used by the administration pages, and is also where the basic
+ * views for statistics are added.
*
- * @package Elgg
- * @subpackage Core
+ * @package Elgg.Core
+ * @subpackage Statistics
*/
/**
* 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($owner_guid = 0) {
@@ -21,7 +23,10 @@ function get_entity_statistics($owner_guid = 0) {
$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";
+ $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