Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/07/2010 11:33:21 AM (15 years ago)
Author:
boonebgorges
Message:

Adds exclude parameter to bp_has_activities. Fixes #2646

File:
1 edited

Legend:

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

    r3369 r3373  
    7171            $this->primary_link = $bp->loggedin_user->domain;
    7272
    73         /* If we have an existing ID, update the activity item, otherwise insert it. */
     73        // If we have an existing ID, update the activity item, otherwise insert it.
    7474        if ( $this->id )
    7575            $q = $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET user_id = %d, component = %s, type = %s, action = %s, content = %s, primary_link = %s, date_recorded = %s, item_id = %s, secondary_item_id = %s, hide_sitewide = %d WHERE id = %d", $this->user_id, $this->component, $this->type, $this->action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->id );
     
    8787    }
    8888
    89     /* Static Functions */
    90 
    91     function get( $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false, $show_hidden = false ) {
    92         global $wpdb, $bp;
    93 
    94         /* Select conditions */
     89    // Static Functions
     90
     91    function get( $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false, $show_hidden = false, $exclude = false ) {
     92        global $wpdb, $bp;
     93
     94        // Select conditions
    9595        $select_sql = "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name";
    9696
    9797        $from_sql = " FROM {$bp->activity->table_name} a LEFT JOIN {$wpdb->users} u ON a.user_id = u.ID";
    9898
    99         /* Where conditions */
     99        // Where conditions
    100100        $where_conditions = array();
    101101
    102         /* Searching */
     102        // Searching
    103103        if ( $search_terms ) {
    104104            $search_terms = $wpdb->escape( $search_terms );
     
    106106        }
    107107
    108         /* Filtering */
     108        // Filtering
    109109        if ( $filter && $filter_sql = BP_Activity_Activity::get_filter_sql( $filter ) )
    110110            $where_conditions['filter_sql'] = $filter_sql;
    111111
    112         /* Sorting */
     112        // Sorting
    113113        if ( $sort != 'ASC' && $sort != 'DESC' )
    114114            $sort = 'DESC';
    115115
    116         /* Hide Hidden Items? */
     116        // Hide Hidden Items?
    117117        if ( !$show_hidden )
    118118            $where_conditions['hidden_sql'] = "a.hide_sitewide = 0";
    119119
    120         /* Alter the query based on whether we want to show activity item comments in the stream like normal comments or threaded below the activity */
     120        // Exclude specified items
     121        if ( $exclude )
     122            $where_conditions['exclude'] = "a.id NOT IN ({$exclude})";
     123
     124        // Alter the query based on whether we want to show activity item comments in the stream like normal comments or threaded below the activity
    121125        if ( !$display_comments || 'threaded' == $display_comments ) {
    122126            $where_conditions[] = "a.type != 'activity_comment'";
     
    134138        $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(a.id) FROM {$bp->activity->table_name} a {$where_sql} ORDER BY a.date_recorded {$sort}" ) );
    135139
    136         /* Get the fullnames of users so we don't have to query in the loop */
     140        // Get the fullnames of users so we don't have to query in the loop
    137141        if ( bp_is_active( 'xprofile' ) && $activities ) {
    138142            foreach ( (array)$activities as $activity ) {
     
    161165            $activities = BP_Activity_Activity::append_comments( &$activities );
    162166
    163         /* If $max is set, only return up to the max results */
     167        // If $max is set, only return up to the max results
    164168        if ( !empty( $max ) ) {
    165169            if ( (int)$total_activities > (int)$max )
     
    194198            $activities = BP_Activity_Activity::append_comments( $activities );
    195199
    196         /* If $max is set, only return up to the max results */
     200        // If $max is set, only return up to the max results
    197201        if ( !empty( $max ) ) {
    198202            if ( (int)$total_activities > (int)$max )
Note: See TracChangeset for help on using the changeset viewer.