Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/10/2009 01:24:01 AM (12 years ago)
Author:
apeatling
Message:

Added support for significantly more advanced activity stream filtering.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-templatetags.php

    r1834 r1839  
    1717    var $full_name;
    1818
    19     function bp_activity_template( $type, $user_id, $per_page, $max, $timeframe, $filter ) {
     19    function bp_activity_template( $type, $user_id, $per_page, $max, $filter ) {
    2020        global $bp;
    2121
     
    2828       
    2929        if ( $type == 'personal' )
    30             $this->activities = bp_activity_get_user_activity( $user_id, $max, $timeframe, $this->pag_num, $this->pag_page, $filter );
     30            $this->activities = bp_activity_get_user_activity( $user_id, $max, $this->pag_num, $this->pag_page, $filter );
    3131
    3232        if ( $type == 'friends' && ( bp_is_home() || is_site_admin() || $bp->loggedin_user->id == $user_id ) )
    33             $this->activities = bp_activity_get_friends_activity( $user_id, $max, $timeframe, false, $this->pag_num, $this->pag_page, $filter );
     33            $this->activities = bp_activity_get_friends_activity( $user_id, $max, false, $this->pag_num, $this->pag_page, $filter );
    3434       
    3535        if ( !$max || $max >= (int)$this->activities['total'] )
     
    8989            return true;
    9090        } elseif ( $this->current_activity + 1 == $this->activity_count ) {
    91             do_action('loop_end');
     91            do_action('activity_loop_end');
    9292            // Do some cleaning up after the loop
    9393            $this->rewind_activities();
     
    108108
    109109        if ( $this->current_activity == 0 ) // loop has just started
    110             do_action('loop_start');
     110            do_action('activity_loop_start');
    111111    }
    112112}
     
    125125function bp_has_activities( $args = '' ) {
    126126    global $bp, $activities_template, $bp_activity_user_id, $bp_activity_limit;
    127 
     127   
     128    /* Note: any params used for filtering can be a single value, or multiple values comma seperated. */
     129   
    128130    $defaults = array(
    129131        'type' => 'sitewide',
    130         'user_id' => false,
    131132        'per_page' => 25,
    132133        'max' => false,
    133         'timeframe' => '-4 weeks',
    134         'filter' => false
     134        'user_id' => false, // user_id to filter on
     135        'object' => false, // object to filter on e.g. groups, profile, status, friends
     136        'action' => false, // action to filter on e.g. new_wire_post, new_forum_post, profile_updated
     137        'primary_id' => false, // object ID to filter on e.g. a group_id or forum_id or blog_id etc.
     138        'secondary_id' => false, // secondary object ID to filter on e.g. a post_id
    135139    );
    136140
     
    162166   
    163167    if ( isset( $_GET['afilter'] ) )
    164         $filter = $_GET['afilter'];
    165 
    166     $activities_template = new BP_Activity_Template( $type, $user_id, $per_page, $max, $timeframe, $filter );       
     168        $filter = array( 'object' => $_GET['afilter'] );
     169    else
     170        $filter = array( 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id );
     171   
     172    $activities_template = new BP_Activity_Template( $type, $user_id, $per_page, $max, $filter );       
    167173    return $activities_template->has_activities();
    168174}
Note: See TracChangeset for help on using the changeset viewer.