Skip to:
Content

BuddyPress.org

Changeset 5419


Ignore:
Timestamp:
11/30/2011 07:32:53 AM (10 years ago)
Author:
djpaul
Message:

On the Activity admin screen, when filtered to show a specific activity (via speech bubble), display all its child activities on the same screen. See #3660. Props Tom J Nowell and Lee Willis

File:
1 edited

Legend:

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

    r5408 r5419  
    492492        ) );
    493493
     494        // If we're viewing a specific activity, flatten all activites into a single array.
     495        if ( $include_id ) {
     496            $activities['activities'] = BP_Activity_List_Table::flatten_activity_array( $activities['activities'] );
     497            $activities['total']      = count( $activities['activities'] );
     498
     499            // Sort the array by the activity object's date_recorded value
     500            usort( $activities['activities'], create_function( '$a, $b', 'return $a->date_recorded > $b->date_recorded;' ) );
     501        }
     502
    494503        // bp_activity_get returns an array of objects; cast these to arrays for WP_List_Table.
    495504        $new_activities = array();
     
    500509            $this->activity_user_id[$activity_item->id] = $activity_item->user_id;
    501510        }
    502 
    503         // @todo If we're viewing a specific activity, check/merge $activity->children into the main list (recursive).
    504         /*if ( $include_id ) {
    505         }*/
    506511
    507512        // Set raw data to display
     
    871876        }
    872877    }
     878
     879    /**
     880     * Helper function to flatten all activites returned from bp_activity_get() into a single array.
     881     *
     882     * @param array $tree Source array
     883     * @return array Flattened array
     884     * @since 1.6
     885     */
     886    public static function flatten_activity_array( $tree ){
     887        foreach ( (array) $tree as $node ) {
     888            if ( isset( $node->children ) ) {
     889
     890                foreach ( BP_Activity_List_Table::flatten_activity_array( $node->children ) as $child ) {
     891                    $tree[] = $child;
     892                }
     893
     894                unset( $node->children );
     895            }
     896        }
     897
     898        return $tree;
     899    }
    873900}
    874901?>
Note: See TracChangeset for help on using the changeset viewer.