]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
The activity stream's count uses the river table instead of trying to combine entitie...
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 24 May 2010 15:40:47 +0000 (15:40 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 24 May 2010 15:40:47 +0000 (15:40 +0000)
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
mod/riverdashboard/index.php
mod/riverdashboard/views/default/river/item/list.php
mod/riverdashboard/views/default/river/item/wrapper.php
mod/riverdashboard/views/default/riverdashboard/container.php
mod/riverdashboard/views/default/riverdashboard/js.php

index ef30475d9810aa5913ad1788d6069a3df20ebc65..93625e1b721a5a0e614faf8c440387e75a0132bf 100644 (file)
@@ -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;
 }
index 4f13e323ee144a04ca68814368cae8c06cd463bc..a5e61057b3b25f927de78c707723ade7be5b2cff 100644 (file)
@@ -41,13 +41,12 @@ switch($orient) {
                break;
 }
 
-
 $title = elgg_view_title($title_wording);
 
 $river = elgg_view_river_items($subject_guid, 0, $relationship_type, $type, $subtype, '', 20, 0, 0, true, false);
 
 // Replacing callback calls in the nav with something meaningless
-$river = str_replace('callback=true','replaced=88,334',$river);
+$river = str_replace('callback=true', 'replaced=88,334', $river);
 
 $nav = elgg_view('riverdashboard/nav',array('type' => $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
+}
index 4c3e240ac6393f8fa2aed825072ac94e08df9760..bddb2f5e45ab592ee66d2aba6bedabbcca1f3511 100644 (file)
@@ -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 = '';
 
index 8506262a8bd68bb385ab9482ac9565540aab12c0..b90b00f99af5d82fdc9d2fa1183ce7bcdce440f8 100644 (file)
@@ -41,31 +41,31 @@ if ($comment_count < 3) {
                <?php echo elgg_view("profile/icon",array('entity' => $user, 'size' => 'small')); ?>
        </span>
        <div class="river_item_contents clearfloat">
-       <?php 
+       <?php
                // body contents, generated by the river view in each plugin
-               echo $vars['body'];     
-       
+               echo $vars['body'];
+
 //display latest 3 comments if there are any
 if ($get_comments){
        $counter = 0;
        //$background = "";
-       
+
        echo "<div class='river_comments_tabs clearfloat'>";
-       
+
        if ($comment_count <= 3) {
                echo "<a class='river_more_comments show_comments_button link'>Comments</a>";
        }
-       
+
        //display 'more comments' if there are any
        if ($num_comments != 0) {
                echo "<a class='river_more_comments show_comments_button link'>Comments (+{$num_comments} more)</a>";
        }
-       
+
        if ($numoflikes != 0) {
                echo elgg_view('likes/forms/display', array('entity' => $object));
        }
        echo "</div>"; // close river_comments_tabs
-       
+
        echo "<div class='river_comments'>";
 
        if ($numoflikes != 0) {
@@ -74,7 +74,7 @@ if ($get_comments){
                echo list_annotations($object->getGUID(), 'likes', 99);
                echo "</div>";
        }
-               
+
        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 "<div class='river_comments_tabs clearfloat'>";
        }
@@ -117,7 +117,7 @@ if ($get_comments){
        if ($vars['item']->type != 'user' && $numoflikes != 0) {
                echo "</div>"; // close river_comments_tabs
        }
-       
+
        if ($vars['item']->type != 'user') {
                echo "<div class='river_comments'>";
        }
@@ -127,7 +127,7 @@ if ($get_comments){
                echo list_annotations($object->getGUID(), 'likes', 99);
                echo "</div>";
        }
-       
+
        // 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') {
index 7d72453d15608b3d20a0cd09fe316589d52eafdb..c7123a72227007d984d2df5b519525825820299f 100644 (file)
@@ -2,21 +2,21 @@
 
 <script type="text/javascript">
 $(document).ready(function(){
-       var updates = new thewireUpdateChecker(10000);
+       var updates = new activityUpdateChecker(10000);
        updates.start();
 });
 
 // check for updates on the wire.
-function thewireUpdateChecker(interval) {
+function activityUpdateChecker(interval) {
        this.intervalID = null;
        this.interval = interval;
        this.url = '<?php echo $vars['url']; ?>mod/riverdashboard/endpoint/ping.php';
        this.seconds_passed = 0;
-       
+
        this.start = function() {
                // needed to complete closure scope.
                var self = this;
-               
+
                this.intervalID = setInterval(function() { self.checkUpdates(); }, this.interval);
        }
 
@@ -32,7 +32,7 @@ function thewireUpdateChecker(interval) {
                                if (data) {
                                        $('#riverdashboard_updates').html(data).slideDown();
                                        // could crank down the interval here.
-                                       // if we change the message to simply "New Posts!" 
+                                       // if we change the message to simply "New Posts!"
                                        // we could stop the polling altogether.
                                }
                        }
index b1bace04a8dcb52439b66daa2a96d6f185fa1514..1e97a510a46f7c77d9b06d6cf65181cb3a03acd2 100644 (file)
@@ -1,9 +1,9 @@
 <script type="text/javascript">
        $(document).ready(function() {
                $('.river_comment_form_button').click(function() {
-                       elgg_slide_toggle(this,'.river_item','.river_comment_form');                    
+                       elgg_slide_toggle(this, '.river_item', '.river_comment_form');
                });
-               
+
                $('.likes_user_list_button').click(function() {
                        var myParent = $(this).closest('.river_item');
                        if (myParent.find('.likes_list').css('display') == 'none') {
                                myParent.find('.show_comments_button').addClass('off');
                                myParent.find('.likes_user_list_button').removeClass('off');
                                // show users that liked object
-                               elgg_slide_toggle(this,'.river_item','.likes_list');
+                               elgg_slide_toggle(this, '.river_item', '.likes_list');
                        }
                });
-               
-               
+
                $('.show_comments_button').click(function() {
                        var myParent = $(this).closest('.river_item');
                        if (myParent.find('.river_comment').css('display') == 'none') {
@@ -27,9 +26,9 @@
                                myParent.find('.show_comments_button').removeClass('off');
                                myParent.find('.likes_user_list_button').addClass('off');
                                // show users that liked object
-                               elgg_slide_toggle(this,'.river_item','.river_comment');
+                               elgg_slide_toggle(this, '.river_item', '.river_comment');
                        }
-               });             
-               
+               });
+
        });
 </script>
\ No newline at end of file