本文整理汇总了PHP中friends_check_friendship函数的典型用法代码示例。如果您正苦于以下问题:PHP friends_check_friendship函数的具体用法?PHP friends_check_friendship怎么用?PHP friends_check_friendship使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了friends_check_friendship函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: friends_add_friend
/**
* Create a new friendship.
*
* @since 1.0.0
*
* @param int $initiator_userid ID of the "initiator" user (the user who is
* sending the friendship request).
* @param int $friend_userid ID of the "friend" user (the user whose friendship
* is being requested).
* @param bool $force_accept Optional. Whether to force acceptance. When false,
* running friends_add_friend() will result in a friendship request.
* When true, running friends_add_friend() will result in an accepted
* friendship, with no notifications being sent. Default: false.
* @return bool True on success, false on failure.
*/
function friends_add_friend($initiator_userid, $friend_userid, $force_accept = false)
{
// You cannot be friends with yourself!
if ($initiator_userid == $friend_userid) {
return false;
}
// Check if already friends, and bail if so.
if (friends_check_friendship($initiator_userid, $friend_userid)) {
return true;
}
// Setup the friendship data.
$friendship = new BP_Friends_Friendship();
$friendship->initiator_user_id = $initiator_userid;
$friendship->friend_user_id = $friend_userid;
$friendship->is_confirmed = 0;
$friendship->is_limited = 0;
$friendship->date_created = bp_core_current_time();
if (!empty($force_accept)) {
$friendship->is_confirmed = 1;
}
// Bail if friendship could not be saved (how sad!).
if (!$friendship->save()) {
return false;
}
// Send notifications.
if (empty($force_accept)) {
$action = 'requested';
// Update friend totals.
} else {
$action = 'accepted';
friends_update_friend_totals($friendship->initiator_user_id, $friendship->friend_user_id, 'add');
}
/**
* Fires at the end of initiating a new friendship connection.
*
* This is a variable hook, depending on context.
* The two potential hooks are: friends_friendship_requested, friends_friendship_accepted.
*
* @since 1.0.0
*
* @param int $id ID of the pending friendship connection.
* @param int $initiator_user_id ID of the friendship initiator.
* @param int $friend_user_id ID of the friend user.
* @param object $friendship BuddyPress Friendship Object.
*/
do_action('friends_friendship_' . $action, $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id, $friendship);
return true;
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:63,代码来源:bp-friends-functions.php
示例2: test_friends_delete_activity
/**
* @group friends_delete_activity
*/
public function test_friends_delete_activity()
{
$old_user = get_current_user_id();
$u1 = $this->factory->user->create();
$u2 = $this->factory->user->create();
friends_add_friend($u2, $u1);
$friendship_id = friends_get_friendship_id($u2, $u1);
// Set current user to u1 to accepte the friendship
$this->set_current_user($u1);
friends_accept_friendship($friendship_id);
// Reset the current user
$this->set_current_user($old_user);
// Random activities
$au1 = $this->factory->activity->create(array('user_id' => $u1));
$au2 = $this->factory->activity->create(array('user_id' => $u2));
$fc_act = bp_activity_get(array('component' => buddypress()->friends->id, 'item_id' => $friendship_id, 'filter' => array('action' => array('friendship_created')), 'show_hidden' => false));
$this->assertTrue(count($fc_act['activities']) == 1, '1 public activity should be created when a friendship is confirmed');
// Remove the friendship
friends_remove_friend($u2, $u1);
$this->assertFalse(friends_check_friendship($u2, $u1), '2 users should not be friend once the friendship is removed');
$fd_act = bp_activity_get(array('component' => buddypress()->friends->id, 'item_id' => $friendship_id, 'filter' => array('action' => array('friendship_created')), 'show_hidden' => true));
$this->assertTrue(count($fd_act['activities']) == 0, 'friends_delete_activity() should remove "friendship_created" activities about a deleted friendship');
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:26,代码来源:activity.php
示例3: groups_ajax_invite_user
function groups_ajax_invite_user()
{
global $bp;
check_ajax_referer('groups_invite_uninvite_user');
if (!$_POST['friend_id'] || !$_POST['friend_action'] || !$_POST['group_id']) {
return false;
}
if (!groups_is_user_admin($bp->loggedin_user->id, $_POST['group_id'])) {
return false;
}
if (!friends_check_friendship($bp->loggedin_user->id, $_POST['friend_id'])) {
return false;
}
if ('invite' == $_POST['friend_action']) {
if (!groups_invite_user($_POST['friend_id'], $_POST['group_id'])) {
return false;
}
$user = new BP_Core_User($_POST['friend_id']);
echo '<li id="uid-' . $user->id . '">';
echo attribute_escape($user->avatar_thumb);
echo '<h4>' . attribute_escape($user->user_link) . '</h4>';
echo '<span class="activity">' . attribute_escape($user->last_active) . '</span>';
echo '<div class="action">
<a class="remove" href="' . wp_nonce_url($bp->loggedin_user->domain . $bp->groups->slug . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user') . '" id="uid-' . attribute_escape($user->id) . '">' . __('Remove Invite', 'buddypress') . '</a>
</div>';
echo '</li>';
} else {
if ('uninvite' == $_POST['friend_action']) {
if (!groups_uninvite_user($_POST['friend_id'], $_POST['group_id'])) {
return false;
}
return true;
} else {
return false;
}
}
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:37,代码来源:bp-groups-ajax.php
示例4: friends_add_friend
/**
* Create a new friendship.
*
* @param int $initiator_userid ID of the "initiator" user (the user who is
* sending the friendship request).
* @param int $friend_userid ID of the "friend" user (the user whose friendship
* is being requested).
* @param bool $force_accept Optional. Whether to force acceptance. When false,
* running friends_add_friend() will result in a friendship request.
* When true, running friends_add_friend() will result in an accepted
* friendship, with no notifications being sent. Default: false.
* @return bool True on success, false on failure.
*/
function friends_add_friend($initiator_userid, $friend_userid, $force_accept = false)
{
// You cannot be friends with yourself!
if ($initiator_userid == $friend_userid) {
return false;
}
// Check if already friends, and bail if so
if (friends_check_friendship($initiator_userid, $friend_userid)) {
return true;
}
// Setup the friendship data
$friendship = new BP_Friends_Friendship();
$friendship->initiator_user_id = $initiator_userid;
$friendship->friend_user_id = $friend_userid;
$friendship->is_confirmed = 0;
$friendship->is_limited = 0;
$friendship->date_created = bp_core_current_time();
if (!empty($force_accept)) {
$friendship->is_confirmed = 1;
}
// Bail if friendship could not be saved (how sad!)
if (!$friendship->save()) {
return false;
}
// Send notifications
if (empty($force_accept)) {
$action = 'friends_friendship_requested';
// Update friend totals
} else {
$action = 'friends_friendship_accepted';
friends_update_friend_totals($friendship->initiator_user_id, $friendship->friend_user_id, 'add');
}
// Call the above titled action and pass friendship data into it
do_action($action, $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id, $friendship);
return true;
}
开发者ID:eresyyl,项目名称:mk,代码行数:49,代码来源:bp-friends-functions.php
示例5: bp_dtheme_ajax_invite_user
/**
* Invites a friend to join a group via a POST request.
*
* @return unknown
* @since BuddyPress (1.2)
* @todo Audit return types
*/
function bp_dtheme_ajax_invite_user()
{
// Bail if not a POST action
if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
return;
}
check_ajax_referer('groups_invite_uninvite_user');
if (!$_POST['friend_id'] || !$_POST['friend_action'] || !$_POST['group_id']) {
return;
}
if (!bp_groups_user_can_send_invites($_POST['group_id'])) {
return;
}
if (!friends_check_friendship(bp_loggedin_user_id(), $_POST['friend_id'])) {
return;
}
if ('invite' == $_POST['friend_action']) {
if (!groups_invite_user(array('user_id' => $_POST['friend_id'], 'group_id' => $_POST['group_id']))) {
return;
}
$user = new BP_Core_User($_POST['friend_id']);
echo '<li id="uid-' . $user->id . '">';
echo $user->avatar_thumb;
echo '<h4>' . $user->user_link . '</h4>';
echo '<span class="activity">' . esc_attr($user->last_active) . '</span>';
echo '<div class="action">
<a class="button remove" href="' . wp_nonce_url(bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user') . '" id="uid-' . esc_attr($user->id) . '">' . __('Remove Invite', 'logicalboneshug') . '</a>
</div>';
echo '</li>';
exit;
} elseif ('uninvite' == $_POST['friend_action']) {
if (!groups_uninvite_user($_POST['friend_id'], $_POST['group_id'])) {
return;
}
exit;
} else {
return;
}
}
开发者ID:raminjan,项目名称:logicalbones_hug,代码行数:46,代码来源:ajax.php
示例6: bp_get_loggedin_user_nav
/**
* Render the navigation markup for the logged-in user.
*
* Each component adds to this navigation array within its own
* [component_name]setup_nav() function.
*
* This navigation array is the top level navigation, so it contains items such as:
* [Blog, Profile, Messages, Groups, Friends] ...
*
* The function will also analyze the current component the user is in, to
* determine whether or not to highlight a particular nav item.
*
* @todo Move to a back-compat file?
* @deprecated Does not seem to be called anywhere in BP core.
*/
function bp_get_loggedin_user_nav()
{
$bp = buddypress();
// Loop through each navigation item.
foreach ((array) $bp->bp_nav as $nav_item) {
$selected = '';
// If the current component matches the nav item id, then add a highlight CSS class.
if (!bp_is_directory() && !empty($bp->active_components[bp_current_component()]) && $bp->active_components[bp_current_component()] == $nav_item['css_id']) {
$selected = ' class="current selected"';
}
// If we are viewing another person (current_userid does not equal
// loggedin_user->id then check to see if the two users are friends.
// if they are, add a highlight CSS class to the friends nav item
// if it exists.
if (!bp_is_my_profile() && bp_displayed_user_id()) {
$selected = '';
if (bp_is_active('friends')) {
if ($nav_item['css_id'] == $bp->friends->id) {
if (friends_check_friendship(bp_loggedin_user_id(), bp_displayed_user_id())) {
$selected = ' class="current selected"';
}
}
}
}
// Echo out the final list item.
echo apply_filters_ref_array('bp_get_loggedin_user_nav_' . $nav_item['css_id'], array('<li id="li-nav-' . $nav_item['css_id'] . '" ' . $selected . '><a id="my-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a></li>', &$nav_item));
}
// Always add a log out list item to the end of the navigation.
$logout_link = '<li><a id="wp-logout" href="' . wp_logout_url(bp_get_root_domain()) . '">' . __('Log Out', 'buddypress') . '</a></li>';
echo apply_filters('bp_logout_nav_link', $logout_link);
}
开发者ID:mawilliamson,项目名称:wordpress,代码行数:46,代码来源:bp-members-template.php
示例7: buddydrive_current_user_can_link
/**
* Checks if the user can get the link of an item
*
* @param array $privacy the sharing options
* @uses buddydrive_get_owner_id() to get owner's id
* @uses bp_loggedin_user_id() to get current user id
* @uses is_user_logged_in() to check if the visitor is not logged in
* @uses bp_is_active() to check for friends and groups component
* @uses friends_check_friendship() to check the friendship between owner and current user
* @uses groups_is_user_member() to check if the current user is member of the group the BuddyDrive item is attached to
* @return boolean true or false
*/
function buddydrive_current_user_can_link($privacy = false)
{
$can_link = false;
if (buddydrive_get_owner_id() == bp_loggedin_user_id()) {
$can_link = true;
} else {
if (empty($privacy)) {
$can_link = false;
} else {
if (!is_user_logged_in()) {
$can_link = false;
} else {
if ($privacy['privacy'] == 'public') {
$can_link = true;
} else {
if ($privacy['privacy'] == 'friends' && bp_is_active('friends') && friends_check_friendship(buddydrive_get_owner_id(), bp_loggedin_user_id())) {
$can_link = true;
} else {
if ($privacy['privacy'] == 'groups' && bp_is_active('groups') && !empty($privacy['group']) && groups_is_user_member(bp_loggedin_user_id(), intval($privacy['group']))) {
$can_link = true;
} else {
if (is_super_admin()) {
$can_link = true;
}
}
}
}
}
}
}
return apply_filters('buddydrive_current_user_can_link', $can_link);
}
开发者ID:MrVibe,项目名称:buddydrive,代码行数:44,代码来源:buddydrive-item-template.php
示例8: get_status_sql
function get_status_sql($link_owner_user_id = false, $format_string = '%s')
{
global $bp;
// if user is the site admin or is logged in and viewing their own links, then no limitations
if (is_super_admin() || bp_is_my_profile()) {
// return an empty string
return '';
} else {
// everyone can see the public links
$status_opts = array(self::STATUS_PUBLIC);
// if logged in user is a friend, show friends only links too
if (bp_links_is_friends_enabled()) {
if ($link_owner_user_id && $link_owner_user_id != $bp->loggedin_user->id && friends_check_friendship($link_owner_user_id, $bp->loggedin_user->id)) {
$status_opts[] = self::STATUS_FRIENDS;
}
}
// return the sql string
return sprintf($format_string, sprintf('status IN (%s)', join(',', $status_opts)));
}
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:20,代码来源:bp-links-classes.php
示例9: ez_bp_profile_current_visitor_is
/**
* Evaluates current visitor and determines what a vistor is relative to various biz rules. these "flags" are used for managing editability and visibility.
*/
public function ez_bp_profile_current_visitor_is($int_compare_to_user_id = '')
{
global $bp;
// start with nothing
$arr_visitor_is = array();
// EVERY visitor gets to see public - if there is any public
$arr_visitor_is['public'] = true;
/**
* If the visitor is not loggedin then all other checks are irrelevant; so save time and return if not logged in.
*/
if (is_user_logged_in()) {
$arr_visitor_is['loggedin'] = true;
} else {
return $arr_visitor_is;
}
// now that we're sure we have a logged in visitor use the $bp global to work some magic
$int_loggedin_user_id = $bp->loggedin_user->id;
$int_displayed_user_id = $bp->displayed_user->id;
/**
* fyi - did you notice, we're going to allow a user id to be passed in and used for the current loggedin user.
* we don't really need this now per se, but it made sense to bake it in for later, just in case.
*/
if (is_int($int_compare_to_user_id)) {
$int_displayed_user_id = $int_compare_to_user_id;
}
/**
* what if you want more layers in your organization? then you only have to customize this one method.
*/
$arr_visitor_is_custom = $this->ez_bp_profile_current_visitor_is_custom($int_compare_to_user_id = '');
// if we get an array back then merge it in
if (is_array($arr_visitor_is_custom)) {
$arr_visitor_is = array_merge($arr_visitor_is, $arr_visitor_is_custom);
}
// if the loggedin user is the display / compare to user then set the user flag and return 'cause checking friends and groups doesn't make sense.
if ($int_loggedin_user_id == $int_displayed_user_id) {
$arr_visitor_is['user'] = true;
return $arr_visitor_is;
}
if (bp_is_active('friends')) {
if (friends_check_friendship($int_displayed_user_id, $int_loggedin_user_id)) {
$arr_visitor_is['friends'] = true;
}
}
if (bp_is_active('groups')) {
// does the current (loggedin) visitor share any groups with the profile'd person?
if ($int_loggedin_user_id != $int_displayed_user_id) {
$arr_displayed_user_id_groups = BP_Groups_Member::get_group_ids($int_displayed_user_id);
$arr_loggedin_user_id_groups = BP_Groups_Member::get_group_ids($int_loggedin_user_id);
$arr_intersect_groups = array_intersect($arr_displayed_user_id_groups['groups'], $arr_loggedin_user_id_groups['groups']);
// intersect means the users have a group(s) in common
if (!empty($arr_intersect_groups)) {
$arr_visitor_is['groups'] = true;
}
}
}
return $arr_visitor_is;
}
开发者ID:WPezClasses,项目名称:class-wp-ezclasses-buddypress-editability-visibility-1,代码行数:60,代码来源:class-wp-ezclasses-buddypress-editability-visibility-1.php
示例10: get
/**
* The selection query
*
* @param array $args arguments to customize the query
* @uses wp_parse_args() to merge args with defaults one
* @uses bp_displayed_user_id() to get the displayed user id
* @uses bp_is_my_profile() to check if we're on current user profile
* @uses bp_is_active() to check for groups and friends component
* @uses friends_check_friendship() to check if current user is friend with item owner
* @uses friends_get_friend_user_ids() to get the friends of current user
* @uses paginate_links()
* @uses add_query_arg()
*/
public function get($args)
{
// Only run the query once
if (empty($this->query)) {
$defaults = array('id' => false, 'name' => false, 'group_id' => false, 'user_id' => false, 'per_page' => 10, 'paged' => 1, 'type' => false, 'buddydrive_scope' => false, 'search' => false, 'buddydrive_parent' => 0, 'exclude' => false, 'orderby' => 'title', 'order' => 'ASC');
$r = wp_parse_args($args, $defaults);
$paged = !empty($_POST['page']) ? intval($_POST['page']) : $r['paged'];
if (!empty($r['id'])) {
$query_args = array('post_status' => 'publish', 'post_type' => $r['type'], 'p' => $r['id'], 'posts_per_page' => $r['per_page'], 'paged' => $paged);
} else {
if (!empty($r['name']) && !empty($r['type'])) {
$query_args = array('post_status' => 'publish', 'post_type' => $r['type'], 'name' => $r['name'], 'posts_per_page' => $r['per_page'], 'paged' => $paged);
} else {
$query_args = array('post_status' => 'publish', 'post_type' => $r['type'], 'post_parent' => $r['buddydrive_parent'], 'posts_per_page' => $r['per_page'], 'paged' => $paged, 'orderby' => $r['orderby'], 'order' => $r['order'], 'meta_query' => array());
switch ($r['buddydrive_scope']) {
case 'files':
if (!empty($r['user_id']) && (int) $r['user_id'] === (int) bp_displayed_user_id()) {
$query_args['author'] = $r['user_id'];
}
if (!bp_is_my_profile() && !bp_current_user_can('bp_moderate')) {
$privacy = array('private');
if (bp_is_active('friends') && !friends_check_friendship($r['user_id'], bp_loggedin_user_id())) {
$privacy[] = 'friends';
}
$query_args['meta_query'][] = array('key' => '_buddydrive_sharing_option', 'value' => $privacy, 'compare' => 'NOT IN');
}
break;
case 'friends':
if (bp_is_active('friends')) {
$ids = friends_get_friend_user_ids(bp_loggedin_user_id());
if (!empty($ids)) {
$query_args['author'] = implode(',', $ids);
$query_args['meta_query'][] = array('key' => '_buddydrive_sharing_option', 'value' => 'friends', 'compare' => '=');
} else {
// we need to use a dummy query to avoid listing all files !
$query_args['meta_query'][] = array('key' => '_buddydrive_sharing_option', 'value' => 'dummyvalue', 'compare' => '=');
}
}
break;
case 'groups':
if (bp_is_active('groups') && !empty($r['group_id']) && empty($r['buddydrive_parent'])) {
$query_args['meta_query'][] = array('key' => '_buddydrive_sharing_groups', 'value' => $r['group_id'], 'compare' => 'IN');
}
break;
case 'admin':
if (!empty($r['user_id'])) {
$query_args['author'] = $r['user_id'];
}
if (bp_is_active('groups') && !empty($r['group_id']) && empty($r['buddydrive_parent'])) {
$query_args['meta_query'][] = array('key' => '_buddydrive_sharing_groups', 'value' => $r['group_id'], 'compare' => 'IN');
}
// Search is only possible for Super Admin, as searching makes it difficult to garanty privacy
if (!empty($r['search'])) {
$query_args['s'] = $r['search'];
}
break;
default:
// non public meta values are restricted to admins
if ('public' !== $r['buddydrive_scope'] && !bp_current_user_can('bp_moderate')) {
$meta_value = 'dummyvalue';
} else {
$meta_value = $r['buddydrive_scope'];
}
/**
* Use the scope to build a meta query
*
* if the scope match a sharing option, files or folders will be fetched
*/
$query_args['meta_query'][] = array('key' => '_buddydrive_sharing_option', 'value' => $meta_value, 'compare' => '=');
}
}
}
if (!empty($r['exclude'])) {
if (!is_array($r['exclude'])) {
$r['exclude'] = explode(',', $r['exclude']);
}
$query_args['post__not_in'] = $r['exclude'];
}
/**
* Use the 'buddydrive_item_get' filter to customize the query args
*
* @since 1.3.2
*
* @param array $query_args the arguments for the BuddyDrive query
* @param array $r the requested arguments
*/
$this->query = new WP_Query(apply_filters('buddydrive_item_get', $query_args, $r));
//.........这里部分代码省略.........
开发者ID:nikitansk,项目名称:devschool,代码行数:101,代码来源:buddydrive-item-classes.php
示例11: bp_legacy_theme_ajax_invite_user
/**
* Invites a friend to join a group via a POST request.
*
* @since BuddyPress (1.2)
* @todo Audit return types
*/
function bp_legacy_theme_ajax_invite_user()
{
// Bail if not a POST action
if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
return;
}
check_ajax_referer('groups_invite_uninvite_user');
if (!$_POST['friend_id'] || !$_POST['friend_action'] || !$_POST['group_id']) {
return;
}
if (!bp_groups_user_can_send_invites($_POST['group_id'])) {
return;
}
if (!friends_check_friendship(bp_loggedin_user_id(), $_POST['friend_id'])) {
return;
}
$group_id = (int) $_POST['group_id'];
$friend_id = (int) $_POST['friend_id'];
if ('invite' == $_POST['friend_action']) {
$group = groups_get_group($group_id);
// Users who have previously requested membership do not need
// another invitation created for them
if (BP_Groups_Member::check_for_membership_request($friend_id, $group_id)) {
$user_status = 'is_pending';
// Create the user invitation
} elseif (groups_invite_user(array('user_id' => $friend_id, 'group_id' => $group_id))) {
$user_status = 'is_invited';
// Miscellaneous failure
} else {
return;
}
$user = new BP_Core_User($friend_id);
$uninvite_url = bp_is_current_action('create') ? bp_get_groups_directory_permalink() . 'create/step/group-invites/?user_id=' . $friend_id : bp_get_group_permalink($group) . 'send-invites/remove/' . $friend_id;
echo '<li id="uid-' . esc_attr($user->id) . '">';
echo $user->avatar_thumb;
echo '<h4>' . $user->user_link . '</h4>';
echo '<span class="activity">' . esc_attr($user->last_active) . '</span>';
echo '<div class="action">
<a class="button remove" href="' . wp_nonce_url($uninvite_url, 'groups_invite_uninvite_user') . '" id="uid-' . esc_attr($user->id) . '">' . __('Remove Invite', 'buddypress') . '</a>
</div>';
if ('is_pending' == $user_status) {
echo '<p class="description">' . sprintf(__('%s has previously requested to join this group. Sending an invitation will automatically add the member to the group.', 'buddypress'), $user->user_link) . '</p>';
}
echo '</li>';
exit;
} elseif ('uninvite' == $_POST['friend_action']) {
// Users who have previously requested membership should not
// have their requests deleted on the "uninvite" action
if (BP_Groups_Member::check_for_membership_request($friend_id, $group_id)) {
return;
}
// Remove the unsent invitation
if (!groups_uninvite_user($friend_id, $group_id)) {
return;
}
exit;
} else {
return;
}
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:66,代码来源:buddypress-functions.php
示例12: bp_xprofile_get_hidden_fields_for_user
/**
* Get the ids of fields that are hidden for this displayed/loggedin user pair
*
* This is the function primarily responsible for profile field visibility. It works by determining
* the relationship between the displayed_user (ie the profile owner) and the current_user (ie the
* profile viewer). Then, based on that relationship, we query for the set of fields that should
* be excluded from the profile loop.
*
* @since 1.6
* @see BP_XProfile_Group::get()
* @uses apply_filters() Filter bp_xprofile_get_hidden_fields_for_user to modify visibility levels,
* or if you have added your own custom levels
*
* @param int $displayed_user_id The id of the user the profile fields belong to
* @param int $current_user_id The id of the user viewing the profile
* @return array An array of field ids that should be excluded from the profile query
*/
function bp_xprofile_get_hidden_fields_for_user($displayed_user_id = 0, $current_user_id = 0)
{
if (!$displayed_user_id) {
$displayed_user_id = bp_displayed_user_id();
}
if (!$displayed_user_id) {
return array();
}
if (!$current_user_id) {
$current_user_id = bp_loggedin_user_id();
}
// @todo - This is where you'd swap out for current_user_can() checks
if ($current_user_id) {
// Current user is logged in
if ($displayed_user_id == $current_user_id) {
// If you're viewing your own profile, nothing's private
$hidden_fields = array();
} else {
if (bp_is_active('friends') && friends_check_friendship($displayed_user_id, $current_user_id)) {
// If the current user and displayed user are friends, show all
$hidden_fields = array();
} else {
// current user is logged-in but not friends, so exclude friends-only
$hidden_levels = array('friends');
$hidden_fields = bp_xprofile_get_fields_by_visibility_levels($displayed_user_id, $hidden_levels);
}
}
} else {
// Current user is not logged in, so exclude friends-only and loggedin
$hidden_levels = array('friends', 'loggedin');
$hidden_fields = bp_xprofile_get_fields_by_visibility_levels($displayed_user_id, $hidden_levels);
}
return apply_filters('bp_xprofile_get_hidden_fields_for_user', $hidden_fields, $displayed_user_id, $current_user_id);
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:51,代码来源:bp-xprofile-functions.php
示例13: bp_xprofile_get_hidden_field_types_for_user
/**
* Get the visibility levels that should be hidden for this user pair
*
* Field visibility is determined based on the relationship between the
* logged-in user, the displayed user, and the visibility setting for the
* current field. (See bp_xprofile_get_hidden_fields_for_user().) This
* utility function speeds up this matching by fetching the visibility levels
* that should be hidden for the current user pair.
*
* @since BuddyPress (1.8.2)
* @see bp_xprofile_get_hidden_fields_for_user()
*
* @param int $displayed_user_id The id of the user the profile fields belong to
* @param int $current_user_id The id of the user viewing the profile
* @return array An array of visibility levels hidden to the current user
*/
function bp_xprofile_get_hidden_field_types_for_user($displayed_user_id = 0, $current_user_id = 0)
{
// Current user is logged in
if (!empty($current_user_id)) {
// Nothing's private when viewing your own profile, or when the
// current user is an admin
if ($displayed_user_id == $current_user_id || bp_current_user_can('bp_moderate')) {
$hidden_levels = array();
// If the current user and displayed user are friends, show all
} elseif (bp_is_active('friends') && friends_check_friendship($displayed_user_id, $current_user_id)) {
$hidden_levels = array('adminsonly');
// current user is logged in but not friends, so exclude friends-only
} else {
$hidden_levels = array('friends', 'adminsonly');
}
// Current user is not logged in, so exclude friends-only, loggedin, and adminsonly.
} else {
$hidden_levels = array('friends', 'loggedin', 'adminsonly');
}
return apply_filters('bp_xprofile_get_hidden_field_types_for_user', $hidden_levels, $displayed_user_id, $current_user_id);
}
开发者ID:danielcoats,项目名称:schoolpress,代码行数:37,代码来源:bp-xprofile-functions.php
示例14: bp_mute_filter_members_friends
/**
* Filter the members loop to show muted friends.
*
* @since 1.0.0
*
* @param array $r Arguments for changing the contents of the loop.
* @return array
*/
function bp_mute_filter_members_friends($r)
{
if (!bp_is_active('friends')) {
return $r;
}
if (bp_is_current_component('mute') && bp_is_current_action('friends')) {
$ids = Mute::get_muting(bp_displayed_user_id());
foreach ($ids as $id) {
$result = friends_check_friendship(bp_displayed_user_id(), $id);
if ($result) {
$array[] = $id;
}
}
if (empty($array)) {
$r['include'] = 0;
} else {
$r['include'] = $array;
}
}
return $r;
}
开发者ID:sbrajesh,项目名称:buddypress-mute,代码行数:29,代码来源:functions.php
示例15: if
/**
* Generate content for our picture grid
*
* @since BuddyBoss 2.0
* @todo Update the theme file (members/single/pictures.php) and create a Wordpress like loop for the images
e.g.
<?php if ( buddyboss_picgrid_has_pics() ): while( buddyboss_picgrid_has_pics() ): ?>
<?php buddyboss_picgrid_thumbnail(); ?>
- and -
<a href="<?php buddyboss_picgrid_fullsize_url(); ?>" title="<?php buddyboss_picgrid_image_title(); ?>">
<img src="<?php buddyboss_picgrid_thumbnail_url(); ?>" width="<?php buddyboss_picgrid_thumbnail_width(); ?>" height="<?php buddyboss_picgrid_thumbnail_height(); ?>" />
</a>
<?php endwhile; endif; ?>
(need to rename these for clarity, I think they're too long (JP))
* functions to create:
buddyboss_picgrid_has_pics() For the if/while Wordpress style loop
buddyboss_picgrid_attachment_id() Returns the ID of the current image
buddyboss_picgrid_thumbnail() Echo '<li><a><img>' tags for you of the current thumbnail
buddyboss_picgrid_thumbnail_url() Echos the url location of the current thumbnail
get_buddyboss_picgrid_thumbnail_url() Returns the url location of the current thumbnail
buddyboss_picgrid_thumbnail_width() Echos the current thumbnail width
get_buddyboss_picgrid_thumbnail_width() Returns the current thumbnail width
buddyboss_picgrid_thumbnail_height() Echos the current thumbnail height
get_buddyboss_picgrid_thumbnail_height() Returns the current thumbnail height
buddyboss_picgrid_fullsize_url() Echos the url location of the current full size image
get_buddyboss_picgrid_fullsize_url() Returns the url location of the current thumbnail
buddyboss_picgrid_fullsize_width() Echos the current full size image width
get_buddyboss_picgrid_fullsize_width() Returns the current full size image width
buddyboss_picgrid_fullsize_height() Echos the current full size image height
get_buddyboss_picgrid_fullsize_height() Returns the current full size image height
*/
function buddyboss_pics_screen_picture_grid_content()
{
global $bp, $wpdb, $buddyboss_pics;
$wpdb->show_errors = BUDDYBOSS_DEBUG;
//$img_size = is_active_sidebar( 'Profile' ) ? 'buddyboss_pic_med' : 'buddyboss_pic_wide';
$img_size = 'buddyboss_pic_wide';
$gallery_class = is_active_sidebar('Profile') ? 'gallery has-sidebar' : 'gallery';
$user_id = $bp->displayed_user->id;
$activity_table = bp_core_get_table_prefix() . 'bp_activity';
$activity_meta_table = bp_core_get_table_prefix() . 'bp_activity_meta';
$groups_table = bp_core_get_table_prefix() . 'bp_groups';
$pages_sql = "SELECT COUNT(*) FROM {$activity_table} a\n\t\t\t\t\t\t\t\tINNER JOIN {$activity_meta_table} am ON a.id = am.activity_id\n\t\t\t\t\t\t\t\tLEFT JOIN (SELECT activity_id, meta_key, meta_value FROM {$activity_meta_table}\n\t\t\t\t\t\t\t\t WHERE meta_key = 'activityprivacy') am2 ON a.id = am2.activity_id\n\t\t\t\t\t\t\t\tLEFT JOIN (SELECT id FROM {$groups_table} WHERE status != 'public' ) grp ON a.item_id = grp.id\n\t\t\t\t\t\t\t\tWHERE a.user_id = {$user_id}\n\t\t\t\t\t\t\t\tAND (am.meta_key = 'buddyboss_pics_aid' OR am.meta_key = 'bboss_pics_aid')\n\t\t\t\t\t\t\t\tAND (a.component != 'groups' || a.item_id != grp.id)";
$buddyboss_pics->grid_num_pics = $wpdb->get_var($pages_sql);
$buddyboss_pics->grid_current_page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
// Prepare a SQL query to retrieve the activity posts
// that have pictures associated with them
$sql = "SELECT a.*, am.meta_value, am2.meta_value as privacy FROM {$activity_table} a\n\t\t\t\t\tINNER JOIN {$activity_meta_table} am ON a.id = am.activity_id\n\t\t\t\t\tLEFT JOIN (SELECT activity_id, meta_key, meta_value FROM {$activity_meta_table}\n\t\t\t\t\t WHERE meta_key = 'activityprivacy') am2 ON a.id = am2.activity_id\n\t\t\t\t\tLEFT JOIN (SELECT id FROM {$groups_table} WHERE status != 'public' ) grp ON a.item_id = grp.id\n\t\t\t\t\tWHERE a.user_id = {$user_id}\n\t\t\t\t\tAND (am.meta_key = 'buddyboss_pics_aid' OR am.meta_key = 'bboss_pics_aid')\n\t\t\t\t\tAND (a.component != 'groups' || a.item_id != grp.id)\n\t\t\t\t\tORDER BY a.date_recorded DESC";
buddyboss_log("SQL: {$sql}");
$pics = $wpdb->get_results($sql, ARRAY_A);
$buddyboss_pics->grid_pagination = new BuddyBoss_Paginated($pics, $buddyboss_pics->grid_pics_per_page, $buddyboss_pics->grid_current_page);
buddyboss_log("RESULT: {$pics}");
// If we have results let's print out a simple grid
if (!empty($pics)) {
$buddyboss_pics->grid_had_pics = true;
$buddyboss_pics->grid_num_pics = count($pics);
/**
* DEBUG
*/
// echo '<br/><br/><div style="display:block;background:#f0f0f0;border:2px solid #ccc;margin:20px;padding:15px;color:#333;"><pre>';
// var_dump( $pics );
// echo '</pre></div><hr/><br/><br/><br/><br/>';
// die;
/**/
$html_grid = '<ul class="' . $gallery_class . '" id="buddyboss-pics-grid">' . "\n";
foreach ($pics as $pic) {
/**
* DEBUG
*/
// echo '<br/><br/><div style="display:block;background:#f0f0f0;border:2px solid #ccc;margin:20px;padding:15px;color:#333;"><pre>';
// var_dump( bp_activity_get_permalink($pic['id']), $pic );
// echo '</pre></div><hr/><br/><br/><br/><br/>';
// die;
/**/
//BP ACTIVITY PRIVACY FIX
if (function_exists('bp_activity_privacy_add_js')) {
$is_super_admin = is_super_admin();
$bp_displayed_user_id = bp_displayed_user_id();
$bp_loggedin_user_id = bp_loggedin_user_id();
if ($pic['privacy'] == 'loggedin' && !$bp_loggedin_user_id) {
continue;
}
if ($pic['privacy'] == 'friends' && !friends_check_friendship($bp_loggedin_user_id, $bp_displayed_user_id) && $bp_loggedin_user_id != $bp_displayed_user_id) {
continue;
}
if ($pic['privacy'] == 'groupfriends' && !friends_check_friendship($bp_loggedin_user_id, $bp_displayed_user_id || !groups_is_user_member($bp_loggedin_user_id, $bp_displayed_user_id))) {
continue;
}
if ($pic['privacy'] == 'grouponly' && !groups_is_user_member($bp_loggedin_user_id, $bp_displayed_user_id)) {
continue;
}
if ($pic['privacy'] == 'groupmoderators' && !groups_is_user_mod($bp_loggedin_user_id, $bp_displayed_user_id)) {
continue;
}
if ($pic['privacy'] == 'groupadmins' && !groups_is_user_admin($bp_loggedin_user_id, $bp_displayed_user_id)) {
continue;
}
if ($pic['privacy'] == 'adminsonly' && !$is_super_admin) {
continue;
//.........这里部分代码省略.........
开发者ID:tvolmari,项目名称:hammydowns,代码行数:101,代码来源:buddyboss-pics-loader.php
示例16: buddydrive_open_buddyfolder
/**
* Opens a folder and list the files attach to it depending on its privacy
*
* @uses buddydrive_get_buddyfile() to get the folder
* @uses buddydrive_get_folder_post_type() to get the folder post type
* @uses bp_is_active() to check if friends or groups components are actives
* @uses friends_check_friendship() to check if current user is a friend of the folder owner
* @uses groups_is_user_member() to check if the user is a member of the group the folder is attached to
* @uses buddydrive_get_template() to get the template for bp-default or any theme
* @return string the list of files
*/
function buddydrive_open_buddyfolder()
{
// Bail if not a POST action
if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
return;
}
$buddyfolder_id = $_POST['folder'];
$buddyfolder = buddydrive_get_buddyfile($buddyfolder_id, buddydrive_get_folder_post_type());
$result = array();
$access = false;
$buddyscope = $_POST['scope'];
if (empty($buddyfolder->ID)) {
$result[] = '<tr id="no-buddyitems"><td colspan="5"><div id="message" class="info"><p>' . __('Sorry, this folder does not exist anymore.', 'buddydrive') . '</p></div></td></tr>';
} else {
switch ($buddyfolder->check_for) {
case 'private':
$access = $buddyfolder->user_id == bp_loggedin_user_id() ? true : false;
break;
case 'public':
|
请发表评论