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


PHP friends_accept_friendship函数代码示例

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


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

示例1: friends_screen_requests

/**
 * Catch and process the Requests page.
 */
function friends_screen_requests()
{
    if (bp_is_action_variable('accept', 0) && is_numeric(bp_action_variable(1))) {
        // Check the nonce
        check_admin_referer('friends_accept_friendship');
        if (friends_accept_friendship(bp_action_variable(1))) {
            bp_core_add_message(__('Friendship accepted', 'buddypress'));
        } else {
            bp_core_add_message(__('Friendship could not be accepted', 'buddypress'), 'error');
        }
        bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
    } elseif (bp_is_action_variable('reject', 0) && is_numeric(bp_action_variable(1))) {
        // Check the nonce
        check_admin_referer('friends_reject_friendship');
        if (friends_reject_friendship(bp_action_variable(1))) {
            bp_core_add_message(__('Friendship rejected', 'buddypress'));
        } else {
            bp_core_add_message(__('Friendship could not be rejected', 'buddypress'), 'error');
        }
        bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
    } elseif (bp_is_action_variable('cancel', 0) && is_numeric(bp_action_variable(1))) {
        // Check the nonce
        check_admin_referer('friends_withdraw_friendship');
        if (friends_withdraw_friendship(bp_loggedin_user_id(), bp_action_variable(1))) {
            bp_core_add_message(__('Friendship request withdrawn', 'buddypress'));
        } else {
            bp_core_add_message(__('Friendship request could not be withdrawn', 'buddypress'), 'error');
        }
        bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
    }
    do_action('friends_screen_requests');
    bp_core_load_template(apply_filters('friends_template_requests', 'members/single/home'));
}
开发者ID:eresyyl,项目名称:mk,代码行数:36,代码来源:bp-friends-screens.php

示例2: friends_screen_requests

function friends_screen_requests()
{
    if (bp_is_action_variable('accept', 0) && is_numeric(bp_action_variable(1))) {
        // Check the nonce
        check_admin_referer('friends_accept_friendship');
        if (friends_accept_friendship(bp_action_variable(1))) {
            bp_core_add_message(__('Friendship accepted', 'buddypress'));
        } else {
            bp_core_add_message(__('Friendship could not be accepted', 'buddypress'), 'error');
        }
        bp_core_redirect(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action());
    } elseif (bp_is_action_variable('reject', 0) && is_numeric(bp_action_variable(1))) {
        // Check the nonce
        check_admin_referer('friends_reject_friendship');
        if (friends_reject_friendship(bp_action_variable(1))) {
            bp_core_add_message(__('Friendship rejected', 'buddypress'));
        } else {
            bp_core_add_message(__('Friendship could not be rejected', 'buddypress'), 'error');
        }
        bp_core_redirect(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action());
    }
    do_action('friends_screen_requests');
    if (isset($_GET['new'])) {
        bp_core_delete_notifications_by_type(bp_loggedin_user_id(), 'friends', 'friendship_request');
    }
    bp_core_load_template(apply_filters('friends_template_requests', 'members/single/home'));
}
开发者ID:hornetalcala,项目名称:trunk,代码行数:27,代码来源:bp-friends-screens.php

