/** * Create the member favorites CSV when requested. * * @since 1.0.0 */ public function run_member_favorites_csv() { // Output headers so that the file is downloaded rather than displayed. header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=cc-member-favorites.csv'); // Create a file pointer connected to the output stream. $output = fopen('php://output', 'w'); // Write a header row. $row = array('user_id', 'user_email', 'favorited_post_by_user_id', 'favorited_post_by_user_email', 'date_recorded'); // Write the row. fputcsv($output, $row); // Use a WP_User_Query meta_query to find users who have favorited activities. $args = array('meta_key' => 'bp_favorite_activities', 'meta_compare' => 'EXISTS', 'orderby' => 'ID'); $user_query = new WP_User_Query($args); // User Loop if (!empty($user_query->results)) { foreach ($user_query->results as $user) { $favorites = bp_activity_get_user_favorites($user->ID); // Passing an empty array to activity_ids gets them all. Abort! if (empty($favorites)) { continue; } // Next, get all of these activity items. $items = bp_activity_get_specific(array('activity_ids' => $favorites, 'update_meta_cache' => false)); foreach ($items['activities'] as $item) { $op = get_userdata($item->user_id); $row = array($user->ID, $user->user_email, $item->user_id, $op->user_email, $item->date_recorded); fputcsv($output, $row); } } } fclose($output); exit; }
</pubDate> <generator>http://buddypress.org/?v=<?php echo BP_VERSION; ?> </generator> <language><?php echo get_option('rss_language'); ?> </language> <?php do_action('bp_activity_favorites_feed_head'); ?> <?php $favs = bp_activity_get_user_favorites(bp_displayed_user_id()); $fav_ids = implode(',', (array) $favs); ?> <?php if (bp_has_activities('include=' . $fav_ids . '&max=50&display_comments=stream')) { ?> <?php while (bp_activities()) { bp_the_activity(); ?> <item> <guid><?php bp_activity_thread_permalink(); ?>
</pubDate> <generator>http://buddypress.org/?v=<?php echo BP_VERSION; ?> </generator> <language><?php echo get_option('rss_language'); ?> </language> <?php do_action('bp_activity_favorites_feed_head'); ?> <?php $favs = bp_activity_get_user_favorites($bp->displayed_user->id); $fav_ids = implode(',', (array) $favs); ?> <?php if (bp_has_activities('include=' . $fav_ids . '&max=50&display_comments=stream')) { ?> <?php while (bp_activities()) { bp_the_activity(); ?> <item> <guid><?php bp_activity_thread_permalink(); ?>
/** * Set up activity arguments for use with the 'favorites' scope. * * @since 2.2.0 * * @param array $retval Empty array by default. * @param array $filter Current activity arguments. * @return array $retval */ function bp_activity_filter_favorites_scope($retval = array(), $filter = array()) { // Determine the user_id. if (!empty($filter['user_id'])) { $user_id = $filter['user_id']; } else { $user_id = bp_displayed_user_id() ? bp_displayed_user_id() : bp_loggedin_user_id(); } // Determine the favorites. $favs = bp_activity_get_user_favorites($user_id); if (empty($favs)) { $favs = array(0); } // Should we show all items regardless of sitewide visibility? $show_hidden = array(); if (!empty($user_id) && $user_id !== bp_loggedin_user_id()) { $show_hidden = array('column' => 'hide_sitewide', 'value' => 0); } $retval = array('relation' => 'AND', array('column' => 'id', 'compare' => 'IN', 'value' => (array) $favs), $show_hidden, 'override' => array('display_comments' => true, 'filter' => array('user_id' => 0), 'show_hidden' => true)); return $retval; }
/** * Initializes the activity loop. * * Based on the $args passed, bp_has_activities() populates the $activities_template global. * * @since 1.0.0 * * @param array $args Arguments for limiting the contents of the activity loop. Can be passed as an associative array or as a URL argument string * * @global object $activities_template {@link BP_Activity_Template} * @global object $bp BuddyPress global settings * @uses groups_is_user_member() * @uses bp_current_action() * @uses bp_is_current_action() * @uses bp_get_activity_slug() * @uses bp_action_variable() * @uses nxt_parse_args() * @uses bp_is_active() * @uses friends_get_friend_user_ids() * @uses groups_get_user_groups() * @uses bp_activity_get_user_favorites() * @uses apply_filters() To call the 'bp_has_activities' hook * * @return bool Returns true when activities are found */ function bp_has_activities($args = '') { global $activities_template, $bp; /*** * Set the defaults based on the current page. Any of these will be overridden * if arguments are directly passed into the loop. Custom plugins should always * pass their parameters directly to the loop. */ $user_id = false; $include = false; $exclude = false; $in = false; $show_hidden = false; $object = false; $primary_id = false; // User filtering if (!empty($bp->displayed_user->id)) { $user_id = $bp->displayed_user->id; } // Group filtering if (!empty($bp->groups->current_group)) { $object = $bp->groups->id; $primary_id = $bp->groups->current_group->id; if ('public' != $bp->groups->current_group->status && (groups_is_user_member($bp->loggedin_user->id, $bp->groups->current_group->id) || $bp->loggedin_user->is_super_admin)) { $show_hidden = true; } } // The default scope should recognize custom slugs if (array_key_exists($bp->current_action, (array) $bp->loaded_components)) { $scope = $bp->loaded_components[$bp->current_action]; } else { $scope = bp_current_action(); } // Support for permalinks on single item pages: /groups/my-group/activity/124/ if (bp_is_current_action(bp_get_activity_slug())) { $include = bp_action_variable(0); } // Note: any params used for filtering can be a single value, or multiple values comma separated. $defaults = array('display_comments' => 'threaded', 'include' => $include, 'exclude' => $exclude, 'in' => $in, 'sort' => 'DESC', 'page' => 1, 'per_page' => 20, 'max' => false, 'show_hidden' => $show_hidden, 'scope' => $scope, 'user_id' => $user_id, 'object' => $object, 'action' => false, 'primary_id' => $primary_id, 'secondary_id' => false, 'search_terms' => false); $r = nxt_parse_args($args, $defaults); extract($r); // If you have passed a "scope" then this will override any filters you have passed. if ('just-me' == $scope || 'friends' == $scope || 'groups' == $scope || 'favorites' == $scope || 'mentions' == $scope) { if ('just-me' == $scope) { $display_comments = 'stream'; } // determine which user_id applies if (empty($user_id)) { $user_id = !empty($bp->displayed_user->id) ? $bp->displayed_user->id : $bp->loggedin_user->id; } // are we displaying user specific activity? if (is_numeric($user_id)) { $show_hidden = $user_id == $bp->loggedin_user->id && $scope != 'friends' ? 1 : 0; switch ($scope) { case 'friends': if (bp_is_active('friends')) { $friends = friends_get_friend_user_ids($user_id); } if (empty($friends)) { return false; } $user_id = implode(',', (array) $friends); break; case 'groups': if (bp_is_active('groups')) { $groups = groups_get_user_groups($user_id); if (empty($groups['groups'])) { return false; } $object = $bp->groups->id; $primary_id = implode(',', (array) $groups['groups']); $user_id = 0; } break; case 'favorites': $favs = bp_activity_get_user_favorites($user_id); if (empty($favs)) { return false; } $include = implode(',', (array) $favs); $display_comments = true; break; case 'mentions': $user_nicename = !empty($bp->displayed_user->id) ? $bp->displayed_user->userdata->user_nicename : $bp->loggedin_user->userdata->user_nicename; $user_login = !empty($bp->displayed_user->id) ? $bp->displayed_user->userdata->user_login : $bp->loggedin_user->userdata->user_login; $search_terms = '@' . bp_core_get_username($user_id, $user_nicename, $user_login) . '<'; // Start search at @ symbol and stop search at closing tag delimiter. $display_comments = 'stream'; $user_id = 0; break; } } } // Do not exceed the maximum per page if (!empty($max) && (int) $per_page > (int) $max) { $per_page = $max; } // Support for basic filters in earlier BP versions. if (isset($_GET['afilter'])) { $filter = array('object' => $_GET['afilter']); } else { if (!empty($user_id) || !empty($object) || !empty($action) || !empty($primary_id) || !empty($secondary_id)) { $filter = array('user_id' => $user_id, 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id); } else { $filter = false; } } $activities_template = new BP_Activity_Template($page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden, $exclude, $in); return apply_filters('bp_has_activities', $activities_template->has_activities(), $activities_template); }
/** * Load a user's favorites feed. * * @since 1.2.0 * * @uses bp_is_user_activity() * @uses bp_is_current_action() * @uses bp_is_action_variable() * @uses status_header() * * @return bool False on failure. */ function bp_activity_action_favorites_feed() { if (!bp_is_user_activity() || !bp_is_current_action('favorites') || !bp_is_action_variable('feed', 0)) { return false; } // Get displayed user's favorite activity IDs. $favs = bp_activity_get_user_favorites(bp_displayed_user_id()); $fav_ids = implode(',', (array) $favs); // Setup the feed. buddypress()->activity->feed = new BP_Activity_Feed(array('id' => 'favorites', 'title' => sprintf(__('%1$s | %2$s | Favorites', 'buddypress'), bp_get_site_name(), bp_get_displayed_user_fullname()), 'link' => bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/', 'description' => sprintf(__("Activity feed of %s's favorites.", 'buddypress'), bp_get_displayed_user_fullname()), 'activity_args' => 'include=' . $fav_ids)); }
/** * Initialize the activity loop. * * Based on the $args passed, bp_has_activities() populates the * $activities_template global, enabling the use of BuddyPress templates and * template functions to display a list of activity items. * * @since BuddyPress (1.0) * * @global object $activities_template {@link BP_Activity_Template} * @global object $bp BuddyPress global settings. * @uses groups_is_user_member() * @uses bp_current_action() * @uses bp_is_current_action() * @uses bp_get_activity_slug() * @uses bp_action_variable() * @uses wp_parse_args() * @uses bp_is_active() * @uses friends_get_friend_user_ids() * @uses groups_get_user_groups() * @uses bp_activity_get_user_favorites() * @uses apply_filters() To call the 'bp_has_activities' hook. * * @param array $args { * Arguments for limiting the contents of the activity loop. Most * arguments are in the same format as {@link BP_Activity_Activity::get()}. * However, because the format of the arguments accepted here differs in * a number of ways, and because bp_has_activities() determines some * default arguments in a dynamic fashion, we list all accepted arguments * here as well. * * Arguments can be passed as an associative array, or as a URL query * string (eg, 'user_id=4&display_comments=threaded'). * * @type int $page Which page of results to fetch. Using page=1 without * per_page will result in no pagination. Default: 1. * @type int|bool $per_page Number of results per page. Default: 20. * @type string $page_arg The string used as a query parameter in * pagination links. Default: 'acpage'. * @type int|bool $max Maximum number of results to return. * Default: false (unlimited). * @type string $sort 'ASC' or 'DESC'. Default: 'DESC'. * @type array|bool $exclude Array of activity IDs to exclude. Default: false. * @type array|bool $in Array of IDs to limit query by (IN). 'in' is * intended to be used in conjunction with other filter parameters. * Default: false. * @type array|bool $include Array of exact activity IDs to query. * Providing an 'include' array will override all other filters * passed in the argument array. When viewing a the permalink page * for a single activity item, this value defaults to the ID of that * item. Otherwise the default is false. * @type array $meta_query Limit by activitymeta by passing an array of * meta_query conditions. See {@link WP_Meta_Query::queries} for a * description of the syntax. * @type string $search_terms Limit results by a search term. Default: false. * @type string|bool $scope Use one of BuddyPress's pre-built filters. In * each case, the term 'current user' refers to the displayed user * when looking at a user profile, and otherwise to the logged-in user. * - 'just-me' retrieves items belonging only to the logged-in user; * this is equivalent to passing a 'user_id' argument * - 'friends' retrieves items belonging to the friends of the * current user * - 'groups' retrieves items associated with the groups to which * the current user belongs * - 'favorites' retrieves the current user's favorited activity * items * - 'mentions' retrieves activity items where the current user has * received an @-mention * The default value of 'scope' is set to one of the above if that * value appears in the appropriate place in the URL; eg, 'scope' will * be 'groups' when visiting http://example.com/members/joe/activity/groups/. * Otherwise defaults to false. * @type int|array|bool $user_id The ID(s) of user(s) whose activity should * be fetched. Pass a single ID or an array of IDs. When viewing a * user profile page (but not that user's activity subpages, ie My * Friends, My Groups, etc), 'user_id' defaults to the ID of the * displayed user. Otherwise the default is false. * @type string|array|bool $object Filters by the `component` column in the * database, which is generally the component ID in the case of * BuddyPress components, or the plugin slug in the case of plugins. * For example, 'groups' will limit results to those that are * associated with the BP Groups component. Accepts a single * component string, or an array of multiple components. Defaults to * 'groups' when viewing the page of a single group, the My Groups * activity filter, or the Activity > Groups filter of a user profile. * Otherwise defaults to false. * @type string|array|bool $action Filters by the `type` column in the * database, which is a string categorizing the activity item (eg, * 'new_blog_post', 'created_group'). Accepts a single type string, * or an array of multiple types. Defaults to false. * @type int|array|bool $primary_id Filters by the `item_id` column in the * database. The meaning of 'primary_id' differs between components/ * types; for example, in the case of 'created_group', 'primary_id' * is the ID of the group. Accepts a single ID, or an array of * multiple IDs. When viewing a single group, defaults to the current * group ID. When viewing a user's Groups stream page, defaults to * the IDs of the user's groups. Otherwise defaults to false. * @type int|array|bool $secondary_id Filters by the `secondary_item_id` * column in the database. The meaning of 'secondary_id' differs * between components/types. Accepts a single ID, or an array of * multiple IDs. Defaults to false. * @type int $offset Return only activity items with an ID greater than or * equal to this one. Note that providing an offset will disable * pagination. Default: false. * @type string|bool $display_comments How to handle activity comments. * Possible values: * - 'threaded' - comments appear in a threaded tree, under their * parent items * - 'stream' - the activity stream is presented in a flat manner, * with comments sorted in chronological order alongside other * activity items * - false - don't fetch activity comments at all * Default: 'threaded'. * @type bool $show_hidden Whether to show items marked hide_sitewide. * Defaults to false, except in the following cases: * - User is viewing his own activity stream * - User is viewing the activity stream of a non-public group of * which he is a member * @type bool $show_hidden Normally defaults to false, except when: * - a user is viewing his own activity stream * - a user is viewing the activity stream of a non-public group of * which he is a member * @type string|bool $spam Spam status. 'ham_only', 'spam_only', or false * to show all activity regardless of spam status. Default: 'ham_only'. * @type bool $populate_extras Whether to pre-fetch the activity metadata * for the queried items. Default: true. * } * @return bool Returns true when activities are found, otherwise false. */ function bp_has_activities($args = '') { global $activities_template, $bp; /*** * Set the defaults based on the current page. Any of these will be overridden * if arguments are directly passed into the loop. Custom plugins should always * pass their parameters directly to the loop. */ $user_id = false; $include = false; $exclude = false; $in = false; $show_hidden = false; $object = false; $primary_id = false; // User filtering if (bp_displayed_user_id()) { $user_id = bp_displayed_user_id(); } // Group filtering if (!empty($bp->groups->current_group)) { $object = $bp->groups->id; $primary_id = $bp->groups->current_group->id; if (groups_is_user_member(bp_loggedin_user_id(), $bp->groups->current_group->id) || bp_current_user_can('bp_moderate')) { $show_hidden = true; } } // The default scope should recognize custom slugs if (array_key_exists(bp_current_action(), (array) $bp->loaded_components)) { $scope = $bp->loaded_components[bp_current_action()]; } else { $scope = bp_current_action(); } // Support for permalinks on single item pages: /groups/my-group/activity/124/ if (bp_is_current_action(bp_get_activity_slug())) { $include = bp_action_variable(0); } // Note: any params used for filtering can be a single value, or multiple values comma separated. $defaults = array('display_comments' => 'threaded', 'include' => $include, 'exclude' => $exclude, 'in' => $in, 'sort' => 'DESC', 'page' => 1, 'per_page' => 20, 'max' => false, 'show_hidden' => $show_hidden, 'spam' => 'ham_only', 'page_arg' => 'acpage', 'scope' => $scope, 'user_id' => $user_id, 'object' => $object, 'action' => false, 'primary_id' => $primary_id, 'secondary_id' => false, 'offset' => false, 'since' => false, 'meta_query' => false, 'date_query' => false, 'search_terms' => false, 'update_meta_cache' => true); $r = bp_parse_args($args, $defaults, 'has_activities'); extract($r); // Translate various values for 'display_comments' // This allows disabling comments via ?display_comments=0 // or =none or =false. Final true is a strict type check. See #5029 if (in_array($display_comments, array(0, '0', 'none', 'false'), true)) { $display_comments = false; } // Ignore pagination if an offset is passed if (!empty($offset)) { $page = 0; } if (empty($search_terms) && !empty($_REQUEST['s'])) { $search_terms = $_REQUEST['s']; } // If you have passed a "scope" then this will override any filters you have passed. if ('just-me' == $scope || 'friends' == $scope || 'groups' == $scope || 'favorites' == $scope || 'mentions' == $scope) { if ('just-me' == $scope) { $display_comments = 'stream'; } // determine which user_id applies if (empty($user_id)) { $user_id = bp_displayed_user_id() ? bp_displayed_user_id() : bp_loggedin_user_id(); } // are we displaying user specific activity? if (is_numeric($user_id)) { $show_hidden = $user_id == bp_loggedin_user_id() && $scope != 'friends' ? 1 : 0; switch ($scope) { case 'friends': if (bp_is_active('friends')) { $friends = friends_get_friend_user_ids($user_id); } if (empty($friends)) { return false; } $user_id = implode(',', (array) $friends); break; case 'groups': if (bp_is_active('groups')) { $groups = groups_get_user_groups($user_id); if (empty($groups['groups'])) { return false; } $object = $bp->groups->id; $primary_id = implode(',', (array) $groups['groups']); $user_id = 0; } break; case 'favorites': $favs = bp_activity_get_user_favorites($user_id); if (empty($favs)) { return false; } $in = implode(',', (array) $favs); $display_comments = true; $user_id = 0; break; case 'mentions': // Are mentions disabled? if (!bp_activity_do_mentions()) { return false; } // Start search at @ symbol and stop search at closing tag delimiter. $search_terms = '@' . bp_activity_get_user_mentionname($user_id) . '<'; $display_comments = 'stream'; $user_id = 0; break; } } } // Do not exceed the maximum per page if (!empty($max) && (int) $per_page > (int) $max) { $per_page = $max; } // Support for basic filters in earlier BP versions is disabled by default. To enable, put // add_filter( 'bp_activity_enable_afilter_support', '__return_true' ); // into bp-custom.php or your theme's functions.php if (isset($_GET['afilter']) && apply_filters('bp_activity_enable_afilter_support', false)) { $filter = array('object' => $_GET['afilter']); } else { if (!empty($user_id) || !empty($object) || !empty($action) || !empty($primary_id) || !empty($secondary_id) || !empty($offset) || !empty($since)) { $filter = array('user_id' => $user_id, 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id, 'offset' => $offset, 'since' => $since); } else { $filter = false; } } // If specific activity items have been requested, override the $hide_spam argument. This prevents backpat errors with AJAX. if (!empty($include) && 'ham_only' == $spam) { $spam = 'all'; } $template_args = array('page' => $page, 'per_page' => $per_page, 'page_arg' => $page_arg, 'max' => $max, 'sort' => $sort, 'include' => $include, 'exclude' => $exclude, 'in' => $in, 'filter' => $filter, 'search_terms' => $search_terms, 'meta_query' => $meta_query, 'date_query' => $date_query, 'display_comments' => $display_comments, 'show_hidden' => $show_hidden, 'spam' => $spam, 'update_meta_cache' => $update_meta_cache); $activities_template = new BP_Activity_Template($template_args); return apply_filters('bp_has_activities', $activities_template->has_activities(), $activities_template, $template_args); }
/** * is this activity item in the user's list of favorites? * * should be in BP */ public function user_has_favorited_activity($user_id, $activity_id) { if (!$activity_id || !$user_id) { return false; } $user_favs = (array) bp_activity_get_user_favorites($user_id); return in_array($activity_id, $user_favs); }
/** * Return true when the deposit activity is a favorite of the current user. * * @global object $activities_template {@link BP_Activity_Template} * @uses apply_filters() To call the 'humcore_deposit_activity_is_favorite' hook. * * @return bool $is_favorite True if favorite, false if not. */ function humcore_deposit_activity_is_favorite($activity_id) { // TODO activity component must be active. $user_favs = bp_activity_get_user_favorites(bp_loggedin_user_id()); return apply_filters('humcore_deposit_activity_is_favorite', in_array($activity_id, (array) $user_favs)); }
/** * @group favorites * @group bp_activity_add_user_favorite */ public function test_add_user_favorite_already_favorited() { $u = $this->factory->user->create(); $a = $this->factory->activity->create(); // bp_activity_add_user_favorite() requires a logged-in user. $current_user = bp_loggedin_user_id(); $this->set_current_user($u); $this->assertTrue(bp_activity_add_user_favorite($a, $u)); $this->assertFalse(bp_activity_add_user_favorite($a, $u)); $this->assertSame(array($a), bp_activity_get_user_favorites($u)); $this->assertEquals(1, bp_activity_get_meta($a, 'favorite_count')); $this->set_current_user($current_user); }
function bp_has_activities( $args = '' ) { global $bp, $activities_template; /*** * Set the defaults based on the current page. Any of these will be overridden * if arguments are directly passed into the loop. Custom plugins should always * pass their parameters directly to the loop. */ $user_id = false; $include = false; $show_hidden = false; $object = false; $primary_id = false; /* User filtering */ if ( !empty( $bp->displayed_user->id ) ) $user_id = $bp->displayed_user->id; /* Group filtering */ if ( !empty( $bp->groups->current_group ) ) { $object = $bp->groups->id; $primary_id = $bp->groups->current_group->id; if ( 'public' != $bp->groups->current_group->status && ( groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) || $bp->loggedin_user->is_super_admin ) ) $show_hidden = true; } /* Support for permalinks on single item pages: /groups/my-group/activity/124/ */ if ( $bp->current_action == $bp->activity->slug ) $include = $bp->action_variables[0]; /* Note: any params used for filtering can be a single value, or multiple values comma separated. */ $defaults = array( 'display_comments' => 'threaded', // false for none, stream/threaded - show comments in the stream or threaded under items 'include' => $include, // pass an activity_id or string of ID's comma separated 'sort' => 'DESC', // sort DESC or ASC 'page' => 1, // which page to load 'per_page' => 20, // number of items per page 'max' => false, // max number to return 'show_hidden' => $show_hidden, // Show activity items that are hidden site-wide? /* Scope - pre-built activity filters for a user (friends/groups/favorites/mentions) */ 'scope' => $bp->current_action, /* Filtering */ 'user_id' => $user_id, // user_id to filter on 'object' => $object, // object to filter on e.g. groups, profile, status, friends 'action' => false, // action to filter on e.g. activity_update, new_forum_post, profile_updated 'primary_id' => $primary_id, // object ID to filter on e.g. a group_id or forum_id or blog_id etc. 'secondary_id' => false, // secondary object ID to filter on e.g. a post_id /* Searching */ 'search_terms' => false // specify terms to search on ); $r = wp_parse_args( $args, $defaults ); extract( $r ); /* If you have passed a "scope" then this will override any filters you have passed. */ if ( 'just-me' == $scope || 'friends' == $scope || 'groups' == $scope || 'favorites' == $scope || 'mentions' == $scope ) { if ( 'just-me' == $scope ) $display_comments = 'stream'; if ( $user_id = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->id : $bp->loggedin_user->id ) { $show_hidden = ( $user_id == $bp->loggedin_user->id && $scope != 'friends' ) ? 1 : 0; switch ( $scope ) { case 'friends': if ( function_exists( 'friends_get_friend_user_ids' ) ) $friends = friends_get_friend_user_ids( $user_id ); if ( empty( $friends ) ) return false; $user_id = implode( ',', (array)$friends ); break; case 'groups': if ( function_exists( 'groups_get_user_groups' ) ) { $groups = groups_get_user_groups( $user_id ); if ( empty( $groups['groups'] ) ) return false; $object = $bp->groups->id; $primary_id = implode( ',', (array)$groups['groups'] ); $user_id = false; } break; case 'favorites': $favs = bp_activity_get_user_favorites( $user_id ); if ( empty( $favs ) ) return false; $include = implode( ',', (array)$favs ); break; case 'mentions': $user_nicename = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->userdata->user_nicename : $bp->loggedin_user->userdata->user_nicename; $user_login = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->userdata->user_login : $bp->loggedin_user->userdata->user_login; $search_terms = '@' . bp_core_get_username( $user_id, $user_nicename, $user_login ) . '<'; // Start search at @ symbol and stop search at closing tag delimiter. $display_comments = 'stream'; $user_id = false; break; } } } if ( $max ) { if ( $per_page > $max ) $per_page = $max; } /* Support for basic filters in earlier BP versions. */ $filter = false; if ( isset( $_GET['afilter'] ) ) $filter = array( 'object' => $_GET['afilter'] ); else if ( !empty( $user_id ) || !empty( $object ) || !empty( $action ) || !empty( $primary_id ) || !empty( $secondary_id ) ) $filter = array( 'user_id' => $user_id, 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id ); $activities_template = new BP_Activity_Template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden ); return apply_filters( 'bp_has_activities', $activities_template->has_activities(), &$activities_template ); }