当前位置: 首页>>代码示例>>PHP>>正文


PHP bp_activity_get_user_favorites函数代码示例

本文整理汇总了PHP中bp_activity_get_user_favorites函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_activity_get_user_favorites函数的具体用法?PHP bp_activity_get_user_favorites怎么用?PHP bp_activity_get_user_favorites使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了bp_activity_get_user_favorites函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run_member_favorites_csv

 /**
  * 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;
 }
开发者ID:careshub,项目名称:cc-stats,代码行数:39,代码来源:class-cc-stats-admin.php

示例2: get_option

</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();
        ?>
开发者ID:newington,项目名称:buddypress,代码行数:31,代码来源:bp-activity-favorites-feed.php

示例3: get_option

</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();
        ?>
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:31,代码来源:bp-activity-favorites-feed.php

示例4: bp_activity_filter_favorites_scope

/**
 * 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;
}
开发者ID:mawilliamson,项目名称:wordpress,代码行数:30,代码来源:bp-activity-filters.php

示例5: bp_has_activities


//.........这里部分代码省略.........
    $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);
}
开发者ID:nxtclass,项目名称:NXTClass,代码行数:101,代码来源:bp-activity-template.php

示例6: bp_activity_action_favorites_feed

/**
 * 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));
}
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:23,代码来源:bp-activity-actions.php

示例7: bp_has_activities


//.........这里部分代码省略.........
    // 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);
}
开发者ID:eresyyl,项目名称:mk,代码行数:101,代码来源:bp-activity-template.php

示例8: user_has_favorited_activity

 /**
  * 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);
 }
开发者ID:kosir,项目名称:thatcamp-org,代码行数:13,代码来源:thatcamp-favorites.php

示例9: humcore_deposit_activity_is_favorite

/**
 * 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));
}
开发者ID:MartinPaulEve,项目名称:humcore,代码行数:14,代码来源:template.php

示例10: test_add_user_favorite_already_favorited

 /**
  * @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);
 }
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:17,代码来源:functions.php

示例11: bp_has_activities

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;
//.........这里部分代码省略.........
开发者ID:n-sane,项目名称:zaroka,代码行数:101,代码来源:bp-activity-templatetags.php


注:本文中的bp_activity_get_user_favorites函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。