/**
 * Filter all AJAX bp_activity_request() calls for the 'activity' object with the 'links' scope
 *
 * @param string $query_string
 * @param string $object
 * @param string $filter
 * @param string $scope
 * @param integer $page
 * @param string $search_terms
 * @param string $extras
 * @return string
 */
function bp_links_dtheme_activity_filter($query_string, $object, $filter, $scope, $page, $search_terms, $extras)
{
    global $bp;
    $do_filter = false;
    // only filter activity.
    if (bp_links_is_activity_enabled() && $bp->activity->id == $object) {
        if (bp_is_user()) {
            // handle filtering for profile pages
            // this nav does not use AJAX so don't rely on $scope
            if (bp_is_activity_component() && bp_links_slug() == $bp->current_action) {
                $do_filter = 'user';
            }
        } else {
            // handle filtering for all non-profile, non-links pages
            if (!bp_current_component() || bp_is_activity_component()) {
                // filter under 'activity' component with 'links' scope
                if (bp_links_id() == $scope) {
                    $do_filter = 'user';
                }
            } elseif (bp_is_links_component()) {
                // filter 'links' component home pages
                if ($bp->is_single_item) {
                    $do_filter = 'default';
                }
            }
        }
    }
    if ($do_filter) {
        // parse query string
        $args = array();
        parse_str($query_string, $args);
        switch ($do_filter) {
            case 'user':
                // override with links object
                $args['object'] = bp_links_id();
                // user_id must be empty to show OTHER user's actions for this user's links
                $args['user_id'] = false;
                // get recent link cloud ids for this user
                $recent_ids = bp_links_recent_activity_item_ids_for_user();
                // if there is activity, send the ids
                if (count($recent_ids)) {
                    $args['primary_id'] = join(',', $recent_ids);
                }
                break;
            case 'default':
                // override with links object
                $args['object'] = bp_links_id();
                // set primary id to current link id if applicable
                if ($bp->links->current_link) {
                    $args['primary_id'] = $bp->links->current_link->id;
                }
                break;
        }
        // return modified query string
        return http_build_query($args);
    }
    // no filtering
    return $query_string;
}
Beispiel #2
0
function bp_links_admin_current_action_variable()
{
    global $bp;
    if (bp_is_links_component() && 'admin' == $bp->current_action) {
        return $bp->action_variables[0];
    } else {
        return false;
    }
}