示例3: test_requests_on_accept

 /**
  * @group friends_get_friendship_request_user_ids
  * @group friends_add_friend
  * @group friends_accept_friendship
  */
 public function test_requests_on_accept()
 {
     $u1 = $this->factory->user->create();
     $u2 = $this->factory->user->create();
     $u3 = $this->factory->user->create();
     // request friendship
     friends_add_friend($u2, $u1);
     friends_add_friend($u3, $u1);
     // Set the time of the earlier friendship for reliable ordering of the results.
     $fid = friends_get_friendship_id($u2, $u1);
     $friendship = new BP_Friends_Friendship($fid, false, false);
     $friendship->date_created = date('Y-m-d H:i:s', time() - 60);
     $friendship->save();
     // get request count for user 1 and assert
     $requests = friends_get_friendship_request_user_ids($u1);
     $this->assertEquals(array($u3, $u2), $requests);
     // accept friendship
     $old_user = get_current_user_id();
     $this->set_current_user($u1);
     friends_accept_friendship(friends_get_friendship_id($u2, $u1));
     // refetch request count for user 1 and assert
     $requests = friends_get_friendship_request_user_ids($u1);
     $this->assertEquals(array($u3), $requests);
     $this->set_current_user($old_user);
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:30,代码来源:functions.php

示例4: friends_screen_requests

/**
 * Catch and process the Requests page.
 */
function friends_screen_requests()
{
    if (bp_is_action_variable('accept', 0) && is_numeric(bp_action_variable(1))) {
        // Check the nonce
        check_admin_referer('friends_accept_friendship');
        if (friends_accept_friendship(bp_action_variable(1))) {
            bp_core_add_message(__('Friendship accepted', 'buddypress'));
        } else {
            bp_core_add_message(__('Friendship could not be accepted', 'buddypress'), 'error');
        }
        bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
    } elseif (bp_is_action_variable('reject', 0) && is_numeric(bp_action_variable(1))) {
        // Check the nonce
        check_admin_referer('friends_reject_friendship');
        if (friends_reject_friendship(bp_action_variable(1))) {
            bp_core_add_message(__('Friendship rejected', 'buddypress'));
        } else {
            bp_core_add_message(__('Friendship could not be rejected', 'buddypress'), 'error');
        }
        bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
    } elseif (bp_is_action_variable('cancel', 0) && is_numeric(bp_action_variable(1))) {
        // Check the nonce
        check_admin_referer('friends_withdraw_friendship');
        if (friends_withdraw_friendship(bp_loggedin_user_id(), bp_action_variable(1))) {
            bp_core_add_message(__('Friendship request withdrawn', 'buddypress'));
        } else {
            bp_core_add_message(__('Friendship request could not be withdrawn', 'buddypress'), 'error');
        }
        bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()));
    }
    /**
     * Fires before the loading of template for the friends requests page.
     *
     * @since BuddyPress (1.0.0)
     */
    do_action('friends_screen_requests');
    /**
     * Filters the template used to display the My Friends page.
     *
     * @since BuddyPress (1.0.0)
     *
     * @param string $template Path to the friends request template to load.
     */
    bp_core_load_template(apply_filters('friends_template_requests', 'members/single/home'));
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:48,代码来源:bp-friends-screens.php

示例5: test_requests_on_accept

 /**
  * @group friends_get_friendship_request_user_ids
  * @group friends_add_friend
  * @group friends_accept_friendship
  */
 public function test_requests_on_accept()
 {
     $u1 = $this->factory->user->create();
     $u2 = $this->factory->user->create();
     $u3 = $this->factory->user->create();
     // request friendship
     friends_add_friend($u2, $u1);
     friends_add_friend($u3, $u1);
     // get request count for user 1 and assert
     $requests = friends_get_friendship_request_user_ids($u1);
     $this->assertEquals(array($u2, $u3), $requests);
     // accept friendship
     $old_user = get_current_user_id();
     $this->set_current_user($u1);
     friends_accept_friendship(friends_get_friendship_id($u2, $u1));
     // refetch request count for user 1 and assert
     $requests = friends_get_friendship_request_user_ids($u1);
     $this->assertEquals(array($u3), $requests);
     $this->set_current_user($old_user);
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:25,代码来源:functions.php

示例6: bp_dtheme_ajax_accept_friendship

function bp_dtheme_ajax_accept_friendship()
{
    check_admin_referer('friends_accept_friendship');
    if (!friends_accept_friendship($_POST['id'])) {
        echo "-1<div id='message' class='error'><p>" . __('There was a problem accepting that request. Please try again.', 'buddypress') . '</p></div>';
    }
    return true;
}
开发者ID:hscale,项目名称:webento,代码行数:8,代码来源:ajax.php

示例7: bp_dtheme_ajax_accept_friendship

function bp_dtheme_ajax_accept_friendship()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    check_admin_referer('friends_accept_friendship');
    if (!friends_accept_friendship($_POST['id'])) {
        echo "-1<div id='message' class='error'><p>" . __('There was a problem accepting that request. Please try again.', 'buddypress') . '</p></div>';
    }
    return true;
}
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:12,代码来源:ajax.php

