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


PHP BP_Groups_Member::save方法代码示例

本文整理汇总了PHP中BP_Groups_Member::save方法的典型用法代码示例。如果您正苦于以下问题:PHP BP_Groups_Member::save方法的具体用法?PHP BP_Groups_Member::save怎么用?PHP BP_Groups_Member::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BP_Groups_Member的用法示例。


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

示例1: create_group_membership_request

 public static function create_group_membership_request($user_id, $group_id)
 {
     $request = new BP_Groups_Member();
     $request->group_id = $group_id;
     $request->user_id = $user_id;
     $request->date_modified = bp_core_current_time();
     $request->inviter_id = 0;
     $request->is_confirmed = 0;
     $request->save();
     return $request->id;
 }
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:11,代码来源:class-bp-groups-member.php

示例2: groups_accept_membership_request

/**
 * Accept a pending group membership request.
 *
 * @param int $membership_id ID of the membership object.
 * @param int $user_id       Optional. ID of the user who requested membership.
 *                           Provide this value along with $group_id to override
 *                           $membership_id.
 * @param int $group_id      Optional. ID of the group to which membership is being
 *                           requested. Provide this value along with $user_id to
 *                           override $membership_id.
 *
 * @return bool True on success, false on failure.
 */
function groups_accept_membership_request($membership_id, $user_id = 0, $group_id = 0)
{
    if (!empty($user_id) && !empty($group_id)) {
        $membership = new BP_Groups_Member($user_id, $group_id);
    } else {
        $membership = new BP_Groups_Member(false, false, $membership_id);
    }
    $membership->accept_request();
    if (!$membership->save()) {
        return false;
    }
    // Check if the user has an outstanding invite, if so delete it.
    if (groups_check_user_has_invite($membership->user_id, $membership->group_id)) {
        groups_delete_invite($membership->user_id, $membership->group_id);
    }
    /**
     * Fires after a group membership request has been accepted.
     *
     * @since 1.0.0
     *
     * @param int  $user_id  ID of the user who accepted membership.
     * @param int  $group_id ID of the group that was accepted membership to.
     * @param bool $value    If membership was accepted.
     */
    do_action('groups_membership_accepted', $membership->user_id, $membership->group_id, true);
    return true;
}
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:40,代码来源:bp-groups-functions.php

示例3: test_get_group_extras_banned

 /**
  * @group get_group_extras
  */
 public function test_get_group_extras_banned()
 {
     $u = $this->factory->user->create();
     $g = $this->factory->group->create();
     $member = new BP_Groups_Member();
     $member->group_id = $g;
     $member->user_id = $u;
     $member->date_modified = bp_core_current_time();
     $member->is_banned = true;
     $member->save();
     $paged_groups = array();
     $paged_groups[] = new stdClass();
     $paged_groups[0]->id = $g;
     $group_ids = array($g);
     $expected = array();
     foreach ($paged_groups as $key => $value) {
         $expected[$key] = new stdClass();
         $expected[$key]->id = $value->id;
         $expected[$key]->is_member = '0';
         $expected[$key]->is_invited = '0';
         $expected[$key]->is_pending = '0';
         $expected[$key]->is_banned = true;
     }
     $old_user = get_current_user_id();
     $this->set_current_user($u);
     $this->assertEquals($expected, BP_Groups_Group::get_group_extras($paged_groups, $group_ids));
     $this->set_current_user($old_user);
 }
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:31,代码来源:class-bp-groups-group.php

