From 65c5ba06227db6c4847fbe17a1ac35a52ed40b02 Mon Sep 17 00:00:00 2001 From: brettp Date: Mon, 24 May 2010 15:40:47 +0000 Subject: 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 --- mod/riverdashboard/endpoint/ping.php | 64 +++++++--------------- mod/riverdashboard/index.php | 7 ++- .../views/default/river/item/list.php | 2 +- .../views/default/river/item/wrapper.php | 24 ++++---- .../views/default/riverdashboard/container.php | 10 ++-- .../views/default/riverdashboard/js.php | 15 +++-- 6 files changed, 50 insertions(+), 72 deletions(-) (limited to 'mod') 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 "$all_activity update$s!"; + $s = ($all_activity == 1) ? '' : 's'; + echo "$all_activity update$s!"; ?> - $type,'subtype' => $subtype,'orient' => $orient)); if (isloggedin()) { @@ -56,11 +55,13 @@ if (isloggedin()) { } else { $sidebar = ''; } + set_context('riverdashboard'); + if (empty($callback)) { $body .= elgg_view('riverdashboard/container', array('body' => $nav . $river . elgg_view('riverdashboard/js'))); page_draw($title_wording,elgg_view_layout('one_column_with_sidebar',$title . $body, $sidebar)); } else { header("Content-type: text/html; charset=UTF-8"); echo $nav . $river . elgg_view('riverdashboard/js'); -} \ No newline at end of file +} diff --git a/mod/riverdashboard/views/default/river/item/list.php b/mod/riverdashboard/views/default/river/item/list.php index 4c3e240ac..bddb2f5e4 100644 --- a/mod/riverdashboard/views/default/river/item/list.php +++ b/mod/riverdashboard/views/default/river/item/list.php @@ -16,7 +16,7 @@ if (isset($vars['items']) && is_array($vars['items'])) { if ($vars['pagination'] !== false) { $baseurl = $_SERVER['REQUEST_URI']; - $baseurl = $baseurl = preg_replace('/[\&\?]offset\=[0-9]*/',"",$baseurl); + $baseurl = preg_replace('/[\&\?]offset\=[0-9]*/',"",$baseurl); $nav = ''; diff --git a/mod/riverdashboard/views/default/river/item/wrapper.php b/mod/riverdashboard/views/default/river/item/wrapper.php index 8506262a8..b90b00f99 100644 --- a/mod/riverdashboard/views/default/river/item/wrapper.php +++ b/mod/riverdashboard/views/default/river/item/wrapper.php @@ -41,31 +41,31 @@ if ($comment_count < 3) { $user, 'size' => 'small')); ?>
- "; - + if ($comment_count <= 3) { echo "Comments"; } - + //display 'more comments' if there are any if ($num_comments != 0) { echo "Comments (+{$num_comments} more)"; } - + if ($numoflikes != 0) { echo elgg_view('likes/forms/display', array('entity' => $object)); } echo "
"; // close river_comments_tabs - + echo "
"; if ($numoflikes != 0) { @@ -74,7 +74,7 @@ if ($get_comments){ echo list_annotations($object->getGUID(), 'likes', 99); echo "
"; } - + foreach ($get_comments as $gc) { //get the comment owner $comment_owner = get_user($gc->owner_guid); @@ -107,7 +107,7 @@ if ($get_comments){ } else { // tab bar nav - for users that liked object $numoflikes = elgg_count_likes($object); - + if ($vars['item']->type != 'user' && $numoflikes != 0) { echo "
"; } @@ -117,7 +117,7 @@ if ($get_comments){ if ($vars['item']->type != 'user' && $numoflikes != 0) { echo "
"; // close river_comments_tabs } - + if ($vars['item']->type != 'user') { echo "
"; } @@ -127,7 +127,7 @@ if ($get_comments){ echo list_annotations($object->getGUID(), 'likes', 99); echo "
"; } - + // if there are no comments to display // and this is not a user or a group discussion entry - include the inline comment form if ($vars['item']->type != 'user' && $vars['item']->subtype != 'groupforumtopic') { diff --git a/mod/riverdashboard/views/default/riverdashboard/container.php b/mod/riverdashboard/views/default/riverdashboard/container.php index 7d72453d1..c7123a722 100644 --- a/mod/riverdashboard/views/default/riverdashboard/container.php +++ b/mod/riverdashboard/views/default/riverdashboard/container.php @@ -2,21 +2,21 @@ \ No newline at end of file -- cgit v1.2.3