示例8: test_delete_friendship_activity_on_user_delete

 /**
  * @group friends_delete_activity
  */
 public function test_delete_friendship_activity_on_user_delete()
 {
     $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 accept the friendship
     $this->set_current_user($u1);
     friends_accept_friendship($friendship_id);
     // Reset the current user
     $this->set_current_user($old_user);
     // Delete $u1.
     wp_delete_user($u1);
     // 'friendship_created' activity item should not exist.
     $friendship_activity = bp_activity_get(array('component' => buddypress()->friends->id, 'filter' => array('action' => array('friendship_created'), 'primary_id' => $friendship_id)));
     $this->assertEmpty($friendship_activity['activities']);
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:21,代码来源:activity.php

示例9: friends_screen_requests

function friends_screen_requests()
{
    global $bp;
    if (isset($bp->action_variables) && 'accept' == $bp->action_variables[0] && is_numeric($bp->action_variables[1])) {
        if (friends_accept_friendship($bp->action_variables[1])) {
            bp_core_add_message(__('Friendship accepted', 'buddypress'));
        } else {
            bp_core_add_message(__('Friendship could not be accepted', 'buddypress'), 'error');
        }
        bp_core_redirect($bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action);
    } else {
        if (isset($bp->action_variables) && 'reject' == $bp->action_variables[0] && is_numeric($bp->action_variables[1])) {
            if (friends_reject_friendship($bp->action_variables[1])) {
                bp_core_add_message(__('Friendship rejected', 'buddypress'));
            } else {
                bp_core_add_message(__('Friendship could not be rejected', 'buddypress'), 'error');
            }
            bp_core_redirect($bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action);
        }
    }
    do_action('friends_screen_requests');
    bp_core_load_template(apply_filters('friends_template_requests', 'friends/requests'));
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:23,代码来源:bp-friends.php

示例10: bp_dtheme_ajax_accept_friendship

/**
 * Accept a user friendship request via a POST request.
 *
 * @return mixed String on error, void on success
 * @since BuddyPress (1.2)
 */
function bp_dtheme_ajax_accept_friendship()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    check_admin_referer('friends_accept_friendship');
    if (!friends_accept_friendship((int) $_POST['id'])) {
        echo "-1<div class='clearfix'></div><div id='message' class='error alert alert-danger'><p>" . __('There was a problem accepting that request. Please try again.', 'firmasite') . '</p></div>';
    }
    exit;
}
开发者ID:paulmedwal,项目名称:edxforumspublic,代码行数:18,代码来源:ajax.php

示例11: friends_screen_requests

function friends_screen_requests() {
	global $bp;

	if ( isset($bp->action_variables) && 'accept' == $bp->action_variables[0] && is_numeric($bp->action_variables[1]) ) {
		/* Check the nonce */
		check_admin_referer( 'friends_accept_friendship' );

		if ( friends_accept_friendship( $bp->action_variables[1] ) ) {
			bp_core_add_message( __( 'Friendship accepted', 'buddypress' ) );
		} else {
			bp_core_add_message( __( 'Friendship could not be accepted', 'buddypress' ), 'error' );
		}
		bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );

	} else if ( isset($bp->action_variables) && 'reject' == $bp->action_variables[0] && is_numeric($bp->action_variables[1]) ) {
		/* Check the nonce */
		check_admin_referer( 'friends_reject_friendship' );

		if ( friends_reject_friendship( $bp->action_variables[1] ) ) {
			bp_core_add_message( __( 'Friendship rejected', 'buddypress' ) );
		} else {
			bp_core_add_message( __( 'Friendship could not be rejected', 'buddypress' ), 'error' );
		}
		bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
	}

	do_action( 'friends_screen_requests' );

	if ( isset( $_GET['new'] ) )
		bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->friends->id, 'friendship_request' );

	bp_core_load_template( apply_filters( 'friends_template_requests', 'members/single/home' ) );
}
开发者ID:n-sane,项目名称:zaroka,代码行数:33,代码来源:bp-friends.php

示例12: test_bp_cleanup_friendship_activities

 /**
  * @group bp_cleanup_friendship_activities
  */
 public function test_bp_cleanup_friendship_activities()
 {
     $old_user = get_current_user_id();
     $u1 = $this->factory->user->create();
     $u2 = $this->factory->user->create();
     $users = array($u1, $u2);
     friends_add_friend($u2, $u1);
     $friendship_id = friends_get_friendship_id($u2, $u1);
     // Set current user to u1 to accepte the friendship and generate a public activity
     $this->set_current_user($u1);
     friends_accept_friendship($friendship_id);
     // Reset the current user
     $this->set_current_user($old_user);
     $users[] = $this->factory->user->create();
     $users[] = $this->factory->user->create();
     foreach ($users as $u) {
         bp_activity_add(array('user_id' => $u, 'item_id' => $friendship_id, 'type' => 'friendship_created', 'component' => buddypress()->friends->id, 'hide_sitewide' => true));
     }
     $hidden = bp_activity_get(array('component' => buddypress()->friends->id, 'filter' => array('action' => array('friendship_created')), 'show_hidden' => true));
     bp_cleanup_friendship_activities();
     $check = bp_activity_get(array('component' => buddypress()->friends->id, 'item_id' => $friendship_id, 'filter' => array('action' => array('friendship_created')), 'show_hidden' => true));
     $this->assertTrue(count($check['activities']) == 1);
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:26,代码来源:activity.php


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