Skip to:
Content

BuddyPress.org

Ticket #2000: activity.diff

File activity.diff, 9.0 KB (added by kunalb, 14 years ago)
  • bp-activity.php

     
    489489                'max' => false, // Maximum number of results to return
    490490                'page' => 1, // page 1 without a per_page will result in no pagination.
    491491                'per_page' => false, // results per page
     492                'offset' => 0,  // offset from the page
    492493                'sort' => 'DESC', // sort ASC or DESC
    493494                'display_comments' => false, // false for no comments. 'stream' for within stream display, 'threaded' for below each activity item
    494495
     
    514515        /* Attempt to return a cached copy of the first page of sitewide activity. */
    515516        if ( 1 == (int)$page && empty( $max ) && empty( $search_terms ) && empty( $filter ) && 'DESC' == $sort ) {
    516517                if ( !$activity = wp_cache_get( 'bp_activity_sitewide_front', 'bp' ) ) {
    517                         $activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden );
     518                        $activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden, $offset );
    518519                        wp_cache_set( 'bp_activity_sitewide_front', $activity, 'bp' );
    519520                }
    520521        } else
    521                 $activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden );
     522                $activity = BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden, $offset );
    522523
    523524        return apply_filters( 'bp_activity_get', $activity, &$r );
    524525}
     
    11121113add_action( 'plugins_loaded', 'bp_register_activity_actions' );
    11131114
    11141115
    1115 ?>
    1116  No newline at end of file
     1116?>
  • bp-themes/bp-default/_inc/ajax.php

     
    4949                        $qs[] = 'scope=' . $_BP_COOKIE['bp-' . $object . '-scope']; // Activity stream scope only on activity directory.
    5050        }
    5151
    52         /* If page and search_terms have been passed via the AJAX post request, use those */
     52        /* If page, offset and search_terms have been passed via the AJAX post request, use those */
    5353        if ( !empty( $_POST['page'] ) && '-1' != $_POST['page'] )
    5454                $qs[] = 'page=' . $_POST['page'];
    5555
    5656        if ( !empty( $_POST['search_terms'] ) && __( 'Search anything...', 'buddypress' ) != $_POST['search_terms'] && 'false' != $_POST['search_terms'] && 'undefined' != $_POST['search_terms'] )
    5757                $qs[] = 'search_terms=' . $_POST['search_terms'];
    5858
     59        if ( !empty ($_POST['offset']) )
     60                $qs[] = 'offset=' . $_POST['offset'];
     61
    5962        /* Now pass the querystring to override default values. */
    6063        $query_string = empty( $qs ) ? '' : join( '&', (array)$qs );
    6164
     
    559562}
    560563add_action( 'wp_ajax_messages_autocomplete_results', 'bp_dtheme_ajax_messages_autocomplete_results' );
    561564
    562 ?>
    563  No newline at end of file
     565?>
  • bp-themes/bp-default/_inc/global.js

     
    9393                                jq("li.new-update").removeClass( 'new-update' );
    9494                                jq("textarea#whats-new").val('');
    9595
     96                                /* Increment the stream offset counter cookie by 1 */
     97                                var offset = jq.cookie( 'bp-activity-offset' );
     98                                if ( offset != null ) {
     99                                        jq.cookie( 'bp-activity-offset', ( 1 * offset ) + 1, {path: '/'} );
     100                                } else {
     101                                        jq.cookie( 'bp-activity-offset', 1, {path: '/'} );
     102                                }
     103
    96104                                /* Re-enable the submit button after 8 seconds. */
    97105                                setTimeout( function() { button.attr("disabled", ''); }, 8000 );
    98106                        }
     
    234242                                jq.cookie('bp-activity-oldestpage', 1, {path: '/'} );
    235243
    236244                        var oldest_page = ( jq.cookie('bp-activity-oldestpage') * 1 ) + 1;
     245                        var offset = jq.cookie('bp-activity-offset');
    237246
    238247                        jq.post( ajaxurl, {
    239248                                action: 'activity_get_older_updates',
    240249                                'cookie': encodeURIComponent(document.cookie),
    241                                 'page': oldest_page
     250                                'page': oldest_page,
     251                                'offset': offset
    242252                        },
    243253                        function(response)
    244254                        {
     
    10451055        /* Reset the page */
    10461056        jq.cookie( 'bp-activity-oldestpage', 1, {path: '/'} );
    10471057
     1058        jq.cookie( 'bp-activity-offset', 0, {path: '/'} );
     1059
    10481060        if ( null != jq.cookie('bp-activity-filter') && jq('#activity-filter-select').length )
    10491061                jq('#activity-filter-select select option[value=' + jq.cookie('bp-activity-filter') + ']').attr( 'selected', 'selected' );
    10501062
  • bp-themes/bp-default/header.php

     
    7676                <?php do_action( 'bp_after_header' ) ?>
    7777                <?php do_action( 'bp_before_container' ) ?>
    7878
    79                 <div id="container">
    80  No newline at end of file
     79                <div id="container">
  • bp-activity/bp-activity-templatetags.php

     
    1515
    1616        var $full_name;
    1717
    18         function bp_activity_template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden ) {
     18        function bp_activity_template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $offset ) {
    1919                global $bp;
    2020
    2121                $this->pag_page = isset( $_REQUEST['acpage'] ) ? intval( $_REQUEST['acpage'] ) : $page;
     
    3131                        /* Fetch specific activity items based on ID's */
    3232                        $this->activities = bp_activity_get_specific( array( 'activity_ids' => explode( ',', $include ), 'max' => $max, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'sort' => $sort, 'display_comments' => $display_comments ) );
    3333                } else {
    34                         $this->activities = bp_activity_get( array( 'display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'filter' => $filter, 'show_hidden' => $show_hidden ) );
     34                        $this->activities = bp_activity_get( array( 'display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'filter' => $filter, 'show_hidden' => $show_hidden, 'offset' => $offset ) );
    3535                }
    3636
    3737                if ( !$max || $max >= (int)$this->activities['total'] )
     
    165165                'sort' => 'DESC', // sort DESC or ASC
    166166                'page' => 1, // which page to load
    167167                'per_page' => 20, // number of items per page
     168                'offset' => 0,  // offset from page
    168169                'max' => false, // max number to return
    169170                'show_hidden' => $show_hidden, // Show activity items that are hidden site-wide?
    170171
     
    249250        else if ( !empty( $user_id ) || !empty( $object ) || !empty( $action ) || !empty( $primary_id ) || !empty( $secondary_id ) )
    250251                $filter = array( 'user_id' => $user_id, 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id );
    251252
    252         $activities_template = new BP_Activity_Template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden );
     253        $activities_template = new BP_Activity_Template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $offset );
    253254
    254255        return apply_filters( 'bp_has_activities', $activities_template->has_activities(), &$activities_template );
    255256}
     
    956957                return apply_filters( 'bp_get_activity_feed_item_description', html_entity_decode( str_replace( '%s', '', $content ) ) );
    957958        }
    958959
    959 ?>
    960  No newline at end of file
     960?>
  • bp-activity/bp-activity-classes.php

     
    8686
    8787        /* Static Functions */
    8888
    89         function get( $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false, $show_hidden = false ) {
     89        function get( $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false, $show_hidden = false, $offset = 0 ) {
    9090                global $wpdb, $bp;
    9191
    9292                /* Select conditions */
     
    129129                }
    130130
    131131                if ( $per_page && $page ) {
    132                         $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $per_page ), intval( $per_page ) );
     132                        $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $per_page + $offset ), intval( $per_page ) );
    133133                        $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', $wpdb->prepare( "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) ) );
    134134                } else
    135135                        $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', $wpdb->prepare( "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort}", $select_sql, $from_sql, $where_sql, $sort ) ) );
     
    556556        }
    557557}
    558558
    559 ?>
    560  No newline at end of file
     559?>