diff options
-rw-r--r-- | engine/lib/statistics.php | 37 | ||||
-rw-r--r-- | languages/en.php | 1 | ||||
-rw-r--r-- | settings/index.php (renamed from usersettings/index.php) | 0 | ||||
-rw-r--r-- | settings/plugins/index.php (renamed from usersettings/plugins/index.php) | 0 | ||||
-rw-r--r-- | settings/statistics/index.php (renamed from usersettings/statistics/index.php) | 0 | ||||
-rw-r--r-- | settings/user/index.php (renamed from usersettings/user/index.php) | 0 | ||||
-rw-r--r-- | views/default/usersettings/main_opt/plugins.php | 2 | ||||
-rw-r--r-- | views/default/usersettings/main_opt/statistics.php | 2 | ||||
-rw-r--r-- | views/default/usersettings/main_opt/user.php | 2 | ||||
-rw-r--r-- | views/default/usersettings/plugins.php | 2 | ||||
-rw-r--r-- | views/default/usersettings/statistics_opt/numentities.php | 45 |
11 files changed, 67 insertions, 24 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 diff --git a/languages/en.php b/languages/en.php index d5f45176d..5c5b12ef7 100644 --- a/languages/en.php +++ b/languages/en.php @@ -301,6 +301,7 @@ 'usersettings:plugins:opt:linktext' => "Configure your tools...", 'usersettings:plugins:description' => "This panel allows you to control and configure the personal settings for the tools installed by your system administrator.", + 'usersettings:statistics:label:numentities' => "Your entities", /**
diff --git a/usersettings/index.php b/settings/index.php index 47cf9caba..47cf9caba 100644 --- a/usersettings/index.php +++ b/settings/index.php diff --git a/usersettings/plugins/index.php b/settings/plugins/index.php index d9c5de6fb..d9c5de6fb 100644 --- a/usersettings/plugins/index.php +++ b/settings/plugins/index.php diff --git a/usersettings/statistics/index.php b/settings/statistics/index.php index 303838a81..303838a81 100644 --- a/usersettings/statistics/index.php +++ b/settings/statistics/index.php diff --git a/usersettings/user/index.php b/settings/user/index.php index 274e86e9b..274e86e9b 100644 --- a/usersettings/user/index.php +++ b/settings/user/index.php diff --git a/views/default/usersettings/main_opt/plugins.php b/views/default/usersettings/main_opt/plugins.php index 7a5030579..ee3773c7e 100644 --- a/views/default/usersettings/main_opt/plugins.php +++ b/views/default/usersettings/main_opt/plugins.php @@ -15,5 +15,5 @@ <div class="admin-menu-option"> <h2><?php echo elgg_echo('usersettings:plugins'); ?> </h2> <p><?php echo elgg_echo('usersettings:plugins:opt:description'); ?><br /> - <a href="<?php echo $CONFIG->wwwroot . "pg/usersettings/plugins/"; ?>"><?php echo elgg_echo('usersettings:plugins:opt:linktext'); ?></a></p> + <a href="<?php echo $CONFIG->wwwroot . "pg/settings/plugins/"; ?>"><?php echo elgg_echo('usersettings:plugins:opt:linktext'); ?></a></p> </div>
\ No newline at end of file diff --git a/views/default/usersettings/main_opt/statistics.php b/views/default/usersettings/main_opt/statistics.php index 973c4f7ce..6460dce16 100644 --- a/views/default/usersettings/main_opt/statistics.php +++ b/views/default/usersettings/main_opt/statistics.php @@ -13,5 +13,5 @@ <div class="admin-menu-option"> <h2><?php echo elgg_echo('usersettings:statistics'); ?> </h2> <p><?php echo elgg_echo('usersettings:statistics:opt:description'); ?><br /> - <a href="<?php echo $CONFIG->wwwroot . "pg/usersettings/statistics/"; ?>"><?php echo elgg_echo('usersettings:statistics:opt:linktext'); ?></a></p> + <a href="<?php echo $CONFIG->wwwroot . "pg/settings/statistics/"; ?>"><?php echo elgg_echo('usersettings:statistics:opt:linktext'); ?></a></p> </div> diff --git a/views/default/usersettings/main_opt/user.php b/views/default/usersettings/main_opt/user.php index 77d3340e3..ee767951c 100644 --- a/views/default/usersettings/main_opt/user.php +++ b/views/default/usersettings/main_opt/user.php @@ -13,5 +13,5 @@ <div class="admin-menu-option"> <h2><?php echo elgg_echo('usersettings:user'); ?> </h2> <p><?php echo elgg_echo('usersettings:user:opt:description'); ?><br /> - <a href="<?php echo $CONFIG->wwwroot . "pg/usersettings/user/"; ?>"><?php echo elgg_echo('usersettings:user:opt:linktext'); ?></a></p> + <a href="<?php echo $CONFIG->wwwroot . "pg/settings/user/"; ?>"><?php echo elgg_echo('usersettings:user:opt:linktext'); ?></a></p> </div>
\ No newline at end of file diff --git a/views/default/usersettings/plugins.php b/views/default/usersettings/plugins.php index 730950178..580a81029 100644 --- a/views/default/usersettings/plugins.php +++ b/views/default/usersettings/plugins.php @@ -26,7 +26,7 @@ foreach ($installed_plugins as $plugin => $data) { if (($n>=$offset) && ($n < $offset+$limit)) - echo elgg_view("usersettings/plugins_opt/plugin", array('plugin' => $plugin, 'details' => $data)); + echo elgg_view("settings/plugins_opt/plugin", array('plugin' => $plugin, 'details' => $data)); $n++; } diff --git a/views/default/usersettings/statistics_opt/numentities.php b/views/default/usersettings/statistics_opt/numentities.php new file mode 100644 index 000000000..4fe218048 --- /dev/null +++ b/views/default/usersettings/statistics_opt/numentities.php @@ -0,0 +1,45 @@ +<?php + /** + * Elgg statistics screen + * + * @package Elgg + * @subpackage Core + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Marcus Povey + * @copyright Curverider Ltd 2008 + * @link http://elgg.org/ + */ + + + // Get entity statistics + $entity_stats = get_entity_statistics($_SESSION['user']->guid); + + if ($entity_stats) + { +?> +<div> + <h2><?php echo elgg_echo('usersettings:statistics:label:numentities'); ?></h2> + <table> + <?php + foreach ($entity_stats as $k => $entry) + { + echo "<table>"; + foreach ($entry as $a => $b) + { + if ($a == "__base__") + $a=$k; + else + $a = "$k $a"; + echo <<< END + <tr> + <td><b>$a :</b></td> + <td>$b</td> + </tr> +END; + } + echo "</table>"; + } + ?> + </table> +</div> +<?php } ?>
\ No newline at end of file |