示例4: test_groups_is_user_pending_should_return_true_for_pending_member

 public function test_groups_is_user_pending_should_return_true_for_pending_member()
 {
     $m = new BP_Groups_Member();
     $m->group_id = self::$groups[1];
     $m->user_id = self::$user;
     $m->inviter_id = 0;
     $m->is_admin = 0;
     $m->user_title = '';
     $m->date_modified = bp_core_current_time();
     $m->is_confirmed = 0;
     $m->comments = 'request';
     $m->save();
     $this->assertNotEmpty(groups_is_user_pending(self::$user, self::$groups[1]));
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:14,代码来源:groupsIsUser.php

示例5: groups_accept_membership_request

function groups_accept_membership_request($membership_id, $user_id = 0, $group_id = 0)
{
    if (!empty($user_id) && !empty($group_id)) {
        $membership = new BP_Groups_Member($user_id, $group_id);
    } else {
        $membership = new BP_Groups_Member(false, false, $membership_id);
    }
    $membership->accept_request();
    if (!$membership->save()) {
        return false;
    }
    // Check if the user has an outstanding invite, if so delete it.
    if (groups_check_user_has_invite($membership->user_id, $membership->group_id)) {
        groups_delete_invite($membership->user_id, $membership->group_id);
    }
    // Record this in activity streams
    $group = groups_get_group(array('group_id' => $membership->group_id));
    groups_record_activity(array('action' => apply_filters_ref_array('groups_activity_membership_accepted_action', array(sprintf(__('%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink($membership->user_id), '<a href="' . bp_get_group_permalink($group) . '">' . esc_attr($group->name) . '</a>'), $membership->user_id, &$group)), 'type' => 'joined_group', 'item_id' => $membership->group_id, 'user_id' => $membership->user_id));
    // Send a notification to the user.
    groups_notification_membership_request_completed($membership->user_id, $membership->group_id, true);
    do_action('groups_membership_accepted', $membership->user_id, $membership->group_id);
    return true;
}
开发者ID:novichkovv,项目名称:candoweightloss,代码行数:23,代码来源:bp-groups-functions.php

示例6: add_user_to_group

 public static function add_user_to_group($user_id, $group_id, $args = array())
 {
     $r = wp_parse_args($args, array('date_modified' => bp_core_current_time(), 'is_confirmed' => 1, 'is_admin' => 0, 'is_mod' => 0, 'invite_sent' => 0, 'inviter_id' => 0));
     $new_member = new BP_Groups_Member();
     $new_member->group_id = $group_id;
     $new_member->user_id = $user_id;
     $new_member->inviter_id = 0;
     $new_member->is_admin = $r['is_admin'];
     $new_member->is_mod = $r['is_mod'];
     $new_member->user_title = '';
     $new_member->date_modified = $r['date_modified'];
     $new_member->is_confirmed = $r['is_confirmed'];
     $new_member->invite_sent = $r['invite_sent'];
     $new_member->inviter_id = $r['inviter_id'];
     $new_member->save();
     return $new_member->id;
 }
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:17,代码来源:testcase.php

示例7: groups_accept_membership_request

/**
 * Accept a pending group membership request.
 *
 * @param int $membership_id ID of the membership object.
 * @param int $user_id Optional. ID of the user who requested membership.
 *        Provide this value along with $group_id to override $membership_id.
 * @param int $group_id Optional. ID of the group to which membership is being
 *        requested. Provide this value along with $user_id to override
 *        $membership_id.
 * @return bool True on success, false on failure.
 */
function groups_accept_membership_request($membership_id, $user_id = 0, $group_id = 0)
{
    if (!empty($user_id) && !empty($group_id)) {
        $membership = new BP_Groups_Member($user_id, $group_id);
    } else {
        $membership = new BP_Groups_Member(false, false, $membership_id);
    }
    $membership->accept_request();
    if (!$membership->save()) {
        return false;
    }
    // Check if the user has an outstanding invite, if so delete it.
    if (groups_check_user_has_invite($membership->user_id, $membership->group_id)) {
        groups_delete_invite($membership->user_id, $membership->group_id);
    }
    do_action('groups_membership_accepted', $membership->user_id, $membership->group_id, true);
    return true;
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:29,代码来源:bp-groups-functions.php

示例8: bpdd_import_groups_members

function bpdd_import_groups_members($groups = false)
{
    $members = array();
    if (!$groups) {
        $groups = bpdd_get_random_groups_ids(0);
    }
    $new_member = new BP_Groups_Member();
    foreach ($groups as $group_id) {
        $user_ids = bpdd_get_random_users_ids(rand(2, 15));
        foreach ($user_ids as $user_id) {
            if (groups_is_user_member($user_id, $group_id)) {
                continue;
            }
            $time = bpdd_get_random_date(25, 1);
            $new_member->id = false;
            $new_member->group_id = $group_id;
            $new_member->user_id = $user_id;
            $new_member->inviter_id = 0;
            $new_member->is_admin = 0;
            $new_member->user_title = '';
            $new_member->date_modified = $time;
            $new_member->is_confirmed = 1;
            // save data - finally
            if ($new_member->save()) {
                $group = new BP_Groups_Group($group_id);
                // record this in activity streams
                $activity_id[] = groups_record_activity(array('action' => apply_filters('groups_activity_joined_group', sprintf(__('%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink($user_id), '<a href="' . bp_get_group_permalink($group) . '">' . esc_attr(bp_get_group_name($group)) . '</a>')), 'type' => 'joined_group', 'item_id' => $group_id, 'user_id' => $user_id, 'recorded_time' => $time));
                // modify group meta
                groups_update_groupmeta($group_id, 'total_member_count', (int) groups_get_groupmeta($group_id, 'total_member_count') + 1);
                groups_update_groupmeta($group_id, 'last_activity', $time);
                do_action('groups_join_group', $group_id, $user_id);
                // I need to know how many users were added to display in report after the import
                $members[] = $group_id;
            }
        }
    }
    return $members;
}
开发者ID:vsalx,项目名称:rattieinfo,代码行数:38,代码来源:bp-default-data.php

示例9: groups_accept_membership_request

function groups_accept_membership_request( $membership_id, $user_id = false, $group_id = false ) {
	global $bp;

	if ( $user_id && $group_id )
		$membership = new BP_Groups_Member( $user_id, $group_id );
	else
		$membership = new BP_Groups_Member( false, false, $membership_id );

	$membership->accept_request();

	if ( !$membership->save() )
		return false;

	/* Check if the user has an outstanding invite, if so delete it. */
	if ( groups_check_user_has_invite( $membership->user_id, $membership->group_id ) )
		groups_delete_invite( $membership->user_id, $membership->group_id );

	/* Modify group member count */
	groups_update_groupmeta( $membership->group_id, 'total_member_count', (int) groups_get_groupmeta( $membership->group_id, 'total_member_count') + 1 );

	/* Record this in activity streams */
	$group = new BP_Groups_Group( $membership->group_id );

	groups_record_activity( array(
		'action'	=> apply_filters( 'groups_activity_membership_accepted_action', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $membership->user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( $group->name ) . '</a>' ), $membership->user_id, &$group ),
		'type'		=> 'joined_group',
		'item_id'	=> $membership->group_id,
		'user_id'	=> $membership->user_id
	) );

	/* Send a notification to the user. */
	require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
	groups_notification_membership_request_completed( $membership->user_id, $membership->group_id, true );

	do_action( 'groups_membership_accepted', $membership->user_id, $membership->group_id );

	return true;
}
开发者ID:n-sane,项目名称:zaroka,代码行数:38,代码来源:bp-groups.php

示例10: groups_accept_membership_request

function groups_accept_membership_request($membership_id)
{
    global $bp;
    /* Check the nonce first. */
    if (!check_admin_referer('groups_accept_membership_request')) {
        return false;
    }
    $membership = new BP_Groups_Member(false, false, $membership_id);
    $membership->accept_request();
    if (!$membership->save()) {
        return false;
    }
    /* Modify group member count */
    groups_update_groupmeta($membership->group_id, 'total_member_count', (int) groups_get_groupmeta($membership->group_id, 'total_member_count') + 1);
    /* Record this in activity streams */
    groups_record_activity(array('item_id' => $membership->group_id, 'component_name' => $bp->groups->slug, 'component_action' => 'joined_group', 'is_private' => 0));
    /* Send a notification to the user. */
    require_once BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php';
    groups_notification_membership_request_completed($membership->user_id, $membership->group_id, true);
    do_action('groups_membership_accepted', $membership->user_id, $membership->group_id);
    return true;
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:22,代码来源:bp-groups.php

示例11: thatcamp_add_member_to_group

/**
 * A short version of groups_join_group(), without notification baggage
 *
 * @param int $user_id
 * @param int $group_id
 * @role string Desired group role. 'member', 'mod', or 'admin'
 */
function thatcamp_add_member_to_group($user_id, $group_id, $role)
{
    $new_member = new BP_Groups_Member();
    $new_member->group_id = $group_id;
    $new_member->user_id = $user_id;
    $new_member->inviter_id = 0;
    $new_member->is_admin = 0;
    $new_member->user_title = '';
    $new_member->date_modified = bp_core_current_time();
    $new_member->is_confirmed = 1;
    $new_member->save();
    groups_update_groupmeta($group_id, 'total_member_count', (int) groups_get_groupmeta($group_id, 'total_member_count') + 1);
    if ('admin' == $role || 'mod' == $role) {
        groups_promote_member($user_id, $group_id, $role);
    }
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:23,代码来源:thatcamp-group-blogs.php

示例12: bp_ning_import_get_discussions


//.........这里部分代码省略.........
            $group_id = $ning_group_id_array[$ning_group_id];
        } else {
            if (isset($discussion->groupId)) {
                $ngroup_id = $discussion->groupId;
                $group_id = $ning_group_id_array[$ngroup_id];
            } else {
                continue;
                // todo fix me!
            }
        }
        $group = new BP_Groups_Group($group_id);
        $args = array('topic_title' => $discussion->title, 'topic_slug' => groups_check_slug(sanitize_title(esc_attr($discussion->title))), 'topic_text' => $discussion->description, 'topic_poster' => $creator_id, 'topic_poster_name' => bp_core_get_user_displayname($creator_id), 'topic_last_poster' => $creator_id, 'topic_last_poster_name' => bp_core_get_user_displayname($creator_id), 'topic_start_time' => $date_created, 'topic_time' => $date_created, 'forum_id' => groups_get_groupmeta($group_id, 'forum_id'));
        $query = "SELECT `topic_id` FROM wp_bb_topics WHERE topic_title = '%s' AND topic_start_time = '%s' LIMIT 1";
        $q = $wpdb->prepare($query, $args['topic_title'], $args['topic_start_time']);
        $topic_exists = $wpdb->get_results($q);
        if (isset($topic_exists[0])) {
            echo "<em>- Topic {$discussion->title} already exists</em><br />";
            $imported[$discussion->id] = true;
            continue;
        }
        if (!$args['forum_id']) {
            echo "No forum id - skipping";
            continue;
        }
        if (!($topic_id = bp_forums_new_topic($args))) {
            // TODO: WTF?
            return false;
            echo "<h2>Refresh to import more discussions</h2>";
            die;
        } else {
            bp_ning_import_process_inline_images_new('discussions', $topic_id, 'topic');
            echo "<strong>- Created topic: {$discussion->title}</strong><br />";
        }
        $activity_content = bp_create_excerpt($discussion->description);
        $skip_activity = get_option('bp_ning_skip_forum_activity');
        if (!$skip_activity) {
            $topic = bp_forums_get_topic_details($topic_id);
            // Activity item
            $activity_action = sprintf(__('%s started the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink($creator_id), '<a href="' . bp_get_group_permalink($group) . 'forum/topic/' . $topic->topic_slug . '/">' . esc_html($topic->topic_title) . '</a>', '<a href="' . bp_get_group_permalink($group) . '">' . esc_html($group->name) . '</a>');
            groups_record_activity(array('user_id' => $creator_id, 'action' => apply_filters('groups_activity_new_forum_topic_action', $activity_action, $discussion->description, $topic), 'content' => apply_filters('groups_activity_new_forum_topic_content', $activity_content, $discussion->description, $topic), 'primary_link' => apply_filters('groups_activity_new_forum_topic_primary_link', bp_get_group_permalink($group) . 'forum/topic/' . $topic->topic_slug . '/'), 'type' => 'new_forum_topic', 'item_id' => $group_id, 'secondary_item_id' => $topic->topic_id, 'recorded_time' => $date_created, 'hide_sitewide' => 0));
            do_action('groups_new_forum_topic', $group_id, $topic);
        }
        // Now check for comments
        if (isset($discussion->comments)) {
            foreach ($discussion->comments as $reply) {
                $ning_group_creator_id = $reply->contributorName;
                $creator_id = $ning_id_array[$ning_group_creator_id];
                $ndate = strtotime($reply->createdDate);
                $date_created = date("Y-m-d H:i:s", $ndate);
                $args = array('topic_id' => $topic_id, 'post_text' => $reply->description, 'post_time' => $date_created, 'poster_id' => $creator_id, 'poster_ip' => '192.168.1.1');
                $query = "SELECT * FROM wp_bb_posts WHERE topic_id = '%s' AND post_text = '%s'";
                $q = $wpdb->prepare($query, $args['topic_id'], $args['post_text']);
                $post_exists = $wpdb->get_results($q);
                if ($post_exists) {
                    continue;
                }
                $post_id = bp_forums_insert_post($args);
                if ($post_id) {
                    bp_ning_import_process_inline_images_new('discussions', $post_id, 'topic_reply');
                    $import_summary = esc_html(bp_create_excerpt($reply->description, 100, array('html' => false)));
                    echo "<em>- Imported forum post: {$import_summary}</em><br />";
                }
                if (!groups_is_user_member($creator_id, $group_id)) {
                    if (!$bp->groups->current_group) {
                        $bp->groups->current_group = new BP_Groups_Group($group_id);
                    }
                    $new_member = new BP_Groups_Member();
                    $new_member->group_id = $group_id;
                    $new_member->user_id = $creator_id;
                    $new_member->inviter_id = 0;
                    $new_member->is_admin = 0;
                    $new_member->user_title = '';
                    $new_member->date_modified = $date_created;
                    $new_member->is_confirmed = 1;
                    $new_member->save();
                    groups_update_groupmeta($group_id, 'total_member_count', (int) groups_get_groupmeta($group_id, 'total_member_count') + 1);
                    groups_update_groupmeta($group_id, 'last_activity', $date_created);
                    do_action('groups_join_group', $group_id, $creator_id);
                }
                if ($skip_activity) {
                    continue;
                }
                // Activity item
                $topic = bp_forums_get_topic_details($topic_id);
                $activity_action = sprintf(__('%s posted on the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink($creator_id), '<a href="' . bp_get_group_permalink($group) . 'forum/topic/' . $topic->topic_slug . '/">' . esc_attr($topic->topic_title) . '</a>', '<a href="' . bp_get_group_permalink($group) . '">' . esc_attr($group->name) . '</a>');
                $activity_content = bp_create_excerpt($reply->description);
                $primary_link = bp_get_group_permalink($group) . 'forum/topic/' . $topic->topic_slug . '/';
                //if ( $page )
                //	$primary_link .= "?topic_page=" . $page;
                //echo $primary_link; die();
                groups_record_activity(array('user_id' => $creator_id, 'action' => apply_filters('groups_activity_new_forum_post_action', $activity_action, $post_id, $reply->description, $topic), 'content' => apply_filters('groups_activity_new_forum_post_content', $activity_content, $post_id, $reply->description, $topic), 'primary_link' => apply_filters('groups_activity_new_forum_post_primary_link', "{$primary_link}#post-{$post_id}"), 'type' => 'new_forum_post', 'item_id' => $group_id, 'secondary_item_id' => $post_id, 'recorded_time' => $date_created, 'hide_sitewide' => 0));
                do_action('groups_new_forum_topic_post', $group_id, $post_id);
            }
        }
        $imported[$discussion->id] = true;
        $counter++;
    }
    update_option('bp_ning_discussions_imported', $imported);
    return true;
}
开发者ID:boonebgorges,项目名称:Import-from-Ning,代码行数:101,代码来源:bp-functions.php

示例13: bp_group_management_join_group

function bp_group_management_join_group($group_id, $user_id = false)
{
    global $bp;
    if (!$user_id) {
        $user_id = $bp->loggedin_user->id;
    }
    /* Check if the user has an outstanding invite, is so delete it. */
    if (groups_check_user_has_invite($user_id, $group_id)) {
        groups_delete_invite($user_id, $group_id);
    }
    /* Check if the user has an outstanding request, is so delete it. */
    if (groups_check_for_membership_request($user_id, $group_id)) {
        groups_delete_membership_request($user_id, $group_id);
    }
    /* User is already a member, just return true */
    if (groups_is_user_member($user_id, $group_id)) {
        return true;
    }
    if (!$bp->groups->current_group) {
        $bp->groups->current_group = new BP_Groups_Group($group_id);
    }
    $new_member = new BP_Groups_Member();
    $new_member->group_id = $group_id;
    $new_member->user_id = $user_id;
    $new_member->inviter_id = 0;
    $new_member->is_admin = 0;
    $new_member->user_title = '';
    $new_member->date_modified = gmdate("Y-m-d H:i:s");
    $new_member->is_confirmed = 1;
    if (!$new_member->save()) {
        return false;
    }
    /* Record this in activity streams */
    groups_record_activity(array('user_id' => $user_id, 'action' => apply_filters('groups_activity_joined_group', sprintf(__('%s joined the group %s', 'bp-group-management'), bp_core_get_userlink($user_id), '<a href="' . bp_get_group_permalink($bp->groups->current_group) . '">' . esc_html($bp->groups->current_group->name) . '</a>')), 'type' => 'joined_group', 'item_id' => $group_id));
    /* Modify group meta */
    groups_update_groupmeta($group_id, 'total_member_count', (int) groups_get_groupmeta($group_id, 'total_member_count') + 1);
    groups_update_groupmeta($group_id, 'last_activity', gmdate("Y-m-d H:i:s"));
    do_action('groups_join_group', $group_id, $user_id);
    return true;
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:40,代码来源:bp-group-management-aux.php


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