本文整理汇总了PHP中friends_get_friend_user_ids函数的典型用法代码示例。如果您正苦于以下问题:PHP friends_get_friend_user_ids函数的具体用法?PHP friends_get_friend_user_ids怎么用?PHP friends_get_friend_user_ids使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了friends_get_friend_user_ids函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: bp_mutual_friend_total_count
/**
* Get the mutual friend count of a current user.
*
* @params $friend_user_id int
*
* @return mixed|void
*/
function bp_mutual_friend_total_count($friend_user_id = 0)
{
$current_user_friends = friends_get_friend_user_ids(get_current_user_id());
if (empty($friend_user_id)) {
$friend_user_id = bp_displayed_user_id();
}
$displayed_user_friends = friends_get_friend_user_ids($friend_user_id);
$result = count(array_intersect($current_user_friends, $displayed_user_friends));
return apply_filters('bp_mutual_friend_total_count', $result);
}
开发者ID:sanketio,项目名称:Mutual-Buddies,代码行数:17,代码来源:bp-mutual-friends-functions.php
示例2: refresh_friends_cache
static function refresh_friends_cache($user)
{
if (!class_exists('BuddyPress')) {
return;
}
if (!bp_is_active('friends')) {
return;
}
$friends = friends_get_friend_user_ids($user);
wp_cache_set('rtmedia-user-friends-' . $user, $friends);
return $friends;
}
开发者ID:fs-contributor,项目名称:rtMedia,代码行数:12,代码来源:RTMediaFriends.php
示例3: social_articles_send_notification
function social_articles_send_notification($id)
{
global $bp, $socialArticles;
$savedPost = get_post($id);
$notification_already_sent = get_post_meta($id, 'notification_already_sent', true);
if (empty($notification_already_sent) && function_exists("friends_get_friend_user_ids") && $savedPost->post_status == "publish" && $savedPost->post_type == "post" && !wp_is_post_revision($id) && $socialArticles->options['bp_notifications'] == "true") {
$friends = friends_get_friend_user_ids($savedPost->post_author);
foreach ($friends as $friend) {
bp_core_add_notification($savedPost->ID, $friend, $bp->social_articles->id, 'new_article' . $savedPost->ID, $savedPost->post_author);
}
bp_core_add_notification($savedPost->ID, $savedPost->post_author, $bp->social_articles->id, 'new_article' . $savedPost->ID, -1);
update_post_meta($id, 'notification_already_sent', true);
}
}
开发者ID:Dannypid,项目名称:Tinymce-social-articles-1.8,代码行数:14,代码来源:social-articles-functions.php
示例4: cacsp_paper_reader_selector
/**
* Generate the reader selector interface.
*/
function cacsp_paper_reader_selector($paper_id)
{
global $wpdb;
// Get a list of readers, friends, and co-group-members to prime selectbox.
// @todo Add AJAX support.
$paper = new CACSP_Paper($paper_id);
$paper_reader_ids = $paper->get_reader_ids();
$groups_of_user = cacsp_get_groups_of_user(bp_loggedin_user_id());
if (empty($groups_of_user)) {
$groups_of_user = array(0);
}
// So dirty.
$bp = buddypress();
$group_member_ids = $wpdb->get_col($wpdb->prepare("SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id IN (" . implode(',', $groups_of_user) . ") AND user_id != %d AND is_banned = 0 AND is_confirmed = 1", bp_loggedin_user_id()));
$group_member_ids = array_map('intval', $group_member_ids);
$friend_member_ids = array();
if (bp_is_active('friends')) {
$friend_member_ids = friends_get_friend_user_ids(bp_loggedin_user_id());
}
$users = bp_core_get_users(array('include' => array_merge($paper_reader_ids, $group_member_ids, $friend_member_ids), 'type' => 'alphabetical'));
$user_data = array();
$selected = array();
if (!empty($users['users'])) {
foreach ($users['users'] as $user) {
$user_id = (int) $user->ID;
$user_data[] = array('id' => $user_id, 'text' => html_entity_decode($user->display_name, ENT_QUOTES, 'UTF-8'));
// Collect data about the existing readers.
if (in_array($user_id, $paper_reader_ids, true)) {
$selected[] = array('id' => $user_id, 'text' => stripslashes($user->display_name));
}
}
}
$script = 'var CACSP_Potential_Readers = ' . wp_json_encode($user_data) . ';';
echo "\n" . '<script type="text/javascript">' . $script . '</script>' . "\n";
// Select2 only needs an <option> printed for the selected options.
?>
<select name="cacsp-readers[]" multiple="multiple" style="width:100%;" id="cacsp-reader-selector">
<?php
foreach ($selected as $_selected) {
echo '<option value="' . esc_attr($_selected['id']) . '" selected="selected">' . esc_html($_selected['text']) . '</option>';
}
?>
</select>
<?php
wp_nonce_field('cacsp-reader-selector', 'cacsp-reader-selector-nonce');
}
开发者ID:sheesh,项目名称:social-paper,代码行数:49,代码来源:readers.php
示例5: widget
/** @see WP_Widget::widget -- do not rename this */
function widget($args, $instance)
{
extract($args);
//Our variables from the widget settings.
$title = apply_filters('widget_title', $instance['title']);
$num = $instance['number'];
$friends = $instance['friends'];
$width = $instance['width'];
echo '<div class="' . $width . '"><div class="dash-widget activity">' . $before_widget;
// Display the widget title
if ($title) {
echo $before_title . $title . $after_title;
}
if (isset($friends) && $friends) {
$friends = friends_get_friend_user_ids(bp_loggedin_user_id());
$friends[] = bp_loggedin_user_id();
$friends_and_me = implode(',', (array) $friends);
} else {
$friends_and_me = bp_loggedin_user_id();
}
global $wpdb, $bp;
$activities = apply_filters('wplms_dashboard_activity', $wpdb->get_results("\n\t\t\tSELECT *\n\t\t FROM {$bp->activity->table_name} AS activity\n\t\t WHERE \tactivity.user_id IN ({$friends_and_me})\n\t\t AND (activity.action != '' OR activity.action IS NOT NULL)\n\t\t ORDER BY activity.date_recorded DESC\n\t\t LIMIT 0,{$num}\n\t\t"));
if (isset($activities) && is_array($activities)) {
echo '<div class="student_activity"><a class="small button ' . ($title ? 'withtitle' : '') . '">' . __('VIEW ALL', 'wplms-dashboard') . '</a>
<ul class="dash-activities">';
foreach ($activities as $activity) {
if (isset($activity->action) && $activity->action != '') {
$time = tofriendlytime(time() - strtotime($activity->date_recorded));
echo '<li class="' . $activity->component . ' ' . $activity->type . '">
<div class="dash-activity">
<span class="dash-activity-time">' . $time . ' ' . __('AGO', 'wplms-dashboard') . '</span>
<strong>' . $activity->action . '</strong>
<p>' . $activity->content . '</p>
</div>
</li>';
}
}
echo '</ul>
</div></div>';
}
echo $after_widget . '</div>';
}
开发者ID:nikitansk,项目名称:devschool,代码行数:43,代码来源:calendar.php
示例6: 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
示例7: get_wall_activities
/**
* GET WALL ACTIVITES
*/
function get_wall_activities($page = 0, $per_page = 20)
{
global $bp, $wpdb;
$min = $page > 0 ? ($page - 1) * $per_page : 0;
$max = ($page + 1) * $per_page;
$per_page = bp_get_activity_per_page();
buddy_boss_log(" per page {$per_page}");
if (isset($bp->loggedin_user) && isset($bp->loggedin_user->id) && $bp->displayed_user->id == $bp->loggedin_user->id) {
$myprofile = true;
} else {
$myprofile = false;
}
$wpdb->show_errors = BUDDY_BOSS_DEBUG;
$user_id = $bp->displayed_user->id;
buddy_boss_log("Looking at {$user_id}");
$filter = addslashes($bp->displayed_user->fullname);
$friend_ids = friends_get_friend_user_ids($user_id);
$admin_ids = array();
//buddyboss_users_by_role( 'administrator' );
$friend_ids = array_merge($friend_ids, $admin_ids);
// var_dump($friend_ids);
buddy_boss_log($friend_ids);
if (!empty($friend_ids)) {
$friend_id_list = implode(",", $friend_ids);
}
buddy_boss_log($friend_id_list);
$table = $wpdb->prefix . bp_activity;
$table2 = $wpdb->prefix . bp_activity_meta;
// Group Display code
if (array_search("groups", $bp->active_components)) {
$groups = BP_Groups_Member::get_group_ids($user_id);
}
//var_dump($groups);
$valid_groups = array();
if (!empty($groups)) {
foreach ($groups['groups'] as $id) {
$group = new BP_Groups_Group($id);
//var_dump($group);
if ("public" == $group->status) {
//echo $group->slug;
$valid_groups[] = $id;
}
$user_group[] = $group->slug;
}
}
$group_modifier = "OR ( {$table}.user_id = {$user_id} AND {$table}.component = 'groups' ) ";
$group_mentions = "OR ( {$table}.component = 'groups' AND ({$table}.content LIKE '%@{$filter}%'))";
$friendships = "OR ( {$table}.user_id = {$user_id} AND {$table}.component = 'friends' )";
$mentions_modifier = "OR ( {$table}.component = 'activity' AND {$table}.action LIKE '%@{$filter}%' ) ";
//$mem_slugs = $bp->members->slug;
$friends_modifier = "OR ( {$table2}.meta_value LIKE '%{$filter}%' AND {$table}.type!='activity_comment') ";
$qry = "SELECT {$table}.id FROM {$table} LEFT JOIN {$table2} ON {$table}.id={$table2}.activity_id\r\n\t\t\tWHERE ( {$table}.user_id = {$user_id} AND {$table}.type!='activity_comment' AND {$table}.type!='friends' )\r\n\t\t\t{$friends_modifier}\r\n\t\t\t{$group_modifier}\r\n\t\t\t{$group_mentions}\r\n\t\t\t{$friendships}\r\n\t\t\t{$mentions_modifier}\r\n\t\t\tORDER BY date_recorded DESC LIMIT {$min}, 30";
//echo $qry;
$activities = $wpdb->get_results($qry, ARRAY_A);
//var_dump($wpdb->print_error());
buddy_boss_log($qry);
buddy_boss_log($activities);
if (empty($activities)) {
return null;
}
$tmp = array();
foreach ($activities as $a) {
$tmp[] = $a["id"];
}
$activity_list = implode(",", $tmp);
return $activity_list;
}
开发者ID:par-orillonsoft,项目名称:Wishmagnet,代码行数:70,代码来源:buddy_boss_wall.php
示例8: bp_get_friend_ids
/**
* Get a comma-separated list of IDs of a user's friends.
*
* @param int $user_id Optional. Default: the displayed user's ID, or the
* logged-in user's ID.
* @return string|bool A comma-separated list of friend IDs if any are found,
* otherwise false.
*/
function bp_get_friend_ids($user_id = 0)
{
if (empty($user_id)) {
$user_id = bp_displayed_user_id() ? bp_displayed_user_id() : bp_loggedin_user_id();
}
$friend_ids = friends_get_friend_user_ids($user_id);
if (empty($friend_ids)) {
return false;
}
return implode(',', friends_get_friend_user_ids($user_id));
}
开发者ID:mawilliamson,项目名称:wordpress,代码行数:19,代码来源:bp-friends-template.php
示例9: bp_show_friend_suggestions_list
function bp_show_friend_suggestions_list($limit = 5)
{
$user_id = get_current_user_id();
$my_friends = (array) friends_get_friend_user_ids($user_id);
//get all friend ids
$my_friend_req = (array) friend_suggest_get_friendship_requested_user_ids($user_id);
//get all friend request by me
$possible_friends = array();
//we will store the possible friend ids here
foreach ($my_friends as $friend_id) {
$possible_friends = array_merge($possible_friends, (array) friends_get_friend_user_ids($friend_id));
}
//we have the list of friends of friends, we will just remove
//now get only udifferent friend ids(unique)
$possible_friends = array_unique($possible_friends);
//intersect my friends with this array
$my_friends[] = get_current_user_id();
//include me to
$excluded_users = get_user_meta($user_id, 'hidden_friend_suggestions', true);
$excluded_users = array_merge($my_friends, (array) $excluded_users, (array) $my_friend_req);
//we may check the preference of the user regarding , like not add
$possible_friends = array_diff($possible_friends, $excluded_users);
//get those user who are not my friend and also exclude me too
if (!empty($possible_friends)) {
shuffle($possible_friends);
//randomize
$possible_friends = array_slice($possible_friends, 0, $limit);
}
if (!empty($possible_friends)) {
?>
<ul id="members-suggestion-list" class="item-list suggested-friend-item-list">
<?php
foreach ($possible_friends as $possible_friend) {
?>
<li>
<?php
$member_link = bp_core_get_user_domain($possible_friend);
$member_name = bp_core_get_user_displayname($possible_friend);
?>
<div class="item-avatar">
<a href="<?php
echo $member_link;
?>
"><?php
echo bp_core_fetch_avatar(array('type' => 'thumb', 'width' => 50, 'height' => 50, 'item_id' => $possible_friend));
?>
</a>
</div>
<div class="item">
<div class="item-title">
<a href="<?php
echo $member_link;
?>
"><?php
echo $member_name;
?>
</a>
</div>
</div>
<div class="action">
<?php
bp_friend_suggest_hide_link($possible_friend);
?>
<?php
bp_add_friend_button($possible_friend);
?>
</div>
<div class="clear"></div>
</li>
<?php
}
?>
</ul>
<?php
} else {
?>
<div id="message" class="info">
<p><?php
_e("We don't have enough details to suggest a friend yet", 'bp-friends-suggest');
?>
</p>
</div>
<?php
}
?>
<?php
}
开发者ID:socialray,项目名称:surfied-2-0,代码行数:92,代码来源:bp-friend-suggest-widget.php
示例10: get_friends
function get_friends()
{
$user_id = get_current_user_id();
if (function_exists('friends_get_friend_user_ids')) {
$friends = friends_get_friend_user_ids($user_id);
foreach ($friends as $key => $friend) {
$friends[$key] = array('id' => $friend, 'pic' => bp_core_fetch_avatar(array('item_id' => $friend, 'type' => 'thumb')), 'name' => bp_core_get_user_displayname($friend));
}
echo json_encode($friends);
}
die;
}
开发者ID:nikitansk,项目名称:devschool,代码行数:12,代码来源:contact_users.php
示例11: bp_friends_filter_activity_scope
/**
* Set up activity arguments for use with the 'friends' scope.
*
* For details on the syntax, see {@link BP_Activity_Query}.
*
* @since 2.2.0
*
* @param array $retval Empty array by default.
* @param array $filter Current activity arguments.
* @return array
*/
function bp_friends_filter_activity_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 friends of user.
$friends = friends_get_friend_user_ids($user_id);
if (empty($friends)) {
$friends = array(0);
}
$retval = array('relation' => 'AND', array('column' => 'user_id', 'compare' => 'IN', 'value' => (array) $friends), array('column' => 'hide_sitewide', 'value' => 0), 'override' => array('filter' => array('user_id' => 0), 'show_hidden' => true));
return $retval;
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:27,代码来源:bp-friends-activity.php
示例12: bfox_bp_plans_schedule_loop_args
function bfox_bp_plans_schedule_loop_args()
{
global $bp;
$plan = bfox_bp_plan();
wp_parse_str(bp_ajax_querystring('reading_schedules'), $args);
if ($plan->id) {
$args['plan_id'] = $plan->id;
if ('my-schedules' == $bp->action_variables[0]) {
$args['user_id'] = $bp->loggedin_user->id;
} elseif ('friend-schedules' == $bp->action_variables[0]) {
$args['user_id'] = (array) friends_get_friend_user_ids($bp->loggedin_user->id);
}
} else {
$args = BfoxReadingSchedule::add_current_owner_to_args($args);
$args['cache_latest_readings'] = true;
}
if (!$args['page']) {
$args['page'] = 1;
}
if (!$args['per_page']) {
$args['per_page'] = 20;
}
return $args;
}
开发者ID:jeffryevans,项目名称:biblefox-wp,代码行数:24,代码来源:plans-directory.php
示例13: get_users
/**
* Get a list of users that match the query parameters.
*
* Since BuddyPress 1.7, use {@link BP_User_Query} instead.
*
* @deprecated 1.7.0 Use {@link BP_User_Query}.
*
* @see BP_User_Query for a description of parameters, most of which
* are used there in the same way.
*
* @param string $type See {@link BP_User_Query}.
* @param int $limit See {@link BP_User_Query}. Default: 0.
* @param int $page See {@link BP_User_Query}. Default: 1.
* @param int $user_id See {@link BP_User_Query}. Default: 0.
* @param mixed $include See {@link BP_User_Query}. Default: false.
* @param string|bool $search_terms See {@link BP_User_Query}.
* Default: false.
* @param bool $populate_extras See {@link BP_User_Query}.
* Default: true.
* @param mixed $exclude See {@link BP_User_Query}. Default: false.
* @param string|bool $meta_key See {@link BP_User_Query}.
* Default: false.
* @param string|bool $meta_value See {@link BP_User_Query}.
* Default: false.
* @return array {
* @type int $total_users Total number of users matched by query
* params.
* @type array $paged_users The current page of users matched by
* query params.
* }
*/
public static function get_users($type, $limit = 0, $page = 1, $user_id = 0, $include = false, $search_terms = false, $populate_extras = true, $exclude = false, $meta_key = false, $meta_value = false)
{
global $wpdb;
_deprecated_function(__METHOD__, '1.7', 'BP_User_Query');
$bp = buddypress();
$sql = array();
$sql['select_main'] = "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.display_name, u.user_email";
if ('active' == $type || 'online' == $type || 'newest' == $type) {
$sql['select_active'] = ", um.meta_value as last_activity";
}
if ('popular' == $type) {
$sql['select_popular'] = ", um.meta_value as total_friend_count";
}
if ('alphabetical' == $type) {
$sql['select_alpha'] = ", pd.value as fullname";
}
if ($meta_key) {
$sql['select_meta'] = ", umm.meta_key";
if ($meta_value) {
$sql['select_meta'] .= ", umm.meta_value";
}
}
$sql['from'] = "FROM {$wpdb->users} u LEFT JOIN {$wpdb->usermeta} um ON um.user_id = u.ID";
// We search against xprofile fields, so we must join the table
if ($search_terms && bp_is_active('xprofile')) {
$sql['join_profiledata_search'] = "LEFT JOIN {$bp->profile->table_name_data} spd ON u.ID = spd.user_id";
}
// Alphabetical sorting is done by the xprofile Full Name field
if ('alphabetical' == $type) {
$sql['join_profiledata_alpha'] = "LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id";
}
if ($meta_key) {
$sql['join_meta'] = "LEFT JOIN {$wpdb->usermeta} umm ON umm.user_id = u.ID";
}
$sql['where'] = 'WHERE ' . bp_core_get_status_sql('u.');
if ('active' == $type || 'online' == $type || 'newest' == $type) {
$sql['where_active'] = $wpdb->prepare("AND um.meta_key = %s", bp_get_user_meta_key('last_activity'));
}
if ('popular' == $type) {
$sql['where_popular'] = $wpdb->prepare("AND um.meta_key = %s", bp_get_user_meta_key('total_friend_count'));
}
if ('online' == $type) {
$sql['where_online'] = "AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= UTC_TIMESTAMP()";
}
if ('alphabetical' == $type) {
$sql['where_alpha'] = "AND pd.field_id = 1";
}
if (!empty($exclude)) {
$exclude = implode(',', wp_parse_id_list($exclude));
$sql['where_exclude'] = "AND u.ID NOT IN ({$exclude})";
}
// Passing an $include value of 0 or '0' will necessarily result in an empty set
// returned. The default value of false will hit the 'else' clause.
if (0 === $include || '0' === $include) {
$sql['where_users'] = "AND 0 = 1";
} else {
if (!empty($include)) {
$include = implode(',', wp_parse_id_list($include));
$sql['where_users'] = "AND u.ID IN ({$include})";
} elseif (!empty($user_id) && bp_is_active('friends')) {
$friend_ids = friends_get_friend_user_ids($user_id);
if (!empty($friend_ids)) {
$friend_ids = implode(',', wp_parse_id_list($friend_ids));
$sql['where_friends'] = "AND u.ID IN ({$friend_ids})";
// User has no friends, return false since there will be no users to fetch.
} else {
return false;
}
}
//.........这里部分代码省略.........
开发者ID:kosir,项目名称:thatcamp-org,代码行数:101,代码来源:class-bp-core-user.php
示例14: mention_autosuggest
/**
* AJAX receiver for the @mention autosuggest jQuery library. Performs a search on the string provided and returns matches.
*
* @global object $bp BuddyPress global settings
* @return mixed Either HTML or JSON. If error, "-1" for missing parameters, "0" for no matches.
* @see bp-labs/beakers/js/jquery.mentions.dev.js
* @since 1.0
*/
public function mention_autosuggest()
{
global $bp;
if (empty($_POST['limit']) || empty($_POST['search'])) {
exit('-1');
}
// Sanitise input
$search_query = implode('', (array) preg_replace(array('|^https?://|i', '|\\*|', '|@|'), '', $_POST['search']));
if (empty($search_query)) {
exit('-1');
}
$args = array('count_total' => false, 'number' => (int) $_POST['limit'], 'search' => "{$search_query}*");
if (!empty($bp->loggedin_user->id)) {
$args['exclude'] = array($bp->loggedin_user->id);
}
if (bp_is_username_compatibility_mode()) {
$args['fields'] = array('ID', 'user_login');
$args['orderby'] = 'login';
} else {
$args['fields'] = array('ID', 'user_nicename');
$args['orderby'] = 'nicename';
}
$args = apply_filters('bpl_mention_autosuggest_args', $args);
// Search users
$user_search_results = get_users($args);
if (empty($user_search_results)) {
// Return JSON
if (!empty($_POST['format']) && 'json' == $_POST['format']) {
exit(json_encode(false));
// Return HTML
} else {
printf('<li class="section error"><p><span>%s</span> %s</p></li>', _x('No matches found.', 'no search results', 'bpl'), _x('Please check your spelling.', 'no search results', 'bpl'));
exit;
}
}
// If logged in, get user's friends
$friend_ids = array();
if (!empty($bp->loggedin_user->id) && bp_is_active('friends')) {
$friend_ids = friends_get_friend_user_ids($bp->loggedin_user->id);
}
$search_results = array('friends' => array(), 'others' => array());
// Build results
foreach ((array) $user_search_results as $user) {
$result = new stdClass();
$result->avatar = bp_core_fetch_avatar(array('item_id' => $user->ID, 'width' => 30, 'height' => 30, 'type' => 'thumb', 'alt' => __('Profile picture of %s', 'bpl')));
$result->name = bp_core_get_user_displayname($user->ID);
if (bp_is_username_compatibility_mode()) {
$result->id = $user->user_login;
} else {
$result->id = $user->user_nicename;
}
if (in_array($user->ID, (array) $friend_ids)) {
$search_results['friends'][] = $result;
} else {
$search_results['others'][] = $result;
}
}
apply_filters_ref_array('bpl_mention_autosuggest', array(&$search_results, $args));
// Return JSON
if (!empty($_POST['format']) && 'json' == $_POST['format']) {
exit(json_encode($search_results));
// Return HTML
} else {
$html = array();
foreach ($search_results as $section => $items) {
if (empty($items)) {
continue;
}
// Friends and other users
if ('friends' == $section || 'others' == $section) {
if ('friends' == $section) {
$html[] = sprintf('<li class="section friends"><p>%s</p></li>', __('Your friends', 'bpl'));
} elseif ('others' == $section) {
if (!empty($search_results['friends'])) {
$html[] = sprintf('<li class="section other"><p>%s</p></li>', sprintf(__('Other people on %s', 'bpl'), get_bloginfo('name', 'display')));
} else {
$html[] = sprintf('<li class="section other"><p>%s</p></li>', sprintf(__('People on %s', 'bpl'), get_bloginfo('name', 'display')));
}
}
foreach ($items as $item) {
$html[] = sprintf('<li class=%s><p>%s</p></li>', esc_attr($item->id), $item->avatar . esc_html($item->name));
}
// For third-party extensions
} else {
$custom_section = apply_filters('bpl_mention_autosuggest_custom_section', false, $section, $items);
if (!empty($custom_section)) {
$html = array_merge($html, (array) $custom_section);
}
}
}
// Safety net
if (empty($html)) {
//.........这里部分代码省略.........
开发者ID:rmccue,项目名称:BP-Labs,代码行数:101,代码来源:class-bplabs-autosuggest.php
示例15: bp_mute_filter_user_activity_scope_friends
/**
* Filter user activity stream if scope is "friends".
*
* @since 1.0.3
*
* @param array $r The activity arguments.
* @return array
*/
function bp_mute_filter_user_activity_scope_friends($r)
{
if (!bp_is_my_profile()) {
return $r;
}
if ($r['scope'] !== "friends") {
return $r;
}
$r['scope'] = '';
$friend_ids = friends_get_friend_user_ids(bp_displayed_user_id());
$muted_ids = Mute::get_muting(bp_displayed_user_id());
$r['user_id'] = array_diff($friend_ids, $muted_ids);
return $r;
}
开发者ID:sbrajesh,项目名称:buddypress-mute,代码行数:22,代码来源:functions.php
示例16: widget
function widget($args, $instance)
{
if (!function_exists('bp_is_active')) {
return false;
}
extract($args);
$blog_url = get_bloginfo('url');
$title = apply_filters('widget_title', empty($instance['title']) ? 'Atividades na rede' : $instance['title']);
$maxActivities = empty($instance['maxActivities']) ? 9 : $instance['maxActivities'];
$activityFilterBy = empty($instance['activityFilterBy']) ? '' : $instance['activityFilterBy'];
// cria o filtro de actions, pega as chaves do array e cria uma string separando os valores por virgula
$query_string = '&action=' . implode(",", array_keys($activityFilterBy));
// máximo de atividades
$query_string .= '&max=' . $maxActivities;
$query_string .= '&per_page=' . $maxActivities;
// $query_string .= '&display_comments=stream';
// TODO: remover Mostrar essa widget apenas no perfil do usuário e na página inicial
// se for a página do usuário
if (bp_displayed_user_id()) {
// pega os amigos do usuário da página atual
$friends = friends_get_friend_user_ids(bp_displayed_user_id());
if (!empty($friends)) {
$friends_and_me = implode(',', (array) $friends);
$friends_and_me = '&user_id=' . $friends_and_me;
$query_string = $query_string . $friends_and_me;
} else {
return false;
}
// se não for a página inicial retorna falso.
} else {
if (!is_home()) {
return false;
}
}
print $before_widget;
if (!empty($instance['title'])) {
print $before_head;
print $before_title . "<a href='{$blog_url}/activity' title='ver mais atividades'> " . $instance['title'] . "</a>" . $after_title;
print $after_head;
}
print $before_body;
?>
<?php
do_action('bp_before_directory_activity');
?>
<div id="buddypress" >
<div class="<?php
echo is_home() ? 'activity' : '';
?>
" role="main">
<?php
do_action('template_notices');
?>
<?php
do_action('bp_before_directory_activity_content');
?>
<?php
if (is_user_logged_in() and is_home()) {
?>
<?php
bp_get_template_part('activity/post-form');
?>
<?php
}
?>
<?php
do_action('bp_before_directory_activity_list');
?>
<!-- loop -->
<?php
do_action('bp_before_activity_loop');
?>
<?php
//echo $query_string;
?>
<?php
if (bp_has_activities(bp_ajax_querystring('activity') . $query_string)) {
?>
<ul id="activity-stream" class="activity-list item-list">
<?php
while (bp_activities()) {
bp_the_activity();
?>
//.........这里部分代码省略.........
开发者ID:CoordCulturaDigital-Minc,项目名称:cdigital2014,代码行数:101,代码来源:widget-atividades.php
示例17: get_friend_user_ids
/**
* Get friends/Following user ids
* @param type $logged_user_id
* @return type
*/
public static function get_friend_user_ids($logged_user_id)
{
$friend_ids = array();
if (function_exists('friends_get_friend_user_ids')) {
$friend_ids = friends_get_friend_user_ids($logged_user_id);
} elseif (function_exists('bp_follow_get_following')) {
$friend_ids = bp_follow_get_following(array('user_id' => $logged_user_id));
}
return apply_filters('fblike_activity_get_friend_ids', $friend_ids, $logged_user_id);
}
开发者ID:poweronio,项目名称:mbsite,代码行数:15,代码来源:bp-fblike-activity-stream.php
示例18: get_users
function get_users( $type, $limit = null, $page = 1, $user_id = false, $include = false, $search_terms = false, $populate_extras = true ) {
global $wpdb, $bp;
$sql = array();
$sql['select_main'] = "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.display_name, u.user_email";
if ( 'active' == $type || 'online' == $type )
$sql['select_active'] = ", um.meta_value as last_activity";
if ( 'popular' == $type )
$sql['select_popular'] = ", um.meta_value as total_friend_count";
if ( 'alphabetical' == $type )
$sql['select_alpha'] = ", pd.value as fullname";
$sql['from'] = "FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN " . CUSTOM_USER_META_TABLE . " um ON um.user_id = u.ID";
if ( $search_terms && function_exists( 'xprofile_install' ) || 'alphabetical' == $type )
$sql['join_profiledata'] = "LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id";
$sql['where'] = 'WHERE ' . bp_core_get_status_sql( 'u.' );
if ( 'active' == $type || 'online' == $type )
$sql['where_active'] = "AND um.meta_key = 'last_activity'";
if ( 'popular' == $type )
$sql['where_popular'] = "AND um.meta_key = 'total_friend_count'";
if ( 'online' == $type )
$sql['where_online'] = "AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= UTC_TIMESTAMP()";
if ( 'alphabetical' == $type )
$sql['where_alpha'] = "AND pd.field_id = 1";
if ( $include ) {
if ( is_array( $include ) )
$uids = $wpdb->escape( implode( ',', (array)$include ) );
else
$uids = $wpdb->escape( $include );
if ( !empty( $uids ) )
$sql['where_users'] = "AND u.ID IN ({$uids})";
}
else if ( $user_id && function_exists( 'friends_install' ) ) {
$friend_ids = friends_get_friend_user_ids( $user_id );
$friend_ids = $wpdb->escape( implode( ',', (array)$friend_ids ) );
if ( !empty( $friend_ids ) )
$sql['where_friends'] = "AND u.ID IN ({$friend_ids})";
else {
/* User has no friends, return false since there will be no users to fetch. */
return false;
}
}
if ( $search_terms && function_exists( 'xprofile_install' ) ) {
$search_terms = like_escape( $wpdb->escape( $search_terms ) );
$sql['where_searchterms'] = "AND pd.value LIKE '%%$search_terms%%'";
}
switch ( $type ) {
case 'active': case 'online': default:
$sql[] = "ORDER BY um.meta_value DESC";
break;
case 'newest'
|
请发表评论