diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-05-24 15:40:47 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-05-24 15:40:47 +0000 |
commit | 65c5ba06227db6c4847fbe17a1ac35a52ed40b02 (patch) | |
tree | d9bbfa236e8e9481eb464d70c316052c89a79044 /mod/riverdashboard/endpoint/ping.php | |
parent | f56c4ae4c881345e0a11d1f24a2e6a06668fb0ca (diff) | |
download | elgg-65c5ba06227db6c4847fbe17a1ac35a52ed40b02.tar.gz elgg-65c5ba06227db6c4847fbe17a1ac35a52ed40b02.tar.bz2 |
The activity stream's count uses the river table instead of trying to combine entities + annotations based up on time_created.
Also brought small bits of code up to standards.
git-svn-id: http://code.elgg.org/elgg/trunk@6173 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/riverdashboard/endpoint/ping.php')
-rw-r--r-- | mod/riverdashboard/endpoint/ping.php | 64 |
1 files changed, 21 insertions, 43 deletions
diff --git a/mod/riverdashboard/endpoint/ping.php b/mod/riverdashboard/endpoint/ping.php index ef30475d9..93625e1b7 100644 --- a/mod/riverdashboard/endpoint/ping.php +++ b/mod/riverdashboard/endpoint/ping.php @@ -6,71 +6,49 @@ // Load Elgg engine will not include plugins require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"); - + // check for last checked time if (!$seconds_passed = get_input('seconds_passed', 0)) { - echo ''; - exit; + echo ''; + exit; } $last_reload = time() - $seconds_passed; -//grab any new annotations -$annotations = count_annotations('', '', '', '', '', '', '', $last_reload); -if (!$annotations) { - $annotations = 0; -} - -//grab all new objects created -$entity_creation = elgg_get_entities(array( - 'count' => TRUE, - 'created_time_lower' => $last_reload, - 'wheres' => array('e.type != \'user\'') -)); +// This entire system is driven by the river table. +// There is no core interface to simply grab the number of entries in the table. +// In order for something to count as an update, you must put a call to add_river_item(). +$q = "SELECT COUNT(id) as all_activity FROM {$CONFIG->dbprefix}river r, {$CONFIG->dbprefix}entities e + WHERE r.posted > $last_reload AND r.object_guid = e.guid"; -if (!$entity_creation) { - $entity_creation = 0; -} - -//grab any entities updated -$entity_update = elgg_get_entities(array( - 'count' => TRUE, - 'modified_time_lower' => $last_reload, - 'wheres' => array('e.type != \'user\'') -)); -if (!$entity_update) { - $entity_update = 0; +if ($d = get_data($q)) { + $all_activity = $d[0]->all_activity; +} else { + $all_activity = 0; } -//get any relationships, such as friending - this is not working quite right yet -//$relationship_action = elgg_get_entities_from_relationship(array('count' => TRUE)); -//if(!$relationship_action) -// $relationship_action = 0; - -//sum all totals -$all_activity = $annotations + $entity_creation + $entity_update; if ($all_activity > 0) { - $s = ($all_activity == 1) ? '' : 's'; - echo "<a href='' onClick=\"window.location.reload();\" class='update_link'>$all_activity update$s!</a>"; + $s = ($all_activity == 1) ? '' : 's'; + echo "<a href='' onClick=\"window.location.reload();\" class='update_link'>$all_activity update$s!</a>"; ?> <script type="text/javascript"> $(document).ready(function(){ - + var pageTitleSubstring; var stringStartPosition = document.title.indexOf("]"); - + if (stringStartPosition == -1) { // we haven't already altered page title - pageTitleSubstring = document.title; + pageTitleSubstring = document.title; } else { // we previously prepended to page title, need to remove it first pageTitleSubstring = document.title.substring( (stringStartPosition+2) ); } - + document.title = "[<?php echo $all_activity; ?> update<?php echo $s; ?>] "+pageTitleSubstring; }); </script> -<?php +<?php } else { - echo ''; - exit; + echo ''; + exit; } |